hch/chatgpt-integration-bundle 问题修复 & 功能扩展

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

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

hch/chatgpt-integration-bundle

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hch/chatgpt-integration-bundle

包简介

A Symfony bundle to integrate ChatGPT API.

README 文档

README

This bundle provides a simple way to integrate ChatGPT API with Symfony applications.

Installation

composer require HCH/chatgpt-integration-bundle

Configuration

In your Symfony config, add your OpenAI API key, API URL, and model:

# config/packages/chatgpt_integration.yaml
chatgpt_integration:
    api_key: '%env(CHATGPT_API_KEY)%'
    api_url: 'https://api.openai.com/v1/chat/completions'
    model: 'gpt-3.5-turbo'

Usage

Inject the ChatGPTClient service wherever needed:

use HCH\ChatGPTIntegrationBundle\Service\ChatGPTClient;

class SomeService
{
    private $chatGPTClient;

    public function __construct(ChatGPTClient $chatGPTClient)
    {
        $this->chatGPTClient = $chatGPTClient;
    }

    public function getResponseFromChatGPT(string $message): string
    {
        return $this->chatGPTClient->ask($message);
    }
}

Testing

Run tests with PHPUnit:

php bin/phpunit

License

This bundle is released under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-25