定制 cblink/openai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cblink/openai

最新稳定版本:v0.1.2

Composer 安装命令:

composer require cblink/openai

包简介

An OpenAI REST API Client with ChatGPT, GPT-3, Codex, DALL·E.

README 文档

README

OpenAI 应用 ChatGPT

安装

$ composer require cblink/openai -vvv

使用

// 传入配置
$config = [
    // openai的apikey
    'api_key' => '',
    // 请求的初始配置
    'guzzle' => [
        // 代理配置,如果没有的话可以不传入,配置参考 https://docs.guzzlephp.org/en/stable/request-options.html#proxy
        'proxy' => [],
    ],
];

$openai = new Cblink\ChatGPT\OpenAI($config);

// 查询可用的模型
$openai->models->lists();

// 创建对话
$openai->chat->create([
    'model' => 'gpt-3.5-turbo',
    'messages' => [
        ['role' => 'user', 'content' => 'hello!'],
    ],
]);

// 创建图片
$openai->image->create([
    'prompt' => 'A cute baby sea otter',
]);


// 未封装的接口请求

// get 请求
$openai->httpGet('v1/files')

// post 请求 ,参数: 路径,请求参数,文件
$openai->httpPost('v1/files', [
    'purpose' => 'fine-tune',
], [
    // 此处传入路径即可
    'file' => '/path/file'
])

// delete请求
$file_id = 'file-XjGxS3KTG0uNmNOK362iJua3';
$openai->httpDelete(sprintf('v1/files/%s', $file_id))

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

统计信息

  • 总下载量: 886
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-13