File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ class EVEClient:
3939 """
4040
4141 _DEFAULT_TIMEOUT = 30.0
42+ _SSE_DONE_SENTINEL = "[DONE]"
4243
4344 def __init__ (
4445 self ,
@@ -260,9 +261,7 @@ async def stream(
260261 if not line or not line .startswith ("data: " ):
261262 continue
262263
263- if ( # pylint: disable=magic-value-comparison
264- data_str := line [6 :]
265- ) == "[DONE]" :
264+ if (data_str := line [6 :]) == self ._SSE_DONE_SENTINEL :
266265 return
267266
268267 try :
Original file line number Diff line number Diff line change 2121
2222
2323class StatusEvent (TypedDict ):
24+ """SSE event emitted while the server is still working."""
25+
2426 type : Literal ["status" ]
2527 content : str
2628
2729
2830class TokenEvent (TypedDict ):
31+ """SSE event carrying an incremental token of the streamed response."""
32+
2933 type : Literal ["token" ]
3034 content : str
3135
3236
3337class FinalEvent (TypedDict ):
38+ """SSE event marking the final, complete response."""
39+
3440 type : Literal ["final" ]
3541 content : str
3642 message_id : str
3743
3844
3945class ErrorEvent (TypedDict ):
46+ """SSE event indicating the stream terminated with an error."""
47+
4048 type : Literal ["error" ]
4149 content : str
4250
You can’t perform that action at this time.
0 commit comments