Fix: python api streaming structure (#11105)

### What problem does this PR solve?

Fix: python api streaming structure

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Billy Bao 2025-11-07 16:50:58 +08:00 committed by GitHub
parent dd1c8c5779
commit c7bd0a755c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"