savvym / chatgpt
dev-main
2023-07-27 03:25 UTC
Requires
- guzzlehttp/guzzle: ^7.7
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^10.2
This package is auto-updated.
Last update: 2024-04-27 05:11:28 UTC
README
基于ChatGPT API的PHP组件
安装
$ composer require savvym/chatgpt -vvv
配置
在使用本扩展前,你需要去OpenAI获取应用的API key.
使用
无上下文功能:
use Savvym\Chatgpt\ChatGPT; $key = 'xxxxxxxxxxxxx'; $c = new ChatGPT($key);
带上下文功能:
use Savvym\Chatgpt\ChatGPT; use Savvym\Chatgpt\History\FileHistory; $key = 'xxxxxxxxxxxxx'; $history = new FileHistory('./data/cache.php'); $c = new ChatGPT($key, $history); $res = $c->chat('做一首诗'); $res = $c->chat('翻译前面的话');
参数说明
string chat(string $msg)
$msg
- 发送消息
参考
TODO
- Redis history
- ...
Licence
MIT