We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0ec6e6 commit dc39cc0Copy full SHA for dc39cc0
llama_cpp/server/app.py
@@ -259,8 +259,15 @@ def create_completion(
259
)
260
261
if request.stream:
262
+
263
+ async def server_sent_events(
264
+ chunks: Iterator[llama_cpp.CompletionChunk],
265
+ ):
266
+ for chunk in chunks:
267
+ yield dict(data=json.dumps(chunk))
268
269
chunks: Iterator[llama_cpp.CompletionChunk] = completion_or_chunks # type: ignore
- return EventSourceResponse(dict(data=json.dumps(chunk)) for chunk in chunks)
270
+ return EventSourceResponse(server_sent_events(chunks))
271
completion: llama_cpp.Completion = completion_or_chunks # type: ignore
272
return completion
273
0 commit comments