mirror of
https://github.com/open-webui/pipelines
synced 2025-06-26 18:15:58 +00:00
following SSE standard with data:
This commit is contained in:
parent
42dc791278
commit
e1ac385395
9
main.py
9
main.py
@ -685,8 +685,11 @@ async def generate_openai_chat_completion(form_data: OpenAIChatCompletionForm):
|
||||
def stream_content():
|
||||
|
||||
def __event_emitter__(event):
|
||||
logging.error(f"stream_event:{event}")
|
||||
return f"event: {json.dumps(event)}\n\n"
|
||||
logging.info(f"stream_event:{event}")
|
||||
eventData = {
|
||||
"event" : event
|
||||
}
|
||||
return f"data: {json.dumps(eventData)}\n\n"
|
||||
|
||||
res = pipe(
|
||||
user_message=user_message,
|
||||
@ -716,7 +719,7 @@ async def generate_openai_chat_completion(form_data: OpenAIChatCompletionForm):
|
||||
|
||||
logging.info(f"stream_content:Generator:{line}")
|
||||
|
||||
if line.startswith("data:") or line.startswith("event:"):
|
||||
if line.startswith("data:"):
|
||||
yield f"{line}\n\n"
|
||||
else:
|
||||
line = stream_message_template(form_data.model, line)
|
||||
|
Loading…
Reference in New Issue
Block a user