Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

score.md

69 lines956 Bytes

1---
2id: score
3title: score
4---
5​
6```ts
7function score<TLevels>(options): object;
8```
9​
10Defined in: packages/ai/src/activities/evaluate/index.ts:393
11​
12Build a score question. The model rates `state` on ordered `levels`.
13​
14You must pass at least two levels. `.value` is the nearest level label.
15The raw fraction stays on `.score`. On the wire, `levels` is sent as
16TypeSafe `criteria`.
17​
18## Type Parameters
19​
20### TLevels
21​
22`TLevels` *extends* readonly `string`[]
23​
24## Parameters
25​
26### options
27​
28#### instructions
29​
30`EvaluateJsonValue`
31​
32What the model should rate.
33​
34#### levels
35​
36`TLevels`
37​
38Ordered labels, lowest first. At least two.
39​
40## Returns
41​
42`object`
43​
44### criteria
45​
46```ts
47criteria: TLevels = options.levels;
48```
49​
50### instructions
51​
52```ts
53instructions: EvaluateJsonValue = options.instructions;
54```
55​
56### type
57​
58```ts
59type: "score";
60```
61​
62## Example
63​
64```ts
65const urgency = score({
66 instructions: 'How urgent is this ticket?',
67 levels: ['low', 'medium', 'high'],
68})
69```