cblink/openai
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:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- 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
cblink/openai 适用场景与选型建议
cblink/openai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 886 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「codex」 「GPT-3」 「openai」 「ChatGpt」 「PHP ChatGPT」 「ChatGPT SDK」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cblink/openai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cblink/openai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cblink/openai 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP 8.0+ OpenAI API client with fully typed/documented requests+responses models, guzzle and symfony/http-client support and async/parallel requests.
WordPress® Settings API service provider
OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API
Estimate AI API costs before making expensive calls
A powerful package that seamlessly integrates OpenAI's advanced AI capabilities into your Laravel applications. This package offers quick setup and intuitive configuration to leverage AI models for chat, embeddings, and more.
A Laravel package that installs and refreshes AI agent harnessing, local runtime drivers, and quality foundations.
统计信息
- 总下载量: 886
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-13