taravel/6. `app/Services/OpenAIService.php

24 lines
421 B
PHP

<?php
namespace App\Services;
use OpenAI\Client;
class OpenAIService
{
protected $client;
public function __construct(Client $client)
{
$this->client = $client;
}
public function sendPrompt($prompt)
{
return $this->client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => $prompt,
'max_tokens' => 150,
]);
}
}