@arizeai/phoenix-client 7.3.1 → 7.4.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 (31) hide show
  1. package/dist/esm/constants/serverRequirements.d.ts +1 -0
  2. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  3. package/dist/esm/constants/serverRequirements.js +7 -0
  4. package/dist/esm/constants/serverRequirements.js.map +1 -1
  5. package/dist/esm/prompts/index.d.ts +1 -0
  6. package/dist/esm/prompts/index.d.ts.map +1 -1
  7. package/dist/esm/prompts/index.js +1 -0
  8. package/dist/esm/prompts/index.js.map +1 -1
  9. package/dist/esm/prompts/updatePrompt.d.ts +51 -0
  10. package/dist/esm/prompts/updatePrompt.d.ts.map +1 -0
  11. package/dist/esm/prompts/updatePrompt.js +62 -0
  12. package/dist/esm/prompts/updatePrompt.js.map +1 -0
  13. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  14. package/dist/src/constants/serverRequirements.d.ts +1 -0
  15. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  16. package/dist/src/constants/serverRequirements.js +8 -1
  17. package/dist/src/constants/serverRequirements.js.map +1 -1
  18. package/dist/src/prompts/index.d.ts +1 -0
  19. package/dist/src/prompts/index.d.ts.map +1 -1
  20. package/dist/src/prompts/index.js +1 -0
  21. package/dist/src/prompts/index.js.map +1 -1
  22. package/dist/src/prompts/updatePrompt.d.ts +51 -0
  23. package/dist/src/prompts/updatePrompt.d.ts.map +1 -0
  24. package/dist/src/prompts/updatePrompt.js +66 -0
  25. package/dist/src/prompts/updatePrompt.js.map +1 -0
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/docs/prompts.mdx +18 -1
  28. package/package.json +1 -1
  29. package/src/constants/serverRequirements.ts +8 -0
  30. package/src/prompts/index.ts +1 -0
  31. package/src/prompts/updatePrompt.ts +95 -0
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, and adapt prompt versions to supported provider SDKs.
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, 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,22 @@ const prompt = await getPrompt({
43
43
 
44
44
  `prompt` can be selected by `{ name }`, `{ name, tag }`, or `{ versionId }`.
45
45
 
46
+ ## Update Description And Metadata
47
+
48
+ ```ts
49
+ import { updatePrompt } from "@arizeai/phoenix-client/prompts";
50
+
51
+ await updatePrompt({
52
+ promptIdentifier: "support-response",
53
+ description: "Customer support reply prompt",
54
+ metadata: { team: "ml", env: "production" },
55
+ });
56
+ ```
57
+
58
+ `promptIdentifier` is a prompt name or ID. Omit a field to leave it unchanged, and pass `description: null` to clear it. `metadata` replaces the existing metadata object as a whole rather than merging into it.
59
+
60
+ Requires a Phoenix server on 19.18.0 or later.
61
+
46
62
  ## Convert To Another SDK
47
63
 
48
64
  ```ts
@@ -67,6 +83,7 @@ Supported `sdk` targets:
67
83
  <li><code>src/prompts/createPrompt.ts</code></li>
68
84
  <li><code>src/prompts/getPrompt.ts</code></li>
69
85
  <li><code>src/prompts/listPrompts.ts</code></li>
86
+ <li><code>src/prompts/updatePrompt.ts</code></li>
70
87
  <li><code>src/prompts/sdks/toSDK.ts</code></li>
71
88
  <li><code>src/types/prompts.ts</code></li>
72
89
  </ul>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-client",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "description": "A client for the Phoenix API",
5
5
  "keywords": [
6
6
  "arize",
@@ -138,6 +138,13 @@ export const ADD_SESSION_NOTE_IDENTIFIER: ParameterRequirement = {
138
138
  minServerVersion: [15, 5, 0],
139
139
  };
140
140
 
141
+ export const PATCH_PROMPT: RouteRequirement = {
142
+ kind: "route",
143
+ method: "PATCH",
144
+ path: "/v1/prompts/{prompt_identifier}",
145
+ minServerVersion: [19, 18, 0],
146
+ };
147
+
141
148
  /**
142
149
  * Aggregate list of every known capability requirement.
143
150
  *
@@ -161,4 +168,5 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
161
168
  ADD_TRACE_NOTE_IDENTIFIER,
162
169
  ADD_SPAN_NOTE_IDENTIFIER,
163
170
  ADD_SESSION_NOTE_IDENTIFIER,
171
+ PATCH_PROMPT,
164
172
  ] as const;
@@ -1,4 +1,5 @@
1
1
  export * from "./getPrompt";
2
2
  export * from "./createPrompt";
3
3
  export * from "./listPrompts";
4
+ export * from "./updatePrompt";
4
5
  export * from "./sdks";
@@ -0,0 +1,95 @@
1
+ import invariant from "tiny-invariant";
2
+
3
+ import { createClient } from "../client";
4
+ import { PATCH_PROMPT } from "../constants/serverRequirements";
5
+ import { HttpError } from "../errors";
6
+ import type { ClientFn } from "../types/core";
7
+ import type { Prompt } from "../types/prompts";
8
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
9
+
10
+ /**
11
+ * Parameters for updating a prompt's description and/or metadata.
12
+ *
13
+ * Omit a field to leave it unchanged. Pass `description: null` to clear the
14
+ * description. `metadata` replaces the existing metadata object as a whole.
15
+ */
16
+ export interface UpdatePromptParams extends ClientFn {
17
+ /**
18
+ * The prompt name or ID.
19
+ */
20
+ promptIdentifier: string;
21
+ /**
22
+ * New description for the prompt. Pass `null` to clear it. Omit to leave
23
+ * unchanged.
24
+ */
25
+ description?: string | null;
26
+ /**
27
+ * New metadata object for the prompt (full replace). Omit to leave unchanged.
28
+ */
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+
32
+ /**
33
+ * Update a prompt's description and/or metadata via
34
+ * `PATCH /v1/prompts/{prompt_identifier}`.
35
+ *
36
+ * @param params - The parameters to update the prompt.
37
+ * @returns The updated prompt.
38
+ *
39
+ * @requires Phoenix server >= 19.18.0
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import { updatePrompt } from "@arizeai/phoenix-client/prompts";
44
+ *
45
+ * const prompt = await updatePrompt({
46
+ * promptIdentifier: "my-prompt",
47
+ * description: "Production classifier",
48
+ * metadata: { team: "ml", env: "prod" },
49
+ * });
50
+ *
51
+ * // Clear the description only
52
+ * await updatePrompt({
53
+ * promptIdentifier: "my-prompt",
54
+ * description: null,
55
+ * });
56
+ * ```
57
+ */
58
+ export async function updatePrompt({
59
+ client: _client,
60
+ promptIdentifier,
61
+ description,
62
+ metadata,
63
+ }: UpdatePromptParams): Promise<Prompt> {
64
+ if (description === undefined && metadata === undefined) {
65
+ throw new Error(
66
+ "At least one of description or metadata must be provided."
67
+ );
68
+ }
69
+
70
+ const client = _client ?? createClient();
71
+ await ensureServerCapability({ client, requirement: PATCH_PROMPT });
72
+
73
+ try {
74
+ const response = await client.PATCH("/v1/prompts/{prompt_identifier}", {
75
+ params: {
76
+ path: {
77
+ prompt_identifier: promptIdentifier,
78
+ },
79
+ },
80
+ body: {
81
+ ...(description !== undefined ? { description } : {}),
82
+ ...(metadata !== undefined ? { metadata } : {}),
83
+ },
84
+ });
85
+ invariant(response.data?.data, "Failed to update prompt");
86
+ return response.data.data;
87
+ } catch (error) {
88
+ if (error instanceof HttpError && error.status === 404) {
89
+ throw new Error(`Prompt not found: ${promptIdentifier}`, {
90
+ cause: error,
91
+ });
92
+ }
93
+ throw error;
94
+ }
95
+ }