@arizeai/phoenix-client 6.9.1 → 6.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/__generated__/api/v1.d.ts +1809 -18
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/client.d.ts +1 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toAI.js +31 -11
- package/dist/esm/prompts/sdks/toAI.js.map +1 -1
- package/dist/esm/prompts/sdks/toAnthropic.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toAnthropic.js +23 -13
- package/dist/esm/prompts/sdks/toAnthropic.js.map +1 -1
- package/dist/esm/prompts/sdks/toOpenAI.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toOpenAI.js +62 -20
- package/dist/esm/prompts/sdks/toOpenAI.js.map +1 -1
- package/dist/esm/schemas/llm/constants.d.ts +1 -1
- package/dist/esm/schemas/llm/converters.d.ts +4 -4
- package/dist/esm/schemas/llm/openai/converters.d.ts +1 -1
- package/dist/esm/schemas/llm/openai/messageSchemas.d.ts +1 -1
- package/dist/esm/schemas/llm/phoenixPrompt/converters.d.ts +2 -2
- package/dist/esm/schemas/llm/phoenixPrompt/converters.js +2 -2
- package/dist/esm/schemas/llm/phoenixPrompt/converters.js.map +1 -1
- package/dist/esm/schemas/llm/phoenixPrompt/messageSchemas.d.ts +3 -3
- package/dist/esm/schemas/llm/phoenixPrompt/toolSchemas.d.ts +2 -2
- package/dist/esm/schemas/llm/phoenixPrompt/toolSchemas.d.ts.map +1 -1
- package/dist/esm/schemas/llm/phoenixPrompt/toolSchemas.js +1 -1
- package/dist/esm/schemas/llm/phoenixPrompt/toolSchemas.js.map +1 -1
- package/dist/esm/schemas/llm/schemas.d.ts +1 -1
- package/dist/esm/schemas/llm/schemas.js +2 -2
- package/dist/esm/schemas/llm/schemas.js.map +1 -1
- package/dist/esm/schemas/llm/utils.js +2 -2
- package/dist/esm/schemas/llm/utils.js.map +1 -1
- package/dist/esm/schemas/llm/vercel/messageSchemas.d.ts +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types/prompts.d.ts +4 -0
- package/dist/esm/types/prompts.d.ts.map +1 -1
- package/dist/esm/types/prompts.js +6 -1
- package/dist/esm/types/prompts.js.map +1 -1
- package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
- package/dist/esm/utils/getPromptBySelector.d.ts +294 -5
- package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
- package/dist/src/__generated__/api/v1.d.ts +1809 -18
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/client.d.ts +11 -10
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toAI.js +35 -15
- package/dist/src/prompts/sdks/toAI.js.map +1 -1
- package/dist/src/prompts/sdks/toAnthropic.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toAnthropic.js +24 -14
- package/dist/src/prompts/sdks/toAnthropic.js.map +1 -1
- package/dist/src/prompts/sdks/toOpenAI.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toOpenAI.js +63 -21
- package/dist/src/prompts/sdks/toOpenAI.js.map +1 -1
- package/dist/src/schemas/llm/constants.d.ts +1 -1
- package/dist/src/schemas/llm/converters.d.ts +4 -4
- package/dist/src/schemas/llm/openai/converters.d.ts +1 -1
- package/dist/src/schemas/llm/openai/messageSchemas.d.ts +1 -1
- package/dist/src/schemas/llm/phoenixPrompt/converters.d.ts +2 -2
- package/dist/src/schemas/llm/phoenixPrompt/converters.js +1 -1
- package/dist/src/schemas/llm/phoenixPrompt/converters.js.map +1 -1
- package/dist/src/schemas/llm/phoenixPrompt/messageSchemas.d.ts +3 -3
- package/dist/src/schemas/llm/phoenixPrompt/toolSchemas.d.ts +2 -2
- package/dist/src/schemas/llm/phoenixPrompt/toolSchemas.d.ts.map +1 -1
- package/dist/src/schemas/llm/phoenixPrompt/toolSchemas.js +2 -2
- package/dist/src/schemas/llm/phoenixPrompt/toolSchemas.js.map +1 -1
- package/dist/src/schemas/llm/schemas.d.ts +1 -1
- package/dist/src/schemas/llm/schemas.js +1 -1
- package/dist/src/schemas/llm/schemas.js.map +1 -1
- package/dist/src/schemas/llm/utils.js +1 -1
- package/dist/src/schemas/llm/utils.js.map +1 -1
- package/dist/src/schemas/llm/vercel/messageSchemas.d.ts +1 -1
- package/dist/src/types/prompts.d.ts +4 -0
- package/dist/src/types/prompts.d.ts.map +1 -1
- package/dist/src/types/prompts.js +8 -0
- package/dist/src/types/prompts.js.map +1 -1
- package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
- package/dist/src/utils/getPromptBySelector.d.ts +294 -5
- package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/annotations.mdx +7 -3
- package/docs/overview.mdx +1 -1
- package/docs/sessions.mdx +20 -0
- package/docs/traces.mdx +76 -5
- package/package.json +3 -3
- package/src/__generated__/api/v1.ts +1809 -18
- package/src/prompts/sdks/toAI.ts +33 -11
- package/src/prompts/sdks/toAnthropic.ts +26 -15
- package/src/prompts/sdks/toOpenAI.ts +66 -23
- package/src/schemas/llm/phoenixPrompt/converters.ts +2 -2
- package/src/schemas/llm/phoenixPrompt/toolSchemas.ts +16 -13
- package/src/schemas/llm/schemas.ts +2 -2
- package/src/schemas/llm/utils.ts +2 -2
- package/src/types/prompts.ts +13 -0
package/docs/annotations.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Annotations"
|
|
3
|
-
description: "Attach structured feedback to spans, documents, and sessions with @arizeai/phoenix-client"
|
|
3
|
+
description: "Attach structured feedback to spans, documents, traces, and sessions with @arizeai/phoenix-client"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Annotations are structured feedback records — labels, scores, and explanations — attached to observability artifacts in Phoenix. They are the primary mechanism for recording quality signals, whether those signals come from end-users, LLM judges, or programmatic checks.
|
|
@@ -11,6 +11,7 @@ Annotations are structured feedback records — labels, scores, and explanations
|
|
|
11
11
|
<li><code>src/types/annotations.ts</code> for the shared <code>Annotation</code> base interface</li>
|
|
12
12
|
<li><code>src/spans/types.ts</code> for <code>SpanAnnotation</code> and <code>DocumentAnnotation</code></li>
|
|
13
13
|
<li><code>src/sessions/types.ts</code> for <code>SessionAnnotation</code></li>
|
|
14
|
+
<li><code>src/traces/types.ts</code> for <code>TraceAnnotation</code></li>
|
|
14
15
|
</ul>
|
|
15
16
|
</section>
|
|
16
17
|
|
|
@@ -26,11 +27,12 @@ Once attached, annotations appear in the Phoenix UI alongside traces and can be
|
|
|
26
27
|
|
|
27
28
|
## Annotation Targets
|
|
28
29
|
|
|
29
|
-
Phoenix supports
|
|
30
|
+
Phoenix supports four annotation targets, each focused on a different level of your application:
|
|
30
31
|
|
|
31
32
|
- **[Span Annotations](./span-annotations)** — Feedback on individual traced operations: an LLM call, a tool invocation, a retrieval step. The most common annotation target.
|
|
32
33
|
- **[Document Annotations](./document-annotations)** — Feedback on specific retrieved documents within a retriever span, indexed by position. Essential for evaluating RAG pipeline quality.
|
|
33
34
|
- **[Session Annotations](./session-annotations)** — Feedback on multi-turn conversations or threads as a whole. Use for conversation-level quality signals like resolution rate or customer satisfaction.
|
|
35
|
+
- **[Trace Annotations](./traces#annotate-a-single-trace)** — Feedback attached to a single trace, identified by its trace ID. Use `addTraceAnnotation` or `logTraceAnnotations` from `@arizeai/phoenix-client/traces` when scoring an end-to-end request. Reach for session annotations instead when scoring a multi-turn conversation as a whole.
|
|
34
36
|
|
|
35
37
|
## Annotator Kinds
|
|
36
38
|
|
|
@@ -59,7 +61,7 @@ interface Annotation {
|
|
|
59
61
|
|
|
60
62
|
At least one of `label`, `score`, or `explanation` must be provided.
|
|
61
63
|
|
|
62
|
-
Each target adds its own identifier field — `spanId` for spans, `spanId` + `documentPosition` for documents, and `sessionId` for sessions.
|
|
64
|
+
Each target adds its own identifier field — `spanId` for spans, `spanId` + `documentPosition` for documents, `traceId` for traces, and `sessionId` for sessions.
|
|
63
65
|
|
|
64
66
|
## Sync vs. Async
|
|
65
67
|
|
|
@@ -79,5 +81,7 @@ All annotation write functions accept an optional `sync` parameter:
|
|
|
79
81
|
<li><code>src/spans/getSpanAnnotations.ts</code></li>
|
|
80
82
|
<li><code>src/sessions/addSessionAnnotation.ts</code></li>
|
|
81
83
|
<li><code>src/sessions/logSessionAnnotations.ts</code></li>
|
|
84
|
+
<li><code>src/traces/addTraceAnnotation.ts</code></li>
|
|
85
|
+
<li><code>src/traces/logTraceAnnotations.ts</code></li>
|
|
82
86
|
</ul>
|
|
83
87
|
</section>
|
package/docs/overview.mdx
CHANGED
|
@@ -42,7 +42,7 @@ That gives the agent version-matched docs plus the exact implementation and gene
|
|
|
42
42
|
| `@arizeai/phoenix-client/experiments` | Experiment execution and lifecycle |
|
|
43
43
|
| `@arizeai/phoenix-client/spans` | Span search, notes, and span/document annotations |
|
|
44
44
|
| `@arizeai/phoenix-client/sessions` | Session listing, retrieval, and session annotations |
|
|
45
|
-
| `@arizeai/phoenix-client/traces` | Project trace retrieval |
|
|
45
|
+
| `@arizeai/phoenix-client/traces` | Project trace retrieval and trace annotations |
|
|
46
46
|
|
|
47
47
|
## Configuration
|
|
48
48
|
|
package/docs/sessions.mdx
CHANGED
|
@@ -70,6 +70,25 @@ await addSessionAnnotation({
|
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
## Add a Note to a Session
|
|
74
|
+
|
|
75
|
+
Use `addSessionNote` to append a free-text note to a session. Multiple notes can be added to the same session; each receives a unique UUIDv4 identifier.
|
|
76
|
+
|
|
77
|
+
Requires Phoenix server `>= 14.17.0`.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { addSessionNote } from "@arizeai/phoenix-client/sessions";
|
|
81
|
+
|
|
82
|
+
const result = await addSessionNote({
|
|
83
|
+
sessionNote: {
|
|
84
|
+
sessionId: "cst_123",
|
|
85
|
+
note: "Needs review — retrieval returned empty results on turn 3",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
console.log(result.id); // UUIDv4 for the created note
|
|
90
|
+
```
|
|
91
|
+
|
|
73
92
|
## Cleanup
|
|
74
93
|
|
|
75
94
|
Use `deleteSession` or `deleteSessions` when you need to remove session records by identifier.
|
|
@@ -81,6 +100,7 @@ Use `deleteSession` or `deleteSessions` when you need to remove session records
|
|
|
81
100
|
<li><code>src/sessions/getSession.ts</code></li>
|
|
82
101
|
<li><code>src/sessions/getSessionTurns.ts</code></li>
|
|
83
102
|
<li><code>src/sessions/addSessionAnnotation.ts</code></li>
|
|
103
|
+
<li><code>src/sessions/addSessionNote.ts</code></li>
|
|
84
104
|
<li><code>src/sessions/deleteSession.ts</code></li>
|
|
85
105
|
<li><code>src/sessions/deleteSessions.ts</code></li>
|
|
86
106
|
</ul>
|
package/docs/traces.mdx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Traces"
|
|
3
|
-
description: "Retrieve traces with @arizeai/phoenix-client"
|
|
3
|
+
description: "Retrieve traces and annotate them with @arizeai/phoenix-client"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
The traces module provides trace retrieval and trace-level annotation functions.
|
|
7
7
|
|
|
8
8
|
<section className="hidden" data-agent-context="relevant-source-files" aria-label="Relevant source files">
|
|
9
9
|
<h2>Relevant Source Files</h2>
|
|
@@ -12,10 +12,21 @@ Use `getTraces` when you want trace-centric pagination by project, optional inli
|
|
|
12
12
|
<code>src/traces/getTraces.ts</code> for the exact query shape and server
|
|
13
13
|
requirement
|
|
14
14
|
</li>
|
|
15
|
+
<li>
|
|
16
|
+
<code>src/traces/addTraceAnnotation.ts</code> for single annotation writes
|
|
17
|
+
</li>
|
|
18
|
+
<li>
|
|
19
|
+
<code>src/traces/logTraceAnnotations.ts</code> for batched annotation writes
|
|
20
|
+
</li>
|
|
21
|
+
<li>
|
|
22
|
+
<code>src/traces/types.ts</code> for the <code>TraceAnnotation</code> type
|
|
23
|
+
</li>
|
|
15
24
|
</ul>
|
|
16
25
|
</section>
|
|
17
26
|
|
|
18
|
-
##
|
|
27
|
+
## Retrieve Traces
|
|
28
|
+
|
|
29
|
+
Use `getTraces` when you want trace-centric pagination by project, optional inline spans, or filtering by session.
|
|
19
30
|
|
|
20
31
|
```ts
|
|
21
32
|
import { getTraces } from "@arizeai/phoenix-client/traces";
|
|
@@ -35,7 +46,7 @@ for (const trace of result.traces) {
|
|
|
35
46
|
console.log(result.nextCursor);
|
|
36
47
|
```
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
### Supported Filters
|
|
39
50
|
|
|
40
51
|
- `project`
|
|
41
52
|
- `startTime`
|
|
@@ -47,17 +58,77 @@ console.log(result.nextCursor);
|
|
|
47
58
|
- `includeSpans`
|
|
48
59
|
- `sessionId`
|
|
49
60
|
|
|
50
|
-
|
|
61
|
+
### Notes
|
|
51
62
|
|
|
52
63
|
- `getTraces` requires a Phoenix server that supports project trace listing
|
|
53
64
|
- Use the returned `nextCursor` to continue pagination
|
|
54
65
|
- Set `includeSpans` when you need a trace-centric fetch that also contains span details
|
|
55
66
|
- `project` accepts `{ project }`, `{ projectId }`, or `{ projectName }`
|
|
56
67
|
|
|
68
|
+
## Annotate a Single Trace
|
|
69
|
+
|
|
70
|
+
Use `addTraceAnnotation` to attach a label, score, or explanation to one trace. If you supply an `identifier`, Phoenix upserts the annotation when an annotation with that identifier already exists.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { addTraceAnnotation } from "@arizeai/phoenix-client/traces";
|
|
74
|
+
|
|
75
|
+
const result = await addTraceAnnotation({
|
|
76
|
+
traceAnnotation: {
|
|
77
|
+
traceId: "abc123",
|
|
78
|
+
name: "correctness",
|
|
79
|
+
label: "correct",
|
|
80
|
+
score: 1.0,
|
|
81
|
+
annotatorKind: "HUMAN",
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// result is { id: string } when sync: true, or null when sync: false (default)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Set `sync: true` to receive the annotation ID immediately; omit it (or pass `false`) for higher-throughput async writes.
|
|
89
|
+
|
|
90
|
+
### TraceAnnotation Fields
|
|
91
|
+
|
|
92
|
+
| Field | Type | Required | Description |
|
|
93
|
+
|-------|------|----------|-------------|
|
|
94
|
+
| `traceId` | `string` | Yes | OpenTelemetry Trace ID (hex, no `0x` prefix) |
|
|
95
|
+
| `name` | `string` | Yes | What is being measured (e.g. `"groundedness"`). The name `"note"` is reserved — use `addTraceNote` instead. |
|
|
96
|
+
| `annotatorKind` | `"HUMAN" \| "LLM" \| "CODE"` | No | Defaults to `"HUMAN"` |
|
|
97
|
+
| `label` | `string` | At least one of label/score/explanation | Categorical result (e.g. `"correct"`) |
|
|
98
|
+
| `score` | `number` | At least one of label/score/explanation | Numeric result (e.g. `0.95`) |
|
|
99
|
+
| `explanation` | `string` | At least one of label/score/explanation | Free-text justification |
|
|
100
|
+
| `identifier` | `string` | No | Stable ID for idempotent upserts |
|
|
101
|
+
| `metadata` | `Record<string, unknown>` | No | Arbitrary context |
|
|
102
|
+
|
|
103
|
+
## Annotate Multiple Traces
|
|
104
|
+
|
|
105
|
+
Use `logTraceAnnotations` to batch-write annotations across many traces in a single request.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { logTraceAnnotations } from "@arizeai/phoenix-client/traces";
|
|
109
|
+
|
|
110
|
+
const results = await logTraceAnnotations({
|
|
111
|
+
traceAnnotations: [
|
|
112
|
+
{ traceId: "abc123", name: "faithfulness", score: 0.9, annotatorKind: "LLM" },
|
|
113
|
+
{ traceId: "def456", name: "faithfulness", score: 0.7, annotatorKind: "LLM" },
|
|
114
|
+
],
|
|
115
|
+
sync: true,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
for (const r of results) {
|
|
119
|
+
console.log(r.id);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`logTraceAnnotations` sends all annotations in a single POST and returns an array of `{ id: string }` objects (or an empty array when `sync: false`).
|
|
124
|
+
|
|
57
125
|
<section className="hidden" data-agent-context="source-map" aria-label="Source map">
|
|
58
126
|
<h2>Source Map</h2>
|
|
59
127
|
<ul>
|
|
60
128
|
<li><code>src/traces/getTraces.ts</code></li>
|
|
129
|
+
<li><code>src/traces/addTraceAnnotation.ts</code></li>
|
|
130
|
+
<li><code>src/traces/logTraceAnnotations.ts</code></li>
|
|
131
|
+
<li><code>src/traces/types.ts</code></li>
|
|
61
132
|
<li><code>src/types/projects.ts</code></li>
|
|
62
133
|
</ul>
|
|
63
134
|
</section>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-client",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.3",
|
|
4
4
|
"description": "A client for the Phoenix API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"@arizeai/openinference-semantic-conventions": "^2.1.7",
|
|
77
77
|
"@arizeai/openinference-vercel": "^2.7.0",
|
|
78
78
|
"async": "^3.2.6",
|
|
79
|
-
"openapi-fetch": "^0.
|
|
79
|
+
"openapi-fetch": "^0.17.0",
|
|
80
80
|
"tiny-invariant": "^1.3.3",
|
|
81
81
|
"zod": "^4.0.14",
|
|
82
82
|
"@arizeai/phoenix-config": "0.1.4",
|
|
83
|
-
"@arizeai/phoenix-otel": "1.0.
|
|
83
|
+
"@arizeai/phoenix-otel": "1.0.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@ai-sdk/openai": "^3.0.29",
|