Hello everyone!, I’m trying to write an application using gps 3.5 turbo 16k, but there is a problem and it lies in the fact that when writing a 2000 tokens, the server constantly goes into timeout
The code of my controller is given below: (If there is anything else you need, then be sure to write) :
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Http;
use Illuminate\Http\Request;
class ChatController extends Controller
{
private $openAIRequest;
public function __construct()
{
$this->openAIRequest = Http::withoutVerifying()
->withOptions(['timeout' => 120])
->withHeaders([
'Authorization' => 'Bearer ' . config('openai.api_key'),
'Content-Type' => 'application/json',
]);
}
public function messeges(Request $request)
{
$prompt = $request->input('prompt');
$proglang = $request->input('proglang');
$framework = $request->input('framework');
$size = $request->input('size');
$lang = $request->input('lang');
$message = $proglang . $framework . $size . $lang . $prompt ;
return $this->askToChatGPT($message);
}
private function askToChatGPT($message)
{
$response = $this->openAIRequest->post('https://api.openai.com/v1/chat/completions', [
"model" => "gpt-3.5-turbo-16k",
"messages" => [
[
"role" => "user",
"content" => $message
]
],
"max_tokens" => 5000,
]);
return $response->json()['choices'][0]['message']['content'];
}
}
"message": "Maximum execution time of 60 seconds exceeded",
"exception": "Symfony\\Component\\ErrorHandler\\Error\\Fatal error
And also here are the laravel logs:
[previous exception] [object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] Disconnection is not set, because the conjugator has disabled access to the connection in C:\\Users\\crash\\OneDrive\\Рабочий stol\\ANGELS-iT DOCUMENTARIAN\\Application\\provider\\laravel\\framework\\src\\Illuminate\\Database\\Connectors\\Connector.php:65)
[stack tracking]
[2023-10-13 08:08:13] local.mistake: Exceeded the maximum execution time by 60 seconds {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Exceeded the maximum execution time by 60 seconds when C:\\Users\\crash\\OneDrive\\Рабочий table\\ANGELS is A DOCUMENTARIAN\\Application\\provider\\guzzlehttp\\guzzle\\src\\Handler\\CurlHandler.php:45)
[stack tracking]
#0 {main}