Download the PHP package swoole-inc/open-ai without Composer

On this page you can find all versions of the php package swoole-inc/open-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package open-ai

OpenAI API Client in PHP

为何 fork 此库而不是向原项目发起 PR ,主要是是作者的响应时间太长,一个非常简单的 PR 经常 1-2 周的时间没有任何回复。 我们需要快速验证迭代,后续会抽时间提交给 orhanerday/open-ai

改进

orhanerday/open-ai 库做了一些改进,包括如下内容:

  1. 支持了获取 curl 底层错误码,在出现网络底层的问题后可以根据错误信息排查问题
  2. 支持设置 HTTP 版本,使用方法 $openai->setHttpVersion(2) ,通过设置 HTTP2 协议可以绕过 Nginx 的 proxy cache
  3. 改进了 setBaseUrl() 方法,原库是硬编码写死了 api.openai.com,发送请求前通过字符串替换设置 BaseUrl,不是很优雅
  4. 改进了 chat stream 的实现,原库直接使用了 WRITE_FUNCTION,应用层需要分割 Chunks并手工解析 Event-Stream 消息

使用

实例

代理

在中国无法直接访问 OpenAI 服务器,可以设置代理。


All versions of open-ai with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package swoole-inc/open-ai contains the following files

Loading the files please wait ....