暗语初步支持 (#27)

This commit is contained in:
Akarin~
2025-06-10 13:30:54 +08:00
committed by GitHub
parent 6bfa2c39a1
commit dc6786deab
7 changed files with 96 additions and 18 deletions

View File

@ -16,7 +16,7 @@ async def process_chat_stream(
last_chunk = chunk
# print(chunk)
if not is_first_token_appeared:
logger.debug(f"{chunk.id}: 第一个 token 已出现")
logger.info(f"{chunk.id}: 第一个 token 已出现")
is_first_token_appeared = True
if not chunk.choices:
logger.info("Usage:", chunk.usage)
@ -29,7 +29,7 @@ async def process_chat_stream(
reasoning_contents += delta.reasoning_content
else:
if not is_answering:
logger.debug(
logger.info(
f"{chunk.id}: 思维链已输出完毕或无 reasoning_content 字段输出"
)
is_answering = True
@ -69,3 +69,19 @@ async def process_chat_stream(
object="chat.completion",
usage=None,
)
async def process_completion_to_details(completion: ChatCompletion) -> str:
usage_text = ""
usage = completion.usage
if usage is None:
usage_text = ""
else:
usage_text = str(usage)
details_text = f"""=========消息详情=========
模型: {completion.model}
消息 ID: {completion.id}
用量信息: {usage_text}"""
# print(details_text)
return details_text