mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-03-10 18:31:03 +08:00
✨ 修复上下文重置逻辑;增加调试和信息日志
This commit is contained in:
parent
b28e6921c5
commit
23ca88b93a
@ -147,6 +147,9 @@ async def load_context(target: MsgTarget, arg: Message = CommandArg()):
|
|||||||
async def resetmem(target: MsgTarget):
|
async def resetmem(target: MsgTarget):
|
||||||
if [target.id, target.private] not in target_list:
|
if [target.id, target.private] not in target_list:
|
||||||
target_list.append([target.id, target.private])
|
target_list.append([target.id, target.private])
|
||||||
|
backup_context = await get_backup_context(target.id, target.private)
|
||||||
|
if backup_context:
|
||||||
|
context.set_context(backup_context, target.id, target.private)
|
||||||
context.reset(target.id, target.private)
|
context.reset(target.id, target.private)
|
||||||
await resetmem_cmd.finish("上下文已重置")
|
await resetmem_cmd.finish("上下文已重置")
|
||||||
|
|
||||||
@ -284,6 +287,7 @@ async def marsho(
|
|||||||
tools_lists = tools.tools_list + list(
|
tools_lists = tools.tools_list + list(
|
||||||
map(lambda v: v.data(), get_function_calls().values())
|
map(lambda v: v.data(), get_function_calls().values())
|
||||||
)
|
)
|
||||||
|
logger.debug(f"正在获取回答,模型:{model_name}")
|
||||||
response = await make_chat_openai(
|
response = await make_chat_openai(
|
||||||
client=client,
|
client=client,
|
||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
@ -296,6 +300,7 @@ async def marsho(
|
|||||||
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
||||||
if choice.message.tool_calls != None and config.marshoai_fix_toolcalls:
|
if choice.message.tool_calls != None and config.marshoai_fix_toolcalls:
|
||||||
choice.finish_reason = CompletionsFinishReason.TOOL_CALLS
|
choice.finish_reason = CompletionsFinishReason.TOOL_CALLS
|
||||||
|
logger.info(f"完成原因:{choice.finish_reason}")
|
||||||
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
||||||
# 当对话成功时,将dict的上下文添加到上下文类中
|
# 当对话成功时,将dict的上下文添加到上下文类中
|
||||||
context.append(
|
context.append(
|
||||||
@ -445,6 +450,7 @@ with contextlib.suppress(ImportError): # 优化先不做()
|
|||||||
user_nickname = nicknames.get(user_id, "")
|
user_nickname = nicknames.get(user_id, "")
|
||||||
try:
|
try:
|
||||||
if config.marshoai_poke_suffix != "":
|
if config.marshoai_poke_suffix != "":
|
||||||
|
logger.info(f"收到戳一戳,用户昵称:{user_nickname},用户ID:{user_id}")
|
||||||
response = await make_chat_openai(
|
response = await make_chat_openai(
|
||||||
client=client,
|
client=client,
|
||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user