From 127ce5d8a9fc595d42d2f374a1813ed12a2edf10 Mon Sep 17 00:00:00 2001 From: MerCry Date: Thu, 5 Mar 2026 17:25:38 +0800 Subject: [PATCH] feat: add slot definition management page [AC-MRS-07,08,16] --- ai-service-admin/src/App.vue | 10 +- ai-service-admin/src/api/slot-definition.ts | 53 ++ ai-service-admin/src/router/index.ts | 18 + ai-service-admin/src/types/slot-definition.ts | 71 +++ .../src/views/admin/slot-definition/index.vue | 470 ++++++++++++++++++ 5 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 ai-service-admin/src/api/slot-definition.ts create mode 100644 ai-service-admin/src/types/slot-definition.ts create mode 100644 ai-service-admin/src/views/admin/slot-definition/index.vue diff --git a/ai-service-admin/src/App.vue b/ai-service-admin/src/App.vue index c2f605f..4347615 100644 --- a/ai-service-admin/src/App.vue +++ b/ai-service-admin/src/App.vue @@ -54,10 +54,18 @@ 输出护栏 + + + 中台联调 + 元数据配置 + + + 槽位定义 +
@@ -90,7 +98,7 @@ import { ref, onMounted } from 'vue' import { useRoute } from 'vue-router' import { useTenantStore } from '@/stores/tenant' import { getTenantList, type Tenant } from '@/api/tenant' -import { Odometer, FolderOpened, Cpu, Monitor, Connection, ChatDotSquare, Document, Aim, Share, Warning, Setting } from '@element-plus/icons-vue' +import { Odometer, FolderOpened, Cpu, Monitor, Connection, ChatDotSquare, Document, Aim, Share, Warning, Setting, ChatLineRound, Grid } from '@element-plus/icons-vue' import { ElMessage } from 'element-plus' const route = useRoute() diff --git a/ai-service-admin/src/api/slot-definition.ts b/ai-service-admin/src/api/slot-definition.ts new file mode 100644 index 0000000..b685b4d --- /dev/null +++ b/ai-service-admin/src/api/slot-definition.ts @@ -0,0 +1,53 @@ +import request from '@/utils/request' +import type { + SlotDefinition, + SlotDefinitionCreateRequest, + SlotDefinitionUpdateRequest, + RuntimeSlotValue +} from '@/types/slot-definition' +import type { FieldRole } from '@/types/metadata' + +export const slotDefinitionApi = { + list: (required?: boolean) => + request({ + method: 'GET', + url: '/admin/slot-definitions', + params: required !== undefined ? { required } : {} + }), + + get: (id: string) => + request({ method: 'GET', url: `/admin/slot-definitions/${id}` }), + + create: (data: SlotDefinitionCreateRequest) => + request({ method: 'POST', url: '/admin/slot-definitions', data }), + + update: (id: string, data: SlotDefinitionUpdateRequest) => + request({ method: 'PUT', url: `/admin/slot-definitions/${id}`, data }), + + delete: (id: string) => + request({ method: 'DELETE', url: `/admin/slot-definitions/${id}` }), + + getByRole: (role: FieldRole) => + request({ + method: 'GET', + url: '/mid/slots/by-role', + params: { role } + }), + + getSlotValue: (slotKey: string, userId?: string, sessionId?: string) => + request({ + method: 'GET', + url: `/mid/slots/${slotKey}`, + params: { + ...(userId ? { user_id: userId } : {}), + ...(sessionId ? { session_id: sessionId } : {}) + } + }) +} + +export type { + SlotDefinition, + SlotDefinitionCreateRequest, + SlotDefinitionUpdateRequest, + RuntimeSlotValue +} diff --git a/ai-service-admin/src/router/index.ts b/ai-service-admin/src/router/index.ts index b4b58e5..053f86d 100644 --- a/ai-service-admin/src/router/index.ts +++ b/ai-service-admin/src/router/index.ts @@ -5,6 +5,12 @@ const routes: Array = [ path: '/', redirect: '/dashboard' }, + { + path: '/share/:token', + name: 'SharedSession', + component: () => import('@/views/share/index.vue'), + meta: { title: '共享对话', public: true } + }, { path: '/dashboard', name: 'Dashboard', @@ -59,6 +65,12 @@ const routes: Array = [ component: () => import('@/views/admin/metadata-schema/index.vue'), meta: { title: '元数据模式配置' } }, + { + path: '/admin/slot-definitions', + name: 'SlotDefinition', + component: () => import('@/views/admin/slot-definition/index.vue'), + meta: { title: '槽位定义管理' } + }, { path: '/admin/intent-rules', name: 'IntentRule', @@ -77,6 +89,12 @@ const routes: Array = [ component: () => import('@/views/admin/guardrail/index.vue'), meta: { title: '输出护栏管理' } }, + { + path: '/admin/mid-platform-playground', + name: 'MidPlatformPlayground', + component: () => import('@/views/admin/mid-platform-playground/index.vue'), + meta: { title: '中台联调工作台' } + }, { path: '/admin/decomposition-templates', name: 'DecompositionTemplate', diff --git a/ai-service-admin/src/types/slot-definition.ts b/ai-service-admin/src/types/slot-definition.ts new file mode 100644 index 0000000..ae8feaa --- /dev/null +++ b/ai-service-admin/src/types/slot-definition.ts @@ -0,0 +1,71 @@ +export type SlotType = 'string' | 'number' | 'boolean' | 'enum' | 'array_enum' +export type ExtractStrategy = 'rule' | 'llm' | 'user_input' +export type SlotSource = 'user_confirmed' | 'rule_extracted' | 'llm_inferred' | 'default' + +export interface SlotDefinition { + id: string + tenant_id: string + slot_key: string + type: SlotType + required: boolean + extract_strategy?: ExtractStrategy + validation_rule?: string + ask_back_prompt?: string + default_value?: string | number | boolean | string[] + linked_field_id?: string + linked_field?: LinkedField + created_at?: string + updated_at?: string +} + +export interface LinkedField { + id: string + field_key: string + label: string + type: string + field_roles: string[] +} + +export interface SlotDefinitionCreateRequest { + tenant_id?: string + slot_key: string + type: SlotType + required: boolean + extract_strategy?: ExtractStrategy + validation_rule?: string + ask_back_prompt?: string + default_value?: string | number | boolean | string[] + linked_field_id?: string +} + +export interface SlotDefinitionUpdateRequest { + type?: SlotType + required?: boolean + extract_strategy?: ExtractStrategy + validation_rule?: string + ask_back_prompt?: string + default_value?: string | number | boolean | string[] + linked_field_id?: string +} + +export interface RuntimeSlotValue { + key: string + value: string | number | boolean | string[] | undefined + source: SlotSource + confidence: number + updated_at?: string +} + +export const SLOT_TYPE_OPTIONS = [ + { value: 'string', label: '文本' }, + { value: 'number', label: '数字' }, + { value: 'boolean', label: '布尔值' }, + { value: 'enum', label: '单选枚举' }, + { value: 'array_enum', label: '多选枚举' } +] + +export const EXTRACT_STRATEGY_OPTIONS = [ + { value: 'rule', label: '规则提取', description: '通过预定义规则从对话中提取' }, + { value: 'llm', label: 'LLM 推断', description: '通过大语言模型推断槽位值' }, + { value: 'user_input', label: '用户输入', description: '通过追问提示语让用户主动输入' } +] diff --git a/ai-service-admin/src/views/admin/slot-definition/index.vue b/ai-service-admin/src/views/admin/slot-definition/index.vue new file mode 100644 index 0000000..9d679c7 --- /dev/null +++ b/ai-service-admin/src/views/admin/slot-definition/index.vue @@ -0,0 +1,470 @@ + + + + +