@arizeai/phoenix-client 7.13.0 → 7.15.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 +14 -0
- package/dist/esm/__generated__/api/v1.d.ts +17 -4
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +5 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +35 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/datasets/createDatasetSplit.d.ts +39 -0
- package/dist/esm/datasets/createDatasetSplit.d.ts.map +1 -0
- package/dist/esm/datasets/createDatasetSplit.js +42 -0
- package/dist/esm/datasets/createDatasetSplit.js.map +1 -0
- package/dist/esm/datasets/deleteDatasetSplit.d.ts +24 -0
- package/dist/esm/datasets/deleteDatasetSplit.d.ts.map +1 -0
- package/dist/esm/datasets/deleteDatasetSplit.js +31 -0
- package/dist/esm/datasets/deleteDatasetSplit.js.map +1 -0
- package/dist/esm/datasets/index.d.ts +4 -0
- package/dist/esm/datasets/index.d.ts.map +1 -1
- package/dist/esm/datasets/index.js +3 -0
- package/dist/esm/datasets/index.js.map +1 -1
- package/dist/esm/datasets/resolveDatasetIdentifier.d.ts +4 -0
- package/dist/esm/datasets/resolveDatasetIdentifier.d.ts.map +1 -0
- package/dist/esm/datasets/resolveDatasetIdentifier.js +5 -0
- package/dist/esm/datasets/resolveDatasetIdentifier.js.map +1 -0
- package/dist/esm/datasets/updateDatasetSplit.d.ts +48 -0
- package/dist/esm/datasets/updateDatasetSplit.d.ts.map +1 -0
- package/dist/esm/datasets/updateDatasetSplit.js +55 -0
- package/dist/esm/datasets/updateDatasetSplit.js.map +1 -0
- package/dist/esm/prompts/deletePromptVersionTag.d.ts +36 -0
- package/dist/esm/prompts/deletePromptVersionTag.d.ts.map +1 -0
- package/dist/esm/prompts/deletePromptVersionTag.js +44 -0
- package/dist/esm/prompts/deletePromptVersionTag.js.map +1 -0
- package/dist/esm/prompts/index.d.ts +2 -0
- package/dist/esm/prompts/index.d.ts.map +1 -1
- package/dist/esm/prompts/index.js +2 -0
- package/dist/esm/prompts/index.js.map +1 -1
- package/dist/esm/prompts/upsertPromptVersionTag.d.ts +40 -0
- package/dist/esm/prompts/upsertPromptVersionTag.d.ts.map +1 -0
- package/dist/esm/prompts/upsertPromptVersionTag.js +49 -0
- package/dist/esm/prompts/upsertPromptVersionTag.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types/datasets.d.ts +10 -5
- package/dist/esm/types/datasets.d.ts.map +1 -1
- package/dist/esm/utils/resolvePromptVersionId.d.ts +11 -0
- package/dist/esm/utils/resolvePromptVersionId.d.ts.map +1 -0
- package/dist/esm/utils/resolvePromptVersionId.js +15 -0
- package/dist/esm/utils/resolvePromptVersionId.js.map +1 -0
- package/dist/src/__generated__/api/v1.d.ts +17 -4
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +5 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +36 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/datasets/createDatasetSplit.d.ts +39 -0
- package/dist/src/datasets/createDatasetSplit.d.ts.map +1 -0
- package/dist/src/datasets/createDatasetSplit.js +42 -0
- package/dist/src/datasets/createDatasetSplit.js.map +1 -0
- package/dist/src/datasets/deleteDatasetSplit.d.ts +24 -0
- package/dist/src/datasets/deleteDatasetSplit.d.ts.map +1 -0
- package/dist/src/datasets/deleteDatasetSplit.js +34 -0
- package/dist/src/datasets/deleteDatasetSplit.js.map +1 -0
- package/dist/src/datasets/index.d.ts +4 -0
- package/dist/src/datasets/index.d.ts.map +1 -1
- package/dist/src/datasets/index.js +3 -0
- package/dist/src/datasets/index.js.map +1 -1
- package/dist/src/datasets/resolveDatasetIdentifier.d.ts +4 -0
- package/dist/src/datasets/resolveDatasetIdentifier.d.ts.map +1 -0
- package/dist/src/datasets/resolveDatasetIdentifier.js +8 -0
- package/dist/src/datasets/resolveDatasetIdentifier.js.map +1 -0
- package/dist/src/datasets/updateDatasetSplit.d.ts +48 -0
- package/dist/src/datasets/updateDatasetSplit.d.ts.map +1 -0
- package/dist/src/datasets/updateDatasetSplit.js +54 -0
- package/dist/src/datasets/updateDatasetSplit.js.map +1 -0
- package/dist/src/prompts/deletePromptVersionTag.d.ts +36 -0
- package/dist/src/prompts/deletePromptVersionTag.d.ts.map +1 -0
- package/dist/src/prompts/deletePromptVersionTag.js +47 -0
- package/dist/src/prompts/deletePromptVersionTag.js.map +1 -0
- package/dist/src/prompts/index.d.ts +2 -0
- package/dist/src/prompts/index.d.ts.map +1 -1
- package/dist/src/prompts/index.js +2 -0
- package/dist/src/prompts/index.js.map +1 -1
- package/dist/src/prompts/upsertPromptVersionTag.d.ts +40 -0
- package/dist/src/prompts/upsertPromptVersionTag.d.ts.map +1 -0
- package/dist/src/prompts/upsertPromptVersionTag.js +52 -0
- package/dist/src/prompts/upsertPromptVersionTag.js.map +1 -0
- package/dist/src/types/datasets.d.ts +10 -5
- package/dist/src/types/datasets.d.ts.map +1 -1
- package/dist/src/utils/resolvePromptVersionId.d.ts +11 -0
- package/dist/src/utils/resolvePromptVersionId.d.ts.map +1 -0
- package/dist/src/utils/resolvePromptVersionId.js +18 -0
- package/dist/src/utils/resolvePromptVersionId.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/datasets.mdx +74 -1
- package/docs/prompts.mdx +30 -1
- package/package.json +7 -7
- package/src/__generated__/api/v1.ts +17 -4
- package/src/constants/serverRequirements.ts +40 -0
- package/src/datasets/createDatasetSplit.ts +80 -0
- package/src/datasets/deleteDatasetSplit.ts +46 -0
- package/src/datasets/index.ts +4 -0
- package/src/datasets/resolveDatasetIdentifier.ts +6 -0
- package/src/datasets/updateDatasetSplit.ts +99 -0
- package/src/prompts/deletePromptVersionTag.ts +64 -0
- package/src/prompts/index.ts +2 -0
- package/src/prompts/upsertPromptVersionTag.ts +69 -0
- package/src/types/datasets.ts +8 -3
- package/src/utils/resolvePromptVersionId.ts +18 -0
package/docs/datasets.mdx
CHANGED
|
@@ -3,7 +3,7 @@ title: "Datasets"
|
|
|
3
3
|
description: "Create and inspect datasets with @arizeai/phoenix-client"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Datasets are the foundation for experiment runs. The dataset helpers cover creation (which upserts by name), record inspection, and
|
|
6
|
+
Datasets are the foundation for experiment runs. The dataset helpers cover creation (which upserts by name), record inspection, example appends, and split management.
|
|
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>
|
|
@@ -25,14 +25,27 @@ const { datasetId } = await createDataset({
|
|
|
25
25
|
description: "Support questions with expected answers",
|
|
26
26
|
examples: [
|
|
27
27
|
{
|
|
28
|
+
id: "order-tracking",
|
|
28
29
|
input: { question: "Where is my order?" },
|
|
29
30
|
output: { answer: "Use the tracking page in your account." },
|
|
30
31
|
metadata: { channel: "chat" },
|
|
31
32
|
},
|
|
33
|
+
{
|
|
34
|
+
id: "password-reset",
|
|
35
|
+
input: { question: "How do I reset my password?" },
|
|
36
|
+
output: { answer: "Use the forgot password flow." },
|
|
37
|
+
metadata: { channel: "chat" },
|
|
38
|
+
},
|
|
32
39
|
],
|
|
33
40
|
});
|
|
34
41
|
```
|
|
35
42
|
|
|
43
|
+
`id` is optional. When you do provide it, give every example its own value:
|
|
44
|
+
example IDs are unique per dataset, so reusing one across examples in the same
|
|
45
|
+
dataset is an error. A stable, unique `id` is what `createDataset()` matches on
|
|
46
|
+
when it upserts, and what you can hand to the split helpers below instead of the
|
|
47
|
+
server-generated `nodeId`. Omit `id` and the server generates one for you.
|
|
48
|
+
|
|
36
49
|
## Upsert Or Append
|
|
37
50
|
|
|
38
51
|
`createDataset()` upserts by name: re-running it with the same name updates the existing dataset to match the examples you pass, and an unchanged upload is a no-op. To keep existing examples and add more, use `appendDatasetExamples()` instead of re-running `createDataset()` with the extra examples.
|
|
@@ -48,6 +61,7 @@ const dataset = await createDataset({
|
|
|
48
61
|
description: "Support questions with expected answers",
|
|
49
62
|
examples: [
|
|
50
63
|
{
|
|
64
|
+
id: "order-tracking",
|
|
51
65
|
input: { question: "Where is my order?" },
|
|
52
66
|
output: { answer: "Use the tracking page in your account." },
|
|
53
67
|
},
|
|
@@ -58,6 +72,7 @@ await appendDatasetExamples({
|
|
|
58
72
|
dataset,
|
|
59
73
|
examples: [
|
|
60
74
|
{
|
|
75
|
+
id: "password-reset",
|
|
61
76
|
input: { question: "How do I reset my password?" },
|
|
62
77
|
output: { answer: "Use the forgot password flow." },
|
|
63
78
|
},
|
|
@@ -71,6 +86,61 @@ await appendDatasetExamples({
|
|
|
71
86
|
|
|
72
87
|
Use `getDataset`, `getDatasetExamples`, and `getDatasetInfo` to inspect datasets after creation.
|
|
73
88
|
|
|
89
|
+
## Manage Splits On An Existing Dataset
|
|
90
|
+
|
|
91
|
+
Use `createDatasetSplit`, `updateDatasetSplit`, and `deleteDatasetSplit` to
|
|
92
|
+
manage train, test, validation, or other named subsets after a dataset exists.
|
|
93
|
+
Select the dataset by name or GlobalID. Example membership accepts either the
|
|
94
|
+
user-provided `id` or Phoenix `nodeId` returned by `getDatasetExamples`.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import {
|
|
98
|
+
createDatasetSplit,
|
|
99
|
+
deleteDatasetSplit,
|
|
100
|
+
getDatasetExamples,
|
|
101
|
+
updateDatasetSplit,
|
|
102
|
+
} from "@arizeai/phoenix-client/datasets";
|
|
103
|
+
|
|
104
|
+
const datasetIdentifier = "support-eval";
|
|
105
|
+
const dataset = { datasetName: datasetIdentifier };
|
|
106
|
+
const { examples } = await getDatasetExamples({
|
|
107
|
+
dataset,
|
|
108
|
+
});
|
|
109
|
+
const [firstExample, secondExample] = examples;
|
|
110
|
+
if (firstExample == null || secondExample == null) {
|
|
111
|
+
throw new Error("At least two examples are required to demonstrate split updates");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const testSplit = await createDatasetSplit({
|
|
115
|
+
dataset,
|
|
116
|
+
name: "test",
|
|
117
|
+
description: "Held-out evaluation examples",
|
|
118
|
+
exampleIds: [firstExample.id],
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Only provided fields change. Adding an existing member or removing a
|
|
122
|
+
// non-member is an idempotent no-op.
|
|
123
|
+
await updateDatasetSplit({
|
|
124
|
+
dataset,
|
|
125
|
+
splitId: testSplit.id,
|
|
126
|
+
description: "Reviewed held-out examples",
|
|
127
|
+
addExampleIds: [secondExample.id],
|
|
128
|
+
removeExampleIds: [firstExample.id],
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Deleting a split removes its memberships, not the underlying examples.
|
|
132
|
+
await deleteDatasetSplit({
|
|
133
|
+
dataset,
|
|
134
|
+
splitId: testSplit.id,
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Split names are unique across the Phoenix instance. Creating or renaming a
|
|
139
|
+
split to an existing name fails with HTTP 409. These helpers require Phoenix
|
|
140
|
+
server 19.20.0 or newer. Servers on 19.20.0 through 20.15.0 resolve membership
|
|
141
|
+
by `nodeId` only — user-provided `id` values are accepted from the release that
|
|
142
|
+
follows 20.15.0, so pass `nodeId` when you target an older server.
|
|
143
|
+
|
|
74
144
|
<section className="hidden" data-agent-context="source-map" aria-label="Source map">
|
|
75
145
|
<h2>Source Map</h2>
|
|
76
146
|
<ul>
|
|
@@ -79,5 +149,8 @@ Use `getDataset`, `getDatasetExamples`, and `getDatasetInfo` to inspect datasets
|
|
|
79
149
|
<li><code>src/datasets/getDataset.ts</code></li>
|
|
80
150
|
<li><code>src/datasets/getDatasetExamples.ts</code></li>
|
|
81
151
|
<li><code>src/datasets/getDatasetInfo.ts</code></li>
|
|
152
|
+
<li><code>src/datasets/createDatasetSplit.ts</code></li>
|
|
153
|
+
<li><code>src/datasets/updateDatasetSplit.ts</code></li>
|
|
154
|
+
<li><code>src/datasets/deleteDatasetSplit.ts</code></li>
|
|
82
155
|
</ul>
|
|
83
156
|
</section>
|
package/docs/prompts.mdx
CHANGED
|
@@ -3,7 +3,7 @@ title: "Prompts"
|
|
|
3
3
|
description: "Manage prompts with @arizeai/phoenix-client"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
The prompts module lets you create prompt versions in Phoenix, fetch them back by selector, list prompts, update a prompt's description and metadata, delete a prompt, and adapt prompt versions to supported provider SDKs.
|
|
6
|
+
The prompts module lets you create prompt versions in Phoenix, fetch them back by selector, manage prompt version tags, list prompts, update a prompt's description and metadata, delete a prompt, and adapt prompt versions to supported provider SDKs.
|
|
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>
|
|
@@ -43,6 +43,32 @@ const prompt = await getPrompt({
|
|
|
43
43
|
|
|
44
44
|
`prompt` can be selected by `{ name }`, `{ name, tag }`, or `{ versionId }`.
|
|
45
45
|
|
|
46
|
+
## Manage Version Tags
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import {
|
|
50
|
+
deletePromptVersionTag,
|
|
51
|
+
upsertPromptVersionTag,
|
|
52
|
+
} from "@arizeai/phoenix-client/prompts";
|
|
53
|
+
|
|
54
|
+
await upsertPromptVersionTag({
|
|
55
|
+
prompt: { versionId: "UHJvbXB0VmVyc2lvbjox" },
|
|
56
|
+
name: "production",
|
|
57
|
+
description: "Currently deployed version",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
await deletePromptVersionTag({
|
|
61
|
+
prompt: { versionId: "UHJvbXB0VmVyc2lvbjox" },
|
|
62
|
+
name: "staging",
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Tag names are unique within a prompt, not within an individual version. Upserting a new name creates the tag on the target version. Upserting a name that already exists on another version of the same prompt moves that tag to the target version and updates its description. The same name can still be used independently by unrelated prompts.
|
|
67
|
+
|
|
68
|
+
Deletion also resolves the name within the prompt identified by `prompt.versionId`; the tag can be attached to any version of that prompt.
|
|
69
|
+
|
|
70
|
+
Tag upserts require Phoenix 8.22.0 or later. Tag deletion requires Phoenix 13.20.0 or later.
|
|
71
|
+
|
|
46
72
|
## Update Description And Metadata
|
|
47
73
|
|
|
48
74
|
```ts
|
|
@@ -99,9 +125,12 @@ Supported `sdk` targets:
|
|
|
99
125
|
<ul>
|
|
100
126
|
<li><code>src/prompts/createPrompt.ts</code></li>
|
|
101
127
|
<li><code>src/prompts/deletePrompt.ts</code></li>
|
|
128
|
+
<li><code>src/prompts/deletePromptVersionTag.ts</code></li>
|
|
102
129
|
<li><code>src/prompts/getPrompt.ts</code></li>
|
|
103
130
|
<li><code>src/prompts/listPrompts.ts</code></li>
|
|
104
131
|
<li><code>src/prompts/updatePrompt.ts</code></li>
|
|
132
|
+
<li><code>src/prompts/upsertPromptVersionTag.ts</code></li>
|
|
133
|
+
<li><code>src/utils/resolvePromptVersionId.ts</code></li>
|
|
105
134
|
<li><code>src/prompts/sdks/toSDK.ts</code></li>
|
|
106
135
|
<li><code>src/types/prompts.ts</code></li>
|
|
107
136
|
</ul>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.0",
|
|
4
4
|
"description": "A client for the Phoenix API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -116,22 +116,22 @@
|
|
|
116
116
|
"zod": "^4.6.5"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@ai-sdk/openai": "^4.0.
|
|
120
|
-
"@ai-sdk/otel": "^1.0.
|
|
119
|
+
"@ai-sdk/openai": "^4.0.78",
|
|
120
|
+
"@ai-sdk/otel": "^1.0.116",
|
|
121
121
|
"@anthropic-ai/sdk": "^0.111.0",
|
|
122
122
|
"@arizeai/phoenix-evals": "2.6.0",
|
|
123
123
|
"@arizeai/phoenix-testing": "0.0.0",
|
|
124
124
|
"@opentelemetry/api": "^1.9.1",
|
|
125
125
|
"@opentelemetry/sdk-trace-node": "^2.11.0",
|
|
126
126
|
"@types/async": "^3.2.26",
|
|
127
|
-
"@types/node": "^26.6.
|
|
128
|
-
"ai": "^7.0.
|
|
127
|
+
"@types/node": "^26.6.3",
|
|
128
|
+
"ai": "^7.0.116",
|
|
129
129
|
"dotenv": "^17.4.2",
|
|
130
130
|
"jest": "^30.5.2",
|
|
131
131
|
"openai": "^6.49.0",
|
|
132
132
|
"openapi-typescript": "^7.13.0",
|
|
133
|
-
"tsx": "^4.23.
|
|
134
|
-
"vitest": "^5.0.
|
|
133
|
+
"tsx": "^4.23.15",
|
|
134
|
+
"vitest": "^5.0.2"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"@anthropic-ai/sdk": "^0.35.0",
|
|
@@ -2679,7 +2679,7 @@ export interface components {
|
|
|
2679
2679
|
};
|
|
2680
2680
|
/**
|
|
2681
2681
|
* Example Ids
|
|
2682
|
-
* @description Optional dataset example
|
|
2682
|
+
* @description Optional dataset example identifiers (GlobalIDs or user-provided IDs) to seed the split with. Each example must belong to this dataset. Omit to create an empty split.
|
|
2683
2683
|
*/
|
|
2684
2684
|
example_ids?: string[];
|
|
2685
2685
|
};
|
|
@@ -3334,6 +3334,11 @@ export interface components {
|
|
|
3334
3334
|
* @description The description of the experiment
|
|
3335
3335
|
*/
|
|
3336
3336
|
description: string | null;
|
|
3337
|
+
/**
|
|
3338
|
+
* Sequence Number
|
|
3339
|
+
* @description The 1-based sequence number of the experiment within its dataset, in creation order.
|
|
3340
|
+
*/
|
|
3341
|
+
sequence_number: number;
|
|
3337
3342
|
/**
|
|
3338
3343
|
* Repetitions
|
|
3339
3344
|
* @description Number of times the experiment is repeated
|
|
@@ -6716,12 +6721,12 @@ export interface components {
|
|
|
6716
6721
|
} | null;
|
|
6717
6722
|
/**
|
|
6718
6723
|
* Add Example Ids
|
|
6719
|
-
* @description Dataset example
|
|
6724
|
+
* @description Dataset example identifiers (GlobalIDs or user-provided IDs) to add to the split. Each example must belong to this dataset. Adding an example already in the split is a no-op.
|
|
6720
6725
|
*/
|
|
6721
6726
|
add_example_ids?: string[];
|
|
6722
6727
|
/**
|
|
6723
6728
|
* Remove Example Ids
|
|
6724
|
-
* @description Dataset example
|
|
6729
|
+
* @description Dataset example identifiers (GlobalIDs or user-provided IDs) to remove from the split.
|
|
6725
6730
|
*/
|
|
6726
6731
|
remove_example_ids?: string[];
|
|
6727
6732
|
};
|
|
@@ -9383,6 +9388,10 @@ export interface operations {
|
|
|
9383
9388
|
cursor?: string | null;
|
|
9384
9389
|
/** @description The max number of experiments to return at a time. */
|
|
9385
9390
|
limit?: number;
|
|
9391
|
+
/** @description Order by creation: 'desc' (default) returns newest experiments first, 'asc' returns oldest first so the lowest sequence numbers are on the first page. */
|
|
9392
|
+
sort_dir?: "asc" | "desc";
|
|
9393
|
+
/** @description When provided, return only the experiments with these 1-based per-dataset sequence numbers. */
|
|
9394
|
+
sequence_numbers?: number[] | null;
|
|
9386
9395
|
};
|
|
9387
9396
|
header?: never;
|
|
9388
9397
|
path: {
|
|
@@ -10580,10 +10589,14 @@ export interface operations {
|
|
|
10580
10589
|
getSpans: {
|
|
10581
10590
|
parameters: {
|
|
10582
10591
|
query?: {
|
|
10583
|
-
/** @description Pagination cursor
|
|
10592
|
+
/** @description Pagination cursor: the next_cursor of a previous response with the same sort */
|
|
10584
10593
|
cursor?: string | null;
|
|
10585
10594
|
/** @description Maximum number of spans to return */
|
|
10586
10595
|
limit?: number;
|
|
10596
|
+
/** @description Sort field. 'id' orders by insertion; 'start_time' orders by when the span started, breaking ties by id. */
|
|
10597
|
+
sort?: "id" | "start_time";
|
|
10598
|
+
/** @description Sort direction */
|
|
10599
|
+
order?: "asc" | "desc";
|
|
10587
10600
|
/** @description Inclusive lower bound time */
|
|
10588
10601
|
start_time?: string | null;
|
|
10589
10602
|
/** @description Exclusive upper bound time */
|
|
@@ -147,6 +147,27 @@ export const DATASET_UPLOAD_EXAMPLE_IDS: ParameterRequirement = {
|
|
|
147
147
|
minServerVersion: [15, 0, 0],
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
export const CREATE_DATASET_SPLIT: RouteRequirement = {
|
|
151
|
+
kind: "route",
|
|
152
|
+
method: "POST",
|
|
153
|
+
path: "/v1/datasets/{dataset_identifier}/splits",
|
|
154
|
+
minServerVersion: [19, 20, 0],
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const UPDATE_DATASET_SPLIT: RouteRequirement = {
|
|
158
|
+
kind: "route",
|
|
159
|
+
method: "PATCH",
|
|
160
|
+
path: "/v1/datasets/{dataset_identifier}/splits/{split_id}",
|
|
161
|
+
minServerVersion: [19, 20, 0],
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const DELETE_DATASET_SPLIT: RouteRequirement = {
|
|
165
|
+
kind: "route",
|
|
166
|
+
method: "DELETE",
|
|
167
|
+
path: "/v1/datasets/{dataset_identifier}/splits/{split_id}",
|
|
168
|
+
minServerVersion: [19, 20, 0],
|
|
169
|
+
};
|
|
170
|
+
|
|
150
171
|
export const ADD_TRACE_NOTE_IDENTIFIER: ParameterRequirement = {
|
|
151
172
|
kind: "parameter",
|
|
152
173
|
parameterName: "identifier",
|
|
@@ -178,6 +199,20 @@ export const DELETE_PROMPT: RouteRequirement = {
|
|
|
178
199
|
minServerVersion: [13, 20, 0],
|
|
179
200
|
};
|
|
180
201
|
|
|
202
|
+
export const UPSERT_PROMPT_VERSION_TAG: RouteRequirement = {
|
|
203
|
+
kind: "route",
|
|
204
|
+
method: "POST",
|
|
205
|
+
path: "/v1/prompt_versions/{prompt_version_id}/tags",
|
|
206
|
+
minServerVersion: [8, 22, 0],
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const DELETE_PROMPT_VERSION_TAG: RouteRequirement = {
|
|
210
|
+
kind: "route",
|
|
211
|
+
method: "DELETE",
|
|
212
|
+
path: "/v1/prompt_versions/{prompt_version_id}/tags/{tag_name}",
|
|
213
|
+
minServerVersion: [13, 20, 0],
|
|
214
|
+
};
|
|
215
|
+
|
|
181
216
|
export const PATCH_PROMPT: RouteRequirement = {
|
|
182
217
|
kind: "route",
|
|
183
218
|
method: "PATCH",
|
|
@@ -265,10 +300,15 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
|
|
|
265
300
|
LIST_SESSIONS_FILTER_EXPRESSION,
|
|
266
301
|
TRANSFER_TRACES,
|
|
267
302
|
DATASET_UPLOAD_EXAMPLE_IDS,
|
|
303
|
+
CREATE_DATASET_SPLIT,
|
|
304
|
+
UPDATE_DATASET_SPLIT,
|
|
305
|
+
DELETE_DATASET_SPLIT,
|
|
268
306
|
ADD_TRACE_NOTE_IDENTIFIER,
|
|
269
307
|
ADD_SPAN_NOTE_IDENTIFIER,
|
|
270
308
|
ADD_SESSION_NOTE_IDENTIFIER,
|
|
271
309
|
DELETE_PROMPT,
|
|
310
|
+
UPSERT_PROMPT_VERSION_TAG,
|
|
311
|
+
DELETE_PROMPT_VERSION_TAG,
|
|
272
312
|
PATCH_PROMPT,
|
|
273
313
|
AGENT_SESSION_CREATE,
|
|
274
314
|
AGENT_SESSION_LIST,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import invariant from "tiny-invariant";
|
|
2
|
+
|
|
3
|
+
import type { components } from "../__generated__/api/v1";
|
|
4
|
+
import { createClient } from "../client";
|
|
5
|
+
import { CREATE_DATASET_SPLIT } from "../constants/serverRequirements";
|
|
6
|
+
import type { ClientFn } from "../types/core";
|
|
7
|
+
import type { DatasetIdentifier, DatasetSplit } from "../types/datasets";
|
|
8
|
+
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
9
|
+
import { resolveDatasetIdentifier } from "./resolveDatasetIdentifier";
|
|
10
|
+
|
|
11
|
+
type CreateDatasetSplitRequestBody =
|
|
12
|
+
components["schemas"]["CreateDatasetSplitRequestBody"];
|
|
13
|
+
type CreateDatasetSplitResponseBody =
|
|
14
|
+
components["schemas"]["CreateDatasetSplitResponseBody"];
|
|
15
|
+
|
|
16
|
+
/** Parameters for creating a dataset split. */
|
|
17
|
+
export interface CreateDatasetSplitParams extends ClientFn {
|
|
18
|
+
/** The dataset, selected by name or GlobalID. */
|
|
19
|
+
dataset: DatasetIdentifier;
|
|
20
|
+
/** A unique name for the split. */
|
|
21
|
+
name: CreateDatasetSplitRequestBody["name"];
|
|
22
|
+
/** An optional description of the split. */
|
|
23
|
+
description?: CreateDatasetSplitRequestBody["description"];
|
|
24
|
+
/** An optional hex color for the split. */
|
|
25
|
+
color?: CreateDatasetSplitRequestBody["color"];
|
|
26
|
+
/** Arbitrary JSON metadata for the split. */
|
|
27
|
+
metadata?: CreateDatasetSplitRequestBody["metadata"];
|
|
28
|
+
/** Dataset example GlobalIDs or user-provided IDs with which to seed the split. */
|
|
29
|
+
exampleIds?: CreateDatasetSplitRequestBody["example_ids"];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a split on an existing dataset.
|
|
34
|
+
*
|
|
35
|
+
* @param params - The split to create.
|
|
36
|
+
* @param params.client - Optional Phoenix client instance.
|
|
37
|
+
* @param params.dataset - The dataset, selected by name or GlobalID.
|
|
38
|
+
* @param params.name - A unique name for the split.
|
|
39
|
+
* @param params.description - An optional description of the split.
|
|
40
|
+
* @param params.color - An optional hex color for the split.
|
|
41
|
+
* @param params.metadata - Arbitrary JSON metadata for the split.
|
|
42
|
+
* @param params.exampleIds - Dataset example GlobalIDs or user-provided IDs with which to seed the split.
|
|
43
|
+
* @returns The created dataset split.
|
|
44
|
+
* @throws {HttpError} If the dataset or an example does not exist, the name is
|
|
45
|
+
* already in use, or the request is invalid.
|
|
46
|
+
*
|
|
47
|
+
* @requires Phoenix server >= 19.20.0
|
|
48
|
+
*/
|
|
49
|
+
export async function createDatasetSplit({
|
|
50
|
+
client: _client,
|
|
51
|
+
dataset,
|
|
52
|
+
name,
|
|
53
|
+
description,
|
|
54
|
+
color,
|
|
55
|
+
metadata,
|
|
56
|
+
exampleIds,
|
|
57
|
+
}: CreateDatasetSplitParams): Promise<DatasetSplit> {
|
|
58
|
+
const client = _client ?? createClient();
|
|
59
|
+
await ensureServerCapability({ client, requirement: CREATE_DATASET_SPLIT });
|
|
60
|
+
const datasetIdentifier = resolveDatasetIdentifier(dataset);
|
|
61
|
+
|
|
62
|
+
const body: CreateDatasetSplitRequestBody = {
|
|
63
|
+
name,
|
|
64
|
+
...(description !== undefined ? { description } : {}),
|
|
65
|
+
...(color !== undefined ? { color } : {}),
|
|
66
|
+
...(metadata !== undefined ? { metadata } : {}),
|
|
67
|
+
...(exampleIds !== undefined ? { example_ids: exampleIds } : {}),
|
|
68
|
+
};
|
|
69
|
+
const response = await client.POST(
|
|
70
|
+
"/v1/datasets/{dataset_identifier}/splits",
|
|
71
|
+
{
|
|
72
|
+
params: { path: { dataset_identifier: datasetIdentifier } },
|
|
73
|
+
body,
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
const responseBody: CreateDatasetSplitResponseBody | undefined =
|
|
77
|
+
response.data;
|
|
78
|
+
invariant(responseBody?.data, "Failed to create dataset split");
|
|
79
|
+
return responseBody.data;
|
|
80
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createClient } from "../client";
|
|
2
|
+
import { DELETE_DATASET_SPLIT } from "../constants/serverRequirements";
|
|
3
|
+
import type { ClientFn } from "../types/core";
|
|
4
|
+
import type { DatasetIdentifier } from "../types/datasets";
|
|
5
|
+
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
6
|
+
import { resolveDatasetIdentifier } from "./resolveDatasetIdentifier";
|
|
7
|
+
|
|
8
|
+
/** Parameters for deleting a dataset split. */
|
|
9
|
+
export interface DeleteDatasetSplitParams extends ClientFn {
|
|
10
|
+
/** The dataset, selected by name or GlobalID. */
|
|
11
|
+
dataset: DatasetIdentifier;
|
|
12
|
+
/** The dataset split GlobalID. */
|
|
13
|
+
splitId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Delete a dataset split and its memberships without deleting its examples.
|
|
18
|
+
*
|
|
19
|
+
* @param params - The split to delete.
|
|
20
|
+
* @param params.client - Optional Phoenix client instance.
|
|
21
|
+
* @param params.dataset - The dataset, selected by name or GlobalID.
|
|
22
|
+
* @param params.splitId - The dataset split GlobalID.
|
|
23
|
+
* @returns A promise that resolves once the split is deleted.
|
|
24
|
+
* @throws {HttpError} If the dataset or split does not exist, or the split ID
|
|
25
|
+
* is invalid.
|
|
26
|
+
*
|
|
27
|
+
* @requires Phoenix server >= 19.20.0
|
|
28
|
+
*/
|
|
29
|
+
export async function deleteDatasetSplit({
|
|
30
|
+
client: _client,
|
|
31
|
+
dataset,
|
|
32
|
+
splitId,
|
|
33
|
+
}: DeleteDatasetSplitParams): Promise<void> {
|
|
34
|
+
const client = _client ?? createClient();
|
|
35
|
+
await ensureServerCapability({ client, requirement: DELETE_DATASET_SPLIT });
|
|
36
|
+
const datasetIdentifier = resolveDatasetIdentifier(dataset);
|
|
37
|
+
|
|
38
|
+
await client.DELETE("/v1/datasets/{dataset_identifier}/splits/{split_id}", {
|
|
39
|
+
params: {
|
|
40
|
+
path: {
|
|
41
|
+
dataset_identifier: datasetIdentifier,
|
|
42
|
+
split_id: splitId,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
package/src/datasets/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from "./createDataset";
|
|
2
|
+
export * from "./createDatasetSplit";
|
|
3
|
+
export * from "./deleteDatasetSplit";
|
|
2
4
|
export * from "./getDataset";
|
|
3
5
|
export * from "./getDatasetExamples";
|
|
4
6
|
export * from "./appendDatasetExamples";
|
|
5
7
|
export * from "./getDatasetInfo";
|
|
8
|
+
export * from "./updateDatasetSplit";
|
|
9
|
+
export type { DatasetIdentifier, DatasetSplit } from "../types/datasets";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DatasetIdentifier } from "../types/datasets";
|
|
2
|
+
|
|
3
|
+
/** Resolve a typed dataset selector to the REST path identifier. */
|
|
4
|
+
export function resolveDatasetIdentifier(dataset: DatasetIdentifier): string {
|
|
5
|
+
return "datasetName" in dataset ? dataset.datasetName : dataset.datasetId;
|
|
6
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import invariant from "tiny-invariant";
|
|
2
|
+
|
|
3
|
+
import type { components } from "../__generated__/api/v1";
|
|
4
|
+
import { createClient } from "../client";
|
|
5
|
+
import { UPDATE_DATASET_SPLIT } from "../constants/serverRequirements";
|
|
6
|
+
import type { ClientFn } from "../types/core";
|
|
7
|
+
import type { DatasetIdentifier, DatasetSplit } from "../types/datasets";
|
|
8
|
+
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
9
|
+
import { resolveDatasetIdentifier } from "./resolveDatasetIdentifier";
|
|
10
|
+
|
|
11
|
+
type UpdateDatasetSplitRequestBody =
|
|
12
|
+
components["schemas"]["UpdateDatasetSplitRequestBody"];
|
|
13
|
+
type UpdateDatasetSplitResponseBody =
|
|
14
|
+
components["schemas"]["UpdateDatasetSplitResponseBody"];
|
|
15
|
+
|
|
16
|
+
/** Parameters for partially updating a dataset split. */
|
|
17
|
+
export interface UpdateDatasetSplitParams extends ClientFn {
|
|
18
|
+
/** The dataset, selected by name or GlobalID. */
|
|
19
|
+
dataset: DatasetIdentifier;
|
|
20
|
+
/** The dataset split GlobalID. */
|
|
21
|
+
splitId: string;
|
|
22
|
+
/** A new unique name for the split. */
|
|
23
|
+
name?: UpdateDatasetSplitRequestBody["name"];
|
|
24
|
+
/** A new description, or null to clear it. */
|
|
25
|
+
description?: UpdateDatasetSplitRequestBody["description"];
|
|
26
|
+
/** A new hex color for the split. */
|
|
27
|
+
color?: UpdateDatasetSplitRequestBody["color"];
|
|
28
|
+
/** JSON metadata that replaces the existing metadata. */
|
|
29
|
+
metadata?: UpdateDatasetSplitRequestBody["metadata"];
|
|
30
|
+
/** Dataset example GlobalIDs or user-provided IDs to add. Existing memberships are no-ops. */
|
|
31
|
+
addExampleIds?: UpdateDatasetSplitRequestBody["add_example_ids"];
|
|
32
|
+
/** Dataset example GlobalIDs or user-provided IDs to remove. Missing memberships are no-ops. */
|
|
33
|
+
removeExampleIds?: UpdateDatasetSplitRequestBody["remove_example_ids"];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Partially update a dataset split and/or its example membership.
|
|
38
|
+
*
|
|
39
|
+
* Only provided fields change. Membership additions and removals are
|
|
40
|
+
* idempotent; if an example appears in both arrays, removal wins.
|
|
41
|
+
*
|
|
42
|
+
* @param params - The split fields and memberships to update.
|
|
43
|
+
* @param params.client - Optional Phoenix client instance.
|
|
44
|
+
* @param params.dataset - The dataset, selected by name or GlobalID.
|
|
45
|
+
* @param params.splitId - The dataset split GlobalID.
|
|
46
|
+
* @param params.name - A new unique name for the split.
|
|
47
|
+
* @param params.description - A new description, or null to clear it.
|
|
48
|
+
* @param params.color - A new hex color for the split.
|
|
49
|
+
* @param params.metadata - JSON metadata that replaces the existing metadata.
|
|
50
|
+
* @param params.addExampleIds - Dataset example GlobalIDs or user-provided IDs to add.
|
|
51
|
+
* @param params.removeExampleIds - Dataset example GlobalIDs or user-provided IDs to remove.
|
|
52
|
+
* @returns The updated dataset split.
|
|
53
|
+
* @throws {HttpError} If the dataset, split, or an example does not exist, the
|
|
54
|
+
* name is already in use, or the request is invalid.
|
|
55
|
+
*
|
|
56
|
+
* @requires Phoenix server >= 19.20.0
|
|
57
|
+
*/
|
|
58
|
+
export async function updateDatasetSplit({
|
|
59
|
+
client: _client,
|
|
60
|
+
dataset,
|
|
61
|
+
splitId,
|
|
62
|
+
name,
|
|
63
|
+
description,
|
|
64
|
+
color,
|
|
65
|
+
metadata,
|
|
66
|
+
addExampleIds,
|
|
67
|
+
removeExampleIds,
|
|
68
|
+
}: UpdateDatasetSplitParams): Promise<DatasetSplit> {
|
|
69
|
+
const client = _client ?? createClient();
|
|
70
|
+
await ensureServerCapability({ client, requirement: UPDATE_DATASET_SPLIT });
|
|
71
|
+
const datasetIdentifier = resolveDatasetIdentifier(dataset);
|
|
72
|
+
|
|
73
|
+
const body: UpdateDatasetSplitRequestBody = {
|
|
74
|
+
...(name !== undefined ? { name } : {}),
|
|
75
|
+
...(description !== undefined ? { description } : {}),
|
|
76
|
+
...(color !== undefined ? { color } : {}),
|
|
77
|
+
...(metadata !== undefined ? { metadata } : {}),
|
|
78
|
+
...(addExampleIds !== undefined ? { add_example_ids: addExampleIds } : {}),
|
|
79
|
+
...(removeExampleIds !== undefined
|
|
80
|
+
? { remove_example_ids: removeExampleIds }
|
|
81
|
+
: {}),
|
|
82
|
+
};
|
|
83
|
+
const response = await client.PATCH(
|
|
84
|
+
"/v1/datasets/{dataset_identifier}/splits/{split_id}",
|
|
85
|
+
{
|
|
86
|
+
params: {
|
|
87
|
+
path: {
|
|
88
|
+
dataset_identifier: datasetIdentifier,
|
|
89
|
+
split_id: splitId,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
body,
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
const responseBody: UpdateDatasetSplitResponseBody | undefined =
|
|
96
|
+
response.data;
|
|
97
|
+
invariant(responseBody?.data, "Failed to update dataset split");
|
|
98
|
+
return responseBody.data;
|
|
99
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createClient } from "../client";
|
|
2
|
+
import { DELETE_PROMPT_VERSION_TAG } from "../constants/serverRequirements";
|
|
3
|
+
import type { ClientFn } from "../types/core";
|
|
4
|
+
import type { GetPromptByVersionSelector } from "../types/prompts";
|
|
5
|
+
import { resolvePromptVersionId } from "../utils/resolvePromptVersionId";
|
|
6
|
+
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for deleting a prompt version tag.
|
|
10
|
+
*/
|
|
11
|
+
export interface DeletePromptVersionTagParams extends ClientFn {
|
|
12
|
+
/** A version belonging to the prompt that owns the tag. */
|
|
13
|
+
prompt: GetPromptByVersionSelector;
|
|
14
|
+
/** The prompt-scoped tag name to delete. */
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Delete a tag from the prompt that owns the given prompt version.
|
|
20
|
+
*
|
|
21
|
+
* Tag names are unique within a prompt, so `name` identifies the tag across
|
|
22
|
+
* all versions of that prompt. The tag does not need to be attached to the
|
|
23
|
+
* selected version.
|
|
24
|
+
*
|
|
25
|
+
* @param params - The prompt version tag to delete.
|
|
26
|
+
* @param params.prompt - A version selector used to identify the prompt.
|
|
27
|
+
* @param params.name - The prompt-scoped tag name to delete.
|
|
28
|
+
* @returns A promise that resolves once the tag has been deleted.
|
|
29
|
+
* @throws {@link HttpError} when Phoenix rejects the request.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { deletePromptVersionTag } from "@arizeai/phoenix-client/prompts";
|
|
34
|
+
*
|
|
35
|
+
* await deletePromptVersionTag({
|
|
36
|
+
* prompt: { versionId: "UHJvbXB0VmVyc2lvbjox" },
|
|
37
|
+
* name: "production",
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export async function deletePromptVersionTag({
|
|
42
|
+
client: _client,
|
|
43
|
+
prompt,
|
|
44
|
+
name,
|
|
45
|
+
}: DeletePromptVersionTagParams): Promise<void> {
|
|
46
|
+
const promptVersionId = resolvePromptVersionId(prompt);
|
|
47
|
+
const client = _client ?? createClient();
|
|
48
|
+
await ensureServerCapability({
|
|
49
|
+
client,
|
|
50
|
+
requirement: DELETE_PROMPT_VERSION_TAG,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await client.DELETE(
|
|
54
|
+
"/v1/prompt_versions/{prompt_version_id}/tags/{tag_name}",
|
|
55
|
+
{
|
|
56
|
+
params: {
|
|
57
|
+
path: {
|
|
58
|
+
prompt_version_id: promptVersionId,
|
|
59
|
+
tag_name: name,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
package/src/prompts/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./getPrompt";
|
|
2
2
|
export * from "./createPrompt";
|
|
3
3
|
export * from "./deletePrompt";
|
|
4
|
+
export * from "./deletePromptVersionTag";
|
|
4
5
|
export * from "./listPrompts";
|
|
6
|
+
export * from "./upsertPromptVersionTag";
|
|
5
7
|
export * from "./updatePrompt";
|
|
6
8
|
export * from "./sdks";
|