Add (openai): debugging points for inspector
This commit is contained in:
@@ -97,23 +97,31 @@ public static function chatCompletion($system_prompt, $user_prompt, $model)
|
||||
dump($system_prompt);
|
||||
dump($user_prompt);
|
||||
|
||||
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
|
||||
->post('https://api.openai.com/v1/chat/completions', [
|
||||
'model' => $model,
|
||||
'max_tokens' => 2500,
|
||||
'messages' => [
|
||||
['role' => 'system', 'content' => $system_prompt],
|
||||
['role' => 'user', 'content' => $user_prompt],
|
||||
],
|
||||
]);
|
||||
try {
|
||||
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
|
||||
->post('https://api.openai.com/v1/chat/completions', [
|
||||
'model' => $model,
|
||||
'max_tokens' => 2500,
|
||||
'messages' => [
|
||||
['role' => 'system', 'content' => $system_prompt],
|
||||
['role' => 'user', 'content' => $user_prompt],
|
||||
],
|
||||
]);
|
||||
|
||||
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