@@ -591,20 +591,6 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
self._status_check_retry_count = 3
|
||||
self._status_check_retry_delay_seconds = 1
|
||||
self._daily_report_llm_client: Optional[UnifiedLLMClient] = None
|
||||
# 斗鱼插件是典型“快命令 + 慢命令”混合体:
|
||||
# 1. 订阅/列表类命令基本都是 Redis 读写,应该继续走前台同步,保证即时反馈;
|
||||
# 2. 日报类命令会拉历史弹幕、调 LLM、渲染图片,天然属于长任务;
|
||||
# 3. 因此这里把“慢命令名单”集中收口,供分发模式与超时策略共同复用。
|
||||
self._background_report_commands = {
|
||||
"#斗鱼弹幕日报",
|
||||
"斗鱼弹幕日报",
|
||||
"#强制斗鱼弹幕日报",
|
||||
"强制斗鱼弹幕日报",
|
||||
"#斗鱼粉丝日报",
|
||||
"斗鱼粉丝日报",
|
||||
"#强制斗鱼粉丝日报",
|
||||
"强制斗鱼粉丝日报",
|
||||
}
|
||||
# 直播间语义画像:
|
||||
# 1. 允许按房间号补充“主播职业生涯、圈内关系、常见梗来源”等背景;
|
||||
# 2. 这些信息不会直接替代真实弹幕,只用于帮助 LLM 更准确理解圈内黑话;
|
||||
@@ -638,36 +624,6 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
except Exception:
|
||||
return False, day_text
|
||||
|
||||
@staticmethod
|
||||
def _extract_command_token(message: Dict[str, Any]) -> str:
|
||||
"""从消息里提取首个命令词。"""
|
||||
content = str(message.get("content", "") or "").strip()
|
||||
return content.split()[0] if content else ""
|
||||
|
||||
def get_message_dispatch_mode(self, message: Dict[str, Any]) -> str:
|
||||
"""按命令决定斗鱼插件走前台还是后台。
|
||||
|
||||
设计说明:
|
||||
1. 订阅、取消订阅、列表查询都很轻,继续前台执行能保证手感;
|
||||
2. 日报命令一旦命中,后面会进入“查素材 -> 调模型 -> 渲染图片”的长链路;
|
||||
3. 因此只有日报相关命令切后台,避免它们把前台 20 个消息槽位长期占住。
|
||||
"""
|
||||
command = self._extract_command_token(message)
|
||||
if command in self._background_report_commands:
|
||||
return self.normalize_message_dispatch_mode("background")
|
||||
return super().get_message_dispatch_mode(message)
|
||||
|
||||
def get_message_process_timeout_seconds(self, message: Dict[str, Any]) -> Optional[int]:
|
||||
"""只为日报命令放宽总超时,普通命令继续走默认保护值。"""
|
||||
command = self._extract_command_token(message)
|
||||
if command in self._background_report_commands:
|
||||
# 用户已经明确存在 200 秒级长任务:
|
||||
# 1. 斗鱼日报除了 LLM,还包含素材整理与图片渲染;
|
||||
# 2. 这里放宽到 15 分钟,足够覆盖补发历史日报或高峰期模型排队;
|
||||
# 3. 非日报命令不受影响,仍保持原有更紧的保护策略。
|
||||
return 900
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _normalize_text_list(values: Any) -> List[str]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user