大修_execute_request炸程序的问题
This commit is contained in:
@@ -117,9 +117,12 @@ class GoalAnalyzer:
|
||||
}}"""
|
||||
|
||||
logger.debug(f"发送到LLM的提示词: {prompt}")
|
||||
content, _ = await self.llm.generate_response_async(prompt)
|
||||
logger.debug(f"LLM原始返回内容: {content}")
|
||||
|
||||
try:
|
||||
content, _ = await self.llm.generate_response_async(prompt)
|
||||
logger.debug(f"LLM原始返回内容: {content}")
|
||||
except Exception as e:
|
||||
logger.error(f"分析对话目标时出错: {str(e)}")
|
||||
content = ""
|
||||
# 使用简化函数提取JSON内容
|
||||
success, result = get_items_from_json(
|
||||
content,
|
||||
|
||||
@@ -340,6 +340,9 @@ class EmojiManager:
|
||||
|
||||
if description is not None:
|
||||
embedding = await get_embedding(description, request_type="emoji")
|
||||
if not embedding:
|
||||
logger.error("获取消息嵌入向量失败")
|
||||
raise ValueError("获取消息嵌入向量失败")
|
||||
# 准备数据库记录
|
||||
emoji_record = {
|
||||
"filename": filename,
|
||||
|
||||
@@ -79,7 +79,13 @@ async def get_embedding(text, request_type="embedding"):
|
||||
"""获取文本的embedding向量"""
|
||||
llm = LLM_request(model=global_config.embedding, request_type=request_type)
|
||||
# return llm.get_embedding_sync(text)
|
||||
return await llm.get_embedding(text)
|
||||
try:
|
||||
embedding = await llm.get_embedding(text)
|
||||
except Exception as e:
|
||||
logger.error(f"获取embedding失败: {str(e)}")
|
||||
embedding = None
|
||||
return embedding
|
||||
|
||||
|
||||
|
||||
async def get_recent_group_messages(chat_id: str, limit: int = 12) -> list:
|
||||
|
||||
@@ -1316,15 +1316,24 @@ class HippocampusManager:
|
||||
"""从文本中获取相关记忆的公共接口"""
|
||||
if not self._initialized:
|
||||
raise RuntimeError("HippocampusManager 尚未初始化,请先调用 initialize 方法")
|
||||
return await self._hippocampus.get_memory_from_text(
|
||||
text, max_memory_num, max_memory_length, max_depth, fast_retrieval
|
||||
)
|
||||
try:
|
||||
response = await self._hippocampus.get_memory_from_text(text, max_memory_num, max_memory_length, max_depth, fast_retrieval)
|
||||
except Exception as e:
|
||||
logger.error(f"文本激活记忆失败: {e}")
|
||||
response = []
|
||||
return response
|
||||
|
||||
|
||||
async def get_activate_from_text(self, text: str, max_depth: int = 3, fast_retrieval: bool = False) -> float:
|
||||
"""从文本中获取激活值的公共接口"""
|
||||
if not self._initialized:
|
||||
raise RuntimeError("HippocampusManager 尚未初始化,请先调用 initialize 方法")
|
||||
return await self._hippocampus.get_activate_from_text(text, max_depth, fast_retrieval)
|
||||
try:
|
||||
response = await self._hippocampus.get_activate_from_text(text, max_depth, fast_retrieval)
|
||||
except Exception as e:
|
||||
logger.error(f"文本产生激活值失败: {e}")
|
||||
response = 0.0
|
||||
return response
|
||||
|
||||
def get_memory_from_keyword(self, keyword: str, max_depth: int = 2) -> list:
|
||||
"""从关键词获取相关记忆的公共接口"""
|
||||
|
||||
@@ -121,7 +121,11 @@ class ScheduleGenerator:
|
||||
self.today_done_list = []
|
||||
if not self.today_schedule_text:
|
||||
logger.info(f"{today.strftime('%Y-%m-%d')}的日程不存在,准备生成新的日程")
|
||||
self.today_schedule_text = await self.generate_daily_schedule(target_date=today)
|
||||
try:
|
||||
self.today_schedule_text = await self.generate_daily_schedule(target_date=today)
|
||||
except Exception as e:
|
||||
logger.error(f"生成日程时发生错误: {str(e)}")
|
||||
self.today_schedule_text = ""
|
||||
|
||||
self.save_today_schedule_to_db()
|
||||
|
||||
|
||||
@@ -29,10 +29,13 @@ class TopicIdentifier:
|
||||
消息内容:{text}"""
|
||||
|
||||
# 使用 LLM_request 类进行请求
|
||||
topic, _, _ = await self.llm_topic_judge.generate_response(prompt)
|
||||
|
||||
try:
|
||||
topic, _, _ = await self.llm_topic_judge.generate_response(prompt)
|
||||
except Exception as e:
|
||||
logger.error(f"LLM 请求topic失败: {e}")
|
||||
return None
|
||||
if not topic:
|
||||
logger.error("LLM API 返回为空")
|
||||
logger.error("LLM 得到的topic为空")
|
||||
return None
|
||||
|
||||
# 直接在这里处理主题解析
|
||||
|
||||
Reference in New Issue
Block a user