@arizeai/phoenix-client 7.14.0 → 7.16.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +47 -1
  3. package/dist/esm/__generated__/api/v1.d.ts +5 -1
  4. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  5. package/dist/esm/constants/serverRequirements.d.ts +6 -0
  6. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  7. package/dist/esm/constants/serverRequirements.js +42 -0
  8. package/dist/esm/constants/serverRequirements.js.map +1 -1
  9. package/dist/esm/projects/assignProjectAnnotationConfig.d.ts +41 -0
  10. package/dist/esm/projects/assignProjectAnnotationConfig.d.ts.map +1 -0
  11. package/dist/esm/projects/assignProjectAnnotationConfig.js +58 -0
  12. package/dist/esm/projects/assignProjectAnnotationConfig.js.map +1 -0
  13. package/dist/esm/projects/index.d.ts +5 -0
  14. package/dist/esm/projects/index.d.ts.map +1 -1
  15. package/dist/esm/projects/index.js +4 -0
  16. package/dist/esm/projects/index.js.map +1 -1
  17. package/dist/esm/projects/listProjectAnnotationConfigs.d.ts +37 -0
  18. package/dist/esm/projects/listProjectAnnotationConfigs.d.ts.map +1 -0
  19. package/dist/esm/projects/listProjectAnnotationConfigs.js +59 -0
  20. package/dist/esm/projects/listProjectAnnotationConfigs.js.map +1 -0
  21. package/dist/esm/projects/setProjectAnnotationConfigs.d.ts +52 -0
  22. package/dist/esm/projects/setProjectAnnotationConfigs.d.ts.map +1 -0
  23. package/dist/esm/projects/setProjectAnnotationConfigs.js +63 -0
  24. package/dist/esm/projects/setProjectAnnotationConfigs.js.map +1 -0
  25. package/dist/esm/projects/unassignProjectAnnotationConfig.d.ts +41 -0
  26. package/dist/esm/projects/unassignProjectAnnotationConfig.d.ts.map +1 -0
  27. package/dist/esm/projects/unassignProjectAnnotationConfig.js +55 -0
  28. package/dist/esm/projects/unassignProjectAnnotationConfig.js.map +1 -0
  29. package/dist/esm/prompts/deletePromptVersionTag.d.ts +36 -0
  30. package/dist/esm/prompts/deletePromptVersionTag.d.ts.map +1 -0
  31. package/dist/esm/prompts/deletePromptVersionTag.js +44 -0
  32. package/dist/esm/prompts/deletePromptVersionTag.js.map +1 -0
  33. package/dist/esm/prompts/index.d.ts +2 -0
  34. package/dist/esm/prompts/index.d.ts.map +1 -1
  35. package/dist/esm/prompts/index.js +2 -0
  36. package/dist/esm/prompts/index.js.map +1 -1
  37. package/dist/esm/prompts/upsertPromptVersionTag.d.ts +40 -0
  38. package/dist/esm/prompts/upsertPromptVersionTag.d.ts.map +1 -0
  39. package/dist/esm/prompts/upsertPromptVersionTag.js +49 -0
  40. package/dist/esm/prompts/upsertPromptVersionTag.js.map +1 -0
  41. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  42. package/dist/esm/types/annotationConfigs.d.ts +35 -0
  43. package/dist/esm/types/annotationConfigs.d.ts.map +1 -0
  44. package/dist/esm/types/annotationConfigs.js +12 -0
  45. package/dist/esm/types/annotationConfigs.js.map +1 -0
  46. package/dist/esm/utils/resolvePromptVersionId.d.ts +11 -0
  47. package/dist/esm/utils/resolvePromptVersionId.d.ts.map +1 -0
  48. package/dist/esm/utils/resolvePromptVersionId.js +15 -0
  49. package/dist/esm/utils/resolvePromptVersionId.js.map +1 -0
  50. package/dist/src/__generated__/api/v1.d.ts +5 -1
  51. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  52. package/dist/src/constants/serverRequirements.d.ts +6 -0
  53. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  54. package/dist/src/constants/serverRequirements.js +43 -1
  55. package/dist/src/constants/serverRequirements.js.map +1 -1
  56. package/dist/src/projects/assignProjectAnnotationConfig.d.ts +41 -0
  57. package/dist/src/projects/assignProjectAnnotationConfig.d.ts.map +1 -0
  58. package/dist/src/projects/assignProjectAnnotationConfig.js +65 -0
  59. package/dist/src/projects/assignProjectAnnotationConfig.js.map +1 -0
  60. package/dist/src/projects/index.d.ts +5 -0
  61. package/dist/src/projects/index.d.ts.map +1 -1
  62. package/dist/src/projects/index.js +4 -0
  63. package/dist/src/projects/index.js.map +1 -1
  64. package/dist/src/projects/listProjectAnnotationConfigs.d.ts +37 -0
  65. package/dist/src/projects/listProjectAnnotationConfigs.d.ts.map +1 -0
  66. package/dist/src/projects/listProjectAnnotationConfigs.js +67 -0
  67. package/dist/src/projects/listProjectAnnotationConfigs.js.map +1 -0
  68. package/dist/src/projects/setProjectAnnotationConfigs.d.ts +52 -0
  69. package/dist/src/projects/setProjectAnnotationConfigs.d.ts.map +1 -0
  70. package/dist/src/projects/setProjectAnnotationConfigs.js +70 -0
  71. package/dist/src/projects/setProjectAnnotationConfigs.js.map +1 -0
  72. package/dist/src/projects/unassignProjectAnnotationConfig.d.ts +41 -0
  73. package/dist/src/projects/unassignProjectAnnotationConfig.d.ts.map +1 -0
  74. package/dist/src/projects/unassignProjectAnnotationConfig.js +59 -0
  75. package/dist/src/projects/unassignProjectAnnotationConfig.js.map +1 -0
  76. package/dist/src/prompts/deletePromptVersionTag.d.ts +36 -0
  77. package/dist/src/prompts/deletePromptVersionTag.d.ts.map +1 -0
  78. package/dist/src/prompts/deletePromptVersionTag.js +47 -0
  79. package/dist/src/prompts/deletePromptVersionTag.js.map +1 -0
  80. package/dist/src/prompts/index.d.ts +2 -0
  81. package/dist/src/prompts/index.d.ts.map +1 -1
  82. package/dist/src/prompts/index.js +2 -0
  83. package/dist/src/prompts/index.js.map +1 -1
  84. package/dist/src/prompts/upsertPromptVersionTag.d.ts +40 -0
  85. package/dist/src/prompts/upsertPromptVersionTag.d.ts.map +1 -0
  86. package/dist/src/prompts/upsertPromptVersionTag.js +52 -0
  87. package/dist/src/prompts/upsertPromptVersionTag.js.map +1 -0
  88. package/dist/src/types/annotationConfigs.d.ts +35 -0
  89. package/dist/src/types/annotationConfigs.d.ts.map +1 -0
  90. package/dist/src/types/annotationConfigs.js +15 -0
  91. package/dist/src/types/annotationConfigs.js.map +1 -0
  92. package/dist/src/utils/resolvePromptVersionId.d.ts +11 -0
  93. package/dist/src/utils/resolvePromptVersionId.d.ts.map +1 -0
  94. package/dist/src/utils/resolvePromptVersionId.js +18 -0
  95. package/dist/src/utils/resolvePromptVersionId.js.map +1 -0
  96. package/dist/tsconfig.tsbuildinfo +1 -1
  97. package/docs/projects.mdx +55 -2
  98. package/docs/prompts.mdx +30 -1
  99. package/package.json +7 -7
  100. package/src/__generated__/api/v1.ts +5 -1
  101. package/src/constants/serverRequirements.ts +48 -0
  102. package/src/projects/assignProjectAnnotationConfig.ts +78 -0
  103. package/src/projects/index.ts +8 -0
  104. package/src/projects/listProjectAnnotationConfigs.ts +85 -0
  105. package/src/projects/setProjectAnnotationConfigs.ts +86 -0
  106. package/src/projects/unassignProjectAnnotationConfig.ts +71 -0
  107. package/src/prompts/deletePromptVersionTag.ts +64 -0
  108. package/src/prompts/index.ts +2 -0
  109. package/src/prompts/upsertPromptVersionTag.ts +69 -0
  110. package/src/types/annotationConfigs.ts +37 -0
  111. package/src/utils/resolvePromptVersionId.ts +18 -0
