From a3e4878ba63a7f61c468a074c69461c7f58b529c Mon Sep 17 00:00:00 2001 From: boogiedk Date: Thu, 16 Nov 2023 16:42:46 +0300 Subject: [PATCH] logs error --- SerfBot/OpenAiApi.fs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/SerfBot/OpenAiApi.fs b/SerfBot/OpenAiApi.fs index 2c24613..c92385b 100644 --- a/SerfBot/OpenAiApi.fs +++ b/SerfBot/OpenAiApi.fs @@ -7,6 +7,7 @@ open OpenAI.ObjectModels.RequestModels open SerfBot.Types open OpenAI.Chat open System +open Log let defaultContext = "Ты персональный помощник-бот в telegram. Чаще всего тебе нужно генерировать C#, F# или SQL код, но иногда нужно и отвечать на бытовые вопросы." @@ -53,13 +54,19 @@ let gptAnswer userQuestion = completionResult.Choices |> Seq.head |> fun c -> c.Message.Content else match completionResult.Error with - | null -> raise (Exception("Unknown Error")) - | error -> sprintf "%s: %s" error.Code error.Message + | null -> + "Unknown Error" |> logInfo + raise (Exception("Unknown Error")) + | error -> + $"{error.Code} {error.Message}" |> logInfo + sprintf "%s: %s" error.Code error.Message return result with - | ex -> return ex.Message + | ex -> + ex.Message |> logInfo + return ex.Message } let descriptionAnalyzedImage imageLink = @@ -88,5 +95,7 @@ let descriptionAnalyzedImage imageLink = return answer with - | ex -> return ex.Message.ToString() + | ex -> + ex.Message.ToString() |> logInfo + return ex.Message.ToString() } \ No newline at end of file