跳至主要内容

Playground

角色下一步做什么?

角色下一步做什么?血量很低时选择喝药自保,血量充足时选择进攻。

相关文章Agent 工具太多总选错?用 Choice 做工具路由(TypeScript 实战)

示例结果不随所选模型变化。

请求

state
application/json
{  "npc": "边境守卫",  "hp": "12%",  "enemies": 3,  "inventory": {    "healing_potion": 1  },  "terrain": "狭窄桥面",  "ally_nearby": false}

结果

示例数据
对比两个例子

两个例子只差一处,结果会跟着变。

改了什么血量很低 → 血量充足

以下结果为示例数据,并非模型实时输出。登录后可以换成你自己的内容。
action:attack · 攻击 → potion · 喝药
actionchoice
potion · 喝药
各选项置信度
攻击
7%
喝药
58%
逃跑
24%
求和
9%
嘲讽
2%

复制代码

设置 SYSTEM_ONE_API_KEY。代码片段使用目录中已发布的模型 id。

请求 JSON
application/json
{"model":"decider-v1.1","state":{"npc":"边境守卫","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"狭窄桥面","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC's next action given the game state.","criteria":{"attack":"攻击","potion":"喝药","flee":"逃跑","parley":"求和","taunt":"嘲讽"}}}}
cURL · POST /v1/systemone
sh
curl "https://system-one.dev/v1/systemone" \  -H "Authorization: Bearer $SYSTEM_ONE_API_KEY" \  -H 'Content-Type: application/json' \  -H 'Idempotency-Key: saved-operation-id' \  --data '{"model":"decider-v1.1","state":{"npc":"边境守卫","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"狭窄桥面","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC'\''s next action given the game state.","criteria":{"attack":"攻击","potion":"喝药","flee":"逃跑","parley":"求和","taunt":"嘲讽"}}}}'
TypeScript
TypeScript
// npm install @system-one-ai/core@0.6.0 @system-one-ai/transport-fetch@0.6.0 @system-one-ai/adapter-system-one@0.6.0import { createSystemOne, choice, score, booleanQuestion } 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({  baseURL: "https://system-one.dev/v1",  apiKey: process.env.SYSTEM_ONE_API_KEY!,  model: "decider-v1.1",  adapter: systemOneAdapter,  transport: createFetchTransport(),  timeoutMs: 30_000,  maxRetries: 0,});const result = await client.evaluate({  state: {    "npc": "边境守卫",    "hp": "12%",    "enemies": 3,    "inventory": {      "healing_potion": 1    },    "terrain": "狭窄桥面",    "ally_nearby": false  },  questions: {  action: choice("Choose the NPC's next action given the game state.", {    attack: "攻击",    potion: "喝药",    flee: "逃跑",    parley: "求和",    taunt: "嘲讽",  }),  },}, { headers: { 'Idempotency-Key': crypto.randomUUID() } });result.answers.action.choiceresult.response.requestId;