Skip to content

savvym/chatgpt-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT PHP

基于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

About

基于openai api的chatgpt php服务

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages