Enable Binding-scoped agent push/pull, empty-table schema ensure, SyncPage inspect/drop-table, default module import, and agent-bound publish docs from the 宇恒联调意见. Co-authored-by: Cursor <cursoragent@cursor.com>
2.2 KiB
2.2 KiB
AI 服务输入输出约定
输入
POST /api/v1/apps:generate(可由网关转到 FastAPI)
| 字段 | 必填 | 说明 |
|---|---|---|
| prompt | 是 | 用户自然语言需求 |
| excel | 否 | xlsx/xls/csv |
| images[] | 否 | 页面截图/手绘线框,最多 10 |
| storage_mode | 否 | 默认 schema_per_app |
Excel 解析侧建议先产出中间结构再喂给 LLM:
{
"sheets": [
{
"name": "Sheet1",
"headers": ["SKU", "商品名称", "仓库", "数量", "单价", "状态", "更新时间"],
"sample_rows": [
["A-1001", "无线鼠标", "华东仓", 120, 59.9, "在售", "2026-07-01 10:00:00"]
],
"inferred_types": {
"SKU": "string",
"数量": "int",
"单价": "decimal"
}
}
]
}
输出
{
"draft": { "...": "AppBlueprint" },
"warnings": [
"列「备注」样本过少,已标为可空 text",
"截图中有图表区域,已生成 dashboard 草案"
],
"confidence": 0.86,
"require_confirm": true
}
规则:
draft必须能通过app-blueprint.schema.jsonconfidence < 0.75⇒require_confirm=true(前端禁止一键跳过)- 字段名、表名由 AI 生成后,发布前中台会再次规范化/重写
- 不得在输出中包含数据库连接串、密码、任意 SQL
系统提示词要点(实现时使用)
- 只输出符合 Schema 的 JSON(可包在 draft 字段)
- 一表对应 Excel 主 sheet;多 sheet 才多 entity(≤ 20)
- 优先 enum:当某列 distinct 值 ≤ 20 且稳定
- 页面至少包含一个
list;若用户提到统计再加dashboard - API operations 默认
list/get/create/update/delete/**import**/**export**;列表页layout.actions默认含import(及export)。不要因需求未提「导入」而省略。仅当用户明确禁止导入/导出时才去掉对应 op/action security.visibility默认private,row_policies默认tenant_isolated
与中台的分工
AI:理解意图,填蓝图
中台:校验、改写标识符、建表、挂路由、强制租户隔离
前端:确认页编辑蓝图 → publish → 用 blueprint 渲染