From dfff8a367b66678d909a8bb2f89f8220a2070c28 Mon Sep 17 00:00:00 2001 From: boogiedk Date: Mon, 11 Dec 2023 15:39:33 +0300 Subject: [PATCH] fix --- SerfBot/OpenAiApi.fs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/SerfBot/OpenAiApi.fs b/SerfBot/OpenAiApi.fs index 72792ed..a0e2631 100644 --- a/SerfBot/OpenAiApi.fs +++ b/SerfBot/OpenAiApi.fs @@ -51,15 +51,19 @@ let gptAnswer userQuestion = let result = if completionResult.Successful then - completionResult.Choices |> Seq.head |> fun c -> c.Message.Content + completionResult.Choices + |> Seq.head + |> fun c -> c.Message.Content else match completionResult.Error with | null -> - "Unknown Error" |> logInfo - raise (Exception("Unknown Error")) + let errorMessage = "Unknown Error" + errorMessage |> logInfo + errorMessage | error -> - $"{error.Code} {error.Message}" |> logInfo - sprintf "%s: %s" error.Code error.Message + let errorMessage = $"{error.Code} {error.Message}" + errorMessage |> logInfo + errorMessage return result