refactor: complete runtime configuration migration

This commit is contained in:
jxxghp
2026-08-22 19:07:07 +08:00
parent d131f8d571
commit 1bb6e36e8c
80 changed files with 1432 additions and 581 deletions
+19 -9
View File
@@ -21,7 +21,7 @@ from app.chain.site import SiteChain
from app.chain.subscribe import SubscribeChain
from app.chain.transfer import TransferChain
from app.chain.interaction import MediaInteractionChain as _MediaInteractionChain
from app.runtime.config import settings, global_vars
from app.runtime.config import global_vars
from app.application.messaging.agent import agent_interaction_manager, parse_agent_choice_callback
from app.application.messaging.interaction import InteractionContext, InteractionDispatch
from app.application.messaging.media import media_interaction_manager
@@ -477,8 +477,13 @@ class MessageChain(ChainBase):
if (
not no_ai_requested
and
settings.AI_AGENT_ENABLE
and (settings.AI_AGENT_GLOBAL or images or files or has_audio_input)
self.runtime_config.ai_agent_enable
and (
self.runtime_config.ai_agent_global
or images
or files
or has_audio_input
)
):
return self._handle_ai_message(
text=text,
@@ -554,8 +559,13 @@ class MessageChain(ChainBase):
if text.startswith("/"):
return False
if not (
settings.AI_AGENT_ENABLE
and (settings.AI_AGENT_GLOBAL or images or files or has_audio_input)
self.runtime_config.ai_agent_enable
and (
self.runtime_config.ai_agent_global
or images
or files
or has_audio_input
)
):
return False
if self._interaction_router().has_pending(userid):
@@ -1223,7 +1233,7 @@ class MessageChain(ChainBase):
"""
try:
# 检查AI智能体是否启用
if not settings.AI_AGENT_ENABLE:
if not self.runtime_config.ai_agent_enable:
self.post_message(
Message(
channel=channel,
@@ -1280,8 +1290,8 @@ class MessageChain(ChainBase):
original_images = images
all_files = list(files or [])
if images and supports_image_input(
provider=settings.LLM_PROVIDER,
model=settings.LLM_MODEL,
provider=self.runtime_config.llm_provider,
model=self.runtime_config.llm_model,
):
images = self._download_attachments_to_data_urls(
images, channel, source
@@ -1829,7 +1839,7 @@ class MessageChain(ChainBase):
将用户上传文件写入临时目录,并返回本地路径。
"""
safe_name = self._sanitize_attachment_name(filename, mime_type)
base_dir = settings.TEMP_PATH / "agent_uploads" / session_id
base_dir = self.runtime_config.temporary_path / "agent_uploads" / session_id
base_dir.mkdir(parents=True, exist_ok=True)
file_id = uuid.uuid4().hex[:8]