ramprasadm1986/yii2-chatgpt
最新稳定版本:v1.0.1
Composer 安装命令:
composer require ramprasadm1986/yii2-chatgpt
包简介
A Yii2 component for interacting with the OpenAI ChatGPT API, including Agri Advisor GPT for agricultural advisory.
README 文档
README
A Yii2 component to interact with the OpenAI ChatGPT API.
Installation
Install via Composer:
composer require ramprasadm1986/yii2-chatgpt ## ChatGPT Configure `chatGPT` in `config/web.php`: ```php 'components' => [ 'chatGPT' => [ 'class' => 'ramprasadm1986\chatgpt\ChatGPT', 'apiKey' => 'YOUR_OPENAI_API_KEY', ], ], ### Usage Example ```php $response = $response = Yii::$app->chatgpt->askGPT('What is the weather like today?', 'general knowledge', 'gpt-3.5-turbo'); echo $response; ## AgriAdvisorGPT In addition to standard ChatGPT interactions, this package provides `AgriAdvisorGPT` for agriculture-specific questions. It uses a custom system prompt to provide specialized advice. Configure `AgriAdvisorGPT` in `config/web.php`: ```php 'components' => [ 'agriAdvisorGPT' => [ 'class' => 'ramprasadm1986\chatgpt\AgriAdvisorGPT', 'apiKey' => 'YOUR_OPENAI_API_KEY', ], ], ### Usage in Yii2 Project You can now use the `agriAdvisorGPT` component to get tailored advice for agricultural topics. Examples: **General Advice**: ```php $response = Yii::$app->agriAdvisorGPT->askAgriAdvisor('What are the best practices for pest management in organic farming?'); echo $response; $response = Yii::$app->agriAdvisorGPT->askCropAdvisor('corn', 'How often should I irrigate corn during summer?'); echo $response;
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-12