typing和防炸
This commit is contained in:
@@ -739,7 +739,7 @@ class EmojiManager:
|
|||||||
emoji = await self.get_emoji_from_manager(emoji_hash)
|
emoji = await self.get_emoji_from_manager(emoji_hash)
|
||||||
if emoji and emoji.emotion:
|
if emoji and emoji.emotion:
|
||||||
logger.info(f"[缓存命中] 从内存获取表情包描述: {emoji.emotion}...")
|
logger.info(f"[缓存命中] 从内存获取表情包描述: {emoji.emotion}...")
|
||||||
return emoji.emotion
|
return ",".join(emoji.emotion)
|
||||||
|
|
||||||
# 如果内存中没有,从数据库查找
|
# 如果内存中没有,从数据库查找
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ class QAManager:
|
|||||||
logger.debug(f"关系检索用时:{part_end_time - part_start_time:.5f}s")
|
logger.debug(f"关系检索用时:{part_end_time - part_start_time:.5f}s")
|
||||||
|
|
||||||
for res in relation_search_res:
|
for res in relation_search_res:
|
||||||
rel_str = self.embed_manager.relation_embedding_store.store.get(res[0]).str
|
if store_item := self.embed_manager.relation_embedding_store.store.get(res[0]):
|
||||||
|
rel_str = store_item.str
|
||||||
print(f"找到相关关系,相似度:{(res[1] * 100):.2f}% - {rel_str}")
|
print(f"找到相关关系,相似度:{(res[1] * 100):.2f}% - {rel_str}")
|
||||||
|
|
||||||
# TODO: 使用LLM过滤三元组结果
|
# TODO: 使用LLM过滤三元组结果
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def init_prompt():
|
|||||||
{identity_block}
|
{identity_block}
|
||||||
|
|
||||||
{custom_prompt_block}
|
{custom_prompt_block}
|
||||||
{chat_context_description},以下是具体的聊天内容,其中[mxxx]是消息id。
|
{chat_context_description},以下是具体的聊天内容。
|
||||||
{chat_content_block}
|
{chat_content_block}
|
||||||
|
|
||||||
{moderation_prompt}
|
{moderation_prompt}
|
||||||
@@ -63,7 +63,7 @@ def init_prompt():
|
|||||||
|
|
||||||
{action_options_text}
|
{action_options_text}
|
||||||
|
|
||||||
你必须从上面列出的可用action中选择一个,并说明触发action的消息id(不是消息原文)和选择该action的原因。
|
你必须从上面列出的可用action中选择一个,并说明触发action的消息id(不是消息原文)和选择该action的原因。消息id格式:m+数字
|
||||||
|
|
||||||
请根据动作示例,以严格的 JSON 格式输出,不要输出markdown格式```json等内容,直接输出且仅包含 JSON 内容:
|
请根据动作示例,以严格的 JSON 格式输出,不要输出markdown格式```json等内容,直接输出且仅包含 JSON 内容:
|
||||||
""",
|
""",
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ class ImageManager:
|
|||||||
image_bytes = base64.b64decode(image_base64)
|
image_bytes = base64.b64decode(image_base64)
|
||||||
image_hash = hashlib.md5(image_bytes).hexdigest()
|
image_hash = hashlib.md5(image_bytes).hexdigest()
|
||||||
emoji = await emoji_manager.get_emoji_from_manager(image_hash)
|
emoji = await emoji_manager.get_emoji_from_manager(image_hash)
|
||||||
|
if not emoji:
|
||||||
|
return "[表情包:未知]"
|
||||||
emotion_list = emoji.emotion
|
emotion_list = emoji.emotion
|
||||||
tag_str = ",".join(emotion_list)
|
tag_str = ",".join(emotion_list)
|
||||||
return f"[表情包:{tag_str}]"
|
return f"[表情包:{tag_str}]"
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ def get_key_comment(toml_table, key):
|
|||||||
return item.trivia.comment
|
return item.trivia.comment
|
||||||
if hasattr(toml_table, "keys"):
|
if hasattr(toml_table, "keys"):
|
||||||
for k in toml_table.keys():
|
for k in toml_table.keys():
|
||||||
if isinstance(k, KeyType) and k.key == key:
|
if isinstance(k, KeyType) and k.key == key: # type: ignore
|
||||||
return k.trivia.comment
|
return k.trivia.comment # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user