Add (openai): debugging points for inspector

This commit is contained in:
2023-09-25 20:41:58 +08:00
parent 2ddc688926
commit 0f47295328

View File

@@ -97,6 +97,7 @@ public static function chatCompletion($system_prompt, $user_prompt, $model)
dump($system_prompt);
dump($user_prompt);
try {
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
->post('https://api.openai.com/v1/chat/completions', [
'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());
$reply = $json_response?->choices[0]?->message?->content;
return $reply;
}
catch(Exception $e) {
inspector()->reportException($e);
}
return null;
}
}