From d963304f61b0014e92573185cfdcf0f55ce382ad Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Mon, 10 Mar 2025 20:51:08 +0300 Subject: feat: add error detection and handling for LLM API responses --- bot.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index aecc0b9..409a97b 100644 --- a/bot.go +++ b/bot.go @@ -191,7 +191,12 @@ func sendMsgToLLM(body io.Reader) { streamDone <- true break } - // here line can contain some error msg; if it does we should log it and break from loop; ai! + // Handle error messages in response content + if content != "" && strings.Contains(strings.ToLower(content), "error") { + logger.Error("API error response detected", "content", content, "url", cfg.CurrentAPI) + streamDone <- true + break + } if stop { if content != "" { logger.Warn("text inside of finish llmchunk", "chunk", content, "counter", counter) -- cgit v1.2.3