Skip to content

Commit

Permalink
logs error
Browse files Browse the repository at this point in the history
  • Loading branch information
boogiedk committed Nov 16, 2023
1 parent 7df40c8 commit a3e4878
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions SerfBot/OpenAiApi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ open OpenAI.ObjectModels.RequestModels
open SerfBot.Types
open OpenAI.Chat
open System
open Log


let defaultContext = "Ты персональный помощник-бот в telegram. Чаще всего тебе нужно генерировать C#, F# или SQL код, но иногда нужно и отвечать на бытовые вопросы."
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -88,5 +95,7 @@ let descriptionAnalyzedImage imageLink =
return answer

with
| ex -> return ex.Message.ToString()
| ex ->
ex.Message.ToString() |> logInfo
return ex.Message.ToString()
}

0 comments on commit a3e4878

Please sign in to comment.