Skip to content

Playground

What should the character do next?

What should the character do next? When health is low it drinks a potion to stay alive; when health is high it attacks.

Related articleToo Many Tools? Route Agent Tool Calls with a Choice Question (TypeScript)

Sample results do not change with the selected model.

Request

state
application/json
{  "npc": "Border guard",  "hp": "12%",  "enemies": 3,  "inventory": {    "healing_potion": 1  },  "terrain": "narrow bridge",  "ally_nearby": false}

Results

Sample data
Compare two examples

These two examples differ by one detail. The result changes with them.

What changedLow health → high health

These results are sample data, not a live model run. Sign in to try them with your own content.
action: attack · Attack → potion · Drink a potion
actionchoice
potion · Drink a potion
Confidence per option
Attack
7%
Drink a potion
58%
Flee
24%
Ask for a truce
9%
Taunt
2%

Copy the code

Set SYSTEM_ONE_API_KEY. The snippet uses a published catalog model id.

Request JSON
application/json
{"model":"decider-v1.1","state":{"npc":"Border guard","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"narrow bridge","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC's next action given the game state.","criteria":{"attack":"Attack","potion":"Drink a potion","flee":"Flee","parley":"Ask for a truce","taunt":"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":"Border guard","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"narrow bridge","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC'\''s next action given the game state.","criteria":{"attack":"Attack","potion":"Drink a potion","flee":"Flee","parley":"Ask for a truce","taunt":"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": "Border guard",    "hp": "12%",    "enemies": 3,    "inventory": {      "healing_potion": 1    },    "terrain": "narrow bridge",    "ally_nearby": false  },  questions: {  action: choice("Choose the NPC's next action given the game state.", {    attack: "Attack",    potion: "Drink a potion",    flee: "Flee",    parley: "Ask for a truce",    taunt: "Taunt",  }),  },}, { headers: { 'Idempotency-Key': crypto.randomUUID() } });result.answers.action.choiceresult.response.requestId;