PHPackages                             ramprasadm1986/yii2-chatgpt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ramprasadm1986/yii2-chatgpt

ActiveYii2-extension[API Development](/categories/api)

ramprasadm1986/yii2-chatgpt
===========================

A Yii2 component for interacting with the OpenAI ChatGPT API, including Agri Advisor GPT for agricultural advisory.

v1.0.1(1y ago)017MITPHPPHP &gt;=7.4

Since Nov 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ramprasadm1986/yii2-chatgpt)[ Packagist](https://packagist.org/packages/ramprasadm1986/yii2-chatgpt)[ RSS](/packages/ramprasadm1986-yii2-chatgpt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Yii2 ChatGPT Component
======================

[](#yii2-chatgpt-component)

A Yii2 component to interact with the OpenAI ChatGPT API.

Installation
------------

[](#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;
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

547d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/53647737?v=4)[ramprasad](/maintainers/ramprasad)[@Ramprasad](https://github.com/Ramprasad)

---

Top Contributors

[![ramprasadm1986](https://avatars.githubusercontent.com/u/54374127?v=4)](https://github.com/ramprasadm1986 "ramprasadm1986 (3 commits)")

---

Tags

openaiyii2ChatGptadvisoragriculture

### Embed Badge

![Health badge](/badges/ramprasadm1986-yii2-chatgpt/health.svg)

```
[![Health](https://phpackages.com/badges/ramprasadm1986-yii2-chatgpt/health.svg)](https://phpackages.com/packages/ramprasadm1986-yii2-chatgpt)
```

###  Alternatives

[creativecrafts/laravel-ai-assistant

A handy package to access and interact with OpenAi endpoint

141.1k](/packages/creativecrafts-laravel-ai-assistant)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
