From ef99f6429153867789bcbaa899f84d19b5442b5a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 21 Oct 2025 00:47:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0=20agent=20?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=99=A8=E7=B1=BB=E5=9E=8B=E5=8F=8A=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 69 ++++++++++- .../src/components/shared/AstrBotConfigV4.vue | 110 +++++++++--------- 2 files changed, 122 insertions(+), 57 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 7977e4392..361f557fd 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -71,6 +71,9 @@ DEFAULT_CONFIG = { "streaming_response": False, "show_tool_use_status": False, "streaming_segmented": False, + "agent_runner_type": "local", + "dify_runner_provider_id": "", + "coze_runner_provider_id": "", "max_agent_step": 30, "tool_call_timeout": 60, }, @@ -1931,12 +1934,19 @@ CONFIG_METADATA_2 = { "streaming_segmented": { "type": "bool", }, + "agent_runner_type": { + "type": "string", + }, + "dify_runner_provider_id": { + "type": "string", + }, + "coze_runner_provider_id": { + "type": "string", + }, "max_agent_step": { - "description": "工具调用轮数上限", "type": "int", }, "tool_call_timeout": { - "description": "工具调用超时时间(秒)", "type": "int", }, }, @@ -2070,6 +2080,46 @@ CONFIG_METADATA_3 = { "ai_group": { "name": "AI 配置", "metadata": { + "agent_runner": { + "description": "Agent", + "type": "object", + "items": { + "provider_settings.agent_runner_type": { + "description": "执行器", + "type": "string", + "options": ["local", "dify", "coze"], + "labels": ["内置 Agent", "Dify", "Coze"], + }, + }, + }, + "dify_runner": { + "description": "Dify", + "type": "object", + "items": { + "provider_settings.dify_runner_provider_id": { + "description": "Dify 执行器提供商 ID", + "type": "string", + "_special": "select_dify_runner_provider", + }, + }, + "condition": { + "provider_settings.agent_runner_type": "dify", + }, + }, + "coze_runner": { + "description": "Coze", + "type": "object", + "items": { + "provider_settings.coze_runner_provider_id": { + "description": "Coze 执行器提供商 ID", + "type": "string", + "_special": "select_coze_runner_provider", + }, + }, + "condition": { + "provider_settings.agent_runner_type": "coze", + }, + }, "ai": { "description": "模型", "type": "object", @@ -2123,6 +2173,9 @@ CONFIG_METADATA_3 = { "type": "text", }, }, + "condition": { + "provider_settings.agent_runner_type": "local", + }, }, "persona": { "description": "人格", @@ -2134,6 +2187,9 @@ CONFIG_METADATA_3 = { "_special": "select_persona", }, }, + "condition": { + "provider_settings.agent_runner_type": "local", + }, }, "knowledgebase": { "description": "知识库", @@ -2145,6 +2201,9 @@ CONFIG_METADATA_3 = { "_special": "select_knowledgebase", }, }, + "condition": { + "provider_settings.agent_runner_type": "local", + }, }, "websearch": { "description": "网页搜索", @@ -2181,6 +2240,9 @@ CONFIG_METADATA_3 = { "type": "bool", }, }, + "condition": { + "provider_settings.agent_runner_type": "local", + }, }, "others": { "description": "其他配置", @@ -2248,6 +2310,9 @@ CONFIG_METADATA_3 = { "type": "bool", }, }, + "condition": { + "provider_settings.agent_runner_type": "local", + }, }, }, }, diff --git a/dashboard/src/components/shared/AstrBotConfigV4.vue b/dashboard/src/components/shared/AstrBotConfigV4.vue index 6ae758dfb..08373595f 100644 --- a/dashboard/src/components/shared/AstrBotConfigV4.vue +++ b/dashboard/src/components/shared/AstrBotConfigV4.vue @@ -101,6 +101,21 @@ function shouldShowItem(itemMeta, itemKey) { return true } +// 检查最外层的 object 是否应该显示 +function shouldShowSection() { + const sectionMeta = props.metadata[props.metadataKey] + if (!sectionMeta?.condition) { + return true + } + for (const [conditionKey, expectedValue] of Object.entries(sectionMeta.condition)) { + const actualValue = getValueBySelector(props.iterable, conditionKey) + if (actualValue !== expectedValue) { + return false + } + } + return true +} + function hasVisibleItemsAfter(items, currentIndex) { const itemEntries = Object.entries(items) @@ -114,12 +129,27 @@ function hasVisibleItemsAfter(items, currentIndex) { return false } + +// 将 options 和 labels 转换为 v-select 的 items 格式 +function getSelectItems(itemMeta) { + if (!itemMeta?.options) { + return [] + } + if (itemMeta?.labels && itemMeta.labels.length === itemMeta.options.length) { + return itemMeta.options.map((value, index) => ({ + title: itemMeta.labels[index], + value: value + })) + } + return itemMeta.options +} - +