onekb/ChatGPT

采用OpenAI GPT3.5模型API(参考)

Using OpenAI GPT3.5 model API (reference)

Installing

composer require onekb/chat-gpt

Usage

// 你的key // your key $apiKey = 'sk-PXxxxxxxxx'; // 最大提交聊天记录数,内容太多会消耗更多tokens // The maximum number of submitted chat records, too much content will consume more tokens $limit = 10; $chatGPT=new OnekbChatGptChatGpt($apiKey, $limit); // 简单使用 var_dump($chatGPT->ask('你好')); // 设置代理 OnekbChatGptDi::set('proxy', 'http://127.0.0.1:8899'); // 重新发起对话 Reinitiate a conversation // $chatGpt->clearHistory(); // 自定义聊天记录 Custom chat history //$chatGpt->history = [ // [ // 'role' => 'user', // 'content' => '你好', // ], // [ // 'role' => 'assistant', // 'content' => '你好', // ], //];

⚡️ Getting Started

Step 1. 克隆本项目到本地 Clone this project to local

git clone https://github.com/onekb/ChatGPT.git

Step 2. 配置你的环境变量 Configure your environment variables

首先,将 start.php 文件中的 $apiKey 字段替换成你自己的 OpenAI API Key

First, replace the $apiKey field in the start.php file with your own OpenAI API Key

你可以在这里找到参数值

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。