承接 maximerenou/hugging-chat 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maximerenou/hugging-chat

最新稳定版本:v0.5.2

Composer 安装命令:

composer require maximerenou/hugging-chat

包简介

HuggingChat client

README 文档

README

HuggingChat + PHP

HuggingChat client

License Latest Stable Version PHP version cURL extension required

This is an unofficial PHP client for HuggingChat (OpenAssistant's LLaMA model).

HuggingChat API is evolving fast with recurring breaking changes. I try to keep up with it, but it may not always work as expected. Feel free to open an issue if you encounter any problem.

Installation

composer require maximerenou/hugging-chat

Demo

Run examples/chat.php to test it.

Prompt Demo

Usage

use MaximeRenou\HuggingChat\Client as HuggingChat;
use MaximeRenou\HuggingChat\Prompt;

$ai = new HuggingChat();

$conversation = $ai->createConversation();

// $answer - full answer
$answer = $conversation->ask(new Prompt("Hello World"));
Real-time / progressive answer

You may pass a function as second argument to get real-time progression:

// $current_answer - incomplete answer
// $tokens - last tokens received
$final_answer = $conversation->ask($prompt, function ($current_answer, $tokens) {
    echo $tokens;
});
Resume a conversation

If you want to resume a previous conversation, you can retrieve its identifiers:

// Get current identifiers
$identifiers = $conversation->getIdentifiers();

// ...
// Resume conversation with $identifiers parameter
$conversation = $ai->resumeConversation($identifiers);
Use another model

You can use a specific model:

$conversation = $ai->createConversation("bigcode/starcoder");

Default is OpenAssistant.

Generate a conversation's summary

Useful to give a title to a conversation.

// Question asked: "Who's Einstein?"
// ...
$summary = $conversation->getSummary();
// Result: Famous genius mathematician.
Turn on/off data sharing

HuggingChat share your conversations to improve the model. You can turn on/off data sharing:

$conversation->enableSharing(); // on

$conversation->disableSharing(); // off (module default)
Delete a conversation
$conversation->delete();
Handle HuggingChat errors

The code throws exceptions when it receives an error from HuggingChat. You can therefore use a try/catch block to handle errors.

Answers are sometimes malformed (or dumb)

Answers quality depends on the model you're using.

Disclaimer

Using HuggingChat outside huggingface.co/chat may violate HuggingFace terms. Use it at your own risk.

统计信息

  • 总下载量: 90
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固