Skip to content

Commit c236f92

Browse files
committed
bug fix
1 parent 11bc4eb commit c236f92

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/cohere/core/pydantic_utilities.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T:
197197
# Not a discriminated union - parse the data field as JSON
198198
data_value = sse_event.get("data")
199199
if isinstance(data_value, str) and data_value:
200+
# Skip [DONE] marker - it's an expected end-of-stream signal, not data
201+
if data_value.strip() == "[DONE]":
202+
return None # type: ignore
200203
try:
201204
parsed_data = json.loads(data_value)
202205
return parse_obj_as(type_, parsed_data)

0 commit comments

Comments
 (0)