tenko/ai-tools-php
最新稳定版本:v1.0.0
Composer 安装命令:
composer require tenko/ai-tools-php
包简介
Ai Utils for ChatGPT and Azure
README 文档
README
This is a Util for ChatGPT and Azure.
Quick Start
Install
composer require tenko/ai-tools-php
Usage
- ChatGPT:
<?php $config = new OpenAiConfig(); $config->setApiKeys([ 'key1', 'key2', // more... ]); // proxy if you need, "https://api.openai.com" will be replaced by "https://example.com/" in request url. $config->setAgencyUrl('https://example.com/'); $service = new OpenAI($this->getOpenAiConfig()); $service->setContext( new GptContext(GptRoleEnum::SYSTEM, '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本'), new GptContext(GptRoleEnum::USER, '你好') ); // or $service->setContext(...GptContext::construct([ [ 'role' => 'system', 'content' => '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本' ], [ 'role' => 'user', 'content' => '你好' ] ])); $response = $service->chat(); var_dump($response); echo $response->getResponse();
- Azure:
$config = new AzureConfig(); $config->setApiVersion(''); $config->setDeployments(''); $config->setResourceName(''); $config->setApiKeys([ 'key1', 'key2', // more... ]); $service = new Azure($this->getAzureConfig()); $service->setContext( new GptContext(GptRoleEnum::SYSTEM, '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本'), new GptContext(GptRoleEnum::USER, '你好') ); $response = $service->chat(); var_dump($response); echo $response->getResponse();
For more details, see configs.md
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-26