流式调用[WIP] (#19)

* 流式调用 30%

* 流式调用 90%
This commit is contained in:
Akarin~
2025-03-07 19:04:51 +08:00
committed by GitHub
parent 8aff490aeb
commit 6f085b36c6
12 changed files with 125 additions and 54 deletions

View File

@ -257,7 +257,9 @@ async def marsho(
)
logger.info(f"正在获取回答,模型:{model_name}")
# logger.info(f"上下文:{context_msg}")
response = await handler.handle_common_chat(usermsg, model_name, tools_lists)
response = await handler.handle_common_chat(
usermsg, model_name, tools_lists, config.marshoai_stream
)
# await UniMessage(str(response)).send()
if response is not None:
context_user, context_assistant = response
@ -293,7 +295,7 @@ with contextlib.suppress(ImportError): # 优化先不做()
),
],
)
choice = response.choices[0]
choice = response.choices[0] # type: ignore
if choice.finish_reason == CompletionsFinishReason.STOPPED:
content = extract_content_and_think(choice.message)[0]
await UniMessage(" " + str(content)).send(at_sender=True)