feat: add error detection and handling for LLM API responses
This commit is contained in:
7
bot.go
7
bot.go
@@ -191,7 +191,12 @@ func sendMsgToLLM(body io.Reader) {
|
|||||||
streamDone <- true
|
streamDone <- true
|
||||||
break
|
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 stop {
|
||||||
if content != "" {
|
if content != "" {
|
||||||
logger.Warn("text inside of finish llmchunk", "chunk", content, "counter", counter)
|
logger.Warn("text inside of finish llmchunk", "chunk", content, "counter", counter)
|
||||||
|
|||||||
Reference in New Issue
Block a user