feat(web): AI 意图规划置信度阈值与动作策略细化

- workbenchAiIntentPlannerModel 新增 WORKBENCH_AI_INTENT_CONFIDENCE_THRESHOLD 与 isLowConfidenceTravelApplicationPlan,shouldRequestWorkbenchAiIntentPlan 增加业务关键词前置过滤
- resolveExecutableTravelApplicationPlan 区分 requestedSubmit 与提交确认(submitRequiresConfirmation),autoSubmit 不再直接置真
- workbenchIntentActionPolicy 改用 policyDecision 路由(need_confirmation/query_candidates),透传 riskLevel/requiresSelection/requiresConfirmation
- workbenchIntentFrameModel 补充 query 动作识别,usePersonalWorkbenchAiMode/useWorkbenchAiActionRouter/useWorkbenchAiApplicationPreviewFlow 接入低置信度与确认流程
- 更新 intent-planner-model/intent-frame-model/application-gate-model/fast-preview 测试
This commit is contained in:
caoxiaozhu
2026-06-25 10:55:49 +08:00
parent 6b0756a55f
commit 59353308a2
12 changed files with 418 additions and 32 deletions

View File

@@ -3,6 +3,8 @@ import { resolveInlineTravelApplicationRequest } from './workbenchAiApplicationG
export const WORKBENCH_AI_INTENT_SOURCE_MODEL = 'llm_function_call'
export const WORKBENCH_AI_INTENT_SOURCE_RULE_FALLBACK = 'rule_fallback'
export const WORKBENCH_AI_INTENT_CONFIDENCE_THRESHOLD = 0.6
export const WORKBENCH_AI_STEP_BUILD_APPLICATION_PREVIEW = 'build_application_preview'
export const WORKBENCH_AI_STEP_VALIDATE_REQUIRED_FIELDS = 'validate_required_fields'
export const WORKBENCH_AI_STEP_SAVE_APPLICATION_DRAFT = 'save_application_draft'
@@ -233,7 +235,7 @@ export function buildRuleFallbackWorkbenchAiIntentPlan(prompt = '') {
if (!request) {
return null
}
const requestedAction = request.autoSubmit ? 'submit' : normalizePromptAction(prompt)
const requestedAction = request.requestedSubmit ? 'submit' : normalizePromptAction(prompt)
return {
source: WORKBENCH_AI_INTENT_SOURCE_RULE_FALLBACK,
intent: TRAVEL_APPLICATION_INTENT,
@@ -255,9 +257,16 @@ export function shouldRequestWorkbenchAiIntentPlan(prompt = '') {
if (compact.length < 2 || /^[\d\s.,,。:;!?-]+$/.test(compact)) {
return false
}
if (!WORKBENCH_AI_BUSINESS_KEYWORD_PATTERN.test(compact)) {
return false
}
return true
}
const WORKBENCH_AI_BUSINESS_KEYWORD_PATTERN = (
/报销|报账|出差|差旅|申请|审批|审核|报销单|申请单|草稿|删除|提交|保存|查|看|找|列出|发起|新建|创建|驳回|退回|通过|多少|标准|制度|规则|政策/
)
export function resolveExecutableTravelApplicationPlan(plan = null) {
if (!plan || plan.intent !== TRAVEL_APPLICATION_INTENT) {
return null
@@ -265,12 +274,32 @@ export function resolveExecutableTravelApplicationPlan(plan = null) {
if (!Array.isArray(plan.steps) || !plan.steps.includes(WORKBENCH_AI_STEP_BUILD_APPLICATION_PREVIEW)) {
return null
}
const requestedSubmit = plan.steps.includes(WORKBENCH_AI_STEP_SUBMIT_APPLICATION)
return {
expenseType: 'travel',
expenseTypeLabel: '差旅费',
sourceText: String(plan.sourceText || '').trim(),
ontologyFields: normalizeOntologyFields(plan.ontologyFields || {}),
autoSubmit: plan.steps.includes(WORKBENCH_AI_STEP_SUBMIT_APPLICATION),
autoSaveDraft: plan.steps.includes(WORKBENCH_AI_STEP_SAVE_APPLICATION_DRAFT)
autoSubmit: false,
autoSaveDraft: plan.steps.includes(WORKBENCH_AI_STEP_SAVE_APPLICATION_DRAFT),
requestedSubmit,
submitRequiresConfirmation: requestedSubmit
}
}
export function isLowConfidenceTravelApplicationPlan(plan = null) {
if (!plan || plan.intent !== TRAVEL_APPLICATION_INTENT) {
return false
}
if (plan.source === WORKBENCH_AI_INTENT_SOURCE_RULE_FALLBACK) {
return false
}
if (plan.requestedAction === 'submit' || plan.requestedAction === 'save_draft') {
return false
}
const confidence = Number(plan.confidence)
if (!Number.isFinite(confidence)) {
return false
}
return confidence < WORKBENCH_AI_INTENT_CONFIDENCE_THRESHOLD
}