mirror of
https://github.com/open-webui/pipelines
synced 2025-05-12 08:30:43 +00:00
fix
This commit is contained in:
parent
39da1c982a
commit
be06b61e83
4
main.py
4
main.py
@ -135,13 +135,13 @@ async def generate_openai_chat_completion(form_data: OpenAIChatCompletionForm):
|
||||
print(res)
|
||||
|
||||
if isinstance(res, str):
|
||||
message = stream_message_template(res)
|
||||
message = stream_message_template(form_data.model, res)
|
||||
yield f"data: {json.dumps(message)}\n\n"
|
||||
|
||||
elif isinstance(res, Generator):
|
||||
for message in res:
|
||||
print(message)
|
||||
message = stream_message_template(message)
|
||||
message = stream_message_template(form_data.model, message)
|
||||
yield f"data: {json.dumps(message)}\n\n"
|
||||
|
||||
finish_message = {
|
||||
|
5
utils.py
5
utils.py
@ -3,15 +3,14 @@ import time
|
||||
|
||||
from typing import List
|
||||
from schemas import OpenAIChatMessage
|
||||
from config import MODEL_ID
|
||||
|
||||
|
||||
def stream_message_template(message: str):
|
||||
def stream_message_template(model: str, message: str):
|
||||
return {
|
||||
"id": f"rag-{str(uuid.uuid4())}",
|
||||
"object": "chat.completion.chunk",
|
||||
"created": int(time.time()),
|
||||
"model": MODEL_ID,
|
||||
"model": model,
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
|
Loading…
Reference in New Issue
Block a user