From f952d6dc5885ccad5ba6b803c15c4153a184089a Mon Sep 17 00:00:00 2001 From: Nelson <1475262689@qq.com> Date: Thu, 13 Aug 2026 17:25:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20Agent=20=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E6=89=B9=E6=B5=8B=E4=B8=8E=E6=B4=9E=E5=AF=9F=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai_knowledge_base_v2/.env.example | 2 + .../src/components/AgentBatchTestPanel.vue | 26 ++- .../src/components/AgentManagementView.vue | 2 +- .../src/components/RecordAuditView.vue | 28 +++ .../apps/admin-web/src/main.ts | 9 + .../apps/admin-web/src/services/api.ts | 4 + .../apps/admin-web/src/styles.css | 13 ++ .../apps/admin-web/src/types/api.ts | 2 + .../apps/backend/.env.example | 4 + .../versions/0034_agent_batch_concurrency.py | 30 ++++ .../apps/backend/app/api/admin_agent_batch.py | 72 +++++++- .../apps/backend/app/api/admin_records.py | 42 ++++- .../apps/backend/app/core/config.py | 1 + .../apps/backend/app/models/agent_batch.py | 2 + .../app/services/agent_batch_test_service.py | 21 ++- .../app/services/agent_batch_test_worker.py | 117 +++++++++--- .../question_insight_export_service.py | 167 ++++++++++++++++++ .../backend/tests/test_admin_pagination.py | 27 ++- .../backend/tests/test_admin_permissions.py | 23 +++ .../backend/tests/test_agent_batch_tests.py | 116 +++++++++++- ai_knowledge_base_v2/docker-compose.dev.yml | 1 + ai_knowledge_base_v2/docker-compose.prod.yml | 1 + 22 files changed, 666 insertions(+), 44 deletions(-) create mode 100644 ai_knowledge_base_v2/apps/backend/alembic/versions/0034_agent_batch_concurrency.py create mode 100644 ai_knowledge_base_v2/apps/backend/app/services/question_insight_export_service.py diff --git a/ai_knowledge_base_v2/.env.example b/ai_knowledge_base_v2/.env.example index d204700..42c384a 100644 --- a/ai_knowledge_base_v2/.env.example +++ b/ai_knowledge_base_v2/.env.example @@ -35,6 +35,8 @@ TOPIC_SETTLEMENT_MAX_ATTEMPTS=3 AGENT_BATCH_WORKER_ENABLED=true AGENT_BATCH_POLL_SECONDS=2 AGENT_BATCH_STALE_MINUTES=30 +# 单个后端进程同时执行的批量测试问题上限;任务自身还受页面选择的 2-10 路限制。 +AGENT_BATCH_WORKER_CONCURRENCY=10 # ============================================ # 内网穿透(frpc sidecar) diff --git a/ai_knowledge_base_v2/apps/admin-web/src/components/AgentBatchTestPanel.vue b/ai_knowledge_base_v2/apps/admin-web/src/components/AgentBatchTestPanel.vue index e153f15..961c4d4 100644 --- a/ai_knowledge_base_v2/apps/admin-web/src/components/AgentBatchTestPanel.vue +++ b/ai_knowledge_base_v2/apps/admin-web/src/components/AgentBatchTestPanel.vue @@ -15,6 +15,8 @@ const props = defineProps<{ const fileInput = ref(null); const selectedFile = ref(null); const taskName = ref(""); +const executionMode = ref<"sequential" | "concurrent">("sequential"); +const concurrencyLimit = ref(5); const creating = ref(false); const loading = ref(false); const exportingId = ref(null); @@ -81,7 +83,12 @@ async function createJob() { if (!String(props.config.modelId || "")) return ElMessage.warning("请先在调试配置中选择模型"); creating.value = true; try { - const created = await api.createAgentBatch(selectedFile.value, { ...props.config, name: taskName.value.trim() }); + const created = await api.createAgentBatch(selectedFile.value, { + ...props.config, + name: taskName.value.trim(), + executionMode: executionMode.value, + concurrencyLimit: executionMode.value === "sequential" ? 1 : concurrencyLimit.value, + }); ElMessage.success(`已创建批量测试任务,共 ${created.totalCount} 个问题`); clearFile(); taskName.value = ""; @@ -154,6 +161,10 @@ function statusType(status: string) { return "warning"; } +function executionLabel(job: AgentBatchJob) { + return job.executionMode === "concurrent" ? `并发 · ${job.concurrencyLimit} 路` : "逐条串行"; +} + function formatDate(value?: string | null) { return value ? new Date(value).toLocaleString("zh-CN", { hour12: false }) : "—"; } @@ -170,7 +181,7 @@ function errorMessage(error: unknown, fallback: string) {