定制 hstanleycrow/easyphpopenai 二次开发

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

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

hstanleycrow/easyphpopenai

Composer 安装命令:

composer require hstanleycrow/easyphpopenai

包简介

Free PHP Library to use OpenAI API into any PHP project

README 文档

README


Easy PHP OpenAI

Free PHP Library to use OpenAI API into any PHP project

How To UseDownloadLicense

How To Use

# Clone this repository
$ git clone https://github.com/hstanleycrow/EasyPHPOpenAI/

# install libraries
$ composer update

or

# Install using composer
$ composer require hstanleycrow/easyphpopenai

### Using Examples
You can adjdust the parameters like temperature, stop, max_tokens, see full list of parameters on the methods.

```php
$openAIAPI = new OpenAIAPI($OPENAI_API_KEY);

# Get Model lists 
var_dump($openAIAPI->models());

# Completion Example
/*
$prompt = "Por favor, genera un solo meta título basado en los título de los resultados de búsqueda de Google que proporciono basados en las keywords para las que quiero posicionar. Analiza lo mas relevante, trata de apegartea a la longitud de los titulos de muestra. Estos son los titulos de muestra:###\n1- Zapatos azules baratos\n2- Mejores Zapatos azules\n3- Zapatos Azules duraderos\n4- Zapatos deportivos azules baratos\n\n###";

if ($response = $openAIAPI->complete($prompt)) :
    echo "Titulo: $response";
else :
    echo $openAIAPI->errorMessage();
endif;

# Edit Example
$input = "What day of the wek is it?";
$instruction = "Fix the spelling mistakes";
$openAIAPI->setModel("text-davinci-edit-001");
if ($response = $openAIAPI->edit($input, $instruction)) :
    echo "Respuesta: $response";
else :
    echo $openAIAPI->errorMessage();
endif;

Download

You can download the latest version here.

PHP Versions

I have tested this class only in this PHP versions. So, if you have an older version and do not work, let me know.

PHP Version
PHP 8.0
PHP 8.1
PHP 8.2

Support

Buy Me A Coffee

License

MIT

www.hablemosdeseo.net  ·  GitHub @hstanleycrow  ·  Twitter @harold_crow

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-01