fix ruff
This commit is contained in:
@@ -13,7 +13,6 @@ from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
|
|||||||
from src.chat.utils.chat_message_builder import (
|
from src.chat.utils.chat_message_builder import (
|
||||||
build_readable_actions,
|
build_readable_actions,
|
||||||
get_actions_by_timestamp_with_chat,
|
get_actions_by_timestamp_with_chat,
|
||||||
build_readable_messages,
|
|
||||||
build_readable_messages_with_id,
|
build_readable_messages_with_id,
|
||||||
get_raw_msg_before_timestamp_with_chat,
|
get_raw_msg_before_timestamp_with_chat,
|
||||||
)
|
)
|
||||||
@@ -108,6 +107,7 @@ class ActionPlanner:
|
|||||||
reasoning = "规划器初始化默认"
|
reasoning = "规划器初始化默认"
|
||||||
action_data = {}
|
action_data = {}
|
||||||
current_available_actions: Dict[str, ActionInfo] = {}
|
current_available_actions: Dict[str, ActionInfo] = {}
|
||||||
|
target_message = None # 初始化target_message变量
|
||||||
|
|
||||||
try:
|
try:
|
||||||
is_group_chat = True
|
is_group_chat = True
|
||||||
@@ -202,8 +202,6 @@ class ActionPlanner:
|
|||||||
target_message = self.find_message_by_id(target_message_id, message_id_list)
|
target_message = self.find_message_by_id(target_message_id, message_id_list)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"{self.log_prefix}FOCUS模式下动作'{action}'缺少target_message_id")
|
logger.warning(f"{self.log_prefix}FOCUS模式下动作'{action}'缺少target_message_id")
|
||||||
else:
|
|
||||||
target_message = None
|
|
||||||
|
|
||||||
if action == "no_action":
|
if action == "no_action":
|
||||||
reasoning = "normal决定不使用额外动作"
|
reasoning = "normal决定不使用额外动作"
|
||||||
@@ -293,6 +291,7 @@ class ActionPlanner:
|
|||||||
- 如果你刚刚进行了回复,不要对同一个话题重复回应
|
- 如果你刚刚进行了回复,不要对同一个话题重复回应
|
||||||
{
|
{
|
||||||
"action": "reply",
|
"action": "reply",
|
||||||
|
"target_message_id":"触发action的消息id",
|
||||||
"reason":"回复的原因"
|
"reason":"回复的原因"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,8 +185,6 @@ class DefaultReplyer:
|
|||||||
prompt = None
|
prompt = None
|
||||||
if available_actions is None:
|
if available_actions is None:
|
||||||
available_actions = {}
|
available_actions = {}
|
||||||
if reply_data is None:
|
|
||||||
reply_data = {}
|
|
||||||
try:
|
try:
|
||||||
if not reply_data:
|
if not reply_data:
|
||||||
reply_data = {
|
reply_data = {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ def _build_readable_messages_internal(
|
|||||||
pic_id_mapping: Optional[Dict[str, str]] = None,
|
pic_id_mapping: Optional[Dict[str, str]] = None,
|
||||||
pic_counter: int = 1,
|
pic_counter: int = 1,
|
||||||
show_pic: bool = True,
|
show_pic: bool = True,
|
||||||
message_id_list: List[Dict[str, Any]] = [],
|
message_id_list: List[Dict[str, Any]] = None,
|
||||||
) -> Tuple[str, List[Tuple[float, str, str]], Dict[str, str], int]:
|
) -> Tuple[str, List[Tuple[float, str, str]], Dict[str, str], int]:
|
||||||
"""
|
"""
|
||||||
内部辅助函数,构建可读消息字符串和原始消息详情列表。
|
内部辅助函数,构建可读消息字符串和原始消息详情列表。
|
||||||
@@ -697,7 +697,7 @@ def build_readable_messages(
|
|||||||
truncate: bool = False,
|
truncate: bool = False,
|
||||||
show_actions: bool = False,
|
show_actions: bool = False,
|
||||||
show_pic: bool = True,
|
show_pic: bool = True,
|
||||||
message_id_list: List[Dict[str, Any]] = [],
|
message_id_list: List[Dict[str, Any]] = None,
|
||||||
) -> str: # sourcery skip: extract-method
|
) -> str: # sourcery skip: extract-method
|
||||||
"""
|
"""
|
||||||
将消息列表转换为可读的文本格式。
|
将消息列表转换为可读的文本格式。
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ def find_messages(
|
|||||||
query = query.where(Messages.user_id != global_config.bot.qq_account)
|
query = query.where(Messages.user_id != global_config.bot.qq_account)
|
||||||
|
|
||||||
if filter_command:
|
if filter_command:
|
||||||
query = query.where(Messages.is_command == False)
|
query = query.where(not Messages.is_command)
|
||||||
|
|
||||||
if limit > 0:
|
if limit > 0:
|
||||||
if limit_mode == "earliest":
|
if limit_mode == "earliest":
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import List, Dict, Type
|
|
||||||
|
|
||||||
class BaseEventsPlugin(ABC):
|
class BaseEventsPlugin(ABC):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from src.common.logger import get_logger
|
|||||||
from src.plugin_system.apis import generator_api, message_api
|
from src.plugin_system.apis import generator_api, message_api
|
||||||
from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
||||||
from src.plugins.built_in.core_actions.emoji import EmojiAction
|
from src.plugins.built_in.core_actions.emoji import EmojiAction
|
||||||
from src.person_info.person_info import person_info_manager
|
from src.person_info.person_info import get_person_info_manager
|
||||||
|
|
||||||
logger = get_logger("core_actions")
|
logger = get_logger("core_actions")
|
||||||
|
|
||||||
@@ -72,10 +72,12 @@ class ReplyAction(BaseAction):
|
|||||||
|
|
||||||
user_id = self.user_id
|
user_id = self.user_id
|
||||||
platform = self.platform
|
platform = self.platform
|
||||||
person_id = person_info_manager.get_person_id(user_id, platform)
|
# logger.info(f"{self.log_prefix} 用户ID: {user_id}, 平台: {platform}")
|
||||||
|
person_id = get_person_info_manager().get_person_id(platform, user_id)
|
||||||
person_name = person_info_manager.get_value(person_id, "person_name")
|
# logger.info(f"{self.log_prefix} 人物ID: {person_id}")
|
||||||
|
person_name = get_person_info_manager().get_value_sync(person_id, "person_name")
|
||||||
reply_to = f"{person_name}:{self.action_message.get('processed_plain_text', '')}"
|
reply_to = f"{person_name}:{self.action_message.get('processed_plain_text', '')}"
|
||||||
|
logger.info(f"{self.log_prefix} 回复目标: {reply_to}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
prepared_reply = self.action_data.get("prepared_reply", "")
|
prepared_reply = self.action_data.get("prepared_reply", "")
|
||||||
@@ -83,7 +85,7 @@ class ReplyAction(BaseAction):
|
|||||||
try:
|
try:
|
||||||
success, reply_set, _ = await asyncio.wait_for(
|
success, reply_set, _ = await asyncio.wait_for(
|
||||||
generator_api.generate_reply(
|
generator_api.generate_reply(
|
||||||
action_data=self.action_data,
|
extra_info="",
|
||||||
reply_to=reply_to,
|
reply_to=reply_to,
|
||||||
chat_id=self.chat_id,
|
chat_id=self.chat_id,
|
||||||
request_type="chat.replyer.focus",
|
request_type="chat.replyer.focus",
|
||||||
|
|||||||
Reference in New Issue
Block a user