@arizeai/phoenix-client 7.15.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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +47 -1
  3. package/dist/esm/__generated__/api/v1.d.ts +0 -9
  4. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  5. package/dist/esm/constants/serverRequirements.d.ts +4 -0
  6. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  7. package/dist/esm/constants/serverRequirements.js +28 -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/tsconfig.esm.tsbuildinfo +1 -1
  30. package/dist/esm/types/annotationConfigs.d.ts +35 -0
  31. package/dist/esm/types/annotationConfigs.d.ts.map +1 -0
  32. package/dist/esm/types/annotationConfigs.js +12 -0
  33. package/dist/esm/types/annotationConfigs.js.map +1 -0
  34. package/dist/src/__generated__/api/v1.d.ts +0 -9
  35. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  36. package/dist/src/constants/serverRequirements.d.ts +4 -0
  37. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  38. package/dist/src/constants/serverRequirements.js +29 -1
  39. package/dist/src/constants/serverRequirements.js.map +1 -1
  40. package/dist/src/projects/assignProjectAnnotationConfig.d.ts +41 -0
  41. package/dist/src/projects/assignProjectAnnotationConfig.d.ts.map +1 -0
  42. package/dist/src/projects/assignProjectAnnotationConfig.js +65 -0
  43. package/dist/src/projects/assignProjectAnnotationConfig.js.map +1 -0
  44. package/dist/src/projects/index.d.ts +5 -0
  45. package/dist/src/projects/index.d.ts.map +1 -1
  46. package/dist/src/projects/index.js +4 -0
  47. package/dist/src/projects/index.js.map +1 -1
  48. package/dist/src/projects/listProjectAnnotationConfigs.d.ts +37 -0
  49. package/dist/src/projects/listProjectAnnotationConfigs.d.ts.map +1 -0
  50. package/dist/src/projects/listProjectAnnotationConfigs.js +67 -0
  51. package/dist/src/projects/listProjectAnnotationConfigs.js.map +1 -0
  52. package/dist/src/projects/setProjectAnnotationConfigs.d.ts +52 -0
  53. package/dist/src/projects/setProjectAnnotationConfigs.d.ts.map +1 -0
  54. package/dist/src/projects/setProjectAnnotationConfigs.js +70 -0
  55. package/dist/src/projects/setProjectAnnotationConfigs.js.map +1 -0
  56. package/dist/src/projects/unassignProjectAnnotationConfig.d.ts +41 -0
  57. package/dist/src/projects/unassignProjectAnnotationConfig.d.ts.map +1 -0
  58. package/dist/src/projects/unassignProjectAnnotationConfig.js +59 -0
  59. package/dist/src/projects/unassignProjectAnnotationConfig.js.map +1 -0
  60. package/dist/src/types/annotationConfigs.d.ts +35 -0
  61. package/dist/src/types/annotationConfigs.d.ts.map +1 -0
  62. package/dist/src/types/annotationConfigs.js +15 -0
  63. package/dist/src/types/annotationConfigs.js.map +1 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/docs/projects.mdx +55 -2
  66. package/package.json +1 -1
  67. package/src/__generated__/api/v1.ts +0 -9
  68. package/src/constants/serverRequirements.ts +32 -0
  69. package/src/projects/assignProjectAnnotationConfig.ts +78 -0
  70. package/src/projects/index.ts +8 -0
  71. package/src/projects/listProjectAnnotationConfigs.ts +85 -0
  72. package/src/projects/setProjectAnnotationConfigs.ts +86 -0
  73. package/src/projects/unassignProjectAnnotationConfig.ts +71 -0
  74. package/src/types/annotationConfigs.ts +37 -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-client",
3
- "version": "7.15.0",
3
+ "version": "7.16.0",
4
4
  "description": "A client for the Phoenix API",
5
5
  "keywords": [
6
6
  "arize",
@@ -3334,11 +3334,6 @@ 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;
3342
3337
  /**
3343
3338
  * Repetitions
3344
3339
  * @description Number of times the experiment is repeated
@@ -9388,10 +9383,6 @@ export interface operations {
9388
9383
  cursor?: string | null;
9389
9384
  /** @description The max number of experiments to return at a time. */
9390
9385
  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;
9395
9386
  };
9396
9387
  header?: never;
9397
9388
  path: {
@@ -220,6 +220,34 @@ export const PATCH_PROMPT: RouteRequirement = {
220
220
  minServerVersion: [19, 18, 0],
221
221
  };
222
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
+
223
251
  export const AGENT_SESSION_CREATE: RouteRequirement = {
224
252
  kind: "route",
225
253
  method: "POST",
@@ -310,6 +338,10 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
310
338
  UPSERT_PROMPT_VERSION_TAG,
311
339
  DELETE_PROMPT_VERSION_TAG,
312
340
  PATCH_PROMPT,
341
+ LIST_PROJECT_ANNOTATION_CONFIGS,
342
+ SET_PROJECT_ANNOTATION_CONFIGS,
343
+ ASSIGN_PROJECT_ANNOTATION_CONFIG,
344
+ UNASSIGN_PROJECT_ANNOTATION_CONFIG,
313
345
  AGENT_SESSION_CREATE,
314
346
  AGENT_SESSION_LIST,
315
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,37 @@
1
+ import type { components } from "../__generated__/api/v1";
2
+
3
+ /**
4
+ * An annotation configuration as returned by the Phoenix REST API.
5
+ */
6
+ export type AnnotationConfig =
7
+ | components["schemas"]["CategoricalAnnotationConfig"]
8
+ | components["schemas"]["ContinuousAnnotationConfig"]
9
+ | components["schemas"]["FreeformAnnotationConfig"];
10
+
11
+ /**
12
+ * Identifies an annotation configuration. Accepts any of:
13
+ * - `config` — an annotation config ID or name (the server accepts either)
14
+ * - `configId` — an explicit annotation config ID
15
+ * - `configName` — an explicit annotation config name
16
+ *
17
+ * Exactly one of these may be given. All three are sent to the server as the
18
+ * same `config_identifier`, which is tried as a GlobalID before a name. Prefer
19
+ * `configId` when a name may contain `/`, which the server cannot route in a
20
+ * path parameter.
21
+ */
22
+ export type AnnotationConfigIdentifier =
23
+ | { config: string; configId?: never; configName?: never }
24
+ | { configId: string; config?: never; configName?: never }
25
+ | { configName: string; config?: never; configId?: never };
26
+
27
+ /**
28
+ * Resolves an {@link AnnotationConfigIdentifier} union to a plain string
29
+ * suitable for the REST `config_identifier` path parameter.
30
+ */
31
+ export function resolveAnnotationConfigIdentifier(
32
+ identifier: AnnotationConfigIdentifier
33
+ ): string {
34
+ if (identifier.config !== undefined) return identifier.config;
35
+ if (identifier.configId !== undefined) return identifier.configId;
36
+ return identifier.configName;
37
+ }