@arizeai/phoenix-client 6.14.2 → 7.0.0
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/prompts/sdks/toAI.d.ts +2 -1
- package/dist/esm/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toAI.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/src/prompts/sdks/toAI.d.ts +2 -1
- package/dist/src/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toAI.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/experiments.mdx +18 -19
- package/package.json +10 -10
- package/src/prompts/sdks/toAI.ts +3 -1
package/docs/experiments.mdx
CHANGED
|
@@ -111,11 +111,18 @@ This pattern is useful when:
|
|
|
111
111
|
|
|
112
112
|
## Model-Backed Example
|
|
113
113
|
|
|
114
|
-
If you want a model-backed experiment with automatic tracing and an LLM-as-a-judge evaluator, this is the core pattern
|
|
114
|
+
If you want a model-backed experiment with automatic tracing and an LLM-as-a-judge evaluator, this is the core pattern.
|
|
115
|
+
|
|
116
|
+
Install the AI SDK packages alongside the Phoenix packages — `@ai-sdk/otel` provides the telemetry integration that sends AI SDK traces to Phoenix:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install @arizeai/phoenix-client @arizeai/phoenix-evals ai @ai-sdk/openai @ai-sdk/otel
|
|
120
|
+
```
|
|
115
121
|
|
|
116
122
|
```ts
|
|
117
123
|
import { openai } from "@ai-sdk/openai";
|
|
118
|
-
import {
|
|
124
|
+
import { OpenTelemetry } from "@ai-sdk/otel";
|
|
125
|
+
import { createDataset } from "@arizeai/phoenix-client/datasets";
|
|
119
126
|
import { runExperiment } from "@arizeai/phoenix-client/experiments";
|
|
120
127
|
import type { ExperimentTask } from "@arizeai/phoenix-client/types/experiments";
|
|
121
128
|
import { createClassificationEvaluator } from "@arizeai/phoenix-evals";
|
|
@@ -135,7 +142,7 @@ const main = async () => {
|
|
|
135
142
|
},
|
|
136
143
|
});
|
|
137
144
|
|
|
138
|
-
const dataset = await
|
|
145
|
+
const dataset = await createDataset({
|
|
139
146
|
name: "correctness-eval",
|
|
140
147
|
description: "Evaluate the correctness of the model",
|
|
141
148
|
examples: [
|
|
@@ -157,23 +164,15 @@ const main = async () => {
|
|
|
157
164
|
throw new Error("Invalid input: context must be a string");
|
|
158
165
|
}
|
|
159
166
|
|
|
167
|
+
// The per-call `@ai-sdk/otel` integration traces this call through the
|
|
168
|
+
// experiment's tracer provider that runExperiment mounts while tasks run.
|
|
160
169
|
return generateText({
|
|
161
170
|
model,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
prompt: [
|
|
166
|
-
{
|
|
167
|
-
role: "system",
|
|
168
|
-
content: `You answer questions based on this context: ${example.input.context}`,
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
role: "user",
|
|
172
|
-
content: example.input.question,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
171
|
+
instructions: `You answer questions based on this context: ${example.input.context}`,
|
|
172
|
+
prompt: example.input.question,
|
|
173
|
+
telemetry: { integrations: [new OpenTelemetry()] },
|
|
175
174
|
}).then((response) => {
|
|
176
|
-
if (response.text) {
|
|
175
|
+
if (typeof response.text === "string") {
|
|
177
176
|
return response.text;
|
|
178
177
|
}
|
|
179
178
|
throw new Error("Invalid response: text is required");
|
|
@@ -200,9 +199,9 @@ main().catch(console.error);
|
|
|
200
199
|
|
|
201
200
|
## What This Example Shows
|
|
202
201
|
|
|
203
|
-
- `
|
|
202
|
+
- `createDataset()` creates or reuses the dataset the experiment will run against (it upserts by name)
|
|
204
203
|
- `task` receives the full dataset example object
|
|
205
|
-
- `generateText()` emits traces that Phoenix
|
|
204
|
+
- `generateText()` emits traces that Phoenix attaches to the experiment because the call passes the `@ai-sdk/otel` integration via `telemetry.integrations` — without it, no AI SDK spans reach Phoenix
|
|
206
205
|
- `createClassificationEvaluator()` from `@arizeai/phoenix-evals` can be passed directly to `runExperiment()`
|
|
207
206
|
- `runExperiment()` records both task runs and evaluation runs in Phoenix
|
|
208
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A client for the Phoenix API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -96,34 +96,34 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@arizeai/openinference-semantic-conventions": "^2.5.0",
|
|
99
|
-
"@arizeai/openinference-vercel": "^2.8.1",
|
|
100
99
|
"async": "^3.2.6",
|
|
101
100
|
"openapi-fetch": "^0.17.0",
|
|
102
101
|
"tiny-invariant": "^1.3.3",
|
|
103
102
|
"zod": "^4.4.3",
|
|
104
|
-
"@arizeai/phoenix-
|
|
105
|
-
"@arizeai/phoenix-
|
|
103
|
+
"@arizeai/phoenix-config": "0.4.0",
|
|
104
|
+
"@arizeai/phoenix-otel": "2.1.0"
|
|
106
105
|
},
|
|
107
106
|
"devDependencies": {
|
|
108
|
-
"@ai-sdk/openai": "^
|
|
107
|
+
"@ai-sdk/openai": "^4.0.0",
|
|
108
|
+
"@ai-sdk/otel": "^1.0.0",
|
|
109
109
|
"@anthropic-ai/sdk": "^0.111.0",
|
|
110
110
|
"@opentelemetry/api": "^1.9.1",
|
|
111
111
|
"@opentelemetry/sdk-trace-node": "^2.9.0",
|
|
112
112
|
"@types/async": "^3.2.25",
|
|
113
113
|
"@types/node": "^26.1.1",
|
|
114
|
-
"ai": "^
|
|
114
|
+
"ai": "^7.0.0",
|
|
115
115
|
"dotenv": "^17.4.2",
|
|
116
116
|
"jest": "^30.4.2",
|
|
117
117
|
"openai": "^6.48.0",
|
|
118
118
|
"openapi-typescript": "^7.13.0",
|
|
119
119
|
"tsx": "^4.23.1",
|
|
120
120
|
"vitest": "^4.1.10",
|
|
121
|
-
"@arizeai/phoenix-
|
|
122
|
-
"@arizeai/phoenix-
|
|
121
|
+
"@arizeai/phoenix-evals": "2.0.0",
|
|
122
|
+
"@arizeai/phoenix-testing": "0.0.0"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"@anthropic-ai/sdk": "^0.35.0",
|
|
126
|
-
"ai": "^
|
|
126
|
+
"ai": "^7.0.0",
|
|
127
127
|
"jest": ">=27",
|
|
128
128
|
"openai": "^6.10.0",
|
|
129
129
|
"vitest": ">=1"
|
|
@@ -156,6 +156,6 @@
|
|
|
156
156
|
"prebuild": "pnpm run clean && pnpm run generate",
|
|
157
157
|
"test": "vitest run",
|
|
158
158
|
"test:watch": "vitest watch",
|
|
159
|
-
"typecheck": "tsc --noEmit"
|
|
159
|
+
"typecheck": "tsc --noEmit && tsc -p examples/tsconfig.examples.json"
|
|
160
160
|
}
|
|
161
161
|
}
|