unify plugin llm clients on shared utils layer

This commit is contained in:
liuwei
2026-04-10 09:13:42 +08:00
parent a99bbcca39
commit 42b2014f12
5 changed files with 5 additions and 18 deletions

View File

@@ -1,7 +1,6 @@
from __future__ import annotations
from .decision_flow import DecisionFlow
from .llm_client import LLMClient
from .llm_result_parser import LLMResultParser
from .prompt_builder import build_user_prompt
from .reply_formatter import finalize_reply, preview_text
@@ -10,7 +9,6 @@ from .triggers import TriggerResult, TriggerRouter
__all__ = [
"DecisionFlow",
"LLMClient",
"LLMResultParser",
"ResponsePlanner",
"TriggerResult",

View File

@@ -1,6 +0,0 @@
from utils.ai.unified_llm import UnifiedLLMClient
class LLMClient(UnifiedLLMClient):
"""兼容旧调用方式的统一 LLM 客户端别名。"""

View File

@@ -1,5 +0,0 @@
from __future__ import annotations
from .core.llm_client import LLMClient
__all__ = ["LLMClient"]

View File

@@ -8,6 +8,7 @@ from loguru import logger
from base.plugin_common.message_plugin_interface import MessagePluginInterface
from base.plugin_common.plugin_interface import PluginStatus
from utils.ai.unified_llm import UnifiedLLMClient
from utils.robot_cmd.robot_command import GroupBotManager, PermissionStatus
from utils.wechat.contact_manager import ContactManager
from wechat_ipad import WechatAPIClient
@@ -21,7 +22,6 @@ from .context.image_context import (
prepare_quote_image_inputs,
)
from .context.quote_context import parse_quote_context
from .core.llm_client import LLMClient
from .memory.memory_store import MemoryStore
from .memory.vector_memory import VectorMemoryStore
from .profile.persona_engine import PersonaEngine
@@ -113,7 +113,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
self.vector_memory = VectorMemoryStore(self._config.get("memory", {}) or {})
self.context_builder = ContextBuilder(int((self._config.get("mode", {}) or {}).get("recent_context_size", 30)))
self.decision_flow = DecisionFlow()
self.llm_client = LLMClient(self._config.get("api", {}) or {})
self.llm_client = UnifiedLLMClient(self._config.get("api", {}) or {})
self.social_memory = SocialMemoryService(self.db_manager, self._config.get("memory", {}) or {})
self.group_facts = GroupFactsService(self._config.get("memory", {}) or {})
self.memory_ranker = MemoryRanker(self._config.get("memory", {}) or {})

View File

@@ -21,7 +21,7 @@ except ImportError:
from base.plugin_common.message_plugin_interface import MessagePluginInterface
from base.plugin_common.plugin_interface import PluginStatus
from db.connection import DBConnectionManager
from plugins.ai_auto_response.llm_client import LLMClient
from utils.ai.unified_llm import UnifiedLLMClient
from plugins.douyu.danmu_summary import DouyuDanmuSummaryHelper
from plugins.douyu.report_template import render_daily_report_html
from utils.decorator.async_job import async_job
@@ -490,7 +490,7 @@ class DouyuPlugin(MessagePluginInterface):
self._daily_report_max_length = 1800
self._daily_report_send_image = True
self._audience_stats_sample_interval_seconds = 60
self._daily_report_llm_client: Optional[LLMClient] = None
self._daily_report_llm_client: Optional[UnifiedLLMClient] = None
self._danmu_recorders: Dict[str, DouyuDanmuRecorder] = {}
async_job.every_minutes(self._check_interval)(self._scheduled_unified_check_job)
async_job.every_minutes(5)(self._scheduled_daily_report_tick)
@@ -543,7 +543,7 @@ class DouyuPlugin(MessagePluginInterface):
report_api_cfg = cfg.get("report_api", {}) or {}
if report_api_cfg:
self._daily_report_llm_client = LLMClient(report_api_cfg)
self._daily_report_llm_client = UnifiedLLMClient(report_api_cfg)
return True
except Exception as e:
logger.error(f"{self.name} 初始化失败: {e}")