WEB API independent

This commit is contained in:
tuyang.yhj 2023-07-03 21:59:54 +08:00
parent be8ead568a
commit 92920cdaa9
2 changed files with 4 additions and 3 deletions

View File

@ -279,7 +279,7 @@ async def stream_generator(chat):
)
msg = msg.replace("\n", "\\n")
yield f"data:{msg}\n\n"
await asyncio.sleep(0.1)
await asyncio.sleep(0.02)
else:
for chunk in model_response:
if chunk:
@ -289,7 +289,7 @@ async def stream_generator(chat):
msg = msg.replace("\n", "\\n")
yield f"data:{msg}\n\n"
await asyncio.sleep(0.1)
await asyncio.sleep(0.02)
chat.current_message.add_ai_message(msg)
chat.current_message.add_view_message(msg)

View File

@ -172,7 +172,8 @@ class BaseChat(ABC):
from pilot.server.llmserver import worker
output = worker.generate_stream_gate(payload)
for rsp in output:
rsp_str = str(rsp, "utf-8")
rsp = rsp.replace(b"\0", b"")
rsp_str = rsp.decode()
print("[TEST: output]:", rsp_str)
### output parse