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 stream_content():
|
||||||
|
|
||||||
def __event_emitter__(event):
|
def __event_emitter__(event):
|
||||||
logging.error(f"stream_event:{event}")
|
logging.info(f"stream_event:{event}")
|
||||||
return f"event: {json.dumps(event)}\n\n"
|
eventData = {
|
||||||
|
"event" : event
|
||||||
|
}
|
||||||
|
return f"data: {json.dumps(eventData)}\n\n"
|
||||||
|
|
||||||
res = pipe(
|
res = pipe(
|
||||||
user_message=user_message,
|
user_message=user_message,
|
||||||
@ -716,7 +719,7 @@ async def generate_openai_chat_completion(form_data: OpenAIChatCompletionForm):
|
|||||||
|
|
||||||
logging.info(f"stream_content:Generator:{line}")
|
logging.info(f"stream_content:Generator:{line}")
|
||||||
|
|
||||||
if line.startswith("data:") or line.startswith("event:"):
|
if line.startswith("data:"):
|
||||||
yield f"{line}\n\n"
|
yield f"{line}\n\n"
|
||||||
else:
|
else:
|
||||||
line = stream_message_template(form_data.model, line)
|
line = stream_message_template(form_data.model, line)
|
||||||
|
Loading…
Reference in New Issue
Block a user