diff --git a/service/timer.py b/service/timer.py index 19a2ed4..5980c9e 100644 --- a/service/timer.py +++ b/service/timer.py @@ -5,6 +5,7 @@ from astrbot.core.message.message_event_result import MessageChain,Plain from ..tool.pattern import Pattern from astrbot.api.star import Star import asyncio +import json class TimerService: def __init__(self,star:Star) -> None: @@ -60,6 +61,13 @@ class TimerService: logger.error(f"conversation_id获取失败!!umo:{umo}") return False conversation = await conv_mnger.get_conversation(umo,conv_id) + if conversation is None : + conversation = [] + try: + history_list = json.loads(conversation.history) + except: + logger.error("上下文获取失败") + history_list = [] except: logger.error("消息管理失败!") @@ -67,8 +75,8 @@ class TimerService: logger.debug(f"获取上下文:{conversation}") req = await self.star.context.llm_generate( chat_provider_id=provider, - prompt="请输入你的上下文,这里是测试环境,你的输出将会被打印至控制台", - # contexts=conversation + prompt="<你等待的时间内对方没有回复>", + contexts=history_list ) logger.debug(f"llm结果:{req.completion_text }")