OpenAIChat
π¬ Usage of OpenAIChat
OpenAIChatIf you want to use the default model, this is enough, so not a lof ot code:
use 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"If you want to select a specific modal, you need to use the Config & Enums:
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"Right now you can choose these enums:
Here you can find out which exact model is currently being used. https://platform.openai.com/docs/models/continuous-model-upgrades
Last updated
Was this helpful?