Files
TimiServerAPI/src/ai/dsl/main_agent.yml
T
Timi 7e7a9cf60c feat(gao-ai): add confirmed write operations
- add prepare/commit/cancel MCP tools and pending operation state
- enforce execution identity, permissions, exact confirmation and audit
- support attachments and operation confirmation cards
- rewrite Dify DSL for write routing and destructive confirmations
2026-11-24 11:41:59 +08:00

2758 lines
86 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
app:
description: 店长专用门店经营助手。支持知识查询、实时业务查询、混合分析,以及带预览和人工确认的写操作。
icon: 🏪
icon_background: '#E8F5E9'
icon_type: emoji
mode: advanced-chat
name: AI 小糕(开发)
use_icon_as_answer_icon: false
dependencies:
- current_identifier: null
type: marketplace
value:
marketplace_plugin_unique_identifier: langgenius/deepseek:0.0.24@9e12eef09973667f0eaf4f082af883167e1de88740b22e71e71488d020c3778a
version: null
- current_identifier: null
type: marketplace
value:
marketplace_plugin_unique_identifier: langgenius/tongyi:0.2.21@d467c6df6876dc5e70ad0b10c14631656ebbc904347eadf48e95b4fca7eda001
version: null
kind: app
version: 0.7.0
workflow:
conversation_variables: []
environment_variables: []
features:
file_upload:
allowed_file_extensions:
- .JPG
- .JPEG
- .PNG
- .GIF
- .WEBP
- .SVG
allowed_file_types:
- image
allowed_file_upload_methods:
- local_file
- remote_url
enabled: false
fileUploadConfig:
attachment_image_file_size_limit: 2
audio_file_size_limit: 50
batch_count_limit: 5
file_size_limit: 15
file_upload_limit: 20
image_file_batch_limit: 10
image_file_size_limit: 10
single_chunk_attachment_limit: 10
video_file_size_limit: 100
workflow_file_upload_limit: 10
image:
enabled: false
number_limits: 3
transfer_methods:
- local_file
- remote_url
number_limits: 3
opening_statement: 你好,我是门店经营助手。可以查询今日经营、客户、订单、库存和积分,也可以在你确认后办理客户、订单、收款、履约、库存等写操作。删除操作不受理。
retriever_resource:
enabled: false
sensitive_word_avoidance:
enabled: false
speech_to_text:
enabled: false
suggested_questions: []
suggested_questions_after_answer:
enabled: true
text_to_speech:
enabled: false
language: ''
voice: ''
graph:
edges:
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: question-classifier
targetType: knowledge-retrieval
id: classifier-knowledge
source: classifier
sourceHandle: rule
target: knowledge
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: question-classifier
targetType: parameter-extractor
id: classifier-params-hybrid
source: classifier
sourceHandle: hybrid
target: params_hybrid
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: question-classifier
targetType: parameter-extractor
id: classifier-params-realtime
source: classifier
sourceHandle: realtime
target: params_realtime
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: question-classifier
targetType: llm
id: classifier-refuse
source: classifier
sourceHandle: refuse
target: refuse
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: agent
targetType: answer
id: hybrid-answer-output
source: hybrid_agent
sourceHandle: source
target: answer_hybrid
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: knowledge-retrieval
targetType: agent
id: hybrid-knowledge-agent
source: hybrid_knowledge
sourceHandle: source
target: hybrid_agent
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: knowledge-retrieval
targetType: llm
id: knowledge-rule-answer
source: knowledge
sourceHandle: source
target: rule_answer
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: parameter-extractor
targetType: knowledge-retrieval
id: params-hybrid-knowledge
source: params_hybrid
sourceHandle: source
target: hybrid_knowledge
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: parameter-extractor
targetType: agent
id: params-realtime-agent
source: params_realtime
sourceHandle: source
target: realtime_agent
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: agent
targetType: answer
id: realtime-answer-output
source: realtime_agent
sourceHandle: source
target: answer_realtime
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: llm
targetType: answer
id: refuse-answer-output
source: refuse
sourceHandle: source
target: answer_refuse
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: llm
targetType: answer
id: rule-answer-output
source: rule_answer
sourceHandle: source
target: answer_rule
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: start
targetType: if-else
id: start-pending
source: start
sourceHandle: source
target: pending_gate
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: code
id: pending-true
source: pending_gate
sourceHandle: 'true'
target: pending_action
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: question-classifier
id: pending-false
source: pending_gate
sourceHandle: 'false'
target: classifier
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: if-else
id: pending-action-confirm
source: pending_action
sourceHandle: source
target: confirm_gate
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: code
id: confirm-true
source: confirm_gate
sourceHandle: 'true'
target: pending_reason
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: if-else
id: confirm-false
source: confirm_gate
sourceHandle: 'false'
target: cancel_gate
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: tool
id: cancel-true
source: cancel_gate
sourceHandle: 'true'
target: cancel_tool
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: answer
id: cancel-false
source: cancel_gate
sourceHandle: 'false'
target: answer_pending_other
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: tool
id: pending-reason-commit
source: pending_reason
sourceHandle: source
target: commit_tool
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: tool
targetType: code
id: commit-parse
source: commit_tool
sourceHandle: source
target: commit_parse
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: answer
id: commit-answer
source: commit_parse
sourceHandle: source
target: answer_commit
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: tool
targetType: code
id: cancel-parse
source: cancel_tool
sourceHandle: source
target: cancel_parse
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: answer
id: cancel-answer
source: cancel_parse
sourceHandle: source
target: answer_cancel
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: question-classifier
targetType: llm
id: classifier-write
source: classifier
sourceHandle: write
target: write_planner
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: llm
targetType: code
id: write-plan-parse
source: write_planner
sourceHandle: source
target: parse_write_plan
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: if-else
id: plan-valid-gate
source: parse_write_plan
sourceHandle: source
target: plan_valid_gate
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: tool
id: plan-valid-true
source: plan_valid_gate
sourceHandle: 'true'
target: prepare_tool
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: if-else
targetType: answer
id: plan-valid-false
source: plan_valid_gate
sourceHandle: 'false'
target: answer_write_invalid
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: tool
targetType: code
id: prepare-parse
source: prepare_tool
sourceHandle: source
target: parse_prepare
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
isInLoop: false
iteration_id: null
loop_id: null
sourceType: code
targetType: answer
id: prepare-answer
source: parse_prepare
sourceHandle: source
target: answer_write
targetHandle: target
type: custom
zIndex: 0
nodes:
- data:
answer: '{{#hybrid_agent.text#}}'
desc: 混合规则与实时数据回答
selected: false
title: 混合回复
type: answer
variables: []
height: 130
id: answer_hybrid
position:
x: 1640
y: 610
positionAbsolute:
x: 1640
y: 610
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
answer: '{{#realtime_agent.text#}}'
desc: 实时业务数据回答
selected: false
title: 实时回复
type: answer
variables: []
height: 130
id: answer_realtime
position:
x: 1320
y: 330
positionAbsolute:
x: 1320
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
answer: '{{#refuse.text#}}'
desc: 只读限制说明
selected: false
title: 拒绝回复
type: answer
variables: []
height: 130
id: answer_refuse
position:
x: 1000
y: 900
positionAbsolute:
x: 1000
y: 900
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
answer: '{{#rule_answer.text#}}'
desc: 规则与口径回答
selected: false
title: 规则回复
type: answer
variables: []
height: 130
id: answer_rule
position:
x: 1320
y: 80
positionAbsolute:
x: 1320
y: 80
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
classes:
- id: rule
label: CLASS 1
name: 规则与口径:询问制度、SOP、状态含义、指标定义、套餐或积分规则,不需要当前业务数据
- id: realtime
label: CLASS 2
name: 实时业务查询:询问当前门店的客户、订单、资金、产品、库存、积分、事件、日记或报表数据
- id: hybrid
label: CLASS 3
name: 混合问题:同时需要业务规则或指标口径,以及当前门店实时数据和经营分析
- id: write
label: CLASS 4
name: 写操作:创建或修改客户、跟进、日记、事件、库存、订单、收款、履约、积分、套餐、积分兑换,以及允许的取消、拒绝、冲正、退款
- id: refuse
label: CLASS 5
name: 拒绝:物理删除、跨门店、越权、系统配置、无关闲聊、要求绕过权限或无法完成的请求
desc: 按问题的数据来源与权限属性路由,分类器不回答业务问题
instruction: 只按类别定义分类。询问制度、SOP、指标口径归入规则;询问当前门店实时数据归入实时查询;同时需要规则和实时数据归入混合;要求创建、修改、核销、收款、履约、库存变动、积分调整、退款、冲正或取消归入写操作;物理删除、跨门店、越权、系统配置和无关请求归入拒绝。
instructions: ''
model:
completion_params:
temperature: 0
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
query_variable_selector:
- sys
- query
selected: false
title: 问题分类
topics: []
type: question-classifier
height: 306
id: classifier
position:
x: 340
y: 320
positionAbsolute:
x: 340
y: 320
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
agent_parameters:
instruction:
type: constant
value: |
你是当前店长的门店混合查询 Agent。
【知识库片段】
{{#context#}}
【/知识库片段】
当前门店:{{#start.storeName#}};当前日期:{{#start.today#}}。
先使用知识库结果解释规则和统计口径,再调用最少必要的 GAO 只读 MCP 工具获取实时数据;最多 3 次工具调用。
不能调用写操作、不能跨店、不能编造数据。回答必须列出时间范围、统计口径、数据生成时间,并区分数据事实和经营建议。
已提取参数:timePreset={{#params_hybrid.timePreset#}},startDate={{#params_hybrid.startDate#}},endDate={{#params_hybrid.endDate#}},customerKeyword={{#params_hybrid.customerKeyword#}},productKeyword={{#params_hybrid.productKeyword#}},topN={{#params_hybrid.topN#}}。
model:
type: constant
value:
completion_params:
temperature: 0.2
mode: chat
model: deepseek-flash
model_type: llm
name: qwen2.5:latest
provider: langgenius/deepseek/deepseek
type: model-selector
query:
type: constant
value: '{{#sys.query#}}/'
tools:
type: constant
value:
- enabled: true
extra:
description: 查询当前门店销售订单、履约和资金摘要,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店销售订单、履约和资金摘要,严格只读
tool_label: order_query
tool_name: order_query
type: mcp
- enabled: true
extra:
description: 查询当前门店产品、SKU 和库存余额,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店产品、SKU 和库存余额,严格只读
tool_label: product_inventory_query
tool_name: product_inventory_query
type: mcp
- enabled: true
extra:
description: 查询当前门店登记事件记录及事件统计,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店登记事件记录及事件统计,严格只读
tool_label: event_query
tool_name: event_query
type: mcp
- enabled: true
extra:
description: 查询当前门店单个客户的套餐、积分、消费和事件档案
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店单个客户的套餐、积分、消费和事件档案
tool_label: customer_profile
tool_name: customer_profile
type: mcp
- enabled: true
extra:
description: 查询当前门店销售趋势、应收、客户复购和产品排行
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店销售趋势、应收、客户复购和产品排行
tool_label: business_report
tool_name: business_report
type: mcp
- enabled: true
extra:
description: 按客户姓名或编码查询当前门店客户摘要
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 按客户姓名或编码查询当前门店客户摘要
tool_label: customer_search
tool_name: customer_search
type: mcp
- enabled: true
extra:
description: 查询当前门店指定周期的营业日、销售、应收和库存健康总览
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店指定周期的营业日、销售、应收和库存健康总览
tool_label: store_overview
tool_name: store_overview
type: mcp
- enabled: true
extra:
description: 查询当前门店积分账户、积分流水、规则和兑换摘要,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店积分账户、积分流水、规则和兑换摘要,严格只读
tool_label: point_query
tool_name: point_query
type: mcp
- enabled: true
extra:
description: 查询当前门店日记和营业日信息,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店日记和营业日信息,严格只读
tool_label: store_diary_query
tool_name: store_diary_query
type: mcp
- enabled: true
extra:
description: 查询门店经营助手使用的固定指标名称和计算口径
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询门店经营助手使用的固定指标名称和计算口径
tool_label: metric_definition
tool_name: metric_definition
type: mcp
- enabled: true
extra:
description: 查询当前门店履约单,返回订单号、履约请求号、状态和履约时间
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店履约单,返回订单号、履约请求号、状态和履约时间
tool_label: fulfillment_query
tool_name: fulfillment_query
type: mcp
- enabled: true
extra:
description: 查询当前门店客户跟进提醒,返回提醒 ID、客户、内容、提醒时间和状态
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店客户跟进提醒,返回提醒 ID、客户、内容、提醒时间和状态
tool_label: follow_up_query
tool_name: follow_up_query
type: mcp
agent_strategy_label: FunctionCalling
agent_strategy_name: function_calling
agent_strategy_provider_name: langgenius/agent/agent
desc: 导入后绑定 GAO MCP 的 10 个只读工具,并把混合问题知识库结果加到 Agent 上下文
meta:
minimum_dify_version: 1.7.0
version: 0.0.2
output_schema: {}
plugin_unique_identifier: langgenius/agent:0.0.47@b14b5a5259094510a272e5b7facd09aa63352511c13fabcde36a4cac57d1da94
selected: false
title: 混合查询 MCP Agent
tool_node_version: '2'
type: agent
height: 140
id: hybrid_agent
position:
x: 1320
y: 610
positionAbsolute:
x: 1320
y: 610
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
dataset_ids:
- EaJw5gBfWOkJO60gvKoybO2gxGDcnPymkRNCeTUqce05D6wh7Q9BtsnzL1OElHlk
desc: 导入后绑定 GAO 业务知识库,为混合问题提供指标口径和规则依据
metadata_filtering_mode: disabled
multiple_retrieval_config:
reranking_enable: false
reranking_mode: weighted_score
reranking_model: null
score_threshold: 0.35
top_k: 4
weights:
keyword_setting:
keyword_weight: 0.3
vector_setting:
embedding_model_name: text-embedding-v4
embedding_provider_name: langgenius/tongyi/tongyi
vector_weight: 0.7
weight_type: customized
query_attachment_selector: []
query_variable_selector:
- sys
- query
retrieval_mode: multiple
selected: false
title: 混合问题知识检索
type: knowledge-retrieval
vision:
enabled: false
height: 96
id: hybrid_knowledge
position:
x: 1000
y: 610
positionAbsolute:
x: 1000
y: 610
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
dataset_ids:
- EaJw5gBfWOkJO60gvKoybO2gxGDcnPymkRNCeTUqce05D6wh7Q9BtsnzL1OElHlk
desc: 导入后绑定 GAO 业务知识库,只检索制度、规则和指标口径
metadata_filtering_mode: disabled
multiple_retrieval_config:
reranking_enable: false
reranking_mode: weighted_score
reranking_model: null
score_threshold: 0.35
top_k: 4
weights:
keyword_setting:
keyword_weight: 0.3
vector_setting:
embedding_model_name: text-embedding-v4
embedding_provider_name: langgenius/tongyi/tongyi
vector_weight: 0.7
weight_type: customized
query_attachment_selector: []
query_variable_selector:
- sys
- query
retrieval_mode: multiple
selected: false
title: 规则知识检索
type: knowledge-retrieval
vision:
enabled: false
height: 96
id: knowledge
position:
x: 680
y: 80
positionAbsolute:
x: 680
y: 80
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
desc: 混合问题复用同一套参数,只额外取得规则与口径依据
instruction: 从用户问题中提取查询条件。日期没有明确范围时,明细查询使用 TODAY,趋势或经营分析使用 MONTH_TO_DATE。不要提取、生成或修改门店 ID。
model:
completion_params:
temperature: 0
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
parameters:
- description: TODAY、MONTH_TO_DATE、CUSTOM 或空
name: timePreset
required: false
type: string
- description: 自定义开始日期 yyyy-MM-dd
name: startDate
required: false
type: string
- description: 自定义结束日期 yyyy-MM-dd
name: endDate
required: false
type: string
- description: 客户关键词
name: customerKeyword
required: false
type: string
- description: 产品或 SKU 关键词
name: productKeyword
required: false
type: string
- description: 排行数量,最大 20
name: topN
required: false
type: number
query:
- sys
- query
reasoning_mode: prompt
selected: false
title: 混合查询参数提取
type: parameter-extractor
vision:
enabled: false
height: 132
id: params_hybrid
position:
x: 680
y: 610
positionAbsolute:
x: 680
y: 610
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
desc: 提取实时查询的通用筛选条件,空值表示使用 MCP 工具默认值
instruction: 从用户问题中提取查询条件。日期没有明确范围时,明细查询使用 TODAY,趋势或经营分析使用 MONTH_TO_DATE。不要提取、生成或修改门店 ID。
model:
completion_params:
temperature: 0
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
parameters:
- description: TODAY、MONTH_TO_DATE、CUSTOM 或空
name: timePreset
required: false
type: string
- description: 自定义开始日期 yyyy-MM-dd
name: startDate
required: false
type: string
- description: 自定义结束日期 yyyy-MM-dd
name: endDate
required: false
type: string
- description: 客户姓名、编码或其他查询关键词
name: customerKeyword
required: false
type: string
- description: 产品或 SKU 关键词
name: productKeyword
required: false
type: string
- description: 订单号
name: orderNo
required: false
type: string
- description: 事件名称或关键词
name: eventKeyword
required: false
type: string
- description: 排行数量,最大 20
name: topN
required: false
type: number
query:
- sys
- query
reasoning_mode: prompt
selected: false
title: 实时查询参数提取
type: parameter-extractor
vision:
enabled: false
height: 132
id: params_realtime
position:
x: 680
y: 300
positionAbsolute:
x: 680
y: 300
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
agent_parameters:
instruction:
type: constant
value: |
你是当前店长的门店实时数据查询 Agent。
当前门店:{{#start.storeName#}};当前日期:{{#start.today#}}。
只能使用已绑定的 GAO 只读 MCP 工具;一次最多调用 5 个工具。
先根据问题和已提取参数选择最小必要工具。不能调用写操作,不得编造没有工具结果的数据。
回答必须包含时间范围、统计口径、数据生成时间;区分数据事实和经营建议。
已提取参数:timePreset={{#params_realtime.timePreset#}},startDate={{#params_realtime.startDate#}},endDate={{#params_realtime.endDate#}},customerKeyword={{#params_realtime.customerKeyword#}},productKeyword={{#params_realtime.productKeyword#}},orderNo={{#params_realtime.orderNo#}},eventKeyword={{#params_realtime.eventKeyword#}},topN={{#params_realtime.topN#}}。
model:
type: constant
value:
completion_params:
temperature: 0.2
mode: chat
model: deepseek-flash
model_type: llm
name: qwen2.5:latest
provider: langgenius/deepseek/deepseek
type: model-selector
query:
type: constant
value: '{{#sys.query#}}'
tools:
type: constant
value:
- enabled: true
extra:
description: 查询当前门店销售订单、履约和资金摘要,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店销售订单、履约和资金摘要,严格只读
tool_label: order_query
tool_name: order_query
type: mcp
- enabled: true
extra:
description: 查询当前门店产品、SKU 和库存余额,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店产品、SKU 和库存余额,严格只读
tool_label: product_inventory_query
tool_name: product_inventory_query
type: mcp
- enabled: true
extra:
description: 查询当前门店登记事件记录及事件统计,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店登记事件记录及事件统计,严格只读
tool_label: event_query
tool_name: event_query
type: mcp
- enabled: true
extra:
description: 查询当前门店单个客户的套餐、积分、消费和事件档案
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店单个客户的套餐、积分、消费和事件档案
tool_label: customer_profile
tool_name: customer_profile
type: mcp
- enabled: true
extra:
description: 查询当前门店销售趋势、应收、客户复购和产品排行
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店销售趋势、应收、客户复购和产品排行
tool_label: business_report
tool_name: business_report
type: mcp
- enabled: true
extra:
description: 按客户姓名或编码查询当前门店客户摘要
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 按客户姓名或编码查询当前门店客户摘要
tool_label: customer_search
tool_name: customer_search
type: mcp
- enabled: true
extra:
description: 查询当前门店指定周期的营业日、销售、应收和库存健康总览
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店指定周期的营业日、销售、应收和库存健康总览
tool_label: store_overview
tool_name: store_overview
type: mcp
- enabled: true
extra:
description: 查询当前门店积分账户、积分流水、规则和兑换摘要,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店积分账户、积分流水、规则和兑换摘要,严格只读
tool_label: point_query
tool_name: point_query
type: mcp
- enabled: true
extra:
description: 查询当前门店日记和营业日信息,严格只读
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店日记和营业日信息,严格只读
tool_label: store_diary_query
tool_name: store_diary_query
type: mcp
- enabled: true
extra:
description: 查询门店经营助手使用的固定指标名称和计算口径
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询门店经营助手使用的固定指标名称和计算口径
tool_label: metric_definition
tool_name: metric_definition
type: mcp
- enabled: true
extra:
description: 查询当前门店履约单,返回订单号、履约请求号、状态和履约时间
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店履约单,返回订单号、履约请求号、状态和履约时间
tool_label: fulfillment_query
tool_name: fulfillment_query
type: mcp
- enabled: true
extra:
description: 查询当前门店客户跟进提醒,返回提醒 ID、客户、内容、提醒时间和状态
parameters:
aiSessionId:
auto: 0
value:
type: mixed
value: '{{#start.aiSessionId#}}'
cursor:
auto: 1
value: null
filters:
auto: 1
value: null
pageSize:
auto: 1
value: null
query:
auto: 1
value: null
timeRange:
auto: 1
value: null
plugin_id: ''
provider_name: gao-mcp-server-dev
provider_show_name: GAO MCP 服务(开发)
settings: {}
tool_description: 查询当前门店客户跟进提醒,返回提醒 ID、客户、内容、提醒时间和状态
tool_label: follow_up_query
tool_name: follow_up_query
type: mcp
agent_strategy_label: FunctionCalling
agent_strategy_name: function_calling
agent_strategy_provider_name: langgenius/agent/agent
desc: 导入后绑定 GAO MCP 的 10 个只读工具
meta:
minimum_dify_version: 1.7.0
version: 0.0.2
output_schema: {}
plugin_unique_identifier: langgenius/agent:0.0.47@b14b5a5259094510a272e5b7facd09aa63352511c13fabcde36a4cac57d1da94
selected: false
title: 实时 MCP 查询 Agent
tool_node_version: '2'
type: agent
height: 108
id: realtime_agent
position:
x: 1000
y: 330
positionAbsolute:
x: 1000
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
context:
enabled: false
variable_selector: []
desc: 拒绝写操作、跨店、越权和无关请求
memory:
role_prefix:
assistant: 助手
user: 店长
window:
enabled: true
size: 10
model:
completion_params:
temperature: 0
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
prompt_template:
- id: refuse-system
role: system
text: 你是门店经营助手。仅支持当前店长所属门店的业务查询、经营分析,以及本工作流已开放的创建、修改、核销、收款、履约、库存变动、积分调整和允许的取消、拒绝、冲正、退款。明确拒绝物理删除、跨门店查询、越权、系统配置、绕过权限和无关请求;简短说明可支持范围。
- id: refuse-user
role: user
text: '{{#sys.query#}}'
selected: false
title: 拒绝说明
type: llm
variables: []
vision:
enabled: false
height: 116
id: refuse
position:
x: 680
y: 900
positionAbsolute:
x: 680
y: 900
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
context:
enabled: true
variable_selector:
- knowledge
- result
desc: 只使用知识库片段回答规则与口径
memory:
role_prefix:
assistant: 助手
user: 店长
window:
enabled: true
size: 10
model:
completion_params:
temperature: 0.2
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
prompt_template:
- id: rule-system
role: system
text: |-
你是门店经营助手。
【知识库片段】
{{#context#}}
【/知识库片段】
仅依据知识库片段回答用户问题。
如果片段只包含部分步骤,直接回答片段明确给出的步骤,不要因为信息不完整就说不知道。
只有知识库片段完全没有相关内容时,才说明未找到对应规则。
不得编造知识库没有提供的步骤或实时数据。
当前日期:{{#start.today#}}
- id: rule-user
role: user
text: '{{#sys.query#}}'
selected: false
title: 规则回答
type: llm
variables: []
vision:
enabled: false
height: 116
id: rule_answer
position:
x: 1000
y: 80
positionAbsolute:
x: 1000
y: 80
selected: true
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
desc: 后端注入已验证的会话、待确认操作和附件凭证;门店、用户和 token 不进入模型提示词
selected: false
title: 开始
type: start
variables:
- label: AI 会话 ID
max_length: 128
options: []
required: true
type: text-input
variable: aiSessionId
- label: 门店名称
max_length: 128
options: []
required: true
type: text-input
variable: storeName
- label: 当前日期
max_length: 10
options: []
required: true
type: text-input
variable: today
- label: 待确认操作 Token
max_length: 128
options: []
required: false
type: text-input
variable: pendingOperationToken
- label: 待确认操作摘要
max_length: 2000
options: []
required: false
type: paragraph
variable: pendingOperationSummary
- label: 待确认操作风险级别
max_length: 32
options: []
required: false
type: text-input
variable: pendingOperationRisk
- label: 待确认操作精确短语
max_length: 256
options: []
required: false
type: text-input
variable: pendingOperationRequiredPhrase
- label: 待确认操作过期时间
max_length: 32
options: []
required: false
type: text-input
variable: pendingOperationExpiresAt
- label: 附件凭证 JSON
max_length: 4000
options: []
required: false
type: paragraph
variable: attachmentTokensJson
height: 221
id: start
position:
x: 40
y: 360
positionAbsolute:
x: 40
y: 360
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
zIndex: 0
- data:
conditions:
- comparison_operator: not empty
id: pending_gate-condition
value: ''
varType: string
variable_selector:
- start
- pendingOperationToken
desc: 存在待确认操作时,本轮只允许确认或取消,不再进入普通分类器
logical_operator: and
selected: false
title: 待确认操作拦截
type: if-else
height: 140
id: pending_gate
position:
x: 360
y: 130
positionAbsolute:
x: 360
y: 130
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
zIndex: 0
- data:
code: |2
import re
def normalize(value):
return re.sub(r'[\s,。!?、;:,.!?;:\'"“”‘’]', '', value or '').lower()
def main(query, required_phrase, risk):
q = normalize(query)
phrase = normalize(required_phrase)
if phrase and q == phrase:
return {"action": "CONFIRM"}
cancel_exact = {"取消", "放弃", "不要", "算了", "不用了", "停止", "不确认", "取消操作", "放弃操作"}
if q in cancel_exact:
return {"action": "CANCEL"}
if risk == "DESTRUCTIVE" or (risk == "SENSITIVE" and phrase):
return {"action": "OTHER"}
cancel_words = ["取消", "放弃", "不要", "算了", "不用了", "停止", "不确认"]
if any(word in q for word in cancel_words):
return {"action": "CANCEL"}
confirm_words = ["确认", "确定", "执行", "可以", "是的", "同意", "好", "办理"]
if any(word in q for word in confirm_words):
return {"action": "CONFIRM"}
return {"action": "OTHER"}
code_language: python3
desc: 规则匹配确认/取消意图;破坏性和敏感操作只接受精确短语
outputs:
action:
children: null
type: string
selected: false
title: 判断确认意图
type: code
variables:
- value_selector:
- sys
- query
variable: query
- value_selector:
- start
- pendingOperationRequiredPhrase
variable: required_phrase
- value_selector:
- start
- pendingOperationRisk
variable: risk
height: 180
id: pending_action
position:
x: 680
y: 130
positionAbsolute:
x: 680
y: 130
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
conditions:
- comparison_operator: not empty
id: confirm_gate-condition
value: ''
varType: string
variable_selector:
- pending_action
- action
desc: 仅 action=CONFIRM 时进入提交
logical_operator: and
selected: false
title: 是否确认
type: if-else
height: 140
id: confirm_gate
position:
x: 1000
y: 130
positionAbsolute:
x: 1000
y: 130
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
zIndex: 0
- data:
code: |2
def main(query):
return {"reason": "用户文本确认:" + (query or "")}
code_language: python3
desc: 文本确认路径把用户原话作为操作原因
outputs:
reason:
children: null
type: string
selected: false
title: 生成文本确认原因
type: code
variables:
- value_selector:
- sys
- query
variable: query
height: 180
id: pending_reason
position:
x: 1320
y: 40
positionAbsolute:
x: 1320
y: 40
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
desc: 调用独立提交 MCP,只允许传入 token,不接受业务参数
provider_id: gao-mcp-commit-dev
provider_name: gao-mcp-commit-dev
provider_type: mcp
selected: false
title: 提交待确认操作
tool_configurations: {}
tool_label: operation_commit
tool_name: operation_commit
tool_node_version: '2'
tool_parameters:
confirmationToken:
type: variable
value:
- start
- pendingOperationToken
confirmationPhrase:
type: variable
value:
- sys
- query
reason:
type: variable
value:
- pending_reason
- reason
aiSessionId:
type: variable
value:
- start
- aiSessionId
type: tool
height: 160
id: commit_tool
position:
x: 1600
y: 40
positionAbsolute:
x: 1600
y: 40
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 300
zIndex: 0
- data:
code: |2
import json
def parse_payload(raw):
if isinstance(raw, dict):
return raw
text = str(raw or '').strip()
if not text:
return {}
try:
payload = json.loads(text)
if isinstance(payload, dict):
return payload
if isinstance(payload, list):
for item in payload:
if isinstance(item, dict):
if isinstance(item.get('json'), dict):
return item['json']
if isinstance(item.get('text'), str):
try:
candidate = json.loads(item['text'])
if isinstance(candidate, dict):
return candidate
except Exception:
pass
except Exception:
pass
return {}
def main(raw):
payload = parse_payload(raw)
status = str(payload.get('status') or 'FAILED')
if status == 'SUCCEEDED':
text = payload.get('resultText') or '操作已完成。'
if payload.get('entityNo'):
text += '\n业务单号:' + str(payload.get('entityNo'))
elif status == 'FAILED':
text = '未办理:' + str(payload.get('errorMessage') or '操作失败,请稍后重试。')
if payload.get('errorCode'):
text += '\n错误码:' + str(payload.get('errorCode'))
else:
text = str(payload.get('resultText') or payload.get('errorMessage') or '操作未完成。')
return {'answer_text': text, 'status': status}
code_language: python3
desc: 只读取后端返回的结构化结果,不让模型改写金额和单号
outputs:
answer_text:
children: null
type: string
status:
children: null
type: string
selected: false
title: 解析提交结果
type: code
variables:
- value_selector:
- commit_tool
- text
variable: raw
height: 180
id: commit_parse
position:
x: 1940
y: 40
positionAbsolute:
x: 1940
y: 40
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
answer: '{{#commit_parse.answer_text#}}'
desc: ''
selected: false
title: 提交结果
type: answer
variables: []
height: 140
id: answer_commit
position:
x: 2280
y: 40
positionAbsolute:
x: 2280
y: 40
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 260
zIndex: 0
- data:
conditions:
- comparison_operator: not empty
id: cancel_gate-condition
value: ''
varType: string
variable_selector:
- pending_action
- action
desc: action=CANCEL 时进入取消
logical_operator: and
selected: false
title: 是否取消
type: if-else
height: 140
id: cancel_gate
position:
x: 1000
y: 330
positionAbsolute:
x: 1000
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
zIndex: 0
- data:
desc: 调用独立提交 MCP 取消待确认操作
provider_id: gao-mcp-commit-dev
provider_name: gao-mcp-commit-dev
provider_type: mcp
selected: false
title: 取消待确认操作
tool_configurations: {}
tool_label: operation_cancel
tool_name: operation_cancel
tool_node_version: '2'
tool_parameters:
confirmationToken:
type: variable
value:
- start
- pendingOperationToken
aiSessionId:
type: variable
value:
- start
- aiSessionId
type: tool
height: 150
id: cancel_tool
position:
x: 1320
y: 330
positionAbsolute:
x: 1320
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 300
zIndex: 0
- data:
code: |2
import json
def main(raw):
payload = {}
if isinstance(raw, dict):
payload = raw
else:
try:
payload = json.loads(str(raw or '{}'))
except Exception:
payload = {}
if payload.get('status') == 'CANCELLED':
return {'answer_text': '已取消当前待确认操作。'}
return {'answer_text': str(payload.get('errorMessage') or '取消失败,请稍后重试。')}
code_language: python3
desc: 只输出取消结果
outputs:
answer_text:
children: null
type: string
selected: false
title: 解析取消结果
type: code
variables:
- value_selector:
- cancel_tool
- text
variable: raw
height: 180
id: cancel_parse
position:
x: 1660
y: 330
positionAbsolute:
x: 1660
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
answer: '{{#cancel_parse.answer_text#}}'
desc: ''
selected: false
title: 取消结果
type: answer
variables: []
height: 140
id: answer_cancel
position:
x: 2000
y: 330
positionAbsolute:
x: 2000
y: 330
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 260
zIndex: 0
- data:
answer: |-
当前有待确认操作:
{{#start.pendingOperationSummary#}}
请回复“确认”执行,或回复“取消”放弃。
破坏性或敏感操作必须回复完整短语:{{#start.pendingOperationRequiredPhrase#}}
desc: 其他回复不允许绕过确认
selected: false
title: 待确认操作提示
type: answer
variables: []
height: 140
id: answer_pending_other
position:
x: 1320
y: 520
positionAbsolute:
x: 1320
y: 520
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 260
zIndex: 0
- data:
context:
enabled: false
variable_selector: []
desc: 把自然语言请求转成写操作参数,不执行任何写操作
model:
completion_params:
temperature: 0.1
mode: chat
name: deepseek-flash
provider: langgenius/deepseek/deepseek
prompt_template:
- id: write-system
role: system
text: |
你是门店写操作参数规划器。你的唯一任务是把店长本轮请求转换成写操作准备参数。
只输出一个合法 JSON 对象,不要 Markdown,不要解释。格式:
{"operation":"操作代码","arguments":{},"missingFields":[]}
硬性规则:
1. 只能使用下方操作目录中的 operation,不得创造操作。
2. 不得输出 storeId、operatorUserId、requestNo、confirmationToken、operationId、sourceSessionId。
3. 客户、订单、产品等尽量使用店长原话中的姓名、编码、单号、名称;缺少必填信息时放入 missingFields。
4. 一次只规划一个操作。复合请求拆成“先做哪一个”,只输出第一个。
5. 物理删除、跨门店、越权、系统配置、无关请求输出 {"operation":"REFUSE","arguments":{},"missingFields":[]}。
6. 金额单位是分;数量使用数字;时间使用毫秒时间戳或 yyyy-MM-dd HH:mm。
7. 订单明细使用 itemList 数组;履约明细使用 itemList 数组;不要输出请求号、门店、操作人。
操作目录:
CUSTOMER_CREATE: name 必填;gender(男/女)、birthdate(yyyy-MM-dd)、telephone、address、remark、disease 可选。
CUSTOMER_UPDATE: customerKeyword 或 customerId 必填;name、gender、birthdate、telephone、address、remark、disease 可选。
FOLLOW_UP_CREATE: customerKeyword 或 customerId 必填;content 必填;remindAt 或 remindAtText 必填;responsibleUserName 可选,默认当前用户。
FOLLOW_UP_UPDATE: reminderId 必填;content、remindAt 可选。
FOLLOW_UP_COMPLETE: reminderId 必填。
STORE_DIARY_CREATE: title、content 必填。
STORE_DIARY_UPDATE: diaryId 必填;title、content 可选。
EVENT_RECORD_CREATE: customerKeyword 或 customerId 必填;eventKeyword 或 eventId 必填;numberValue、pointValue、registeredAt、remark 可选。
EVENT_RECORD_UPDATE: eventRecordId 必填;remark 可选。
EVENT_RECORD_VERIFY: eventRecordId 必填。
STOCK_MANUAL_IN / STOCK_MANUAL_OUT / STOCK_STOCKTAKE_GAIN / STOCK_STOCKTAKE_LOSS: skuKeyword 或 skuId 必填;unitKeyword 或 skuUnitId 可选;quantity 必填;remark 必填。
SALES_ORDER_CREATE: customerKeyword 或 customerId 必填;itemList 必填,元素 {skuKeyword 或 skuId, unitKeyword 或 skuUnitId, quantity, unitPrice?, remark?};purchasedAt、remark 可选;unitPrice 只有明确改价时输出,并同时输出 overrideReason。
SALES_ORDER_UPDATE: orderNo 或 salesOrderId 必填;remark 可选。
SALES_ORDER_CANCEL: orderNo 或 salesOrderId 必填;reason 必填;fulfillmentRevokeList、fulfillmentReturnList、fundRevokeList、fundRefundList 可选;refund 元素 {amount, occurredAt?, remark?}。
PAYMENT_RECEIVE / PAYMENT_RECEIVE_AND_VERIFY: orderNo 或 salesOrderId 必填;amount 必填;occurredAt、remark 可选。
PAYMENT_VERIFY / PAYMENT_REJECT / PAYMENT_CANCEL: fundRequestNo 或 fundRecordId 必填;reject/cancel 还需要 reason。
PAYMENT_REFUND: orderNo 或 salesOrderId 必填;amount、reason 必填;occurredAt、remark 可选。
FUND_REVOKE: fundRequestNo 或 fundRecordId 必填;reason 必填;occurredAt、remark 可选。
FULFILLMENT_CREATE / FULFILLMENT_CREATE_AND_VERIFY: orderNo 或 salesOrderId 必填;itemList 可用 fulfillAll=true 代替;remark、deliveredAt 可选。
FULFILLMENT_VERIFY / FULFILLMENT_REJECT / FULFILLMENT_CANCEL: fulfillmentId,或 orderNo 加 fulfillmentRequestNo;reject/cancel 需要 reason。
POINT_ADJUST: customerKeyword 或 customerId 必填;pointDelta 必填;remark 必填。
POINT_REDEMPTION_CREATE: customerKeyword 或 customerId 必填;redeemKeyword 或 redeemSkuId 必填;quantity 必填;actualPointCost、remark 可选。
CUSTOMER_PACKAGE_PURCHASE: customerKeyword 或 customerId 必填;packageKeyword 或 packageConfigId 必填;saleAmount、reason、itemList、purchasedAt、remark 可选。
- id: write-user
role: user
text: |-
当前门店:{{#start.storeName#}}
当前日期:{{#start.today#}}
店长请求:{{#sys.query#}}
selected: false
title: 写操作规划
type: llm
variables: []
vision:
enabled: false
height: 180
id: write_planner
position:
x: 680
y: 1050
positionAbsolute:
x: 680
y: 1050
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
code: |2
import json
import re
ALLOWED = {
'CUSTOMER_CREATE','CUSTOMER_UPDATE','FOLLOW_UP_CREATE','FOLLOW_UP_UPDATE','FOLLOW_UP_COMPLETE',
'STORE_DIARY_CREATE','STORE_DIARY_UPDATE','EVENT_RECORD_CREATE','EVENT_RECORD_UPDATE','EVENT_RECORD_VERIFY',
'STOCK_MANUAL_IN','STOCK_MANUAL_OUT','STOCK_STOCKTAKE_GAIN','STOCK_STOCKTAKE_LOSS',
'SALES_ORDER_CREATE','SALES_ORDER_UPDATE','SALES_ORDER_CANCEL',
'PAYMENT_RECEIVE','PAYMENT_RECEIVE_AND_VERIFY','PAYMENT_VERIFY','PAYMENT_REJECT','PAYMENT_CANCEL',
'PAYMENT_REFUND','FUND_REVOKE','FULFILLMENT_CREATE','FULFILLMENT_CREATE_AND_VERIFY',
'FULFILLMENT_VERIFY','FULFILLMENT_REJECT','FULFILLMENT_CANCEL','POINT_ADJUST',
'POINT_REDEMPTION_CREATE','CUSTOMER_PACKAGE_PURCHASE',
}
def parse_json(raw):
text = str(raw or '').strip()
text = re.sub(r'^```(?:json)?\s*', '', text, flags=re.I)
text = re.sub(r'\s*```$', '', text)
try:
return json.loads(text)
except Exception:
match = re.search(r'\{.*\}', text, re.S)
if match:
try:
return json.loads(match.group())
except Exception:
pass
return {}
def main(raw):
payload = parse_json(raw)
operation = str(payload.get('operation') or 'REFUSE').strip().upper()
arguments = payload.get('arguments') if isinstance(payload.get('arguments'), dict) else {}
missing = payload.get('missingFields') if isinstance(payload.get('missingFields'), list) else []
if operation not in ALLOWED:
return {'operation': 'REFUSE', 'arguments_json': '{}', 'valid': False,
'error_text': '该请求不在智能助手允许的写操作范围内。',
'missing_fields_json': '[]'}
return {'operation': operation,
'arguments_json': json.dumps(arguments, ensure_ascii=False),
'valid': True,
'error_text': '',
'missing_fields_json': json.dumps(missing, ensure_ascii=False)}
code_language: python3
desc: 校验操作白名单并序列化参数
outputs:
operation:
children: null
type: string
arguments_json:
children: null
type: string
valid:
children: null
type: boolean
error_text:
children: null
type: string
missing_fields_json:
children: null
type: string
selected: false
title: 校验写操作计划
type: code
variables:
- value_selector:
- write_planner
- text
variable: raw
height: 180
id: parse_write_plan
position:
x: 1000
y: 1050
positionAbsolute:
x: 1000
y: 1050
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
conditions:
- comparison_operator: is
id: plan-valid-condition
value: true
varType: boolean
variable_selector:
- parse_write_plan
- valid
desc: 无效计划直接拒绝,不调用准备工具
logical_operator: and
selected: false
title: 写操作计划是否有效
type: if-else
height: 140
id: plan_valid_gate
position:
x: 1200
y: 1200
positionAbsolute:
x: 1200
y: 1200
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
zIndex: 0
- data:
answer: '{{#parse_write_plan.error_text#}}'
desc: 无效或越权写操作直接拒绝
selected: false
title: 写操作拒绝
type: answer
variables: []
height: 140
id: answer_write_invalid
position:
x: 1200
y: 1380
positionAbsolute:
x: 1200
y: 1380
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 260
zIndex: 0
- data:
desc: 调用 GAO MCP 准备写操作,只生成预览和确认 token
provider_id: gao-mcp-server-dev
provider_name: gao-mcp-server-dev
provider_type: mcp
selected: false
title: 准备写操作
tool_configurations: {}
tool_label: operation_prepare
tool_name: operation_prepare
tool_node_version: '2'
tool_parameters:
operation:
type: variable
value:
- parse_write_plan
- operation
argumentsJson:
type: variable
value:
- parse_write_plan
- arguments_json
attachmentTokensJson:
type: variable
value:
- start
- attachmentTokensJson
aiSessionId:
type: variable
value:
- start
- aiSessionId
type: tool
height: 170
id: prepare_tool
position:
x: 1360
y: 1050
positionAbsolute:
x: 1360
y: 1050
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
code: |2
import json
def parse_payload(raw):
if isinstance(raw, dict):
return raw
text = str(raw or '').strip()
if not text:
return {}
try:
payload = json.loads(text)
if isinstance(payload, dict):
return payload
if isinstance(payload, list):
for item in payload:
if not isinstance(item, dict):
continue
if isinstance(item.get('json'), dict):
return item['json']
if isinstance(item.get('text'), str):
try:
candidate = json.loads(item['text'])
if isinstance(candidate, dict):
return candidate
except Exception:
pass
except Exception:
pass
return {}
def main(raw):
payload = parse_payload(raw)
status = str(payload.get('status') or 'FAILED')
preview = payload.get('previewText')
error = payload.get('errorMessage')
if status == 'PENDING_CONFIRMATION':
text = str(preview or '操作已准备,等待确认。')
elif status == 'NEEDS_CLARIFICATION':
missing = payload.get('missingFields') or []
text = '还缺少必要信息:' + ('、'.join([str(x) for x in missing]) if missing else str(error or '请补充信息。'))
elif status == 'CANDIDATES':
candidates = payload.get('candidates') or []
lines = []
for item in candidates:
if isinstance(item, dict):
lines.append('- ' + ' / '.join([str(v) for v in item.values() if v not in (None, '')]))
else:
lines.append('- ' + str(item))
text = str(error or '匹配到多个结果,请补充更具体的信息。')
if lines:
text += '\n' + '\n'.join(lines[:8])
elif status == 'ATTACHMENT_REQUIRED':
text = str(error or '该操作必须上传凭证照片,请先上传后重试。')
elif status == 'PERMISSION_DENIED':
text = str(error or '当前账号缺少办理该操作的权限。')
elif status == 'FEATURE_DISABLED':
text = str(error or '该操作暂未对智能助手开放。')
else:
text = str(error or preview or '操作准备失败,请稍后重试。')
return {'answer_text': text, 'status': status, 'operation_id': payload.get('operationId') or '',
'error_code': payload.get('errorCode') or ''}
code_language: python3
desc: 把后端预览、缺失字段、候选和错误转换成用户答复
outputs:
answer_text:
children: null
type: string
status:
children: null
type: string
operation_id:
children: null
type: string
error_code:
children: null
type: string
selected: false
title: 解析准备结果
type: code
variables:
- value_selector:
- prepare_tool
- text
variable: raw
height: 180
id: parse_prepare
position:
x: 1720
y: 1050
positionAbsolute:
x: 1720
y: 1050
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 320
zIndex: 0
- data:
answer: '{{#parse_prepare.answer_text#}}'
desc: 直接输出后端预览,不让模型改写金额、单号和状态
selected: false
title: 写操作答复
type: answer
variables: []
height: 140
id: answer_write
position:
x: 2080
y: 1050
positionAbsolute:
x: 2080
y: 1050
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 260
zIndex: 0
viewport:
x: -4.292682679471227
y: 3.141444007269058
zoom: 0.9094299399062398
rag_pipeline_variables: []