定制 laswitchtech/php-openai 二次开发

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

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

laswitchtech/php-openai

最新稳定版本:v1.0.3

Composer 安装命令:

composer require laswitchtech/php-openai

包简介

OpenAI Library for PHP Applications

README 文档

README

GitHub repo logo

phpOpenAI

License GitHub repo size GitHub top language Version

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
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2023-03-01