laswitchtech/php-openai
最新稳定版本:v1.0.3
Composer 安装命令:
composer require laswitchtech/php-openai
包简介
OpenAI Library for PHP Applications
README 文档
README
phpOpenAI
Features
- Easy to use OpenAI cURL Library
Why you might need it
If you are looking for an easy way to integrate OpenAI in your project. This PHP Class is for you.
Can I use this?
Sure!
License
This software is distributed under the GNU General Public License v3.0 license. Please read LICENSE for information on the software availability and distribution.
Requirements
- PHP >= 5.6.0
Security
Please disclose any vulnerabilities found responsibly – report security issues to the maintainers privately.
Installation
Using Composer:
composer require laswitchtech/php-openai
How do I use it?
In this documentations, we will use a table called users for our examples.
Example
Initiate phpOpenAI
//Import phpOpenAI class into the global namespace //These must be at the top of your script, not inside a function use LaswitchTech\phpOpenAI\phpOpenAI; //Load Composer's autoloader require 'vendor/autoload.php'; //Initiate phpOpenAI $phpOpenAI = new phpOpenAI('YOUR_API_KEY');
Completions
//Import phpOpenAI class into the global namespace //These must be at the top of your script, not inside a function use LaswitchTech\phpOpenAI\phpOpenAI; //Load Composer's autoloader require 'vendor/autoload.php'; //Initiate phpOpenAI $phpOpenAI = new phpOpenAI('YOUR_API_KEY'); //Request $phpOpenAI->completions([ 'model' => 'text-davinci-003', 'prompt' => 'Say this is a test', 'temperature' => 0, 'max_tokens' => 7, 'top_p' => 1, 'n' => 1, 'stream' => false, 'logprobs' => null, 'stop' => '\n', ]); // Returns an array
Edits
//Import phpOpenAI class into the global namespace //These must be at the top of your script, not inside a function use LaswitchTech\phpOpenAI\phpOpenAI; //Load Composer's autoloader require 'vendor/autoload.php'; //Initiate phpOpenAI $phpOpenAI = new phpOpenAI('YOUR_API_KEY'); //Request $phpOpenAI->edits([ 'model' => 'text-davinci-edit-001', 'input' => 'What day of the wek is it?', 'instruction' => 'Fix the spelling mistakes', ]); // Returns an array
Moderations
//Import phpOpenAI class into the global namespace //These must be at the top of your script, not inside a function use LaswitchTech\phpOpenAI\phpOpenAI; //Load Composer's autoloader require 'vendor/autoload.php'; //Initiate phpOpenAI $phpOpenAI = new phpOpenAI('YOUR_API_KEY'); //Request $phpOpenAI->moderations([ 'model' => 'text-moderation-stable', 'input' => 'I want to kill them.', ]); // Returns an array
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2023-03-01
