dneustadt/openai-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dneustadt/openai-client

Composer 安装命令:

composer require dneustadt/openai-client

包简介

Client for OpenAI API

README 文档

README

OpenAI is an AI research and deployment company. Our mission is to ensure that artificial general intelligence benefits all of humanity.

Installation & Usage

Requirements

PHP 7.2 and later.

Composer

To install via Composer:

composer require dneustadt/openai-client

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: api_key
$config = OpenAI\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');

$apiInstance = new OpenAI\Client\Api\AnswerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$open_ai_organization = 'open_ai_organization_example'; // optional
$answer_payload = new \OpenAI\Client\Model\AnswerPayload(); // \OpenAI\Client\Model\AnswerPayload

try {
    $result = $apiInstance->postAnswer($open_ai_organization, $answer_payload);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AnswerApi->postAnswer: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://api.openai.com/v1

Class Method HTTP request Description
AnswerApi postAnswer POST /answers Answers the specified question using the provided documents and examples.
ClassificationApi postClassification POST /classifications The endpoint first searches over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the completions endpoint.
CompletionsApi postCompletions POST /engines/{engine_id}/completions Creates a new completion for the provided prompt and parameters
EmbeddingsApi postEmbeddings POST /embeddings Creates an embedding vector representing the input text.
EnginesApi getEngineById GET /engines/{engine_id} Retrieves an engine instance, providing basic information about the engine such as the owner and availability.
EnginesApi getEngines GET /engines Lists the currently available engines, and provides basic information about each one such as the owner and availability.
FilesApi deleteFile DELETE /files/{file_id} Delete a file.
FilesApi getFileById GET /files/{file_id} Returns information about a specific file.
FilesApi getFiles GET /files Returns a list of files that belong to the user's organization.
FilesApi postFile POST /files Upload a file that contains document(s) to be used across various endpoints/features.
FineTunesApi getFineTune GET /fine-tunes/{fine_tune_id} Gets info about the fine-tune job.
FineTunesApi getFineTuneEvents GET /fine-tunes/{fine_tune_id}/events Get fine-grained status updates for a fine-tune job.
FineTunesApi getFineTunes GET /fine-tunes List your organization's fine-tuning jobs
FineTunesApi postFineTuneCancel POST /fine-tunes/{fine_tune_id}/cancel Immediately cancel a fine-tune job.
FineTunesApi postFineTunes POST /fine-tunes Creates a job that fine-tunes a specified model from a given dataset.
ImagesApi postImagesEdits POST /images/edits Creates an edited or extended image given an original image and a prompt.
ImagesApi postImagesGenerations POST /images/generations Given a prompt and/or an input image, the model will generate a new image.
ImagesApi postImagesVariations POST /images/variations Creates a variation of a given image.
ModelsApi deleteModel DELETE /models/{model} Delete a fine-tuned model. You must have the Owner role in your organization.
ModelsApi getModel GET /models/{model} Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
ModelsApi getModels GET /models Lists the currently available models, and provides basic information about each one such as the owner and availability.
ModerationsApi postModerations POST /moderations Classifies if text violates OpenAI's Content Policy
SearchApi postSearch POST /search The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.

Models

Request Payloads

Response Models

dneustadt/openai-client 适用场景与选型建议

dneustadt/openai-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 05 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dneustadt/openai-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dneustadt/openai-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 dneustadt/openai-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-21