topthink / think-ai
v1.0.0
2024-08-30 08:38 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
- topthink/think-helper: ^3.1
This package is auto-updated.
Last update: 2024-11-10 10:11:47 UTC
README
聊天
use think\ai\Client; $client = new Client('YOUR_TOKEN'); //非流式输出 $result = $client->chat()->completions([ 'model' => 'gpt-3.5-turbo', 'messages' => [ ['role' => 'user', 'content' => 'Hello!'], ], 'stream'=>false, ]); dump($result); //流式输出 $result = $client->chat()->completions([ 'model' => 'gpt-3.5-turbo', 'messages' => [ ['role' => 'user', 'content' => 'Hello!'], ], 'stream'=>true, ]); foreach($result as $chunk){ dump($chunk); }
图像
use think\ai\Client; $client = new Client('YOUR_TOKEN'); //画图 $client->images()->generations($params); //涂抹编辑 $client->images()->inpainting($params); //图像扩展 $client->images()->outpainting($params);
...其他用法类似