定制 tallesairan/oobapi-php 二次开发

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

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

tallesairan/oobapi-php

Composer 安装命令:

composer require tallesairan/oobapi-php

包简介

PHP Wrapper for oobabooga's text-generation-webui

README 文档

README

PHP Wrapper for oobabooga's text-generation-webui

This is a PHP client for interacting with WebSocket and HTTP endpoints of the Text Generation API. The client allows you to send requests to the server and receive responses from the WebSocket and HTTP endpoints.

This documentation provides information about the oobapi-php library, a PHP wrapper for oobabooga's text-generation-webui. The library consists of two main classes, ApiClient and StreamClient, each responsible for interacting with different API endpoints.

Table of Contents

Installation

To use the oobapi-php library, you need to have PHP 7.4 or later installed. Additionally, the library depends on the following packages:

  • guzzlehttp/guzzle version 7.0 or later
  • textalk/websocket version 1.6.1 or later

You can install the library via Composer. Add the following to your composer.json file and run composer install:

Requirements

  • PHP 7.4 or higher
  • Composer
composer require tallesairan/oobapi-php

ApiClient

The ApiClient class allows you to interact with the oobabooga's text-generation-webui API using HTTP requests.

Constructor

Create a new ApiClient instance by providing the base URL for the API:

use Airan\OobApi\ApiClient;

$baseUrl = 'http://example.com'; // Replace with your API base URL
$apiClient = new ApiClient($baseUrl);

Methods

generate

Generate text based on a given prompt and optional parameters.

/**
* Generate text based on a given prompt and optional parameters.
*
* @param string $prompt The input prompt for text generation.
* @param array $params Optional parameters to customize text generation.
* @return array An array containing the generated text and additional data.
  */
  public function generate($prompt, $params = []) {
  // Implementation details...
  }

chat

Chat with the API to generate interactive text based on user input and history.

/**
* Chat with the API to generate interactive text based on user input and history.
*
* @param string $userInput The user's input text.
* @param string $history The conversation history.
* @param array $params Optional parameters to customize the chat.
* @return array An array containing the generated response and additional data.
  */
  public function chat($userInput, $history, $params = []) {
  // Implementation details...
  }

stopStream

Stop the text generation stream.

/**
* Stop the text generation stream.
*
* @return array An array containing the response data.
  */
  public function stopStream() {
  // Implementation details...
  }

StreamClient

  • Take careful this is under development

The StreamClient class enables you to interact with the oobabooga's text-generation-webui API using WebSocket.

Constructor

Create a new StreamClient instance by providing the WebSocket base URL:

use Airan\OobApi\StreamClient;

$webSocketBaseUrl = 'ws://example.com'; // Replace with your WebSocket base URL
$streamClient = new StreamClient($webSocketBaseUrl);

Methods

stream

Generate text using WebSocket streaming based on a given prompt and optional parameters.

/**
* Generate text using WebSocket streaming based on a given prompt and optional parameters.
*
* @param string $prompt The input prompt for text generation.
* @param array $params Optional parameters to customize text generation.
* @return array An array containing the generated text and additional data.
  */
  public function stream($prompt, $params = []) {
  // Implementation details...
  }

chatStream

Chat using WebSocket streaming to generate interactive text based on user input and history.

/**
* Chat using WebSocket streaming to generate interactive text based on user input and history.
*
* @param string $userInput The user's input text.
* @param string $history The conversation history.
* @param array $params Optional parameters to customize the chat.
* @return array An array containing the generated response and additional data.
  */
  public function chatStream($userInput, $history, $params = []) {
  // Implementation details...
  }

Please note that the above documentation provides a general overview of the oobapi-php library and its main classes. For more specific implementation details and usage examples, refer to the source code and documentation of the library itself.

Contributions

Contributions are welcome! If you find any issues or want to improve the client, feel free to open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Please make sure to adjust the WebSocket and HTTP endpoint URLs in the Usage section to match the actual implementation of your WebSocket and HTTP servers. Also, update the WebSocket and HTTP server information in the WebSocket Server and HTTP Server sections accordingly.

tallesairan/oobapi-php 适用场景与选型建议

tallesairan/oobapi-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 tallesairan/oobapi-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-07-27