sabir/chatgpt 问题修复 & 功能扩展

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

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

sabir/chatgpt

最新稳定版本:1.0.0

Composer 安装命令:

composer require sabir/chatgpt

包简介

A Laravel package for interacting with ChatGPT APIs.

README 文档

README

To integrate the ChatGPT package with PHP and Laravel, please follow these steps:

Install the package: Install the package via Composer by running the following command in your project directory:

composer require sabir/chatgpt:dev-master Publish configuration file: Run the following command to publish the package's configuration file:

php artisan vendor:publish --tag=chatgpt-config --ansi --force This command will create a configuration file named chatgpt.php in your Laravel project's config directory.

Set API key and model: Open the .env file in your project's root folder and set the values for the following environment variables:

CHAT_API=YOUR_CHAT_API_KEY CHAT_MODEL=YOUR_CHAT_MODEL_ID Replace YOUR_CHAT_API_KEY with your OpenAI Chat API key and YOUR_CHAT_MODEL_ID with the model ID you want to use (e.g., "davinci", "curie", "babbage", or "ada").

Create an instance and call the chat method: In your Laravel code, you can now create an instance of the ChatGPT class and call the chat method to interact with the ChatGPT model. Here's an example:

use Sabir\ChatGPT\Facades\ChatGPT;

// ...

$s = new ChatGPT(); $response = $s->chat('hi, how are you?'); dd($response);

The chat method accepts three parameters:

message (required): The message or prompt to send to the ChatGPT model. type (optional): The API type to use for the chat. If left blank or set to "devinci", "curie", "babbage", or "ada", it will use the OpenAI models. You can extend this functionality to include other types if needed. options (optional): An array of additional options for the API request, such as temperature, max_tokens, top_p, etc. The chat method will return the response from the ChatGPT model.

Note: The provided code snippet is a simplified example. You may need to adjust it based on your project structure and requirements.

Ensure that you have properly configured the API key, model ID, and other settings according to your OpenAI account and desired behavior.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-15