对象创建功能统一方案

对象创建功能统一方案

目标

4个入口(业务对象列表、对话框、数字员工、小程序)创建行为一致,都经过 useCapabilityCreate.create() 这个已验证的基核。

对象列表不需要意图识别(itemType 已知),其余3个入口需要意图识别确定类型,类型不存在时先创建类型再创建对象。

架构

基础核心(已验证):
useCapabilityCreate.create(itemType, description)
  → Schema → LLM → 双库查重 → Sequence → 预创建 → buildAML → 提交SCSAI → 关系创建 → 后置规则

意图识别层(新加):
identifyIntent(description)
  → 类型已知?→ 直接用
  → 类型未知?→ detectItemType → 存在?→ 用;不存在?→ ObjectModeler创建类型 → 用

统一入口:
POST /api/capability/pipeline/identify-and-create
  → identifyIntent → useCapabilityCreate.create(itemType, description)

4个入口的统一方式

业务对象列表(不改)

ProductList.vue → AiCapabilityBar item-type="Product" → useCapabilityCreate.create("Product", desc)

不受影响,不变。

对话框(小改 AiCapabilityBar.vue)

当前:AiCapabilityBarexecuteCapability 直接调 useCapabilityCreate.create(props.itemType, desc)

改后:增加 props.itemType="auto" 模式 → 先调 identify-and-create API

数字员工(大改 capability-pipeline.js)

当前:executePipelinedetectItemType 关键词匹配 → createObject(简易版,缺Sequence/重试/查重)

改后:executePipelineidentifyIntent(含类型创建)→ 同 identify-and-create 流程

小程序(改 后端 API 调用)

当前:SCSAI-create.vuePOST /api/unified/createhandleCreate()(简化版)

改后:同 identify-and-create 流程(服务端走同一套逻辑)

执行步骤

Step 1: 建立基础核心测试(已完成)

  • [x] 确认 useCapabilityCreate.create() 的完整流程(2045行)
  • [x] 确认后端 /SCSAI-api/ApplyItem 代理工作正常
  • [x] 确认 SCSAI 连接正常(ai-inspector/itemtypes 返回真实数据)
  • [x] 确认 Schema API、类型模板 API、双库查重 API 正常
  • [x] 测试创建:Customer ✅ Vendor ✅ Part ✅ Product ✅ Document ✅ Project ⚠️ Model ✅ Part BOM ✅

Step 2: 实现后端 identity-and-create 管线(已编码)

  • [x] object-modeler.applyDefinition 增加 SCSAI ItemType 创建
  • [x] capability-pipeline.js 添加 ObjectModelerModuleensureItemTypeExists
  • [x] capability-pipeline.js 修改 identifyIntent 类型不存在时创建
  • [x] capability-pipeline.js 添加 POST /api/capability/pipeline/identify-and-create 端点

Step 3: 前端适配(已编码)

  • [x] AiCapabilityBar.vue 增加 auto-detect mode(itemType="auto")

Step 4: 验证(待执行)

  • [ ] 重启服务器,加载新代码
  • [ ] 测试 POST /api/capability/pipeline/identify-intent 返回类型和 _typeCreated
  • [ ] 测试 POST /api/capability/pipeline/identify-and-create 完整链路

Step 5: 数字员工接入(待执行)

  • [ ] 修改 executePipeline Step 1 使用 identifyIntent(已有类型创建逻辑)
  • [ ] 修改 executePipeline Step 6 使用 useCapabilityCreate.create() 同级逻辑(不是 createObject

Step 6: 小程序接入(待执行)

  • [ ] 修改 SCSAI-create.vue 在提交时支持自然语言描述检测类型
  • [ ] 调用 /api/capability/pipeline/identify-and-create 代替 /api/unified/create

不改的文件

  • src/composables/useCapabilityCreate.js — 基础核心,不碰
  • src/composables/useCreate.js — 备选,不碰
  • src/utils/AmlBuilder.js — AML构建,不碰
  • src/utils/PromptBuilder.js — Prompt构建,不碰
  • server/routes/unified-create.js — 后端简化版,不动

改动的文件

  1. server/core/object-modeler.jsapplyDefinition 加 SCSAI ItemType创建(已编码)
  2. server/routes/capability-pipeline.jsObjectModelerModuleensureItemTypeExistsidentifyIntentidentify-and-create 端点(已编码)
  3. src/components/ai/AiCapabilityBar.vue — auto-detect mode(已编码)
← 返回案例列表
分享:
🤖 Try Now →
🤖
🎁