← 文章 / AI技术
vercel 4小时前 · 2026-10-07 04:33:40 · 1 阅读

AI 网关增加了基于置信度的决策回退机制

AI Gateway 现在支持基于置信度条件的决策降级:当主模型的回答触发你设置的条件时,请求会自动转给备用模型。

条件可以组合使用,一次降级可以依赖多个信号。你在 models 里列出的普通模型名仍然兜底所有报错,所以现有的降级逻辑不受影响。置信度条件适用于 Choice 和 Score 类问题;Boolean 类问题则改用概率区间来触发。

配置方法很简单:在 providerOptions.gateway.models 里添加一个条件对象即可。不加这个字段时,行为与之前完全一致。

1import { gateway } from '@ai-sdk/gateway';2import { experimental_decide as decide } from 'ai';3const result = await decide({4  model: gateway.decisionModel('typesafe-ai/jev'),5  state: 'I was charged twice and now the app will not load.',6  questions: {7    intent: {8      type: 'choice',9      instructions: 'Which team should handle this?',10      criteria: { billing: 'Charges and refunds', technical: 'Bugs and outages' },11    },12  },13  providerOptions: {14    gateway: {15      models: [{ model: 'openai/gpt-6-astra', when: { question: 'intent', confidenceBelow: 0.6 } }],16    },17  },18});19console.log(result.answers.intent.choice);

通过置信度条件把不确定的回答降级给备用模型

如果省略 question 字段,条件会检查该类型的所有问题。也就是说 { confidenceBelow: 0.6 } 会在任何一个 Choice 或 Score 回答的置信度低于 0.6 时触发降级。

需要注意,降级被触发后会执行第二次决策,因此两个阶段都会计费。

决策降级功能目前处于 beta 阶段,详情见决策降级文档。

原始来源: vercel

评论 (0)