fix ruff
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from typing import Dict, List
|
||||||
from typing import Dict, List, Tuple, Optional
|
|
||||||
|
|
||||||
# Add project root to Python path
|
# Add project root to Python path
|
||||||
|
from src.common.database.database_model import Expression, ChatStreams
|
||||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.insert(0, project_root)
|
sys.path.insert(0, project_root)
|
||||||
|
|
||||||
from src.common.database.database_model import Expression, ChatStreams
|
|
||||||
|
|
||||||
|
|
||||||
def get_chat_name(chat_id: str) -> str:
|
def get_chat_name(chat_id: str) -> str:
|
||||||
@@ -27,7 +27,7 @@ def get_chat_name(chat_id: str) -> str:
|
|||||||
return f"{chat_stream.user_nickname}的私聊 ({chat_id})"
|
return f"{chat_stream.user_nickname}的私聊 ({chat_id})"
|
||||||
else:
|
else:
|
||||||
return f"未知聊天 ({chat_id})"
|
return f"未知聊天 ({chat_id})"
|
||||||
except Exception as e:
|
except Exception:
|
||||||
return f"查询失败 ({chat_id})"
|
return f"查询失败 ({chat_id})"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
|
||||||
from typing import Dict, List, Tuple, Optional
|
from typing import Dict, List, Tuple, Optional
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
|
from src.common.database.database_model import Messages, ChatStreams
|
||||||
# Add project root to Python path
|
# Add project root to Python path
|
||||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.insert(0, project_root)
|
sys.path.insert(0, project_root)
|
||||||
|
|
||||||
from src.common.database.database_model import Messages, ChatStreams
|
|
||||||
|
|
||||||
|
|
||||||
def get_chat_name(chat_id: str) -> str:
|
def get_chat_name(chat_id: str) -> str:
|
||||||
@@ -200,7 +199,7 @@ def analyze_interest_values(chat_id: Optional[str] = None, start_time: Optional[
|
|||||||
stats = get_interest_value_stats(messages)
|
stats = get_interest_value_stats(messages)
|
||||||
|
|
||||||
# 显示结果
|
# 显示结果
|
||||||
print(f"\n=== Interest Value 分析结果 ===")
|
print("\n=== Interest Value 分析结果 ===")
|
||||||
if chat_id:
|
if chat_id:
|
||||||
print(f"聊天: {get_chat_name(chat_id)}")
|
print(f"聊天: {get_chat_name(chat_id)}")
|
||||||
else:
|
else:
|
||||||
@@ -215,14 +214,14 @@ def analyze_interest_values(chat_id: Optional[str] = None, start_time: Optional[
|
|||||||
else:
|
else:
|
||||||
print("时间范围: 不限制")
|
print("时间范围: 不限制")
|
||||||
|
|
||||||
print(f"\n基本统计:")
|
print("\n基本统计:")
|
||||||
print(f"有效消息数量: {stats['count']} (排除null和0值)")
|
print(f"有效消息数量: {stats['count']} (排除null和0值)")
|
||||||
print(f"最小值: {stats['min']:.3f}")
|
print(f"最小值: {stats['min']:.3f}")
|
||||||
print(f"最大值: {stats['max']:.3f}")
|
print(f"最大值: {stats['max']:.3f}")
|
||||||
print(f"平均值: {stats['avg']:.3f}")
|
print(f"平均值: {stats['avg']:.3f}")
|
||||||
print(f"中位数: {stats['median']:.3f}")
|
print(f"中位数: {stats['median']:.3f}")
|
||||||
|
|
||||||
print(f"\nInterest Value 分布:")
|
print("\nInterest Value 分布:")
|
||||||
total = stats['count']
|
total = stats['count']
|
||||||
for range_name, count in distribution.items():
|
for range_name, count in distribution.items():
|
||||||
if count > 0:
|
if count > 0:
|
||||||
@@ -257,7 +256,7 @@ def interactive_menu() -> None:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"\n可用的聊天 (共{len(chats)}个):")
|
print(f"\n可用的聊天 (共{len(chats)}个):")
|
||||||
for i, (cid, name, count) in enumerate(chats, 1):
|
for i, (_cid, name, count) in enumerate(chats, 1):
|
||||||
print(f"{i}. {name} ({count}条有效消息)")
|
print(f"{i}. {name} ({count}条有效消息)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from datetime import datetime
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import queue
|
|
||||||
|
|
||||||
|
|
||||||
class LogIndex:
|
class LogIndex:
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class DefaultReplyer:
|
|||||||
reasoning_content = None
|
reasoning_content = None
|
||||||
model_name = "unknown_model"
|
model_name = "unknown_model"
|
||||||
if not prompt:
|
if not prompt:
|
||||||
logger.error(f"Prompt 构建失败,无法生成回复。")
|
logger.error("Prompt 构建失败,无法生成回复。")
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -345,7 +345,7 @@ class DefaultReplyer:
|
|||||||
else:
|
else:
|
||||||
style_habits.append(f"当{expr['situation']}时,使用 {expr['style']}")
|
style_habits.append(f"当{expr['situation']}时,使用 {expr['style']}")
|
||||||
else:
|
else:
|
||||||
logger.debug(f"没有从处理器获得表达方式,将使用空的表达方式")
|
logger.debug("没有从处理器获得表达方式,将使用空的表达方式")
|
||||||
# 不再在replyer中进行随机选择,全部交给处理器处理
|
# 不再在replyer中进行随机选择,全部交给处理器处理
|
||||||
|
|
||||||
style_habits_str = "\n".join(style_habits)
|
style_habits_str = "\n".join(style_habits)
|
||||||
@@ -440,7 +440,7 @@ class DefaultReplyer:
|
|||||||
|
|
||||||
return tool_info_str
|
return tool_info_str
|
||||||
else:
|
else:
|
||||||
logger.debug(f"未获取到任何工具结果")
|
logger.debug("未获取到任何工具结果")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import glob
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import uuid
|
|||||||
import io
|
import io
|
||||||
import asyncio
|
import asyncio
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import jieba
|
|
||||||
|
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from peewee import Model, DoubleField, IntegerField, BooleanField, TextField, Fl
|
|||||||
from .database import db
|
from .database import db
|
||||||
import datetime
|
import datetime
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
import time
|
|
||||||
|
|
||||||
logger = get_logger("database_model")
|
logger = get_logger("database_model")
|
||||||
# 请在此处定义您的数据库实例。
|
# 请在此处定义您的数据库实例。
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import ast
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from src.mais4u.s4u_config import s4u_config
|
|||||||
from src.person_info.person_info import PersonInfoManager
|
from src.person_info.person_info import PersonInfoManager
|
||||||
from .super_chat_manager import get_super_chat_manager
|
from .super_chat_manager import get_super_chat_manager
|
||||||
from .yes_or_no import yes_or_no_head
|
from .yes_or_no import yes_or_no_head
|
||||||
|
from src.mais4u.constant_s4u import ENABLE_S4U
|
||||||
|
|
||||||
logger = get_logger("S4U_chat")
|
logger = get_logger("S4U_chat")
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ class S4UChatManager:
|
|||||||
self.s4u_chats[chat_stream.stream_id] = S4UChat(chat_stream)
|
self.s4u_chats[chat_stream.stream_id] = S4UChat(chat_stream)
|
||||||
return self.s4u_chats[chat_stream.stream_id]
|
return self.s4u_chats[chat_stream.stream_id]
|
||||||
|
|
||||||
from src.mais4u.constant_s4u import ENABLE_S4U
|
|
||||||
if not ENABLE_S4U:
|
if not ENABLE_S4U:
|
||||||
s4u_chat_manager = None
|
s4u_chat_manager = None
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from src.config.config import global_config
|
|||||||
from src.chat.message_receive.message import MessageRecvS4U
|
from src.chat.message_receive.message import MessageRecvS4U
|
||||||
from src.mais4u.mais4u_chat.s4u_prompt import prompt_builder
|
from src.mais4u.mais4u_chat.s4u_prompt import prompt_builder
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
from src.person_info.person_info import PersonInfoManager, get_person_info_manager
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from dataclasses import dataclass
|
|||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
from src.chat.message_receive.message import MessageRecvS4U
|
from src.chat.message_receive.message import MessageRecvS4U
|
||||||
|
# 全局SuperChat管理器实例
|
||||||
|
from src.mais4u.constant_s4u import ENABLE_S4U
|
||||||
|
|
||||||
logger = get_logger("super_chat_manager")
|
logger = get_logger("super_chat_manager")
|
||||||
|
|
||||||
@@ -296,8 +298,7 @@ class SuperChatManager:
|
|||||||
logger.info("SuperChat管理器已关闭")
|
logger.info("SuperChat管理器已关闭")
|
||||||
|
|
||||||
|
|
||||||
# 全局SuperChat管理器实例
|
|
||||||
from src.mais4u.constant_s4u import ENABLE_S4U
|
|
||||||
|
|
||||||
if ENABLE_S4U:
|
if ENABLE_S4U:
|
||||||
super_chat_manager = SuperChatManager()
|
super_chat_manager = SuperChatManager()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from tomlkit import TOMLDocument
|
|||||||
from tomlkit.items import Table
|
from tomlkit.items import Table
|
||||||
from dataclasses import dataclass, fields, MISSING, field
|
from dataclasses import dataclass, fields, MISSING, field
|
||||||
from typing import TypeVar, Type, Any, get_origin, get_args, Literal
|
from typing import TypeVar, Type, Any, get_origin, get_args, Literal
|
||||||
|
from src.mais4u.constant_s4u import ENABLE_S4U
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
|
|
||||||
logger = get_logger("s4u_config")
|
logger = get_logger("s4u_config")
|
||||||
@@ -352,7 +352,7 @@ def load_s4u_config(config_path: str) -> S4UGlobalConfig:
|
|||||||
logger.critical("S4U配置文件解析失败")
|
logger.critical("S4U配置文件解析失败")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
from src.mais4u.constant_s4u import ENABLE_S4U
|
|
||||||
if not ENABLE_S4U:
|
if not ENABLE_S4U:
|
||||||
s4u_config = None
|
s4u_config = None
|
||||||
s4u_config_main = None
|
s4u_config_main = None
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class EmojiAction(BaseAction):
|
|||||||
请直接返回最匹配的那个情感标签,不要进行任何解释或添加其他多余的文字。
|
请直接返回最匹配的那个情感标签,不要进行任何解释或添加其他多余的文字。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if global_config.debug.enable_debug_log:
|
if global_config.debug.show_prompt:
|
||||||
logger.info(f"{self.log_prefix} 生成的LLM Prompt: {prompt}")
|
logger.info(f"{self.log_prefix} 生成的LLM Prompt: {prompt}")
|
||||||
else:
|
else:
|
||||||
logger.debug(f"{self.log_prefix} 生成的LLM Prompt: {prompt}")
|
logger.debug(f"{self.log_prefix} 生成的LLM Prompt: {prompt}")
|
||||||
|
|||||||
Reference in New Issue
Block a user