feat:优化评分网页,可关闭状态看板
This commit is contained in:
@@ -55,7 +55,7 @@ BOT_CONFIG_PATH: Path = (CONFIG_DIR / "bot_config.toml").resolve().absolute()
|
||||
MODEL_CONFIG_PATH: Path = (CONFIG_DIR / "model_config.toml").resolve().absolute()
|
||||
LEGACY_ENV_PATH: Path = (PROJECT_ROOT / ".env").resolve().absolute()
|
||||
MMC_VERSION: str = "1.0.0"
|
||||
CONFIG_VERSION: str = "8.9.3"
|
||||
CONFIG_VERSION: str = "8.9.4"
|
||||
MODEL_CONFIG_VERSION: str = "1.14.1"
|
||||
|
||||
logger = get_logger("config")
|
||||
|
||||
@@ -1090,6 +1090,15 @@ class DebugConfig(ConfigBase):
|
||||
__ui_label__ = "其他"
|
||||
__ui_icon__ = "more-horizontal"
|
||||
|
||||
enable_maisaka_stage_board: bool = Field(
|
||||
default=True,
|
||||
json_schema_extra={
|
||||
"x-widget": "switch",
|
||||
"x-icon": "layout-dashboard",
|
||||
},
|
||||
)
|
||||
"""是否启用 Maisaka 阶段看板"""
|
||||
|
||||
show_prompt: bool = Field(
|
||||
default=False,
|
||||
json_schema_extra={
|
||||
|
||||
@@ -66,7 +66,8 @@ class MainSystem:
|
||||
|
||||
async def initialize(self) -> None:
|
||||
"""初始化系统组件"""
|
||||
enable_stage_status_board()
|
||||
if global_config.debug.enable_maisaka_stage_board:
|
||||
enable_stage_status_board()
|
||||
logger.info(t("startup.waking_up", nickname=global_config.bot.nickname))
|
||||
|
||||
# 其他初始化任务
|
||||
|
||||
@@ -160,6 +160,7 @@ async def handle_tool(
|
||||
|
||||
reply_segments = tool_ctx.post_process_reply_text(reply_text)
|
||||
combined_reply_text = "".join(reply_segments)
|
||||
sent_message_ids: list[str] = []
|
||||
try:
|
||||
sent = False
|
||||
if tool_ctx.runtime.chat_stream.platform == CLI_PLATFORM_NAME:
|
||||
@@ -181,6 +182,9 @@ async def handle_tool(
|
||||
sent = sent_message is not None
|
||||
if not sent:
|
||||
break
|
||||
sent_message_id = str(getattr(sent_message, "message_id", "") or "").strip()
|
||||
if sent_message_id:
|
||||
sent_message_ids.append(sent_message_id)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
f"{tool_ctx.runtime.log_prefix} 发送文字消息时发生异常,目标消息编号={target_message_id}"
|
||||
@@ -209,6 +213,7 @@ async def handle_tool(
|
||||
if tool_ctx.runtime.chat_stream.platform == CLI_PLATFORM_NAME:
|
||||
tool_ctx.append_guided_reply_to_chat_history(combined_reply_text)
|
||||
tool_ctx.runtime._record_reply_sent()
|
||||
reply_metadata["sent_message_ids"] = sent_message_ids
|
||||
await tool_ctx.runtime.track_reply_effect(
|
||||
tool_call_id=invocation.call_id,
|
||||
target_message=target_message,
|
||||
|
||||
@@ -66,6 +66,7 @@ class FollowupMessageSnapshot:
|
||||
plain_text: str
|
||||
latency_seconds: float
|
||||
is_target_user: bool
|
||||
quote_target_ids: List[str] = field(default_factory=list)
|
||||
attachments: List[Dict[str, Any]] = field(default_factory=list)
|
||||
|
||||
|
||||
|
||||
32
src/maisaka/reply_effect/quote_utils.py
Normal file
32
src/maisaka/reply_effect/quote_utils.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""回复效果记录中的引用消息辅助工具。"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from src.common.data_models.message_component_data_model import MessageSequence, ReplyComponent
|
||||
|
||||
|
||||
def extract_quote_target_ids(message_sequence: MessageSequence | None) -> list[str]:
|
||||
"""从消息片段中提取引用回复目标消息 ID。"""
|
||||
|
||||
if message_sequence is None:
|
||||
return []
|
||||
|
||||
target_ids: list[str] = []
|
||||
for component in getattr(message_sequence, "components", []):
|
||||
if not isinstance(component, ReplyComponent):
|
||||
continue
|
||||
target_message_id = str(component.target_message_id or "").strip()
|
||||
if target_message_id:
|
||||
target_ids.append(target_message_id)
|
||||
return target_ids
|
||||
|
||||
|
||||
def message_id_from_context_message(message: Any) -> str:
|
||||
"""尽量从 Maisaka 上下文消息中取真实消息 ID。"""
|
||||
|
||||
message_id = str(getattr(message, "message_id", "") or "").strip()
|
||||
if message_id:
|
||||
return message_id
|
||||
|
||||
original_message = getattr(message, "original_message", None)
|
||||
return str(getattr(original_message, "message_id", "") or "").strip()
|
||||
@@ -23,6 +23,7 @@ from .models import (
|
||||
UserSnapshot,
|
||||
now_iso,
|
||||
)
|
||||
from .quote_utils import extract_quote_target_ids
|
||||
from .path_utils import build_reply_effect_chat_dir_name
|
||||
from .scoring import (
|
||||
has_explicit_negative_feedback,
|
||||
@@ -190,6 +191,7 @@ class ReplyEffectTracker:
|
||||
plain_text=plain_text,
|
||||
latency_seconds=round(latency_seconds, 3),
|
||||
is_target_user=bool(record.target_user.user_id and user_id == record.target_user.user_id),
|
||||
quote_target_ids=extract_quote_target_ids(message.raw_message),
|
||||
attachments=extract_visual_attachments_from_sequence(message.raw_message),
|
||||
)
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ from .display.stage_status_board import remove_stage_status, update_stage_status
|
||||
from .reasoning_engine import MaisakaReasoningEngine
|
||||
from .reply_effect import ReplyEffectTracker
|
||||
from .reply_effect.image_utils import extract_visual_attachments_from_sequence
|
||||
from .reply_effect.quote_utils import extract_quote_target_ids, message_id_from_context_message
|
||||
from .tool_provider import MaisakaBuiltinToolProvider
|
||||
|
||||
logger = get_logger("maisaka_runtime")
|
||||
@@ -349,10 +350,12 @@ class MaisakaHeartFlowChatting:
|
||||
continue
|
||||
snapshot.append(
|
||||
{
|
||||
"message_id": message_id_from_context_message(message),
|
||||
"source": message.source,
|
||||
"role": message.role,
|
||||
"timestamp": message.timestamp.isoformat(timespec="seconds"),
|
||||
"text": text,
|
||||
"quote_target_ids": extract_quote_target_ids(getattr(message, "raw_message", None)),
|
||||
"attachments": extract_visual_attachments_from_sequence(getattr(message, "raw_message", None)),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user