mirror of
https://github.com/open-webui/pipelines
synced 2025-05-13 17:10:45 +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)
|
print(res)
|
||||||
|
|
||||||
if isinstance(res, str):
|
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"
|
yield f"data: {json.dumps(message)}\n\n"
|
||||||
|
|
||||||
elif isinstance(res, Generator):
|
elif isinstance(res, Generator):
|
||||||
for message in res:
|
for message in res:
|
||||||
print(message)
|
print(message)
|
||||||
message = stream_message_template(message)
|
message = stream_message_template(form_data.model, message)
|
||||||
yield f"data: {json.dumps(message)}\n\n"
|
yield f"data: {json.dumps(message)}\n\n"
|
||||||
|
|
||||||
finish_message = {
|
finish_message = {
|
||||||
|
5
utils.py
5
utils.py
@ -3,15 +3,14 @@ import time
|
|||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from schemas import OpenAIChatMessage
|
from schemas import OpenAIChatMessage
|
||||||
from config import MODEL_ID
|
|
||||||
|
|
||||||
|
|
||||||
def stream_message_template(message: str):
|
def stream_message_template(model: str, message: str):
|
||||||
return {
|
return {
|
||||||
"id": f"rag-{str(uuid.uuid4())}",
|
"id": f"rag-{str(uuid.uuid4())}",
|
||||||
"object": "chat.completion.chunk",
|
"object": "chat.completion.chunk",
|
||||||
"created": int(time.time()),
|
"created": int(time.time()),
|
||||||
"model": MODEL_ID,
|
"model": model,
|
||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"index": 0,
|
"index": 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user