Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions custom_components/webhook_conversation/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ async def _send_payload_streaming(
if line_str:
try:
chunk_data = json.loads(line_str)
if (
chunk_data.get("type") == "item"
and "content" in chunk_data
):
chunk_type = chunk_data.get("type")
if chunk_type == "item" and "content" in chunk_data:
yield chunk_data["content"]
elif chunk_data.get("type") == "end":
break
elif chunk_type == "error":
raise HomeAssistantError(
f"n8n error: {chunk_data.get('message', chunk_data)}"
)
# We don't break on "end" because n8n can send multiple
# begin/end blocks when using tools or intermediate steps.
# We keep reading until the stream actually closes.
except json.JSONDecodeError:
_LOGGER.warning(
"Failed to parse streaming response chunk: %s", line_str
Expand Down
Loading