Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: prevent list index out of range in chat streaming (#10238)

buua43638be53cf317e
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py
index d0b422215b..79304d27a0 100644
--- a/rag/llm/chat_model.py
+++ b/rag/llm/chat_model.py
@@ -146,7 +146,7 @@ class Base(ABC):
response = self.client.chat.completions.create(model=self.model_name, messages=history, **gen_conf, **kwargs)
- if any([not response.choices, not response.choices[0].message, not response.choices[0].message.content]):
+ if (not response.choices or not response.choices[0].message or not response.choices[0].message.content):
return "", 0
ans = response.choices[0].message.content.strip()
if response.choices[0].finish_reason == "length":