damienpayet50320/php-chatgpt-client-api 问题修复 & 功能扩展

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

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

damienpayet50320/php-chatgpt-client-api

Composer 安装命令:

composer create-project damienpayet50320/php-chatgpt-client-api

包简介

PHP Client for Interacting with ChatGPT's GPT-3.5 API

README 文档

README

The ChatGPT PHP Client is a simple PHP library that allows you to interact with the GPT-3.5 API provided by ChatGPT. This library provides an easy way to send prompts to the GPT-3.5 engine and get responses.

Installation

You can install the ChatGPT PHP Client using Composer. Run the following command in your project directory:

composer require damienpayet50320/php-chatgpt-client-api

Usage

To use the ChatGPT PHP Client, you'll need an API key from ChatGPT. Once you have the API key, you can create an instance of the ChatGPTClient class and call the completePrompt method with your desired prompt.

Here's a simple example:

<?php

require_once 'vendor/autoload.php';

use ChatGPT\ChatGPTClient;

$api_key = 'YOUR_API_KEY';
$client = new ChatGPTClient($api_key);

$prompt = 'Hello, I need assistance in writing a paragraph about climate change.';
$options = [
    'temperature' => 0.7,
    'max_tokens' => 100
];

$result = $client->completePrompt($prompt, $options);

echo $result;

Replace 'YOUR_API_KEY' with your actual ChatGPT API key.

CompletePrompt options

  • temperature (float, optional): Controls the randomness of the response. Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more deterministic and focused.

  • max_tokens (integer, optional): Specifies the maximum number of tokens in the generated response. It allows you to limit the length of the generated text.

  • top_p (float, optional): Also known as nucleus sampling or "penalty for words not in nucleus." It restricts the generated output to a cumulative probability until the specified value is reached.

  • frequency_penalty (float, optional): This option allows you to tune the model to avoid repeating the same phrases or words in the output.

  • presence_penalty (float, optional): This option encourages the model to include or avoid certain words in the output. A higher presence penalty discourages the model from using specific words, while a lower value encourages it.

  • stop (string or array of strings, optional): You can provide a list of stop sequences to control the generation and make the model stop when it encounters any of these sequences in the output.

Requirements

  • PHP 8.0 or higher
  • Guzzle HTTP Client 7.x

Documentation

For more information on the available methods and options, please refer to the documentation.

Contributing

Contributions to the ChatGPT PHP Client are welcome! If you find any issues or want to add new features, please submit a pull request or create an issue in the GitHub repository.

License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

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