package/docs/projects.mdx CHANGED
@@ -1,16 +1,21 @@
1
1
  ---
2
2
  title: "Projects"
3
- description: "List projects and manage project retention-policy assignments"
3
+ description: "List projects and manage project retention-policy and annotation-config assignments"
4
4
  ---
5
5
 
6
- The projects module lists Phoenix projects and assigns existing trace retention policies to them.
6
+ The projects module lists Phoenix projects, assigns existing trace retention policies to them, and manages which annotation configs they use.
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>
10
10
  <ul>
11
11
  <li><code>src/projects/getProjects.ts</code></li>
12
12
  <li><code>src/projects/setProjectRetentionPolicy.ts</code></li>
13
+ <li><code>src/projects/listProjectAnnotationConfigs.ts</code></li>
14
+ <li><code>src/projects/assignProjectAnnotationConfig.ts</code></li>
15
+ <li><code>src/projects/unassignProjectAnnotationConfig.ts</code></li>
16
+ <li><code>src/projects/setProjectAnnotationConfigs.ts</code></li>
13
17
  <li><code>src/types/projects.ts</code></li>
18
+ <li><code>src/types/annotationConfigs.ts</code></li>
14
19
  </ul>
15
20
  </section>
16
21
 
@@ -60,12 +65,60 @@ await setProjectRetentionPolicy({
60
65
 
61
66
  Assigning or resetting a retention policy requires an admin when authentication is enabled. Invalid policy GlobalIDs produce a `422` response, while callers without permission receive `403`; both are surfaced as `HttpError` instances by the client.
62
67
 
68
+ ## Assign Annotation Configs
69
+
70
+ Annotation configs define the annotations that can be recorded on a project's traces, spans, and sessions. These helpers change which existing configs a project uses. They don't create, update, or delete the configs themselves. All four require Phoenix server 17.16.0 or later.
71
+
72
+ ```ts
73
+ import {
74
+ assignProjectAnnotationConfig,
75
+ listProjectAnnotationConfigs,
76
+ setProjectAnnotationConfigs,
77
+ unassignProjectAnnotationConfig,
78
+ } from "@arizeai/phoenix-client/projects";
79
+
80
+ // Assign a config by name or GlobalID. Assigning an already-assigned config is a no-op.
81
+ const correctness = await assignProjectAnnotationConfig({
82
+ projectName: "support-bot",
83
+ configName: "correctness",
84
+ });
85
+
86
+ // Unassign a config. Unassigning a config that isn't assigned is a no-op.
87
+ await unassignProjectAnnotationConfig({
88
+ projectName: "support-bot",
89
+ configId: correctness.id,
90
+ });
91
+
92
+ // List every assigned config (pagination is handled automatically)
93
+ const configs = await listProjectAnnotationConfigs({ projectName: "support-bot" });
94
+
95
+ // Replace the whole set, keeping only categorical configs; configs not listed are unassigned
96
+ await setProjectAnnotationConfigs({
97
+ projectName: "support-bot",
98
+ configIds: configs
99
+ .filter((config) => config.type === "CATEGORICAL")
100
+ .map((config) => config.id),
101
+ });
102
+
103
+ // Clear every assignment
104
+ await setProjectAnnotationConfigs({ projectName: "support-bot", configIds: [] });
105
+ ```
106
+
107
+ Select the config with exactly one of `configName`, `configId`, or the shorthand `config`, which accepts either. Use `configId` if a config name contains `/`, because the server can't route it in the URL path.
108
+
109
+ `setProjectAnnotationConfigs` takes config GlobalIDs only, because the server doesn't accept names for this operation. Unknown or invalid config IDs produce a `422` response, and a missing project produces a `404`. The single-config helpers return a `404` when the project or the config is missing. The client surfaces all of these as `HttpError` instances.
110
+
63
111
  <section className="hidden" data-agent-context="source-map" aria-label="Source map">
64
112
  <h2>Source Map</h2>
65
113
  <ul>
66
114
  <li><code>src/projects/getProjects.ts</code></li>
67
115
  <li><code>src/projects/setProjectRetentionPolicy.ts</code></li>
116
+ <li><code>src/projects/listProjectAnnotationConfigs.ts</code></li>
117
+ <li><code>src/projects/assignProjectAnnotationConfig.ts</code></li>
118
+ <li><code>src/projects/unassignProjectAnnotationConfig.ts</code></li>
119
+ <li><code>src/projects/setProjectAnnotationConfigs.ts</code></li>
68
120
  <li><code>src/projects/index.ts</code></li>
69
121
  <li><code>src/types/projects.ts</code></li>
122
+ <li><code>src/types/annotationConfigs.ts</code></li>
70
123
  </ul>
71
124
  </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.14.0",
3
+ "version": "7.16.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.71",
120
- "@ai-sdk/otel": "^1.0.107",
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.2",
128
- "ai": "^7.0.107",
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.13",
134
- "vitest": "^5.0.1"
133
+ "tsx": "^4.23.15",
134
+ "vitest": "^5.0.2"
135
135
  },
136
136
  "peerDependencies": {
137
137
  "@anthropic-ai/sdk": "^0.35.0",
@@ -10580,10 +10580,14 @@ export interface operations {
10580
10580
  getSpans: {
10581
10581
  parameters: {
10582
10582
  query?: {
10583
- /** @description Pagination cursor (Span Global ID) */
10583
+ /** @description Pagination cursor: the next_cursor of a previous response with the same sort */
10584
10584
  cursor?: string | null;
10585
10585
  /** @description Maximum number of spans to return */
10586
10586
  limit?: number;
10587
+ /** @description Sort field. 'id' orders by insertion; 'start_time' orders by when the span started, breaking ties by id. */
10588
+ sort?: "id" | "start_time";
10589
+ /** @description Sort direction */
10590
+ order?: "asc" | "desc";
10587
10591
  /** @description Inclusive lower bound time */
10588
10592
  start_time?: string | null;
10589
10593
  /** @description Exclusive upper bound time */
@@ -199,6 +199,20 @@ export const DELETE_PROMPT: RouteRequirement = {
199
199
  minServerVersion: [13, 20, 0],
200
200
  };
201
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
+
202
216
  export const PATCH_PROMPT: RouteRequirement = {
203
217
  kind: "route",
204
218
  method: "PATCH",
@@ -206,6 +220,34 @@ export const PATCH_PROMPT: RouteRequirement = {
206
220
  minServerVersion: [19, 18, 0],
207
221
  };
208
222
 
223
+ export const LIST_PROJECT_ANNOTATION_CONFIGS: RouteRequirement = {
224
+ kind: "route",
225
+ method: "GET",
226
+ path: "/v1/projects/{project_identifier}/annotation_configs",
227
+ minServerVersion: [17, 16, 0],
228
+ };
229
+
230
+ export const SET_PROJECT_ANNOTATION_CONFIGS: RouteRequirement = {
231
+ kind: "route",
232
+ method: "PUT",
233
+ path: "/v1/projects/{project_identifier}/annotation_configs",
234
+ minServerVersion: [17, 16, 0],
235
+ };
236
+
237
+ export const ASSIGN_PROJECT_ANNOTATION_CONFIG: RouteRequirement = {
238
+ kind: "route",
239
+ method: "PUT",
240
+ path: "/v1/projects/{project_identifier}/annotation_configs/{config_identifier}",
241
+ minServerVersion: [17, 16, 0],
242
+ };
243
+
244
+ export const UNASSIGN_PROJECT_ANNOTATION_CONFIG: RouteRequirement = {
245
+ kind: "route",
246
+ method: "DELETE",
247
+ path: "/v1/projects/{project_identifier}/annotation_configs/{config_identifier}",
248
+ minServerVersion: [17, 16, 0],
249
+ };
250
+
209
251
  export const AGENT_SESSION_CREATE: RouteRequirement = {
210
252
  kind: "route",
211
253
  method: "POST",
@@ -293,7 +335,13 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
293
335
  ADD_SPAN_NOTE_IDENTIFIER,
294
336
  ADD_SESSION_NOTE_IDENTIFIER,
295
337
  DELETE_PROMPT,
338
+ UPSERT_PROMPT_VERSION_TAG,
339
+ DELETE_PROMPT_VERSION_TAG,
296
340
  PATCH_PROMPT,
341
+ LIST_PROJECT_ANNOTATION_CONFIGS,
342
+ SET_PROJECT_ANNOTATION_CONFIGS,
343
+ ASSIGN_PROJECT_ANNOTATION_CONFIG,
344
+ UNASSIGN_PROJECT_ANNOTATION_CONFIG,
297
345
  AGENT_SESSION_CREATE,
298
346
  AGENT_SESSION_LIST,
299
347
  AGENT_SESSION_GET,
@@ -0,0 +1,78 @@
1
+ import invariant from "tiny-invariant";
2
+
3
+ import { createClient } from "../client";
4
+ import { ASSIGN_PROJECT_ANNOTATION_CONFIG } from "../constants/serverRequirements";
5
+ import type {
6
+ AnnotationConfig,
7
+ AnnotationConfigIdentifier,
8
+ } from "../types/annotationConfigs";
9
+ import { resolveAnnotationConfigIdentifier } from "../types/annotationConfigs";
10
+ import type { ClientFn } from "../types/core";
11
+ import type { ProjectIdentifier } from "../types/projects";
12
+ import { resolveProjectIdentifier } from "../types/projects";
13
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
14
+
15
+ /**
16
+ * Parameters for assigning an annotation config to a project.
17
+ */
18
+ export type AssignProjectAnnotationConfigParams = ClientFn &
19
+ ProjectIdentifier &
20
+ AnnotationConfigIdentifier;
21
+
22
+ /**
23
+ * Assign an existing annotation config to a project.
24
+ *
25
+ * Assignment is idempotent: assigning a config that is already assigned to
26
+ * the project succeeds and returns the config.
27
+ *
28
+ * @param params - The project and annotation config to assign.
29
+ * @param params.project - A project name or GlobalID.
30
+ * @param params.projectId - A project GlobalID.
31
+ * @param params.projectName - A project name.
32
+ * @param params.config - An annotation config name or GlobalID.
33
+ * @param params.configId - An annotation config GlobalID.
34
+ * @param params.configName - An annotation config name.
35
+ * Use `configId` instead if the name may contain `/`, which the server
36
+ * cannot route.
37
+ * @param params.client - An optional Phoenix client instance.
38
+ * @returns The assigned annotation config.
39
+ * @throws {@link HttpError} when Phoenix rejects the request, e.g. with a 404
40
+ * if the project or annotation config does not exist.
41
+ *
42
+ * @requires Phoenix server >= 17.16.0
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { assignProjectAnnotationConfig } from "@arizeai/phoenix-client/projects";
47
+ *
48
+ * const config = await assignProjectAnnotationConfig({
49
+ * projectName: "support-bot",
50
+ * configName: "correctness",
51
+ * });
52
+ * ```
53
+ */
54
+ export async function assignProjectAnnotationConfig(
55
+ params: AssignProjectAnnotationConfigParams
56
+ ): Promise<AnnotationConfig> {
57
+ const client = params.client ?? createClient();
58
+ await ensureServerCapability({
59
+ client,
60
+ requirement: ASSIGN_PROJECT_ANNOTATION_CONFIG,
61
+ });
62
+
63
+ const { data, error } = await client.PUT(
64
+ "/v1/projects/{project_identifier}/annotation_configs/{config_identifier}",
65
+ {
66
+ params: {
67
+ path: {
68
+ project_identifier: resolveProjectIdentifier(params),
69
+ config_identifier: resolveAnnotationConfigIdentifier(params),
70
+ },
71
+ },
72
+ }
73
+ );
74
+
75
+ if (error) throw error;
76
+ invariant(data?.data, "Failed to assign annotation config to project");
77
+ return data.data;
78
+ }
@@ -1,2 +1,10 @@
1
+ export * from "./assignProjectAnnotationConfig";
1
2
  export * from "./getProjects";
3
+ export * from "./listProjectAnnotationConfigs";
4
+ export * from "./setProjectAnnotationConfigs";
2
5
  export * from "./setProjectRetentionPolicy";
6
+ export * from "./unassignProjectAnnotationConfig";
7
+ export type {
8
+ AnnotationConfig,
9
+ AnnotationConfigIdentifier,
10
+ } from "../types/annotationConfigs";
@@ -0,0 +1,85 @@
1
+ import invariant from "tiny-invariant";
2
+
3
+ import type { components } from "../__generated__/api/v1";
4
+ import { createClient } from "../client";
5
+ import { LIST_PROJECT_ANNOTATION_CONFIGS } from "../constants/serverRequirements";
6
+ import type { AnnotationConfig } from "../types/annotationConfigs";
7
+ import type { ClientFn } from "../types/core";
8
+ import type { ProjectIdentifier } from "../types/projects";
9
+ import { resolveProjectIdentifier } from "../types/projects";
10
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
11
+
12
+ /**
13
+ * Parameters for listing the annotation configs assigned to a project.
14
+ */
15
+ export type ListProjectAnnotationConfigsParams = ClientFn & ProjectIdentifier;
16
+
17
+ type ProjectAnnotationConfigsResponse =
18
+ components["schemas"]["GetProjectAnnotationConfigsResponseBody"];
19
+
20
+ const DEFAULT_PAGE_SIZE = 100;
21
+
22
+ /**
23
+ * List every annotation config assigned to a project, with automatic
24
+ * pagination handling.
25
+ *
26
+ * @param params - The project whose assigned configs should be listed.
27
+ * @param params.project - A project name or GlobalID.
28
+ * @param params.projectId - A project GlobalID.
29
+ * @param params.projectName - A project name.
30
+ * @param params.client - An optional Phoenix client instance.
31
+ * @returns The annotation configs assigned to the project.
32
+ * @throws {@link HttpError} when Phoenix rejects the request, e.g. with a 404
33
+ * if the project does not exist.
34
+ *
35
+ * @requires Phoenix server >= 17.16.0
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { listProjectAnnotationConfigs } from "@arizeai/phoenix-client/projects";
40
+ *
41
+ * const configs = await listProjectAnnotationConfigs({
42
+ * projectName: "support-bot",
43
+ * });
44
+ *
45
+ * for (const config of configs) {
46
+ * console.log(`${config.name} (${config.type})`);
47
+ * }
48
+ * ```
49
+ */
50
+ export async function listProjectAnnotationConfigs(
51
+ params: ListProjectAnnotationConfigsParams
52
+ ): Promise<AnnotationConfig[]> {
53
+ const client = params.client ?? createClient();
54
+ await ensureServerCapability({
55
+ client,
56
+ requirement: LIST_PROJECT_ANNOTATION_CONFIGS,
57
+ });
58
+ const projectIdentifier = resolveProjectIdentifier(params);
59
+
60
+ const configs: AnnotationConfig[] = [];
61
+ let cursor: string | null = null;
62
+
63
+ do {
64
+ const response: {
65
+ data?: ProjectAnnotationConfigsResponse;
66
+ error?: unknown;
67
+ } = await client.GET(
68
+ "/v1/projects/{project_identifier}/annotation_configs",
69
+ {
70
+ params: {
71
+ path: { project_identifier: projectIdentifier },
72
+ query: { cursor, limit: DEFAULT_PAGE_SIZE },
73
+ },
74
+ }
75
+ );
76
+
77
+ if (response.error) throw response.error;
78
+ invariant(response.data?.data, "Failed to list project annotation configs");
79
+
80
+ cursor = response.data.next_cursor ?? null;
81
+ configs.push(...response.data.data);
82
+ } while (cursor != null);
83
+
84
+ return configs;
85
+ }
@@ -0,0 +1,86 @@
1
+ import invariant from "tiny-invariant";
2
+
3
+ import { createClient } from "../client";
4
+ import { SET_PROJECT_ANNOTATION_CONFIGS } from "../constants/serverRequirements";
5
+ import type { AnnotationConfig } from "../types/annotationConfigs";
6
+ import type { ClientFn } from "../types/core";
7
+ import type { ProjectIdentifier } from "../types/projects";
8
+ import { resolveProjectIdentifier } from "../types/projects";
9
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
10
+
11
+ /**
12
+ * Parameters for replacing the annotation configs assigned to a project.
13
+ */
14
+ export type SetProjectAnnotationConfigsParams = ClientFn &
15
+ ProjectIdentifier & {
16
+ /**
17
+ * The GlobalIDs of every annotation config that should be assigned to the
18
+ * project. Configs not in this list are unassigned; an empty list clears
19
+ * all assignments.
20
+ */
21
+ configIds: string[];
22
+ };
23
+
24
+ /**
25
+ * Replace the full set of annotation configs assigned to a project.
26
+ *
27
+ * Configs in `configIds` that are not yet assigned are added, and assigned
28
+ * configs missing from `configIds` are removed. The annotation configs
29
+ * themselves are never deleted.
30
+ *
31
+ * @param params - The project and its desired annotation configs.
32
+ * @param params.project - A project name or GlobalID.
33
+ * @param params.projectId - A project GlobalID.
34
+ * @param params.projectName - A project name.
35
+ * @param params.configIds - The annotation config GlobalIDs to assign.
36
+ * @param params.client - An optional Phoenix client instance.
37
+ * @returns The annotation configs assigned to the project after the update.
38
+ * @throws {@link HttpError} when Phoenix rejects the request, e.g. with a 404
39
+ * if the project does not exist or a 422 if any config ID is invalid or
40
+ * missing.
41
+ *
42
+ * @requires Phoenix server >= 17.16.0
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { setProjectAnnotationConfigs } from "@arizeai/phoenix-client/projects";
47
+ *
48
+ * await setProjectAnnotationConfigs({
49
+ * projectName: "support-bot",
50
+ * configIds: ["Q2F0ZWdvcmljYWxBbm5vdGF0aW9uQ29uZmlnOjE="],
51
+ * });
52
+ *
53
+ * // Clear every assignment
54
+ * await setProjectAnnotationConfigs({
55
+ * projectName: "support-bot",
56
+ * configIds: [],
57
+ * });
58
+ * ```
59
+ */
60
+ export async function setProjectAnnotationConfigs(
61
+ params: SetProjectAnnotationConfigsParams
62
+ ): Promise<AnnotationConfig[]> {
63
+ const client = params.client ?? createClient();
64
+ await ensureServerCapability({
65
+ client,
66
+ requirement: SET_PROJECT_ANNOTATION_CONFIGS,
67
+ });
68
+
69
+ const { data, error } = await client.PUT(
70
+ "/v1/projects/{project_identifier}/annotation_configs",
71
+ {
72
+ params: {
73
+ path: {
74
+ project_identifier: resolveProjectIdentifier(params),
75
+ },
76
+ },
77
+ body: {
78
+ annotation_config_ids: params.configIds,
79
+ },
80
+ }
81
+ );
82
+
83
+ if (error) throw error;
84
+ invariant(data?.data, "Failed to set project annotation configs");
85
+ return data.data;
86
+ }
@@ -0,0 +1,71 @@
1
+ import { createClient } from "../client";
2
+ import { UNASSIGN_PROJECT_ANNOTATION_CONFIG } from "../constants/serverRequirements";
3
+ import type { AnnotationConfigIdentifier } from "../types/annotationConfigs";
4
+ import { resolveAnnotationConfigIdentifier } from "../types/annotationConfigs";
5
+ import type { ClientFn } from "../types/core";
6
+ import type { ProjectIdentifier } from "../types/projects";
7
+ import { resolveProjectIdentifier } from "../types/projects";
8
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
9
+
10
+ /**
11
+ * Parameters for unassigning an annotation config from a project.
12
+ */
13
+ export type UnassignProjectAnnotationConfigParams = ClientFn &
14
+ ProjectIdentifier &
15
+ AnnotationConfigIdentifier;
16
+
17
+ /**
18
+ * Unassign an annotation config from a project.
19
+ *
20
+ * Unassignment is idempotent: unassigning a config that is not assigned to
21
+ * the project succeeds. The annotation config itself is not deleted.
22
+ *
23
+ * @param params - The project and annotation config to unassign.
24
+ * @param params.project - A project name or GlobalID.
25
+ * @param params.projectId - A project GlobalID.
26
+ * @param params.projectName - A project name.
27
+ * @param params.config - An annotation config name or GlobalID.
28
+ * @param params.configId - An annotation config GlobalID.
29
+ * @param params.configName - An annotation config name.
30
+ * Use `configId` instead if the name may contain `/`, which the server
31
+ * cannot route.
32
+ * @param params.client - An optional Phoenix client instance.
33
+ * @returns A promise that resolves once the config is unassigned.
34
+ * @throws {@link HttpError} when Phoenix rejects the request, e.g. with a 404
35
+ * if the project or annotation config does not exist.
36
+ *
37
+ * @requires Phoenix server >= 17.16.0
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { unassignProjectAnnotationConfig } from "@arizeai/phoenix-client/projects";
42
+ *
43
+ * await unassignProjectAnnotationConfig({
44
+ * projectName: "support-bot",
45
+ * configName: "correctness",
46
+ * });
47
+ * ```
48
+ */
49
+ export async function unassignProjectAnnotationConfig(
50
+ params: UnassignProjectAnnotationConfigParams
51
+ ): Promise<void> {
52
+ const client = params.client ?? createClient();
53
+ await ensureServerCapability({
54
+ client,
55
+ requirement: UNASSIGN_PROJECT_ANNOTATION_CONFIG,
56
+ });
57
+
58
+ const { error } = await client.DELETE(
59
+ "/v1/projects/{project_identifier}/annotation_configs/{config_identifier}",
60
+ {
61
+ params: {
62
+ path: {
63
+ project_identifier: resolveProjectIdentifier(params),
64
+ config_identifier: resolveAnnotationConfigIdentifier(params),
65
+ },
66
+ },
67
+ }
68
+ );
69
+
70
+ if (error) throw error;
71
+ }
@@ -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
+ }
@@ -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";