cyokup / easy-aichat
easy-aichat
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/cyokup/easy-aichat
Requires
- php: ^7.2|^8.0
This package is auto-updated.
Last update: 2026-02-09 19:27:05 UTC
README
简单快速调用主流AI大模型接口
安装命令:
composer require cyokup/easy-aichat
特点
- 支持多种主流大模型,一套写法兼容所有平台
- 调用简单方便,统一的返回值格式
- 欢迎提PR一起完善项目
已支持大模型
- [qwen]阿里通义千问
- [moonshot]Moonshot AI
使用方法
use Cyokup\EasyAiChat\EasyAiChat;
$aiModel = new EasyAiChat();
// 使用通义千问实现文字转向量
list($embedding, $tokens) = $aiModel->gateway('qwen', ['api_key'=>'xxx'])->embeddings("你好");
// 使用通义千问实现问答
$content = [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "hello"
}
];
// 设置模型名字
$parameters['model'] = 'qwen-turbo';
// 最后一个参数true标识流式输出,默认false
$aiModel->gateway('qwen', ['api_key'=>'xxx'])->chat("你好",$parameters,true);
其他
- 作者微信:cyokup