JevHub 指南
Jev 快速入门
最短路径是:安装官方 SDK,设置 TypeSafe API key,发送 state 和 Choice、Score、Noul 问题,然后在代码中读取返回结果。
1. 前置条件
当前官方 JavaScript SDK 要求 Node.js 20 或更高版本,以及一个 TypeSafe API key。
2. 安装官方 SDK
npm install @typesafe-ai/sdk把 TYPESAFE_API_KEY 放在服务端环境变量里,不要写进前端代码。官方客户端也会阻止在浏览器中直接使用它。
3. 发送第一个决策
import { choice, TypeSafeClient } from "@typesafe-ai/sdk";
const client = new TypeSafeClient();
const response = await client.systemOne({
state: {
document: "I was charged twice. Please fix this ASAP.",
},
questions: {
category: choice("What is this ticket about?", {
billing: null,
technical: null,
other: null,
}),
},
});
console.log(response.answers.category.choice);这个示例沿用官方 JavaScript SDK quickstart 的基本写法:让 Jev 从几个固定类别中判断这条客服消息属于哪一类。
4. state 是什么
state 是模型需要判断的信息,可以是文本,也可以是 JSON 兼容的结构化数据。如果应用已经知道支付状态、用户角色、tool 调用结果或允许的 route 等事实,优先用明确字段传入。
5. questions 怎么写
每个 question 都会返回固定格式的结果。Choice 从固定选项中选一个;Noul 返回 yes 的概率;Score 按你定义的等级给出分数和概率分布。
import { choice, noul, score, TypeSafeClient } from "@typesafe-ai/sdk";
const client = new TypeSafeClient();
const response = await client.systemOne({
state: {
message: "Our checkout failed twice and launch is tomorrow.",
},
questions: {
route: choice("Which queue should own this?", {
billing: "Payment and charge issues",
technical: "Product or integration failures",
other: "Everything else",
}),
urgent: noul("Is this time-sensitive?"),
severity: score("How severe is the impact?", [
"Low",
"Moderate",
"High",
"Critical",
]),
},
});常见错误
- 答案范围根本无法提前定义,却要求 Jev 生成长文本。
- Choice 标签含义模糊,没有定义区分标准。
- 把 Jev 的结果直接当成高风险操作的执行授权。
- 把秘密 API key 放在浏览器中调用,而不是放在服务端环境。
一手来源
本页在 2026-09-21 根据官方 JavaScript SDK v0.6.0 源码和 README 核验。
下一步
先在Playground中运行一次,在模板中尝试具体模式,在成本计算器中估算生产用量,或阅读Jev 与 ChatGPT了解两者分别适合什么场景。