You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Async::run(function() {
$search = $this->dataAbc;
// dd($search->uuid);
// \Log::info('This is some useful information.');
// Fetch the API key from the environment variable
$apiKey = api_key;
if (!$apiKey) {
\Log::error('OpenAI API key not found.');
// Handle the error, either notify the user or handle it as per your application's logic
// For example:
// return $this->sendErrorResponse('OpenAI API key not found.');
}
$data = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $apiKey,
])
->post("https://api.openai.com/v1/chat/completions", [
"model" => "gpt-4-1106-preview",
"messages" => $search['messages'],
'temperature' => 0.1,
'stream' => false,
"max_tokens" => 1200,
"top_p" => 1,
"frequency_penalty" => 0,
"presence_penalty" => 0,
"response_format" => [
"type" => "json_object"
]
])->json();
if (isset($data)) {
$query = ChatgptUserResponse::create([
'uuid' => $search['uuid'],
'user_json_response' => json_encode($data),
'status' => true,
]);
\Log::info('Query result:', ['query' => $query]);
// Return success response or handle the data further
// return $this->sendSuccessResponse($data, 'user response.');
} else {
\Log::warning('No data received from OpenAI API.');
// Handle the case where no data is received from the API
// For example:
// return $this->sendErrorResponse('No data received from OpenAI API.');
}
});
This is my laravel code for with an api call, so i need to return an instant reponse to user and call this api in async, but after using this it still wait for inner block completation. Could you check why ?
The text was updated successfully, but these errors were encountered:
Async::run(function() {
$search = $this->dataAbc;
// dd($search->uuid);
// \Log::info('This is some useful information.');
The text was updated successfully, but these errors were encountered: