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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固