panix / yii2-ChatGPT
Yii2 ChatGPT
1.0.0
2023-06-03 14:36 UTC
Requires
README
查看所有方法: https://github.com/orhanerday/open-ai#documentation
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一
php composer require --prefer-dist panix/yii2-chatgpt "*"
或添加
"panix/yii2-chatgpt": "*"
添加配置文件
<?php 'components' => [ 'chatgpt' => [ 'class' => 'panix\ext\chatgpt\ChatGPT', 'apikey' => 'YOUR_API_KEY', //required 'org' => 'ORGANIZATION_KEY' // not required ], //... ] ?>
到您的 composer.json
文件的 require 部分。
使用方法
安装扩展后,只需在您的代码中通过
<?php $gpt = Yii::$app->chatgpt->completion([ 'model' => 'text-davinci-003', 'prompt' => 'Hello', 'temperature' => 0.9, 'max_tokens' => 150, 'frequency_penalty' => 0, 'presence_penalty' => 0.6, ]); print_r($gpt); ?>