mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-09 16:58:27 -04:00
fix: OpenAI apis will now correctly print an error to the console if the request fails
This commit is contained in:
@@ -111,8 +111,20 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||
});
|
||||
|
||||
var dataString = await data.Content.ReadAsStringAsync();
|
||||
|
||||
try
|
||||
{
|
||||
data.EnsureSuccessStatusCode();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to get response from OpenAI: {Message}", ex.Message);
|
||||
return new Error<string>("Failed to get response from OpenAI");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var response = JsonConvert.DeserializeObject<OpenAiCompletionResponse>(dataString);
|
||||
|
||||
// Log.Information("Received response: {Response} ", dataString);
|
||||
|
Reference in New Issue
Block a user