Add (openai): debugging points for inspector
This commit is contained in:
@@ -97,6 +97,7 @@ public static function chatCompletion($system_prompt, $user_prompt, $model)
|
|||||||
dump($system_prompt);
|
dump($system_prompt);
|
||||||
dump($user_prompt);
|
dump($user_prompt);
|
||||||
|
|
||||||
|
try {
|
||||||
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
|
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
|
||||||
->post('https://api.openai.com/v1/chat/completions', [
|
->post('https://api.openai.com/v1/chat/completions', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
@@ -107,13 +108,20 @@ public static function chatCompletion($system_prompt, $user_prompt, $model)
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
dump($response->body);
|
dump($response->body());
|
||||||
|
|
||||||
$json_response = json_decode($response->body());
|
$json_response = json_decode($response->body());
|
||||||
|
|
||||||
$reply = $json_response?->choices[0]?->message?->content;
|
$reply = $json_response?->choices[0]?->message?->content;
|
||||||
|
|
||||||
return $reply;
|
return $reply;
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
|
inspector()->reportException($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user