summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder (aider) <wohilas@gmail.com>2025-03-10 20:51:08 +0300
committerGrail Finder (aider) <wohilas@gmail.com>2025-03-10 20:51:08 +0300
commitd963304f61b0014e92573185cfdcf0f55ce382ad (patch)
treefa344a9d6fcc66a72fb53deb10d54b593b9372e2
parentd04fbc792eba0443025fb3f264e108007562009b (diff)
feat: add error detection and handling for LLM API responses
-rw-r--r--bot.go7
1 files changed, 6 insertions, 1 deletions
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)