OpenAIChat
π¬ Usage of OpenAIChat
OpenAIChatuse EasyAI\Chat\OpenAIChat; // Using OpenAI Chat
// here is the code to call OpenAI API
$chat = new OpenAIChat();
$response = $chat->generateText('What is the population of Tokyo area, answer with only a number.');
// $response = "37 million"use EasyAI\OpenAIConfig; // Using OpenAI Config
use EasyAI\Chat\OpenAIChat; // Using OpenAI Chat
use EasyAI\Chat\Enums\OpenAIChatModel; // Using Enmus OpenAIChatModel
// e.g. in dependencyInjection
$config = new OpenAIConfig();
$config->apiKey = $_ENV['OTHER_KEY']; // Here you can define your key (as default we are using getenv('OPENAI_API_KEY') or $_ENV['OPENAI_API_KEY'])
$config->model = OpenAIChatModel::Gpt35Turbo->getModelName(); // Here you can define the model
$chat = new OpenAIChat($config);
// here is the code to call OpenAI API
$response = $chat->generateText('What is the population of Tokyo area, answer with only a number.');
// $response = "37 million"Last updated