System One 决策 SDK 类型化判断。
用 System One 决策 SDK,一次 evaluate() 接入结构化决策。定义选项、打分量表与是否问题,在应用中直接使用类型化答案。
开源 · TypeScript · Node.js
安装 SDK
npm install @system-one-ai/core@0.8.0 @system-one-ai/adapter-system-one@0.7.0 @system-one-ai/transport-fetch@0.8.0decision.ts
import { createSystemOne, choice } from '@system-one-ai/core';import { systemOneAdapter } from '@system-one-ai/adapter-system-one';import { createFetchTransport } from '@system-one-ai/transport-fetch';const client = createSystemOne({ adapter: systemOneAdapter, transport: createFetchTransport(), baseURL: process.env.SYSTEM_ONE_BASE_URL!, apiKey: process.env.SYSTEM_ONE_API_KEY!, maxRetries: 0,});const result = await client.evaluate({ state: { message: 'I was charged twice.' }, questions: { team: choice('Who should handle this?', { billing: 'Payments and refunds', support: 'Technical issues', }), },});result.answers.team.choice; // 'billing' | 'support'连接模型服务
安装 core、服务适配器与 transport。为 System One API 配置 systemOneAdapter 与 createFetchTransport()。凭证保存在服务器环境中。
SDK 文档.env
SYSTEM_ONE_BASE_URL=https://api.typesafe.ai/v1SYSTEM_ONE_API_KEY=YOUR_TYPESAFE_API_KEY统一的结构化决策接口
从问题到答案的类型
Choice 结果将选项名保留为 TypeScript 字面量类型。Score 与是否概率以数字返回。
连接你的提供方
可直接使用 System One API。可选的 Vercel AI SDK 适配器可连接其他受支持的模型服务。
控制请求行为
配置超时与重试,用 AbortSignal 取消,并在应用中处理类型化错误。
连接到 System One API
使用 System One API 密钥调用托管服务。在 Playground 测试输入,并在控制台查看请求用量。