Skip to content

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

Fix: python api streaming structure (#11105)

Billy Baoc7bd0a755cb7
diff --git a/sdk/python/ragflow_sdk/modules/session.py b/sdk/python/ragflow_sdk/modules/session.py
index 9a54eb5e46..d9b6193c4e 100644
--- a/sdk/python/ragflow_sdk/modules/session.py
+++ b/sdk/python/ragflow_sdk/modules/session.py
@@ -74,15 +74,15 @@ class Session(Base):
json_data = res.json()
except ValueError:
raise Exception(f"Invalid response {res}")
- yield self._structure_answer(json_data)
+ yield self._structure_answer(json_data["data"])
def _structure_answer(self, json_data):
if self.__session_type == "agent":
- answer = json_data["data"]["data"]["content"]
+ answer = json_data["data"]["content"]
elif self.__session_type == "chat":
- answer =json_data["data"]["answer"]
- reference = json_data["data"].get("reference", {})
+ answer = json_data["answer"]
+ reference = json_data.get("reference", {})
temp_dict = {
"content": answer,
"role": "assistant"