@arizeai/phoenix-client 7.11.0 → 7.13.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/CHANGELOG.md +12 -0
- package/README.md +40 -5
- package/dist/esm/__generated__/api/v1.d.ts +98 -4
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +2 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +16 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/secrets/index.d.ts +2 -0
- package/dist/esm/secrets/index.d.ts.map +1 -0
- package/dist/esm/secrets/index.js +2 -0
- package/dist/esm/secrets/index.js.map +1 -0
- package/dist/esm/secrets/upsertOrDeleteSecrets.d.ts +60 -0
- package/dist/esm/secrets/upsertOrDeleteSecrets.d.ts.map +1 -0
- package/dist/esm/secrets/upsertOrDeleteSecrets.js +47 -0
- package/dist/esm/secrets/upsertOrDeleteSecrets.js.map +1 -0
- package/dist/esm/sessions/listSessions.d.ts +10 -1
- package/dist/esm/sessions/listSessions.d.ts.map +1 -1
- package/dist/esm/sessions/listSessions.js +10 -1
- package/dist/esm/sessions/listSessions.js.map +1 -1
- package/dist/esm/traces/getTraces.d.ts +10 -2
- package/dist/esm/traces/getTraces.d.ts.map +1 -1
- package/dist/esm/traces/getTraces.js +12 -4
- package/dist/esm/traces/getTraces.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/src/__generated__/api/v1.d.ts +98 -4
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +2 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +17 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/secrets/index.d.ts +2 -0
- package/dist/src/secrets/index.d.ts.map +1 -0
- package/dist/src/secrets/index.js +18 -0
- package/dist/src/secrets/index.js.map +1 -0
- package/dist/src/secrets/upsertOrDeleteSecrets.d.ts +60 -0
- package/dist/src/secrets/upsertOrDeleteSecrets.d.ts.map +1 -0
- package/dist/src/secrets/upsertOrDeleteSecrets.js +50 -0
- package/dist/src/secrets/upsertOrDeleteSecrets.js.map +1 -0
- package/dist/src/sessions/listSessions.d.ts +10 -1
- package/dist/src/sessions/listSessions.d.ts.map +1 -1
- package/dist/src/sessions/listSessions.js +9 -0
- package/dist/src/sessions/listSessions.js.map +1 -1
- package/dist/src/traces/getTraces.d.ts +10 -2
- package/dist/src/traces/getTraces.d.ts.map +1 -1
- package/dist/src/traces/getTraces.js +11 -3
- package/dist/src/traces/getTraces.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/overview.mdx +4 -1
- package/docs/secrets.mdx +68 -0
- package/docs/sessions.mdx +13 -0
- package/docs/traces.mdx +7 -6
- package/package.json +15 -11
- package/src/__generated__/api/v1.ts +98 -4
- package/src/constants/serverRequirements.ts +18 -0
- package/src/secrets/index.ts +1 -0
- package/src/secrets/upsertOrDeleteSecrets.ts +87 -0
- package/src/sessions/listSessions.ts +22 -2
- package/src/traces/getTraces.ts +21 -2
package/docs/overview.mdx
CHANGED
|
@@ -3,7 +3,7 @@ title: "Overview"
|
|
|
3
3
|
description: "Typed TypeScript client for Phoenix platform APIs"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`@arizeai/phoenix-client` is the typed TypeScript client for Phoenix platform APIs. It ships a small root REST client plus focused module entrypoints for projects, prompts, datasets, experiments, spans, sessions, traces, users, and CI-friendly dataset-backed eval tests.
|
|
6
|
+
`@arizeai/phoenix-client` is the typed TypeScript client for Phoenix platform APIs. It ships a small root REST client plus focused module entrypoints for projects, prompts, datasets, experiments, spans, sessions, traces, secrets, users, and CI-friendly dataset-backed eval tests.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -44,6 +44,7 @@ That gives the agent version-matched docs plus the exact implementation and gene
|
|
|
44
44
|
| `@arizeai/phoenix-client/spans` | Span search, notes, and span/document annotations |
|
|
45
45
|
| `@arizeai/phoenix-client/sessions` | Session listing, retrieval, and session annotations |
|
|
46
46
|
| `@arizeai/phoenix-client/traces` | Project trace retrieval, transfers, and trace annotations |
|
|
47
|
+
| `@arizeai/phoenix-client/secrets` | Atomic secret creation, rotation, and deletion |
|
|
47
48
|
| `@arizeai/phoenix-client/users` | Current authenticated user retrieval |
|
|
48
49
|
| `@arizeai/phoenix-client/vitest` | Vitest entrypoint for dataset-backed eval tests |
|
|
49
50
|
| `@arizeai/phoenix-client/vitest/reporter` | Vitest reporter for Phoenix eval summaries |
|
|
@@ -164,6 +165,7 @@ Prefer this layer when:
|
|
|
164
165
|
- [Annotations](./annotations) — annotation concepts, then [Span](./span-annotations), [Document](./document-annotations), and [Session](./session-annotations) annotations for detailed usage
|
|
165
166
|
- [CI Eval Tests](./ci-evals) — Vitest/Jest eval suites backed by Phoenix datasets and experiments
|
|
166
167
|
- [Spans](./spans), [Sessions](./sessions), [Traces](./traces), [Users](./users) — retrieval and maintenance
|
|
168
|
+
- [Secrets](./secrets) — encrypted provider credential management
|
|
167
169
|
|
|
168
170
|
<section className="hidden" data-agent-context="source-map" aria-label="Source map">
|
|
169
171
|
<h2>Source Map</h2>
|
|
@@ -180,6 +182,7 @@ Prefer this layer when:
|
|
|
180
182
|
<li><code>src/spans/</code></li>
|
|
181
183
|
<li><code>src/sessions/</code></li>
|
|
182
184
|
<li><code>src/traces/</code></li>
|
|
185
|
+
<li><code>src/secrets/</code></li>
|
|
183
186
|
<li><code>src/users/</code></li>
|
|
184
187
|
<li><code>src/vitest/</code></li>
|
|
185
188
|
<li><code>src/jest/</code></li>
|
package/docs/secrets.mdx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Secrets"
|
|
3
|
+
description: "Atomically manage encrypted provider credentials with the Phoenix TypeScript client"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Use `upsertOrDeleteSecrets` from the `@arizeai/phoenix-client/secrets` entrypoint to create, rotate, or delete encrypted provider credentials in one atomic request.
|
|
7
|
+
|
|
8
|
+
<Warning>
|
|
9
|
+
Managing secrets requires an administrator when Phoenix authentication is enabled. Do not log the request batch or retain its values outside your credential store.
|
|
10
|
+
</Warning>
|
|
11
|
+
|
|
12
|
+
## Create, Update, And Delete Secrets
|
|
13
|
+
|
|
14
|
+
Each batch entry has a `key` and a required `value`:
|
|
15
|
+
|
|
16
|
+
- A string value creates or updates the secret.
|
|
17
|
+
- `null` deletes the secret.
|
|
18
|
+
- When a key occurs more than once, its last occurrence wins.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
|
|
22
|
+
|
|
23
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
|
24
|
+
if (!apiKey) throw new Error("OPENAI_API_KEY is required");
|
|
25
|
+
|
|
26
|
+
const result = await upsertOrDeleteSecrets({
|
|
27
|
+
secrets: [
|
|
28
|
+
{ key: "OPENAI_API_KEY", value: apiKey },
|
|
29
|
+
{ key: "OLD_PROVIDER_API_KEY", value: null },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(result.upsertedKeys);
|
|
34
|
+
console.log(result.deletedKeys);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The operation returns only `upsertedKeys` and `deletedKeys`. Submitted secret values are never returned or added to helper error messages.
|
|
38
|
+
|
|
39
|
+
## Use An Explicit Client
|
|
40
|
+
|
|
41
|
+
Pass `client` when you need to target a particular Phoenix instance. Otherwise, the helper creates a client from the standard Phoenix environment configuration.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createClient } from "@arizeai/phoenix-client";
|
|
45
|
+
import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
|
|
46
|
+
|
|
47
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
|
48
|
+
if (!apiKey) throw new Error("OPENAI_API_KEY is required");
|
|
49
|
+
|
|
50
|
+
const client = createClient({
|
|
51
|
+
options: { baseUrl: "https://phoenix.example.com" },
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await upsertOrDeleteSecrets({
|
|
55
|
+
client,
|
|
56
|
+
secrets: [{ key: "OPENAI_API_KEY", value: apiKey }],
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
<section className="hidden" data-agent-context="source-map" aria-label="Source map">
|
|
61
|
+
<h2>Source Map</h2>
|
|
62
|
+
<ul>
|
|
63
|
+
<li><code>src/secrets/index.ts</code></li>
|
|
64
|
+
<li><code>src/secrets/upsertOrDeleteSecrets.ts</code></li>
|
|
65
|
+
<li><code>src/client.ts</code></li>
|
|
66
|
+
<li><code>src/__generated__/api/v1.ts</code></li>
|
|
67
|
+
</ul>
|
|
68
|
+
</section>
|
package/docs/sessions.mdx
CHANGED
|
@@ -42,6 +42,19 @@ Each session includes cumulative prompt, completion, and total token counts acro
|
|
|
42
42
|
all of its spans. The fields may be `undefined` when using a Phoenix server that
|
|
43
43
|
does not return session token usage.
|
|
44
44
|
|
|
45
|
+
Pass a `filter` expression to narrow the results. The language is documented on the
|
|
46
|
+
[Filter Expressions](/docs/phoenix/tracing/how-to-tracing/filter-expressions) page.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
const failedSessions = await listSessions({
|
|
50
|
+
project: "support-bot",
|
|
51
|
+
filter: "num_traces_with_error > 0 and duration_ms >= 60000",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Empty expressions do not filter. Invalid expressions return HTTP 400; older
|
|
56
|
+
servers are rejected before sending an expression.
|
|
57
|
+
|
|
45
58
|
## Retrieve A Session And Its Turns
|
|
46
59
|
|
|
47
60
|
```ts
|
package/docs/traces.mdx
CHANGED
|
@@ -60,16 +60,16 @@ console.log(result.nextCursor);
|
|
|
60
60
|
- `cursor`
|
|
61
61
|
- `includeSpans`
|
|
62
62
|
- `sessionId`
|
|
63
|
-
- `
|
|
64
|
-
- `
|
|
65
|
-
- `
|
|
63
|
+
- `filter` — a trace DSL expression, combined with other filters using AND
|
|
64
|
+
- `error` (deprecated; use `filter`)
|
|
65
|
+
- `minLatencyMs` (deprecated; use `filter`)
|
|
66
|
+
- `maxLatencyMs` (deprecated; use `filter`)
|
|
66
67
|
|
|
67
68
|
```ts
|
|
68
69
|
// Slow traces that contain at least one errored span
|
|
69
70
|
const slowFailures = await getTraces({
|
|
70
71
|
project: { projectName: "support-bot" },
|
|
71
|
-
|
|
72
|
-
minLatencyMs: 1000,
|
|
72
|
+
filter: "error_count > 0 and latency_ms >= 1000",
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -79,7 +79,8 @@ const slowFailures = await getTraces({
|
|
|
79
79
|
- Use the returned `nextCursor` to continue pagination
|
|
80
80
|
- Set `includeSpans` when you need a trace-centric fetch that also contains span details
|
|
81
81
|
- `project` accepts `{ project }`, `{ projectId }`, or `{ projectName }`
|
|
82
|
-
- `
|
|
82
|
+
- `filter` takes a trace filter expression; the language is documented on the [Filter Expressions](/docs/phoenix/tracing/how-to-tracing/filter-expressions) page, and its [Finding field names](/docs/phoenix/tracing/how-to-tracing/filter-expressions#finding-field-names) section covers discovering valid names for your project.
|
|
83
|
+
- `error`, `minLatencyMs`, and `maxLatencyMs` remain supported on Phoenix server >= 20.8.0. Replace them with `error_count > 0` / `error_count == 0`, `latency_ms >= N`, and `latency_ms <= N` respectively. Latency bounds are inclusive and errors include child spans.
|
|
83
84
|
|
|
84
85
|
## Move Traces To Another Project
|
|
85
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.13.0",
|
|
4
4
|
"description": "A client for the Phoenix API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"import": "./dist/esm/sessions/index.js",
|
|
54
54
|
"require": "./dist/src/sessions/index.js"
|
|
55
55
|
},
|
|
56
|
+
"./secrets": {
|
|
57
|
+
"import": "./dist/esm/secrets/index.js",
|
|
58
|
+
"require": "./dist/src/secrets/index.js"
|
|
59
|
+
},
|
|
56
60
|
"./projects": {
|
|
57
61
|
"import": "./dist/esm/projects/index.js",
|
|
58
62
|
"require": "./dist/src/projects/index.js"
|
|
@@ -103,31 +107,31 @@
|
|
|
103
107
|
}
|
|
104
108
|
},
|
|
105
109
|
"dependencies": {
|
|
106
|
-
"@arizeai/openinference-semantic-conventions": "^2.
|
|
110
|
+
"@arizeai/openinference-semantic-conventions": "^2.12.0",
|
|
107
111
|
"@arizeai/phoenix-config": "0.5.0",
|
|
108
112
|
"@arizeai/phoenix-otel": "2.2.0",
|
|
109
113
|
"async": "^3.2.6",
|
|
110
114
|
"openapi-fetch": "^0.17.0",
|
|
111
115
|
"tiny-invariant": "^1.3.3",
|
|
112
|
-
"zod": "^4.5
|
|
116
|
+
"zod": "^4.6.5"
|
|
113
117
|
},
|
|
114
118
|
"devDependencies": {
|
|
115
|
-
"@ai-sdk/openai": "^4.0.
|
|
116
|
-
"@ai-sdk/otel": "^1.0.
|
|
119
|
+
"@ai-sdk/openai": "^4.0.71",
|
|
120
|
+
"@ai-sdk/otel": "^1.0.107",
|
|
117
121
|
"@anthropic-ai/sdk": "^0.111.0",
|
|
118
|
-
"@arizeai/phoenix-evals": "2.
|
|
122
|
+
"@arizeai/phoenix-evals": "2.6.0",
|
|
119
123
|
"@arizeai/phoenix-testing": "0.0.0",
|
|
120
124
|
"@opentelemetry/api": "^1.9.1",
|
|
121
125
|
"@opentelemetry/sdk-trace-node": "^2.11.0",
|
|
122
|
-
"@types/async": "^3.2.
|
|
123
|
-
"@types/node": "^26.
|
|
124
|
-
"ai": "^7.0.
|
|
126
|
+
"@types/async": "^3.2.26",
|
|
127
|
+
"@types/node": "^26.6.2",
|
|
128
|
+
"ai": "^7.0.107",
|
|
125
129
|
"dotenv": "^17.4.2",
|
|
126
|
-
"jest": "^30.5.
|
|
130
|
+
"jest": "^30.5.2",
|
|
127
131
|
"openai": "^6.49.0",
|
|
128
132
|
"openapi-typescript": "^7.13.0",
|
|
129
133
|
"tsx": "^4.23.13",
|
|
130
|
-
"vitest": "^5.0.
|
|
134
|
+
"vitest": "^5.0.1"
|
|
131
135
|
},
|
|
132
136
|
"peerDependencies": {
|
|
133
137
|
"@anthropic-ai/sdk": "^0.35.0",
|
|
@@ -430,7 +430,8 @@ export interface paths {
|
|
|
430
430
|
path?: never;
|
|
431
431
|
cookie?: never;
|
|
432
432
|
};
|
|
433
|
-
|
|
433
|
+
/** List dataset splits */
|
|
434
|
+
get: operations["listDatasetSplits"];
|
|
434
435
|
put?: never;
|
|
435
436
|
/** Create a dataset split */
|
|
436
437
|
post: operations["createDatasetSplit"];
|
|
@@ -3980,6 +3981,13 @@ export interface components {
|
|
|
3980
3981
|
/** Data */
|
|
3981
3982
|
data: components["schemas"]["DatasetLabel"][];
|
|
3982
3983
|
};
|
|
3984
|
+
/** ListDatasetSplitsResponseBody */
|
|
3985
|
+
ListDatasetSplitsResponseBody: {
|
|
3986
|
+
/** Data */
|
|
3987
|
+
data: components["schemas"]["DatasetSplit"][];
|
|
3988
|
+
/** Next Cursor */
|
|
3989
|
+
next_cursor: string | null;
|
|
3990
|
+
};
|
|
3983
3991
|
/** ListDatasetVersionsResponseBody */
|
|
3984
3992
|
ListDatasetVersionsResponseBody: {
|
|
3985
3993
|
/** Data */
|
|
@@ -8959,6 +8967,61 @@ export interface operations {
|
|
|
8959
8967
|
};
|
|
8960
8968
|
};
|
|
8961
8969
|
};
|
|
8970
|
+
listDatasetSplits: {
|
|
8971
|
+
parameters: {
|
|
8972
|
+
query?: {
|
|
8973
|
+
/** @description Cursor for pagination */
|
|
8974
|
+
cursor?: string | null;
|
|
8975
|
+
/** @description The max number of dataset splits to return at a time. */
|
|
8976
|
+
limit?: number;
|
|
8977
|
+
};
|
|
8978
|
+
header?: never;
|
|
8979
|
+
path: {
|
|
8980
|
+
/** @description The dataset identifier: either dataset ID or dataset name. */
|
|
8981
|
+
dataset_identifier: string;
|
|
8982
|
+
};
|
|
8983
|
+
cookie?: never;
|
|
8984
|
+
};
|
|
8985
|
+
requestBody?: never;
|
|
8986
|
+
responses: {
|
|
8987
|
+
/** @description Successful Response */
|
|
8988
|
+
200: {
|
|
8989
|
+
headers: {
|
|
8990
|
+
[name: string]: unknown;
|
|
8991
|
+
};
|
|
8992
|
+
content: {
|
|
8993
|
+
"application/json": components["schemas"]["ListDatasetSplitsResponseBody"];
|
|
8994
|
+
};
|
|
8995
|
+
};
|
|
8996
|
+
/** @description Forbidden */
|
|
8997
|
+
403: {
|
|
8998
|
+
headers: {
|
|
8999
|
+
[name: string]: unknown;
|
|
9000
|
+
};
|
|
9001
|
+
content: {
|
|
9002
|
+
"text/plain": string;
|
|
9003
|
+
};
|
|
9004
|
+
};
|
|
9005
|
+
/** @description Dataset not found */
|
|
9006
|
+
404: {
|
|
9007
|
+
headers: {
|
|
9008
|
+
[name: string]: unknown;
|
|
9009
|
+
};
|
|
9010
|
+
content: {
|
|
9011
|
+
"text/plain": string;
|
|
9012
|
+
};
|
|
9013
|
+
};
|
|
9014
|
+
/** @description Invalid request */
|
|
9015
|
+
422: {
|
|
9016
|
+
headers: {
|
|
9017
|
+
[name: string]: unknown;
|
|
9018
|
+
};
|
|
9019
|
+
content: {
|
|
9020
|
+
"text/plain": string;
|
|
9021
|
+
};
|
|
9022
|
+
};
|
|
9023
|
+
};
|
|
9024
|
+
};
|
|
8962
9025
|
createDatasetSplit: {
|
|
8963
9026
|
parameters: {
|
|
8964
9027
|
query?: never;
|
|
@@ -10112,12 +10175,23 @@ export interface operations {
|
|
|
10112
10175
|
include_spans?: boolean;
|
|
10113
10176
|
/** @description List of session identifiers to filter traces by. Each value can be either a session_id string or a session GlobalID. Only traces belonging to the specified sessions will be returned. */
|
|
10114
10177
|
session_identifier?: string[] | null;
|
|
10115
|
-
/**
|
|
10178
|
+
/**
|
|
10179
|
+
* @deprecated
|
|
10180
|
+
* @description Deprecated: use `filter=error_count > 0` or `filter=error_count == 0`. Filter by trace error status. If true, only return traces that contain at least one span with `status_code == ERROR`. If false, only return traces with no errored spans. If omitted, traces are not filtered by error status.
|
|
10181
|
+
*/
|
|
10116
10182
|
error?: boolean | null;
|
|
10117
|
-
/**
|
|
10183
|
+
/**
|
|
10184
|
+
* @deprecated
|
|
10185
|
+
* @description Inclusive lower bound on trace latency in milliseconds. Deprecated: use `filter=latency_ms >= N`.
|
|
10186
|
+
*/
|
|
10118
10187
|
min_latency_ms?: number | null;
|
|
10119
|
-
/**
|
|
10188
|
+
/**
|
|
10189
|
+
* @deprecated
|
|
10190
|
+
* @description Inclusive upper bound on trace latency in milliseconds. Deprecated: use `filter=latency_ms <= N`.
|
|
10191
|
+
*/
|
|
10120
10192
|
max_latency_ms?: number | null;
|
|
10193
|
+
/** @description Trace filter expression, as documented at https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions. Combined with other filters using AND. Empty expressions do not filter. Invalid expressions return 400. */
|
|
10194
|
+
filter?: string | null;
|
|
10121
10195
|
};
|
|
10122
10196
|
header?: never;
|
|
10123
10197
|
path: {
|
|
@@ -10137,6 +10211,15 @@ export interface operations {
|
|
|
10137
10211
|
"application/json": components["schemas"]["GetTracesResponseBody"];
|
|
10138
10212
|
};
|
|
10139
10213
|
};
|
|
10214
|
+
/** @description Bad Request */
|
|
10215
|
+
400: {
|
|
10216
|
+
headers: {
|
|
10217
|
+
[name: string]: unknown;
|
|
10218
|
+
};
|
|
10219
|
+
content: {
|
|
10220
|
+
"text/plain": string;
|
|
10221
|
+
};
|
|
10222
|
+
};
|
|
10140
10223
|
/** @description Forbidden */
|
|
10141
10224
|
403: {
|
|
10142
10225
|
headers: {
|
|
@@ -11904,6 +11987,8 @@ export interface operations {
|
|
|
11904
11987
|
limit?: number;
|
|
11905
11988
|
/** @description Sort order by ID: 'asc' (ascending) or 'desc' (descending). */
|
|
11906
11989
|
order?: "asc" | "desc";
|
|
11990
|
+
/** @description Session filter expression, as documented at https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions. Empty expressions do not filter. Invalid expressions return 400. */
|
|
11991
|
+
filter?: string | null;
|
|
11907
11992
|
};
|
|
11908
11993
|
header?: never;
|
|
11909
11994
|
path: {
|
|
@@ -11923,6 +12008,15 @@ export interface operations {
|
|
|
11923
12008
|
"application/json": components["schemas"]["GetSessionsResponseBody"];
|
|
11924
12009
|
};
|
|
11925
12010
|
};
|
|
12011
|
+
/** @description Bad Request */
|
|
12012
|
+
400: {
|
|
12013
|
+
headers: {
|
|
12014
|
+
[name: string]: unknown;
|
|
12015
|
+
};
|
|
12016
|
+
content: {
|
|
12017
|
+
"text/plain": string;
|
|
12018
|
+
};
|
|
12019
|
+
};
|
|
11926
12020
|
/** @description Forbidden */
|
|
11927
12021
|
403: {
|
|
11928
12022
|
headers: {
|
|
@@ -108,6 +108,22 @@ export const GET_TRACES_FILTERS: ParameterRequirement = {
|
|
|
108
108
|
"The 'error', 'min_latency_ms', and 'max_latency_ms' query parameters on GET /v1/projects/{id}/traces",
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
export const GET_TRACES_FILTER_EXPRESSION: ParameterRequirement = {
|
|
112
|
+
kind: "parameter",
|
|
113
|
+
parameterName: "filter",
|
|
114
|
+
parameterLocation: "query",
|
|
115
|
+
route: "GET /v1/projects/{id}/traces",
|
|
116
|
+
minServerVersion: [20, 12, 0],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const LIST_SESSIONS_FILTER_EXPRESSION: ParameterRequirement = {
|
|
120
|
+
kind: "parameter",
|
|
121
|
+
parameterName: "filter",
|
|
122
|
+
parameterLocation: "query",
|
|
123
|
+
route: "GET /v1/projects/{id}/sessions",
|
|
124
|
+
minServerVersion: [20, 12, 0],
|
|
125
|
+
};
|
|
126
|
+
|
|
111
127
|
export const TRANSFER_TRACES: RouteRequirement = {
|
|
112
128
|
kind: "route",
|
|
113
129
|
method: "POST",
|
|
@@ -245,6 +261,8 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
|
|
|
245
261
|
GET_SPANS_BY_ATTRIBUTE,
|
|
246
262
|
LIST_PROJECT_TRACES,
|
|
247
263
|
GET_TRACES_FILTERS,
|
|
264
|
+
GET_TRACES_FILTER_EXPRESSION,
|
|
265
|
+
LIST_SESSIONS_FILTER_EXPRESSION,
|
|
248
266
|
TRANSFER_TRACES,
|
|
249
267
|
DATASET_UPLOAD_EXAMPLE_IDS,
|
|
250
268
|
ADD_TRACE_NOTE_IDENTIFIER,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./upsertOrDeleteSecrets";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createClient } from "../client";
|
|
2
|
+
import type { ClientFn } from "../types/core";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A secret to create, update, or delete.
|
|
6
|
+
*/
|
|
7
|
+
export interface SecretInput {
|
|
8
|
+
/** The environment-style key used to identify the secret. */
|
|
9
|
+
key: string;
|
|
10
|
+
/** A value to create or update, or `null` to delete the key. */
|
|
11
|
+
value: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parameters for atomically updating secrets.
|
|
16
|
+
*/
|
|
17
|
+
export interface UpsertOrDeleteSecretsParams extends ClientFn {
|
|
18
|
+
/**
|
|
19
|
+
* Ordered secret updates. When a key occurs more than once, the server
|
|
20
|
+
* applies only its last occurrence.
|
|
21
|
+
*/
|
|
22
|
+
secrets: SecretInput[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The names of the keys changed by a secrets update.
|
|
27
|
+
*
|
|
28
|
+
* Secret values are intentionally excluded.
|
|
29
|
+
*/
|
|
30
|
+
export interface UpsertOrDeleteSecretsResult {
|
|
31
|
+
/** Keys that were created or updated. */
|
|
32
|
+
upsertedKeys: string[];
|
|
33
|
+
/** Keys that were deleted. */
|
|
34
|
+
deletedKeys: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Atomically create, update, or delete a batch of Phoenix secrets.
|
|
39
|
+
*
|
|
40
|
+
* A non-null value creates or updates a secret, while `null` deletes it.
|
|
41
|
+
* Duplicate keys use the last occurrence in the batch. The result contains
|
|
42
|
+
* key names only; submitted values are never returned or logged.
|
|
43
|
+
*
|
|
44
|
+
* @param params - The secrets update.
|
|
45
|
+
* @param params.client - Optional Phoenix client instance.
|
|
46
|
+
* @param params.secrets - Ordered key/value-or-null updates.
|
|
47
|
+
* @returns The names of the keys that were upserted and deleted.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
|
|
52
|
+
*
|
|
53
|
+
* const apiKey = process.env.OPENAI_API_KEY;
|
|
54
|
+
* if (!apiKey) throw new Error("OPENAI_API_KEY is required");
|
|
55
|
+
*
|
|
56
|
+
* const result = await upsertOrDeleteSecrets({
|
|
57
|
+
* secrets: [
|
|
58
|
+
* { key: "OPENAI_API_KEY", value: apiKey },
|
|
59
|
+
* { key: "OLD_PROVIDER_API_KEY", value: null },
|
|
60
|
+
* ],
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export async function upsertOrDeleteSecrets({
|
|
65
|
+
client: _client,
|
|
66
|
+
secrets,
|
|
67
|
+
}: UpsertOrDeleteSecretsParams): Promise<UpsertOrDeleteSecretsResult> {
|
|
68
|
+
const client = _client ?? createClient();
|
|
69
|
+
const { data, error } = await client.PUT("/v1/secrets", {
|
|
70
|
+
body: { secrets },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Do not include the server error payload here: validation responses can be
|
|
74
|
+
// influenced by submitted data, which must never enter helper error text.
|
|
75
|
+
if (error) {
|
|
76
|
+
throw new Error("Failed to upsert or delete secrets");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!data?.data) {
|
|
80
|
+
throw new Error("Failed to upsert or delete secrets: no data returned");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
upsertedKeys: data.data.upserted_keys,
|
|
85
|
+
deletedKeys: data.data.deleted_keys,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -2,7 +2,10 @@ import invariant from "tiny-invariant";
|
|
|
2
2
|
|
|
3
3
|
import type { components } from "../__generated__/api/v1";
|
|
4
4
|
import { createClient } from "../client";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LIST_PROJECT_SESSIONS,
|
|
7
|
+
LIST_SESSIONS_FILTER_EXPRESSION,
|
|
8
|
+
} from "../constants/serverRequirements";
|
|
6
9
|
import type { ClientFn } from "../types/core";
|
|
7
10
|
import type { ProjectIdentifier } from "../types/projects";
|
|
8
11
|
import { resolveProjectIdentifier } from "../types/projects";
|
|
@@ -10,7 +13,15 @@ import type { Session } from "../types/sessions";
|
|
|
10
13
|
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
11
14
|
import { toSession } from "./sessionUtils";
|
|
12
15
|
|
|
13
|
-
export type ListSessionsParams = ClientFn &
|
|
16
|
+
export type ListSessionsParams = ClientFn &
|
|
17
|
+
ProjectIdentifier & {
|
|
18
|
+
/**
|
|
19
|
+
* Session filter expression.
|
|
20
|
+
* @see https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions
|
|
21
|
+
* @requires Phoenix server >= 20.12.0
|
|
22
|
+
*/
|
|
23
|
+
filter?: string | null;
|
|
24
|
+
};
|
|
14
25
|
|
|
15
26
|
type SessionsResponse = components["schemas"]["GetSessionsResponseBody"];
|
|
16
27
|
|
|
@@ -20,6 +31,8 @@ const DEFAULT_PAGE_SIZE = 100;
|
|
|
20
31
|
* List all sessions for a project with automatic pagination handling.
|
|
21
32
|
*
|
|
22
33
|
* @requires Phoenix server >= 13.5.0
|
|
34
|
+
* @param params - Project and filtering options.
|
|
35
|
+
* @param params.filter - Session filter expression, passed unchanged on every page.
|
|
23
36
|
*
|
|
24
37
|
* @example
|
|
25
38
|
* ```ts
|
|
@@ -39,6 +52,12 @@ export async function listSessions(
|
|
|
39
52
|
): Promise<Session[]> {
|
|
40
53
|
const client = params.client || createClient();
|
|
41
54
|
await ensureServerCapability({ client, requirement: LIST_PROJECT_SESSIONS });
|
|
55
|
+
if (params.filter) {
|
|
56
|
+
await ensureServerCapability({
|
|
57
|
+
client,
|
|
58
|
+
requirement: LIST_SESSIONS_FILTER_EXPRESSION,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
42
61
|
const projectIdentifier = resolveProjectIdentifier(params);
|
|
43
62
|
|
|
44
63
|
const sessions: Session[] = [];
|
|
@@ -54,6 +73,7 @@ export async function listSessions(
|
|
|
54
73
|
query: {
|
|
55
74
|
cursor,
|
|
56
75
|
limit: DEFAULT_PAGE_SIZE,
|
|
76
|
+
filter: params.filter || undefined,
|
|
57
77
|
},
|
|
58
78
|
},
|
|
59
79
|
});
|
package/src/traces/getTraces.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { operations } from "../__generated__/api/v1";
|
|
2
2
|
import { createClient } from "../client";
|
|
3
3
|
import {
|
|
4
|
+
GET_TRACES_FILTER_EXPRESSION,
|
|
4
5
|
GET_TRACES_FILTERS,
|
|
5
6
|
LIST_PROJECT_TRACES,
|
|
6
7
|
} from "../constants/serverRequirements";
|
|
@@ -31,22 +32,31 @@ export interface GetTracesParams extends ClientFn {
|
|
|
31
32
|
includeSpans?: boolean;
|
|
32
33
|
/** Filter traces by session identifier(s) (session_id strings or GlobalIDs) */
|
|
33
34
|
sessionId?: string | string[] | null;
|
|
35
|
+
/**
|
|
36
|
+
* Trace filter expression, combined with other filters using AND.
|
|
37
|
+
* @see https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions
|
|
38
|
+
* @requires Phoenix server >= 20.12.0
|
|
39
|
+
*/
|
|
40
|
+
filter?: string | null;
|
|
34
41
|
/**
|
|
35
42
|
* Filter by trace error status. `true` returns only traces containing at
|
|
36
43
|
* least one errored span, `false` only traces with no errored spans.
|
|
37
44
|
* Omit to leave traces unfiltered by error status.
|
|
45
|
+
* @deprecated Use `filter: "error_count > 0"` or `filter: "error_count == 0"`.
|
|
38
46
|
*
|
|
39
47
|
* @requires Phoenix server >= 20.8.0
|
|
40
48
|
*/
|
|
41
49
|
error?: boolean | null;
|
|
42
50
|
/**
|
|
43
51
|
* Inclusive lower bound on trace latency in milliseconds.
|
|
52
|
+
* @deprecated Use `filter: "latency_ms >= N"`.
|
|
44
53
|
*
|
|
45
54
|
* @requires Phoenix server >= 20.8.0
|
|
46
55
|
*/
|
|
47
56
|
minLatencyMs?: number | null;
|
|
48
57
|
/**
|
|
49
58
|
* Inclusive upper bound on trace latency in milliseconds.
|
|
59
|
+
* @deprecated Use `filter: "latency_ms <= N"`.
|
|
50
60
|
*
|
|
51
61
|
* @requires Phoenix server >= 20.8.0
|
|
52
62
|
*/
|
|
@@ -96,11 +106,15 @@ function buildQuery({
|
|
|
96
106
|
order,
|
|
97
107
|
includeSpans,
|
|
98
108
|
sessionId,
|
|
109
|
+
filter,
|
|
99
110
|
error,
|
|
100
111
|
minLatencyMs,
|
|
101
112
|
maxLatencyMs,
|
|
102
113
|
}: Omit<GetTracesParams, "client" | "project">): ListProjectTracesQuery {
|
|
103
114
|
const query: ListProjectTracesQuery = { limit };
|
|
115
|
+
if (filter) {
|
|
116
|
+
query.filter = filter;
|
|
117
|
+
}
|
|
104
118
|
if (cursor) {
|
|
105
119
|
query.cursor = cursor;
|
|
106
120
|
}
|
|
@@ -195,8 +209,7 @@ export type GetTracesResult = {
|
|
|
195
209
|
* const slowFailures = await getTraces({
|
|
196
210
|
* client,
|
|
197
211
|
* project: { projectName: "my-project" },
|
|
198
|
-
*
|
|
199
|
-
* minLatencyMs: 1000,
|
|
212
|
+
* filter: "error_count > 0 and latency_ms >= 1000",
|
|
200
213
|
* });
|
|
201
214
|
* ```
|
|
202
215
|
*/
|
|
@@ -209,6 +222,12 @@ export async function getTraces({
|
|
|
209
222
|
const client = _client ?? createClient();
|
|
210
223
|
validateLatencyBounds({ minLatencyMs, maxLatencyMs });
|
|
211
224
|
await ensureServerCapability({ client, requirement: LIST_PROJECT_TRACES });
|
|
225
|
+
if (params.filter) {
|
|
226
|
+
await ensureServerCapability({
|
|
227
|
+
client,
|
|
228
|
+
requirement: GET_TRACES_FILTER_EXPRESSION,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
212
231
|
if (errorFilter != null || minLatencyMs != null || maxLatencyMs != null) {
|
|
213
232
|
await ensureServerCapability({ client, requirement: GET_TRACES_FILTERS });
|
|
214
233
|
}
|