feat(agent): handle AIMessageChunk content access in copilot streaming

Update agent service to properly access content from AIMessageChunk objects during chat model streaming. Instead of using dictionary get method on the chunk, now use getattr to directly access the content attribute, ensuring compatibility with the AIMessageChunk object structure.
This commit is contained in:
YueGuobin 2026-03-04 13:23:07 +08:00
parent b780bfaf53
commit 5e9aac7514

View File

@ -171,7 +171,8 @@ class AgentService:
if event_type == "on_chat_model_stream":
# Streaming text content from LLM
chunk = data.get("chunk", {})
content = chunk.get("content", "")
# chunk is AIMessageChunk object, access content directly
content = getattr(chunk, "content", "")
if content:
return {"type": "content", "content": content}