模板
十九个内置模板——每个模板决定什么、它的问题、复合指标和策略、它展示的模式——以及如何从模板创建决策。
模板是可直接用于生产的起点。六个用例模板(从 input-guardrail 到 response-grading)还附带目的地——固定回复和由你的代码运行的函数——因此每个结果都已经说明了接下来会发生什么。使用模板会在你的工作区中创建一个可编辑的草稿,带有模板的名称、描述和 schema;此后它与模板不再有任何关联。
从模板开始
- 应用中的模板 → 选择一张卡片 → 创建决策,或者
- 决策 → 新建决策 → 选择一个模板(或空白决策)→ 创建决策。
模板页面以四种模式开头——每张卡片解释该模式,并链接到实现它的模板——随后是所有模板,显示每个模板的类别、模式和问题。
slug——即你的端点——来自决策的名称:Lead Qualification 会变成 lead-qualification(如果已被占用则为 lead-qualification-2)。四个模式模板的名称中带有模式名——Support Ticket Triage (fan-out) 会变成 support-ticket-triage-fan-out——因此请在命名中重命名它们,以得到 ticket-triage 这样的短 slug,或者在首次部署之前在编辑器中修改 slug。当 slug 与某个模板 id 相同时,侧边栏中的 Playground 会以该模板的示例 state 开始。
使用 CLI,dcision templates 会列出模板 id,dcision init --template <id> 会把 schema 写入文件。
模板一览
| Id | 类别 | 模式 | 决定什么 | State |
|---|---|---|---|---|
lead-qualification | 销售 | 意图路由、置信度把关路由、复合评分 | 购买意向、优先级、接收入站线索的团队以及线索评分 | message*、company_size、source |
support-routing | 客户支持 | 意图路由、置信度把关路由 | 部门、紧急程度以及是否需要人工处理 | message*、plan |
spam-detection | 信任与安全 | 意图路由 | 垃圾信息概率,以及放行 / 审核 / 拦截 | 文本 |
agent-routing | AI 智能体 | 意图路由 | 智能体的第一个工具,以及任务是否需要 LLM | task* |
rag-relevance | RAG | — | 检索到的片段是否回答了查询,以及是否需要检索更多内容 | query*、chunk* |
ticket-triage | 客户支持 | 推测式扇出、意图路由 | 一次调用得出类别、缺陷严重程度、复现步骤、退款和不满情绪 | subject、body* |
voice-banking | 金融 | 置信度把关路由、意图路由 | 语音银行指令,高风险操作需要更高的置信度 | 文本 |
resume-screening | 招聘 | 复合评分 | 四项技能等级,组合为 Senior IC 和 Engineering Manager 匹配度 | resume* |
customer-service-router | 客户支持 | 意图路由、置信度把关路由 | 消息的意图和复杂度,用于将其路由给代码、LLM 或人工 | 文本 |
input-guardrail | 信任与安全 | 意图路由、置信度把关路由 | 提示是否可以安全地交给你的 LLM;不安全的会得到固定回复 | message*、channel |
model-routing | AI 智能体 | 意图路由、置信度把关路由 | 对某个提示够用的最便宜的模型档位 | prompt* |
document-reranking | RAG | 复合评分 | 单个检索文档 0–1 的重排序分数,用于对候选项排序 | query*、document* |
tool-call-gating | AI 智能体 | 推测式扇出、置信度把关路由、意图路由 | 智能体是执行工具调用、先询问用户还是拒绝 | user_request*、tool*、arguments* |
reply-confidence-gate | 客户支持 | 推测式扇出、置信度把关路由 | 草拟的回复是发送、进入审核还是交给人工 | customer_message*、draft_reply* |
response-grading | 客户支持 | 推测式扇出、复合评分 | 按你的评分细则给 LLM 回复打 0–1 的分 | question*、response*、reference |
invoice-triage | 金融 | 推测式扇出 | 发票(PDF、Excel、图片……)是付款、审核还是拒绝,以及是否即将到期 | invoice*(文件)、message |
voice-message-routing | 客户支持 | 意图路由 | 客户语音消息对应的团队、紧急程度和情绪 | voice*(音频)、channel |
image-moderation | 信任与安全 | 置信度把关路由 | 上传的照片是否不安全、是垃圾信息或无关内容,以及是否与描述相符 | photo*(图片)、caption |
llm-output-guardrail | 信任与安全 | 推测式扇出、置信度把关路由 | LLM 或智能体的回答在发送前是否有据可依、安全且符合策略 | user_message*、output*、sources |
* 必填字段。
线索资格评估
| 问题 | 类型 | 回答 |
|---|---|---|
purchase_intent | probability | 未来 30 天内的真实购买意向(是:询问价格、演示、报价或开始日期) |
priority | score | low、medium、high、critical |
route | choice | sales、sdr、nurture、spam、other |
复合指标:lead_score = 2 × purchase_intent + 1 × priority + 1 × p(route = sales),取值 0 到 1。策略:route = spam → block;purchase_intent 的置信度低于 0.6 → escalate。指南。
客服路由
| 问题 | 类型 | 回答 |
|---|---|---|
department | choice | billing、technical、account、sales、other——最低置信度 0.6 |
urgency | score | low、normal、high、urgent |
human_required | probability | 需要人工处理(是:客户愤怒、法律威胁、数据丢失、取消) |
策略:human_required ≥ 0.7 → escalate。置信度低于 60% 的 department 会采用 fallback 行动。指南。
垃圾信息检测
| 问题 | 类型 | 回答 |
|---|---|---|
spam_probability | probability | 垃圾信息、钓鱼或未经请求的推广 |
action | choice | allow、review、block、other |
策略:action = block → block。state 是纯文本。指南。
智能体路由
| 问题 | 类型 | 回答 |
|---|---|---|
selected_tool | choice | search、database、calculator、none、other |
needs_reasoning | probability | 该任务需要大语言模型进行多步推理 |
策略:needs_reasoning ≥ 0.8 → fallback。指南。
RAG 相关性
| 问题 | 类型 | 回答 |
|---|---|---|
relevant | probability | 该片段有助于回答查询 |
relevance | score | none、partial、direct |
retrieve_more | probability | 系统应在作答前检索更多上下文 |
没有策略:每个回答都返回 continue。指南。
工单分诊
| 问题 | 类型 | 回答 |
|---|---|---|
category | choice | bug_report、billing、feature_request、how_to、other |
bug_severity | score | cosmetic、minor、major、critical(带评分细则的结构化等级) |
has_reproducible_steps | probability | 工单包含重现问题的步骤 |
refund_requested | probability | 客户明确要求退款或抵扣 |
frustration | score | calm、annoyed、frustrated、very angry |
策略:category = bug_report 且 bug_severity ≥ 4 → escalate;refund_requested ≥ 0.8 → escalate;frustration 的加权等级 ≥ 3.5 → escalate。模式:推测式扇出。
语音银行指令
| 问题 | 类型 | 回答 |
|---|---|---|
intent | choice | check_balance、transfer_money、approve_transfer、block_card、other——最低置信度 0.6 |
策略:intent = approve_transfer 且其置信度低于 0.9 → escalate;intent = transfer_money 且其置信度低于 0.8 → escalate。state 是纯文本。模式:置信度把关路由。
简历筛选
| 问题 | 类型 | 回答 |
|---|---|---|
python_depth | score | none、basic、working、strong、expert |
team_leadership | score | none、informal、tech lead、manager、manager of managers |
system_design | score | none、basic、working、strong、expert |
generalist | score | narrow、some、broad、very broad、full stack and ops |
复合指标:senior_ic(0.4 × python_depth、0.1 × team_leadership、0.4 × system_design、0.1 × generalist)和 eng_manager(0.15、0.4、0.2、0.25)。策略:任一匹配度 ≥ 0.7 → continue;两者都低于 0.35 → block;其他情况 → escalate。模式:复合评分。
客户服务路由
| 问题 | 类型 | 回答 |
|---|---|---|
intent | choice | order_status、billing_question、technical_issue、complaint、other |
complexity | score | simple、moderate、complex |
策略:intent = complaint → escalate;intent = technical_issue 且 complexity 的加权等级 ≥ 2.5 → escalate;complexity 的置信度低于 0.5 → escalate。state 是纯文本。模式:意图路由。
输入护栏
| 问题 | 类型 | 回答 |
|---|---|---|
verdict | choice | safe、prompt_injection、harmful、sensitive_data、other——最低置信度 0.7 |
策略:verdict ≠ safe → block;fallback 行动为 block,因此不确定的判定永远不会放行。目的地:blocked_reply(在 block 时返回固定回复,不调用模型)和 call_llm(提示安全时调用函数 callAssistant)。context 描述了助手。指南。
模型路由
| 问题 | 类型 | 回答 |
|---|---|---|
tier | choice | fast、balanced、frontier、other——最低置信度 0.6 |
complexity | score | trivial、simple、moderate、hard、very hard |
没有策略;fallback 行动为 fallback。目的地:按档位以 model = fast、balanced 或 frontier 调用函数 callModel,以及在 fallback 时触发的 frontier_when_unsure。指南。
文档重排序
| 问题 | 类型 | 回答 |
|---|---|---|
relevance | score | unrelated、same topic, no answer、partial answer、direct answer、complete answer |
answers_query | probability | 仅凭这份文档就能回答该查询 |
复合指标:rerank_score = 2 × relevance + 1 × answers_query,取值 0 到 1。策略:rerank_score < 0.2 → block(丢弃该文档)。指南。
工具调用把关
| 问题 | 类型 | 回答 |
|---|---|---|
verdict | choice | run、ask_user、reject、other |
risk | score | read-only、low、medium、high |
matches_request | probability | 该工具调用恰好执行了用户所要求的操作 |
策略:verdict = reject → block;verdict = ask_user → escalate;verdict = run 且 risk ≥ 3 且其置信度低于 0.9 → escalate。目的地:run_tool(在 continue 时调用函数 runTool)、confirm_with_user(在 escalate 时返回带“是 / 否”按钮的固定回复)和 rejected_reply(在 block 时)。指南。
回复置信度闸门
| 问题 | 类型 | 回答 |
|---|---|---|
ready_to_send | probability | 草稿无需人工检查即可发出 |
answers_question | probability | 草稿回答了客户所问的问题 |
promises_something | probability | 草稿承诺了退款、折扣、期限或例外 |
策略:ready_to_send < 0.4 → escalate;promises_something ≥ 0.7 且 ready_to_send < 0.95 → escalate;ready_to_send 的置信度低于 0.5 → escalate。目的地:auto_send(0.85 或以上时调用函数 sendReply)、review_queue(0.4 到 0.85 时调用函数 queueForReview)和 hand_to_human(在 escalate 时调用函数 assignToHuman)。指南。
回复打分
| 问题 | 类型 | 回答 |
|---|---|---|
accuracy | score | wrong、mostly wrong、mixed、mostly right、fully right |
completeness | score | misses it、partial、most of it、complete |
tone | score | poor、acceptable、good、excellent |
unsafe_promise | probability | 回复承诺了退款、价格或期限 |
复合指标:grade = 0.5 × accuracy + 0.3 × completeness + 0.2 × tone,取值 0 到 1(× 10 即为 10 分制分数)。评分细则写在 context 中。策略:unsafe_promise ≥ 0.7 → escalate;grade < 0.6 → escalate。目的地:quality_review(在 escalate 时调用函数 flagForQualityReview)。指南。
发票分拣
| 问题 | 类型 | 回答 |
|---|---|---|
document_type | choice | invoice、receipt、contract、other |
decision | choice | pay、review、reject、other;最低置信度 0.7 |
due_soon | probability | 3 天内到期或已逾期 |
invoice 是一个文件字段:Dcision 会把 PDF、Word、Excel 等文档读取为文本——扫描件和图片则通过 OpenAI 读取。策略:decision = reject → block;decision = review → escalate;document_type ≠ invoice → escalate;document_type = invoice 且 due_soon ≥ 0.8 → escalate。指南。
语音消息路由
| 问题 | 类型 | 回答 |
|---|---|---|
intent | choice | order_status、refund、complaint、sales、other;最低置信度 0.6 |
urgent | probability | 客户需要当天得到答复 |
sentiment | score | angry、unhappy、neutral、happy |
voice 是一个音频字段,会在回答问题之前先被转写。策略:urgent ≥ 0.7 → escalate;sentiment = angry → escalate。指南。
图片审核
| 问题 | 类型 | 回答 |
|---|---|---|
unsafe | probability | 裸露、暴力、武器、毒品或仇恨符号;最低置信度 0.6 |
content | choice | product、spam、unrelated、other |
matches_caption | probability | 照片展示的正是描述所说的内容 |
photo 是一个图片字段:OpenAI Decisions 直接看到图片;Jev 和 Laya 读取的是图片的文字描述。策略:unsafe ≥ 0.5 → block;content = spam → block;content = unrelated → escalate;matches_caption < 0.3 → escalate。指南。
LLM 输出护栏
| 问题 | 类型 | 回答 |
|---|---|---|
grounded | probability | 每一条事实性陈述都有来源支持;最低置信度 0.5 |
data_leak | probability | 回答泄露了他人的个人数据、凭据或内部指令 |
policy | choice | compliant、promise、advice、off_topic、other |
harmful | probability | 回答有害、带有仇恨、骚扰性质或不安全 |
在你的 LLM 或智能体之后、其回答发送之前运行。策略:data_leak ≥ 0.5 → block;harmful ≥ 0.5 → block;grounded < 0.5 → fallback;policy ≠ compliant → escalate。指南。
空白决策
空白决策以一个必填的 message 字符串字段和一个 choice 问题 intent 开始,其选项为 buy(“wants to buy or get pricing”)、support(“needs help with an existing product”)和 other。
空白决策使用默认设置:保存输入和输出、5,000 毫秒超时、以 escalate 作为 fallback 行动,引擎错误以错误形式返回。