mirror of https://github.com/Mai-with-u/MaiBot.git
ruff
parent
7911e71371
commit
ffc247eaa8
|
|
@ -263,7 +263,8 @@ def split_into_sentences_w_remove_punctuation(text: str) -> list[str]:
|
|||
len_text = len(text)
|
||||
if len_text < 3:
|
||||
stripped_text = text.strip()
|
||||
if not stripped_text: return []
|
||||
if not stripped_text:
|
||||
return []
|
||||
if len(stripped_text) == 1 and stripped_text in SEPARATORS:
|
||||
return []
|
||||
return [stripped_text]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# TODO: 更多的可配置项
|
||||
# TODO: 所有模型单独分离,温度可配置
|
||||
# TODO: 原生多模态支持
|
||||
from importlib.util import spec_from_file_location
|
||||
import os
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import asyncio
|
|||
import datetime
|
||||
import traceback
|
||||
import json
|
||||
import os
|
||||
from typing import Optional, Set, TYPE_CHECKING
|
||||
from src.chat.emoji_system.emoji_manager import emoji_manager
|
||||
from src.common.logger_manager import get_logger
|
||||
|
|
@ -12,7 +11,6 @@ from src.chat.utils.chat_message_builder import build_readable_messages
|
|||
from .pfc_types import ConversationState
|
||||
from .observation_info import ObservationInfo
|
||||
from .conversation_info import ConversationInfo
|
||||
from src.chat.emoji_system.emoji_manager import emoji_manager
|
||||
from src.chat.utils.utils_image import image_path_to_base64 # 假设路径正确
|
||||
from maim_message import Seg, UserInfo # 从 maim_message 导入 Seg 和 UserInfo
|
||||
from src.chat.message_receive.message import MessageSending, MessageSet # PFC 的发送器依赖这些
|
||||
|
|
@ -747,7 +745,7 @@ async def handle_action(
|
|||
"user_info": bot_user_info.to_dict(),
|
||||
"processed_plain_text": f"[表情包: {emoji_description}]",
|
||||
"detailed_plain_text": f"[表情包: {emoji_path} - {emoji_description}]",
|
||||
"raw_message": f"[CQ:image,file=base64://...]" # 示例
|
||||
"raw_message": "[CQ:image,file=base64://...]" # 示例
|
||||
}
|
||||
observation_info.chat_history.append(bot_meme_message_dict)
|
||||
observation_info.chat_history_count = len(observation_info.chat_history)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import time
|
||||
import asyncio
|
||||
import traceback
|
||||
import os
|
||||
from typing import Dict, Any, Optional
|
||||
from src.chat.emoji_system.emoji_manager import emoji_manager
|
||||
from maim_message import Seg
|
||||
from src.common.logger_manager import get_logger
|
||||
from maim_message import UserInfo
|
||||
from src.chat.message_receive.chat_stream import chat_manager, ChatStream
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ def get_items_from_json(
|
|||
Tuple[bool, Union[Dict[str, Any], List[Dict[str, Any]]]]: (是否成功, 提取的字段字典或字典列表)
|
||||
"""
|
||||
cleaned_content = content.strip()
|
||||
result: Union[Dict[str, Any], List[Dict[str, Any]]] = {}
|
||||
_result: Union[Dict[str, Any], List[Dict[str, Any]]] = {}
|
||||
markdown_match = re.search(r"```(?:json)?\s*([\s\S]*?)\s*```", cleaned_content, re.IGNORECASE)
|
||||
if markdown_match:
|
||||
cleaned_content = markdown_match.group(1).strip()
|
||||
|
|
@ -605,7 +605,8 @@ def get_items_from_json(
|
|||
valid_single_object = False
|
||||
break
|
||||
|
||||
if not valid_single_object: return False, default_result.copy() # 如果字段缺失,则校验失败
|
||||
if not valid_single_object:
|
||||
return False, default_result.copy() # 如果字段缺失,则校验失败
|
||||
|
||||
if required_types:
|
||||
for field, expected_type in required_types.items():
|
||||
|
|
@ -616,7 +617,8 @@ def get_items_from_json(
|
|||
valid_single_object = False
|
||||
break
|
||||
|
||||
if not valid_single_object: return False, default_result.copy() # 如果类型错误,则校验失败
|
||||
if not valid_single_object:
|
||||
return False, default_result.copy() # 如果类型错误,则校验失败
|
||||
|
||||
for field in items:
|
||||
if field in current_single_result and \
|
||||
|
|
|
|||
Loading…
Reference in New Issue