@arizeai/phoenix-cli 0.3.1 → 0.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/build/cli.d.ts.map +1 -1
- package/build/cli.js +3 -1
- package/build/cli.js.map +1 -1
- package/build/commands/formatPrompt.d.ts +16 -0
- package/build/commands/formatPrompt.d.ts.map +1 -0
- package/build/commands/formatPrompt.js +160 -0
- package/build/commands/formatPrompt.js.map +1 -0
- package/build/commands/formatPrompts.d.ts +16 -0
- package/build/commands/formatPrompts.d.ts.map +1 -0
- package/build/commands/formatPrompts.js +36 -0
- package/build/commands/formatPrompts.js.map +1 -0
- package/build/commands/index.d.ts +2 -0
- package/build/commands/index.d.ts.map +1 -1
- package/build/commands/index.js +2 -0
- package/build/commands/index.js.map +1 -1
- package/build/commands/prompt.d.ts +6 -0
- package/build/commands/prompt.d.ts.map +1 -0
- package/build/commands/prompt.js +109 -0
- package/build/commands/prompt.js.map +1 -0
- package/build/commands/prompts.d.ts +6 -0
- package/build/commands/prompts.d.ts.map +1 -0
- package/build/commands/prompts.js +97 -0
- package/build/commands/prompts.js.map +1 -0
- package/package.json +2 -2
package/build/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAiBA,wBAAgB,IAAI,SAyBnB"}
|
package/build/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createDatasetCommand, createDatasetsCommand, createExperimentCommand, createExperimentsCommand, createProjectsCommand, createTraceCommand, createTracesCommand, } from "./commands/index.js";
|
|
2
|
+
import { createDatasetCommand, createDatasetsCommand, createExperimentCommand, createExperimentsCommand, createProjectsCommand, createPromptCommand, createPromptsCommand, createTraceCommand, createTracesCommand, } from "./commands/index.js";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
// Phoenix CLI Main Logic
|
|
5
5
|
export function main() {
|
|
@@ -16,6 +16,8 @@ export function main() {
|
|
|
16
16
|
program.addCommand(createDatasetCommand());
|
|
17
17
|
program.addCommand(createExperimentsCommand());
|
|
18
18
|
program.addCommand(createExperimentCommand());
|
|
19
|
+
program.addCommand(createPromptsCommand());
|
|
20
|
+
program.addCommand(createPromptCommand());
|
|
19
21
|
// Show help if no command provided
|
|
20
22
|
if (process.argv.length === 2) {
|
|
21
23
|
program.help();
|
package/build/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,yBAAyB;AACzB,MAAM,UAAU,IAAI;IAClB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,IAAI,CAAC;SACV,WAAW,CAAC,sDAAsD,CAAC;SACnE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC/C,O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;AAClB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { componentsV1 } from "@arizeai/phoenix-client";
|
|
2
|
+
export type OutputFormat = "pretty" | "json" | "raw" | "text";
|
|
3
|
+
type PromptVersion = componentsV1["schemas"]["PromptVersion"];
|
|
4
|
+
export interface FormatPromptOutputOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Prompt version to format.
|
|
7
|
+
*/
|
|
8
|
+
promptVersion: PromptVersion;
|
|
9
|
+
/**
|
|
10
|
+
* Output format. Defaults to `"pretty"`.
|
|
11
|
+
*/
|
|
12
|
+
format?: OutputFormat;
|
|
13
|
+
}
|
|
14
|
+
export declare function formatPromptOutput({ promptVersion, format, }: FormatPromptOutputOptions): string;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=formatPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrompt.d.ts","sourceRoot":"","sources":["../../src/commands/formatPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9D,KAAK,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;AAW9D,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,aAAa,EACb,MAAM,GACP,EAAE,yBAAyB,GAAG,MAAM,CAYpC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export function formatPromptOutput({ promptVersion, format, }) {
|
|
2
|
+
const selected = format || "pretty";
|
|
3
|
+
if (selected === "raw") {
|
|
4
|
+
return JSON.stringify(promptVersion);
|
|
5
|
+
}
|
|
6
|
+
if (selected === "json") {
|
|
7
|
+
return JSON.stringify(promptVersion, null, 2);
|
|
8
|
+
}
|
|
9
|
+
if (selected === "text") {
|
|
10
|
+
return formatPromptText(promptVersion);
|
|
11
|
+
}
|
|
12
|
+
return formatPromptPretty(promptVersion);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Format a prompt version as plain text suitable for piping.
|
|
16
|
+
* Chat templates are formatted with XML-style tags.
|
|
17
|
+
* String templates return the raw template string.
|
|
18
|
+
*/
|
|
19
|
+
function formatPromptText(promptVersion) {
|
|
20
|
+
const template = promptVersion.template;
|
|
21
|
+
if (template.type === "string") {
|
|
22
|
+
return template.template;
|
|
23
|
+
}
|
|
24
|
+
// Chat template - format with XML-style tags
|
|
25
|
+
const lines = [];
|
|
26
|
+
for (const message of template.messages) {
|
|
27
|
+
const role = message.role;
|
|
28
|
+
const content = extractMessageContent(message);
|
|
29
|
+
lines.push(`<${role}>${content}</${role}>`);
|
|
30
|
+
}
|
|
31
|
+
return lines.join("\n");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extract text content from a prompt message.
|
|
35
|
+
* Handles both string content and array of content parts.
|
|
36
|
+
*/
|
|
37
|
+
function extractMessageContent(message) {
|
|
38
|
+
if (typeof message.content === "string") {
|
|
39
|
+
return message.content;
|
|
40
|
+
}
|
|
41
|
+
// Array of content parts
|
|
42
|
+
const textParts = [];
|
|
43
|
+
for (const part of message.content) {
|
|
44
|
+
if (part.type === "text") {
|
|
45
|
+
textParts.push(part.text);
|
|
46
|
+
}
|
|
47
|
+
else if (part.type === "tool_call") {
|
|
48
|
+
const toolCall = part;
|
|
49
|
+
// tool_call contains name and arguments directly
|
|
50
|
+
textParts.push(`[Tool Call: ${toolCall.tool_call.name}(${toolCall.tool_call.arguments})]`);
|
|
51
|
+
}
|
|
52
|
+
else if (part.type === "tool_result") {
|
|
53
|
+
const toolResult = part;
|
|
54
|
+
// tool_result can be boolean | number | string | object
|
|
55
|
+
const resultStr = typeof toolResult.tool_result === "object"
|
|
56
|
+
? JSON.stringify(toolResult.tool_result)
|
|
57
|
+
: String(toolResult.tool_result);
|
|
58
|
+
textParts.push(`[Tool Result: ${resultStr}]`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return textParts.join("\n");
|
|
62
|
+
}
|
|
63
|
+
function formatPromptPretty(promptVersion) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
lines.push(`┌─ Prompt Version: ${promptVersion.id}`);
|
|
66
|
+
lines.push(`│`);
|
|
67
|
+
lines.push(`│ Model: ${promptVersion.model_provider} / ${promptVersion.model_name}`);
|
|
68
|
+
lines.push(`│ Template Type: ${promptVersion.template_type}`);
|
|
69
|
+
lines.push(`│ Template Format: ${promptVersion.template_format}`);
|
|
70
|
+
if (promptVersion.description) {
|
|
71
|
+
lines.push(`│ Description: ${promptVersion.description}`);
|
|
72
|
+
}
|
|
73
|
+
lines.push(`│`);
|
|
74
|
+
lines.push(`│ Template:`);
|
|
75
|
+
const template = promptVersion.template;
|
|
76
|
+
if (template.type === "string") {
|
|
77
|
+
const templateLines = template.template.split("\n");
|
|
78
|
+
for (const line of templateLines) {
|
|
79
|
+
lines.push(`│ ${line}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Chat template
|
|
84
|
+
for (const message of template.messages) {
|
|
85
|
+
const role = message.role.toUpperCase();
|
|
86
|
+
const content = extractMessageContent(message);
|
|
87
|
+
const contentLines = content.split("\n");
|
|
88
|
+
lines.push(`│ [${role}]`);
|
|
89
|
+
for (const line of contentLines) {
|
|
90
|
+
lines.push(`│ ${line}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Invocation parameters
|
|
95
|
+
if (promptVersion.invocation_parameters) {
|
|
96
|
+
lines.push(`│`);
|
|
97
|
+
lines.push(`│ Invocation Parameters:`);
|
|
98
|
+
const params = promptVersion.invocation_parameters;
|
|
99
|
+
const providerParams = params[params.type];
|
|
100
|
+
if (providerParams && typeof providerParams === "object") {
|
|
101
|
+
for (const [key, value] of Object.entries(providerParams)) {
|
|
102
|
+
lines.push(`│ ${key}: ${JSON.stringify(value)}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Tools
|
|
107
|
+
if (promptVersion.tools && promptVersion.tools.tools.length > 0) {
|
|
108
|
+
lines.push(`│`);
|
|
109
|
+
lines.push(`│ Tools:`);
|
|
110
|
+
// Tool choice
|
|
111
|
+
if (promptVersion.tools.tool_choice) {
|
|
112
|
+
const choice = promptVersion.tools.tool_choice;
|
|
113
|
+
if (choice.type === "specific_function") {
|
|
114
|
+
lines.push(`│ Tool Choice: ${choice.function_name} (required)`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
lines.push(`│ Tool Choice: ${choice.type}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const tool of promptVersion.tools.tools) {
|
|
121
|
+
if (tool.type === "function") {
|
|
122
|
+
const fn = tool.function;
|
|
123
|
+
lines.push(`│`);
|
|
124
|
+
lines.push(`│ ┌─ ${fn.name}`);
|
|
125
|
+
if (fn.description) {
|
|
126
|
+
lines.push(`│ │ ${fn.description}`);
|
|
127
|
+
}
|
|
128
|
+
if (fn.parameters) {
|
|
129
|
+
lines.push(`│ │`);
|
|
130
|
+
lines.push(`│ │ Parameters:`);
|
|
131
|
+
const params = fn.parameters;
|
|
132
|
+
if (params.properties) {
|
|
133
|
+
const required = params.required || [];
|
|
134
|
+
for (const [propName, propDef] of Object.entries(params.properties)) {
|
|
135
|
+
const isRequired = required.includes(propName);
|
|
136
|
+
const reqMarker = isRequired ? " (required)" : "";
|
|
137
|
+
const typeStr = propDef.type || "any";
|
|
138
|
+
const enumStr = propDef.enum && propDef.enum.length > 0
|
|
139
|
+
? ` [${propDef.enum.join(", ")}]`
|
|
140
|
+
: "";
|
|
141
|
+
lines.push(`│ │ ${propName}: ${typeStr}${enumStr}${reqMarker}`);
|
|
142
|
+
if (propDef.description) {
|
|
143
|
+
lines.push(`│ │ └─ ${propDef.description}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
lines.push(`│ └─`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Response format
|
|
153
|
+
if (promptVersion.response_format) {
|
|
154
|
+
lines.push(`│`);
|
|
155
|
+
lines.push(`│ Response Format: ${promptVersion.response_format.json_schema.name}`);
|
|
156
|
+
}
|
|
157
|
+
lines.push(`└─`);
|
|
158
|
+
return lines.join("\n");
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=formatPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrompt.js","sourceRoot":"","sources":["../../src/commands/formatPrompt.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,kBAAkB,CAAC,EACjC,aAAa,EACb,MAAM,GACoB;IAC1B,MAAM,QAAQ,GAAG,MAAM,IAAI,QAAQ,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,aAA4B;IACpD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;IAExC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAA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/phoenix-client";
|
|
2
|
+
export type OutputFormat = "pretty" | "json" | "raw";
|
|
3
|
+
type Prompt = componentsV1["schemas"]["Prompt"];
|
|
4
|
+
export interface FormatPromptsOutputOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Prompts to format.
|
|
7
|
+
*/
|
|
8
|
+
prompts: Prompt[];
|
|
9
|
+
/**
|
|
10
|
+
* Output format. Defaults to `"pretty"`.
|
|
11
|
+
*/
|
|
12
|
+
format?: OutputFormat;
|
|
13
|
+
}
|
|
14
|
+
export declare function formatPromptsOutput({ prompts, format, }: FormatPromptsOutputOptions): string;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=formatPrompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrompts.d.ts","sourceRoot":"","sources":["../../src/commands/formatPrompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAErD,KAAK,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEhD,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,GACP,EAAE,0BAA0B,GAAG,MAAM,CASrC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function formatPromptsOutput({ prompts, format, }) {
|
|
2
|
+
const selected = format || "pretty";
|
|
3
|
+
if (selected === "raw") {
|
|
4
|
+
return JSON.stringify(prompts);
|
|
5
|
+
}
|
|
6
|
+
if (selected === "json") {
|
|
7
|
+
return JSON.stringify(prompts, null, 2);
|
|
8
|
+
}
|
|
9
|
+
return formatPromptsPretty(prompts);
|
|
10
|
+
}
|
|
11
|
+
function formatPromptsPretty(prompts) {
|
|
12
|
+
if (prompts.length === 0) {
|
|
13
|
+
return "No prompts found";
|
|
14
|
+
}
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push("Prompts:");
|
|
17
|
+
lines.push("");
|
|
18
|
+
for (const prompt of prompts) {
|
|
19
|
+
const desc = prompt.description === null ||
|
|
20
|
+
prompt.description === undefined ||
|
|
21
|
+
prompt.description === ""
|
|
22
|
+
? ""
|
|
23
|
+
: ` — ${prompt.description}`;
|
|
24
|
+
lines.push(`┌─ ${prompt.name} (${prompt.id})`);
|
|
25
|
+
if (desc) {
|
|
26
|
+
lines.push(`│ Description:${desc}`);
|
|
27
|
+
}
|
|
28
|
+
if (prompt.metadata && Object.keys(prompt.metadata).length > 0) {
|
|
29
|
+
lines.push(`│ Metadata: ${JSON.stringify(prompt.metadata)}`);
|
|
30
|
+
}
|
|
31
|
+
lines.push(`└─`);
|
|
32
|
+
lines.push("");
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n").trimEnd();
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=formatPrompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrompts.js","sourceRoot":"","sources":["../../src/commands/formatPrompts.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,GACqB;IAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,QAAQ,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AA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"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/build/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/commands/prompt.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqIpC;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAmB7C"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { createPhoenixClient } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatPromptOutput } from "./formatPrompt.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
/**
|
|
7
|
+
* Fetch a prompt version from Phoenix
|
|
8
|
+
*/
|
|
9
|
+
async function fetchPromptVersion(client, promptIdentifier, options = {}) {
|
|
10
|
+
// If version ID is provided, fetch that specific version
|
|
11
|
+
if (options.versionId) {
|
|
12
|
+
const response = await client.GET(`/v1/prompt_versions/{prompt_version_id}`, {
|
|
13
|
+
params: { path: { prompt_version_id: options.versionId } },
|
|
14
|
+
});
|
|
15
|
+
if (response.error || !response.data) {
|
|
16
|
+
throw new Error(`Failed to fetch prompt version: ${response.error || "Unknown error"}`);
|
|
17
|
+
}
|
|
18
|
+
return response.data.data;
|
|
19
|
+
}
|
|
20
|
+
// If tag is provided, fetch by tag
|
|
21
|
+
if (options.tag) {
|
|
22
|
+
const response = await client.GET(`/v1/prompts/{prompt_identifier}/tags/{tag_name}`, {
|
|
23
|
+
params: {
|
|
24
|
+
path: { prompt_identifier: promptIdentifier, tag_name: options.tag },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (response.error || !response.data) {
|
|
28
|
+
throw new Error(`Failed to fetch prompt with tag "${options.tag}": ${response.error || "Unknown error"}`);
|
|
29
|
+
}
|
|
30
|
+
return response.data.data;
|
|
31
|
+
}
|
|
32
|
+
// Default: fetch latest version
|
|
33
|
+
const response = await client.GET(`/v1/prompts/{prompt_identifier}/latest`, {
|
|
34
|
+
params: {
|
|
35
|
+
path: { prompt_identifier: promptIdentifier },
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (response.error || !response.data) {
|
|
39
|
+
throw new Error(`Failed to fetch prompt "${promptIdentifier}": ${response.error || "Unknown error"}`);
|
|
40
|
+
}
|
|
41
|
+
return response.data.data;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Prompt command handler
|
|
45
|
+
*/
|
|
46
|
+
async function promptHandler(promptIdentifier, options) {
|
|
47
|
+
try {
|
|
48
|
+
// Resolve configuration
|
|
49
|
+
const config = resolveConfig({
|
|
50
|
+
cliOptions: {
|
|
51
|
+
endpoint: options.endpoint,
|
|
52
|
+
apiKey: options.apiKey,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
// Validate that we have endpoint
|
|
56
|
+
if (!config.endpoint) {
|
|
57
|
+
const errors = [
|
|
58
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
59
|
+
];
|
|
60
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// Create client
|
|
64
|
+
const client = createPhoenixClient({ config });
|
|
65
|
+
writeProgress({
|
|
66
|
+
message: `Fetching prompt "${promptIdentifier}"...`,
|
|
67
|
+
noProgress: !options.progress,
|
|
68
|
+
});
|
|
69
|
+
// Fetch prompt version
|
|
70
|
+
const promptVersion = await fetchPromptVersion(client, promptIdentifier, {
|
|
71
|
+
tag: options.tag,
|
|
72
|
+
versionId: options.version,
|
|
73
|
+
});
|
|
74
|
+
writeProgress({
|
|
75
|
+
message: `Found prompt version ${promptVersion.id}`,
|
|
76
|
+
noProgress: !options.progress,
|
|
77
|
+
});
|
|
78
|
+
// Output prompt
|
|
79
|
+
const output = formatPromptOutput({
|
|
80
|
+
promptVersion,
|
|
81
|
+
format: options.format,
|
|
82
|
+
});
|
|
83
|
+
writeOutput({ message: output });
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
writeError({
|
|
87
|
+
message: `Error fetching prompt: ${error instanceof Error ? error.message : String(error)}`,
|
|
88
|
+
});
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create the prompt command
|
|
94
|
+
*/
|
|
95
|
+
export function createPromptCommand() {
|
|
96
|
+
const command = new Command("prompt");
|
|
97
|
+
command
|
|
98
|
+
.description("Show a Phoenix prompt")
|
|
99
|
+
.argument("<prompt_identifier>", "Prompt name or ID")
|
|
100
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
101
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
102
|
+
.option("--format <format>", "Output format: pretty, json, raw, or text", "pretty")
|
|
103
|
+
.option("--no-progress", "Disable progress indicators")
|
|
104
|
+
.option("--tag <tag>", "Get prompt version by tag name")
|
|
105
|
+
.option("--version <version_id>", "Get specific prompt version by ID")
|
|
106
|
+
.action(promptHandler);
|
|
107
|
+
return command;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/commands/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAqB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAC/B,MAAqB,EACrB,gBAAwB,EACxB,UAAgD,EAAE;IAElD,yDAAyD;IACzD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAC/B,yCAAyC,EACzC;YACE,MAAM,EAAE,EAAE,IAAI,EA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AC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC;YACT,OAAO,EAAE,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAC5F,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtC,OAAO;SACJ,WAAW,CAAC,uBAAuB,CAAC;SACpC,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACpD,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;SAClD,MAAM,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;SAC/D,MAAM,CACL,mBAAmB,EACnB,2CAA2C,EAC3C,QAAQ,CACT;SACA,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;SACtD,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC;SACvD,MAAM,CAAC,wBAAwB,EAAE,mCAAmC,CAAC;SACrE,MAAM,CAAC,aAAa,CAAC,CAAC;IAEzB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/commands/prompts.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuGpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAiB9C"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createPhoenixClient } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatPromptsOutput } from "./formatPrompts.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
/**
|
|
7
|
+
* Fetch all prompts from Phoenix
|
|
8
|
+
*/
|
|
9
|
+
async function fetchPrompts(client, options = {}) {
|
|
10
|
+
const allPrompts = [];
|
|
11
|
+
let cursor;
|
|
12
|
+
const pageLimit = options.limit || 100;
|
|
13
|
+
do {
|
|
14
|
+
const response = await client.GET("/v1/prompts", {
|
|
15
|
+
params: {
|
|
16
|
+
query: {
|
|
17
|
+
cursor,
|
|
18
|
+
limit: pageLimit,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (response.error || !response.data) {
|
|
23
|
+
throw new Error(`Failed to fetch prompts: ${response.error}`);
|
|
24
|
+
}
|
|
25
|
+
allPrompts.push(...response.data.data);
|
|
26
|
+
cursor = response.data.next_cursor || undefined;
|
|
27
|
+
// If we've fetched enough for the requested limit, stop
|
|
28
|
+
if (options.limit && allPrompts.length >= options.limit) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
} while (cursor);
|
|
32
|
+
return allPrompts;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Prompts command handler
|
|
36
|
+
*/
|
|
37
|
+
async function promptsHandler(options) {
|
|
38
|
+
try {
|
|
39
|
+
// Resolve configuration
|
|
40
|
+
const config = resolveConfig({
|
|
41
|
+
cliOptions: {
|
|
42
|
+
endpoint: options.endpoint,
|
|
43
|
+
apiKey: options.apiKey,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
// Validate that we have endpoint
|
|
47
|
+
if (!config.endpoint) {
|
|
48
|
+
const errors = [
|
|
49
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
50
|
+
];
|
|
51
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
// Create client
|
|
55
|
+
const client = createPhoenixClient({ config });
|
|
56
|
+
writeProgress({
|
|
57
|
+
message: "Fetching prompts...",
|
|
58
|
+
noProgress: !options.progress,
|
|
59
|
+
});
|
|
60
|
+
// Fetch prompts
|
|
61
|
+
const prompts = await fetchPrompts(client, {
|
|
62
|
+
limit: options.limit,
|
|
63
|
+
});
|
|
64
|
+
writeProgress({
|
|
65
|
+
message: `Found ${prompts.length} prompt(s)`,
|
|
66
|
+
noProgress: !options.progress,
|
|
67
|
+
});
|
|
68
|
+
// Output prompts
|
|
69
|
+
const output = formatPromptsOutput({
|
|
70
|
+
prompts,
|
|
71
|
+
format: options.format,
|
|
72
|
+
});
|
|
73
|
+
writeOutput({ message: output });
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
writeError({
|
|
77
|
+
message: `Error fetching prompts: ${error instanceof Error ? error.message : String(error)}`,
|
|
78
|
+
});
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create the prompts command
|
|
84
|
+
*/
|
|
85
|
+
export function createPromptsCommand() {
|
|
86
|
+
const command = new Command("prompts");
|
|
87
|
+
command
|
|
88
|
+
.description("List all available Phoenix prompts")
|
|
89
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
90
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
91
|
+
.option("--format <format>", "Output format: pretty, json, or raw", "pretty")
|
|
92
|
+
.option("--no-progress", "Disable progress indicators")
|
|
93
|
+
.option("--limit <number>", "Maximum number of prompts to fetch", parseInt)
|
|
94
|
+
.action(promptsHandler);
|
|
95
|
+
return command;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/commands/prompts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,WAAW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AC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO;SACJ,WAAW,CAAC,oCAAoC,CAAC;SACjD,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;SAClD,MAAM,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;SAC/D,MAAM,CACL,mBAAmB,EACnB,qCAAqC,EACrC,QAAQ,CACT;SACA,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;SACtD,MAAM,CAAC,kBAAkB,EAAE,oCAAoC,EAAE,QAAQ,CAAC;SAC1E,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A command-line interface for Phoenix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@arizeai/openinference-semantic-conventions": "^1.1.0",
|
|
34
34
|
"commander": "^12.1.0",
|
|
35
|
-
"@arizeai/phoenix-client": "5.
|
|
35
|
+
"@arizeai/phoenix-client": "5.8.0",
|
|
36
36
|
"@arizeai/phoenix-config": "0.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|