@arizeai/phoenix-client 7.3.0 → 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.
- package/dist/esm/__generated__/api/v1.d.ts +548 -0
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +1 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +7 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/prompts/index.d.ts +1 -0
- package/dist/esm/prompts/index.d.ts.map +1 -1
- package/dist/esm/prompts/index.js +1 -0
- package/dist/esm/prompts/index.js.map +1 -1
- package/dist/esm/prompts/updatePrompt.d.ts +51 -0
- package/dist/esm/prompts/updatePrompt.d.ts.map +1 -0
- package/dist/esm/prompts/updatePrompt.js +62 -0
- package/dist/esm/prompts/updatePrompt.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/src/__generated__/api/v1.d.ts +548 -0
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +1 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +8 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/prompts/index.d.ts +1 -0
- package/dist/src/prompts/index.d.ts.map +1 -1
- package/dist/src/prompts/index.js +1 -0
- package/dist/src/prompts/index.js.map +1 -1
- package/dist/src/prompts/updatePrompt.d.ts +51 -0
- package/dist/src/prompts/updatePrompt.d.ts.map +1 -0
- package/dist/src/prompts/updatePrompt.js +66 -0
- package/dist/src/prompts/updatePrompt.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/prompts.mdx +18 -1
- package/package.json +11 -11
- package/src/__generated__/api/v1.ts +548 -0
- package/src/constants/serverRequirements.ts +8 -0
- package/src/prompts/index.ts +1 -0
- package/src/prompts/updatePrompt.ts +95 -0
|
@@ -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;
|
package/src/prompts/index.ts
CHANGED
|
@@ -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
|
+
}
|