Skip to content
Snippets Groups Projects
Commit 798f3785 authored by leehuwuj's avatar leehuwuj
Browse files

fix empty chunk

parent dae32495
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,8 @@ class VercelStreamResponse(StreamingResponse):
Accept stream text from either AgentStream or StopEvent with string or AsyncGenerator result
"""
if isinstance(event, AgentStream):
yield event.delta
if event.delta.strip(): # Only yield non-empty deltas
yield event.delta
elif isinstance(event, StopEvent):
if isinstance(event.result, str):
yield event.result
......@@ -76,7 +77,9 @@ class VercelStreamResponse(StreamingResponse):
async for chunk in event.result:
if isinstance(chunk, str):
yield chunk
elif hasattr(chunk, "delta"):
elif (
hasattr(chunk, "delta") and chunk.delta.strip()
): # Only yield non-empty deltas
yield chunk.delta
@classmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment