Open History to see the last commit
1---
2id: choice
3title: choice
4---
5
6```ts
7function choice<TOptions>(options): object;
8```
9
10Defined in: [packages/ai/src/activities/evaluate/index.ts:365](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/evaluate/index.ts#L365)
11
12Build a choice question. The model picks one key from `options`.
13
14Option keys become the union on `.value`. Use `null` when a key needs no
15extra description. On the wire, `options` is sent as TypeSafe `criteria`.
16
17## Type Parameters
18
19### TOptions
20
21`TOptions` *extends* `Record`\<`string`, `string` \| `null`\>
22
23## Parameters
24
25### options
26
27#### instructions
28
29`EvaluateJsonValue`
30
31What the model should decide.
32
33#### options
34
35`TOptions`
36
37Map of option key to description, or `null`.
38
39## Returns
40
41`object`
42
43### criteria
44
45```ts
46criteria: TOptions = options.options;
47```
48
49### instructions
50
51```ts
52instructions: EvaluateJsonValue = options.instructions;
53```
54
55### type
56
57```ts
58type: "choice";
59```
60
61## Example
62
63```ts
64const queue = choice({
65 instructions: 'Which team should handle this ticket?',
66 options: {
67 billing: 'Payments, invoices, refunds',
68 tech: 'Bugs, outages, integrations',
69 sales: 'Pricing, upgrades, new accounts',
70 },
71})
72```