@respan/cli 0.9.0 → 0.10.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/commands/datasets/create-span.js +5 -3
- package/dist/commands/datasets/create.js +5 -4
- package/dist/commands/datasets/get-span.js +5 -1
- package/dist/commands/datasets/get.js +1 -1
- package/dist/commands/datasets/list.js +5 -1
- package/dist/commands/datasets/spans.js +1 -1
- package/dist/commands/datasets/update.js +3 -6
- package/dist/commands/{datasets/add-spans.d.ts → eval/index.d.ts} +2 -3
- package/dist/commands/eval/index.js +26 -0
- package/dist/commands/evaluators/create.js +10 -7
- package/dist/commands/evaluators/get.js +1 -1
- package/dist/commands/evaluators/list.js +1 -1
- package/dist/commands/evaluators/run.js +8 -7
- package/dist/commands/evaluators/update.js +6 -7
- package/dist/commands/experiments/create.js +9 -8
- package/dist/commands/experiments/get.js +1 -1
- package/dist/commands/experiments/list.js +1 -1
- package/dist/commands/logs/create.js +9 -7
- package/dist/commands/logs/get.js +1 -1
- package/dist/commands/logs/list.js +4 -3
- package/dist/commands/logs/summary.js +3 -2
- package/dist/commands/prompts/create-version.js +9 -9
- package/dist/commands/prompts/create.js +5 -4
- package/dist/commands/prompts/get.js +1 -1
- package/dist/commands/prompts/list.js +1 -1
- package/dist/commands/prompts/update.js +3 -6
- package/dist/commands/prompts/versions.js +1 -1
- package/dist/commands/setup/index.js +32 -177
- package/dist/commands/traces/get.js +1 -1
- package/dist/commands/traces/list.js +8 -10
- package/dist/commands/traces/summary.js +6 -2
- package/dist/commands/users/get.js +1 -1
- package/dist/commands/users/list.js +5 -7
- package/dist/lib/base-command.d.ts +2 -0
- package/dist/lib/base-command.js +11 -1
- package/dist/lib/eval/runner.d.ts +15 -0
- package/dist/lib/eval/runner.js +292 -0
- package/dist/lib/eval/schema.d.ts +67 -0
- package/dist/lib/eval/schema.js +22 -0
- package/dist/lib/skill-refs.generated.d.ts +5 -0
- package/dist/lib/skill-refs.generated.js +1168 -0
- package/oclif.manifest.json +181 -189
- package/package.json +7 -3
- package/dist/commands/datasets/add-spans.js +0 -24
|
@@ -14,10 +14,12 @@ class DatasetsCreateSpan extends BaseCommand {
|
|
|
14
14
|
this.error('Invalid JSON for --body');
|
|
15
15
|
}
|
|
16
16
|
const spanData = parsed;
|
|
17
|
-
const data = await this.spin('Creating dataset span', () => client.datasets.
|
|
17
|
+
const data = await this.spin('Creating dataset span', () => client.datasets.createDatasetLog({
|
|
18
|
+
Authorization: this.getAuthHeader(),
|
|
18
19
|
dataset_id: args['dataset-id'],
|
|
19
|
-
input:
|
|
20
|
-
output:
|
|
20
|
+
input: spanData.input,
|
|
21
|
+
output: spanData.output,
|
|
22
|
+
...(spanData.expected_output !== undefined ? { expected_output: spanData.expected_output } : {}),
|
|
21
23
|
...(spanData.metadata ? { metadata: spanData.metadata } : {}),
|
|
22
24
|
}));
|
|
23
25
|
this.log(JSON.stringify(data, null, 2));
|
|
@@ -6,10 +6,11 @@ class DatasetsCreate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const data = await this.spin('Creating dataset', () => client.datasets.createDataset({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
11
|
+
name: flags.name,
|
|
12
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
13
|
+
}));
|
|
13
14
|
this.log(JSON.stringify(data, null, 2));
|
|
14
15
|
}
|
|
15
16
|
catch (error) {
|
|
@@ -6,7 +6,11 @@ class DatasetsGetSpan extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching dataset span', () => client.datasets.
|
|
9
|
+
const data = await this.spin('Fetching dataset span', () => client.datasets.retrieveDatasetLog({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
11
|
+
dataset_id: args['dataset-id'],
|
|
12
|
+
unique_id: args['span-id'],
|
|
13
|
+
}));
|
|
10
14
|
this.log(JSON.stringify(data, null, 2));
|
|
11
15
|
}
|
|
12
16
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class DatasetsGet extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching dataset', () => client.datasets.retrieveDataset({ dataset_id: args.id }));
|
|
9
|
+
const data = await this.spin('Fetching dataset', () => client.datasets.retrieveDataset({ Authorization: this.getAuthHeader(), dataset_id: args.id }));
|
|
10
10
|
this.log(JSON.stringify(data, null, 2));
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,7 +6,11 @@ class DatasetsList extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching datasets', () => client.datasets.listDatasets(
|
|
9
|
+
const data = await this.spin('Fetching datasets', () => client.datasets.listDatasets({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
11
|
+
page: flags.page,
|
|
12
|
+
page_size: flags.limit,
|
|
13
|
+
}));
|
|
10
14
|
this.outputResult(data, ['id', 'name', 'description', 'created_at']);
|
|
11
15
|
}
|
|
12
16
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class DatasetsSpans extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching dataset spans', () => client.datasets.
|
|
9
|
+
const data = await this.spin('Fetching dataset spans', () => client.datasets.listDatasetLogs({ Authorization: this.getAuthHeader(), dataset_id: args['dataset-id'] }));
|
|
10
10
|
this.outputResult(data, ['id', 'input', 'output', 'created_at']);
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,14 +6,11 @@ class DatasetsUpdate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const updateBody = {};
|
|
10
|
-
if (flags.name)
|
|
11
|
-
updateBody.name = flags.name;
|
|
12
|
-
if (flags.description)
|
|
13
|
-
updateBody.description = flags.description;
|
|
14
9
|
const data = await this.spin('Updating dataset', () => client.datasets.updateDataset({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
15
11
|
dataset_id: args.id,
|
|
16
|
-
|
|
12
|
+
...(flags.name ? { name: flags.name } : {}),
|
|
13
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
17
14
|
}));
|
|
18
15
|
this.log(JSON.stringify(data, null, 2));
|
|
19
16
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
-
export default class
|
|
2
|
+
export default class EvalRun extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static args: {
|
|
5
|
-
|
|
5
|
+
file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
7
|
static flags: {
|
|
8
|
-
'span-ids': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
8
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
9
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
10
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
4
|
+
import { runEval } from '../../lib/eval/runner.js';
|
|
5
|
+
class EvalRun extends BaseCommand {
|
|
6
|
+
async run() {
|
|
7
|
+
const { args, flags } = await this.parse(EvalRun);
|
|
8
|
+
this.globalFlags = flags;
|
|
9
|
+
try {
|
|
10
|
+
const client = this.getClient();
|
|
11
|
+
const filePath = resolve(args.file);
|
|
12
|
+
const result = await runEval(filePath, client, this.getAuthHeader(), this.getBaseUrl(), (msg) => this.log(msg));
|
|
13
|
+
this.log('');
|
|
14
|
+
this.log(JSON.stringify(result, null, 2));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
this.handleError(error);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
EvalRun.description = 'Run an eval defined in a JSON file (creates prompt + dataset on the platform)';
|
|
22
|
+
EvalRun.args = {
|
|
23
|
+
file: Args.string({ description: 'Path to eval JSON file', required: true }),
|
|
24
|
+
};
|
|
25
|
+
EvalRun.flags = { ...BaseCommand.baseFlags };
|
|
26
|
+
export default EvalRun;
|
|
@@ -6,20 +6,23 @@ class EvaluatorsCreate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
|
|
10
|
-
if (flags.type)
|
|
11
|
-
body.type = flags.type;
|
|
12
|
-
if (flags.description)
|
|
13
|
-
body.description = flags.description;
|
|
9
|
+
let extra = {};
|
|
14
10
|
if (flags.config) {
|
|
15
11
|
try {
|
|
16
|
-
|
|
12
|
+
extra = JSON.parse(flags.config);
|
|
17
13
|
}
|
|
18
14
|
catch {
|
|
19
15
|
this.error('Invalid JSON for --config');
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
const data = await this.spin('Creating evaluator', () => client.evaluators.createEvaluator(
|
|
18
|
+
const data = await this.spin('Creating evaluator', () => client.evaluators.createEvaluator({
|
|
19
|
+
Authorization: this.getAuthHeader(),
|
|
20
|
+
...extra,
|
|
21
|
+
name: flags.name,
|
|
22
|
+
type: (flags.type ?? extra.type ?? 'llm'),
|
|
23
|
+
score_value_type: (extra.score_value_type ?? 'numerical'),
|
|
24
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
25
|
+
}));
|
|
23
26
|
this.log(JSON.stringify(data, null, 2));
|
|
24
27
|
}
|
|
25
28
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class EvaluatorsGet extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching evaluator', () => client.evaluators.retrieveEvaluator({ evaluator_id: args.id }));
|
|
9
|
+
const data = await this.spin('Fetching evaluator', () => client.evaluators.retrieveEvaluator({ Authorization: this.getAuthHeader(), evaluator_id: args.id }));
|
|
10
10
|
this.log(JSON.stringify(data, null, 2));
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -7,7 +7,7 @@ class EvaluatorsList extends BaseCommand {
|
|
|
7
7
|
this.globalFlags = flags;
|
|
8
8
|
try {
|
|
9
9
|
const client = this.getClient();
|
|
10
|
-
const data = await this.spin('Fetching evaluators', () => client.evaluators.listEvaluators());
|
|
10
|
+
const data = await this.spin('Fetching evaluators', () => client.evaluators.listEvaluators({ Authorization: this.getAuthHeader() }));
|
|
11
11
|
this.outputResult(data, ['id', 'name', 'type', 'is_active', 'created_at']);
|
|
12
12
|
const pagination = extractPagination(data, flags.page);
|
|
13
13
|
this.log(formatPaginationInfo(pagination));
|
|
@@ -6,22 +6,23 @@ class EvaluatorsRun extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
|
|
10
|
-
if (flags['dataset-id'])
|
|
11
|
-
runBody.dataset_id = flags['dataset-id'];
|
|
12
|
-
if (flags['log-ids'])
|
|
13
|
-
runBody.log_ids = flags['log-ids'].split(',').map((s) => s.trim());
|
|
9
|
+
let extra = {};
|
|
14
10
|
if (flags.params) {
|
|
15
11
|
try {
|
|
16
|
-
|
|
12
|
+
extra = JSON.parse(flags.params);
|
|
17
13
|
}
|
|
18
14
|
catch {
|
|
19
15
|
this.error('Invalid JSON for --params');
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
18
|
const data = await this.spin('Running evaluator', () => client.evaluators.runEvaluator({
|
|
19
|
+
Authorization: this.getAuthHeader(),
|
|
20
|
+
...extra,
|
|
23
21
|
evaluator_id: args.id,
|
|
24
|
-
|
|
22
|
+
...(flags['dataset-id'] ? { dataset_id: flags['dataset-id'] } : {}),
|
|
23
|
+
...(flags['log-ids']
|
|
24
|
+
? { log_ids: flags['log-ids'].split(',').map((s) => s.trim()) }
|
|
25
|
+
: {}),
|
|
25
26
|
}));
|
|
26
27
|
this.log(JSON.stringify(data, null, 2));
|
|
27
28
|
}
|
|
@@ -6,22 +6,21 @@ class EvaluatorsUpdate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
|
|
10
|
-
if (flags.name)
|
|
11
|
-
updateBody.name = flags.name;
|
|
12
|
-
if (flags.description)
|
|
13
|
-
updateBody.description = flags.description;
|
|
9
|
+
let extra = {};
|
|
14
10
|
if (flags.config) {
|
|
15
11
|
try {
|
|
16
|
-
|
|
12
|
+
extra = JSON.parse(flags.config);
|
|
17
13
|
}
|
|
18
14
|
catch {
|
|
19
15
|
this.error('Invalid JSON for --config');
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
18
|
const data = await this.spin('Updating evaluator', () => client.evaluators.updateEvaluator({
|
|
19
|
+
Authorization: this.getAuthHeader(),
|
|
20
|
+
...extra,
|
|
23
21
|
evaluator_id: args.id,
|
|
24
|
-
|
|
22
|
+
...(flags.name ? { name: flags.name } : {}),
|
|
23
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
25
24
|
}));
|
|
26
25
|
this.log(JSON.stringify(data, null, 2));
|
|
27
26
|
}
|
|
@@ -6,21 +6,22 @@ class ExperimentsCreate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
|
|
10
|
-
name: flags.name,
|
|
11
|
-
dataset_id: flags['dataset-id'],
|
|
12
|
-
};
|
|
13
|
-
if (flags.description)
|
|
14
|
-
body.description = flags.description;
|
|
9
|
+
let workflows = undefined;
|
|
15
10
|
if (flags.workflows) {
|
|
16
11
|
try {
|
|
17
|
-
|
|
12
|
+
workflows = JSON.parse(flags.workflows);
|
|
18
13
|
}
|
|
19
14
|
catch {
|
|
20
15
|
this.error('Invalid JSON for --workflows');
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
|
-
const data = await this.spin('Creating experiment', () => client.experiments.createExperiment(
|
|
18
|
+
const data = await this.spin('Creating experiment', () => client.experiments.createExperiment({
|
|
19
|
+
Authorization: this.getAuthHeader(),
|
|
20
|
+
name: flags.name,
|
|
21
|
+
dataset_id: flags['dataset-id'],
|
|
22
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
23
|
+
...(workflows ? { workflows: workflows } : {}),
|
|
24
|
+
}));
|
|
24
25
|
this.log(JSON.stringify(data, null, 2));
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class ExperimentsGet extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching experiment', () => client.experiments.retrieveExperiment({ experiment_id: args.id }));
|
|
9
|
+
const data = await this.spin('Fetching experiment', () => client.experiments.retrieveExperiment({ Authorization: this.getAuthHeader(), experiment_id: args.id }));
|
|
10
10
|
this.log(JSON.stringify(data, null, 2));
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class ExperimentsList extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching experiments', () => client.experiments.listExperiments());
|
|
9
|
+
const data = await this.spin('Fetching experiments', () => client.experiments.listExperiments({ Authorization: this.getAuthHeader() }));
|
|
10
10
|
this.outputResult(data, ['id', 'name', 'dataset_id', 'status', 'created_at']);
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,20 +6,22 @@ class LogsCreate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
|
|
10
|
-
if (flags.output)
|
|
11
|
-
body.output = flags.output;
|
|
12
|
-
if (flags.model)
|
|
13
|
-
body.model = flags.model;
|
|
9
|
+
let metadata;
|
|
14
10
|
if (flags.metadata) {
|
|
15
11
|
try {
|
|
16
|
-
|
|
12
|
+
metadata = JSON.parse(flags.metadata);
|
|
17
13
|
}
|
|
18
14
|
catch {
|
|
19
15
|
this.error('Invalid JSON for --metadata');
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
const data = await this.spin('Creating span', () => client.
|
|
18
|
+
const data = await this.spin('Creating span', () => client.spans.createSpan({
|
|
19
|
+
Authorization: this.getAuthHeader(),
|
|
20
|
+
prompt: flags.input,
|
|
21
|
+
...(flags.output ? { completion: flags.output } : {}),
|
|
22
|
+
...(flags.model ? { model: flags.model } : {}),
|
|
23
|
+
...(metadata ? { metadata } : {}),
|
|
24
|
+
}));
|
|
23
25
|
this.log(JSON.stringify(data, null, 2));
|
|
24
26
|
}
|
|
25
27
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class LogsGet extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching span', () => client.
|
|
9
|
+
const data = await this.spin('Fetching span', () => client.spans.retrieveSpan({ Authorization: this.getAuthHeader(), unique_id: args.id }));
|
|
10
10
|
this.log(JSON.stringify(data, null, 2));
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -13,18 +13,19 @@ class LogsList extends BaseCommand {
|
|
|
13
13
|
filters = parseFilters(flags.filter);
|
|
14
14
|
}
|
|
15
15
|
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000).toISOString();
|
|
16
|
-
const data = await this.spin('Fetching logs', () => client.
|
|
16
|
+
const data = await this.spin('Fetching logs', () => client.spans.listSpans({
|
|
17
|
+
Authorization: this.getAuthHeader(),
|
|
17
18
|
start_time: flags['start-time'] || oneHourAgo,
|
|
18
19
|
end_time: flags['end-time'] || new Date().toISOString(),
|
|
19
20
|
sort_by: flags['sort-by'] || '-id',
|
|
20
|
-
operator: '',
|
|
21
|
+
operator: 'AND',
|
|
21
22
|
page_size: flags.limit,
|
|
22
23
|
page: flags.page,
|
|
23
24
|
is_test: flags['is-test'],
|
|
24
25
|
all_envs: flags['all-envs'],
|
|
25
26
|
fetch_filters: 'false',
|
|
26
27
|
include_fields: flags['include-fields'],
|
|
27
|
-
filters,
|
|
28
|
+
filters: filters,
|
|
28
29
|
}));
|
|
29
30
|
this.outputResult(data, ['id', 'model', 'prompt_tokens', 'completion_tokens', 'cost', 'latency', 'timestamp']);
|
|
30
31
|
const pagination = extractPagination(data, flags.page);
|
|
@@ -11,12 +11,13 @@ class LogsSummary extends BaseCommand {
|
|
|
11
11
|
if (flags.filter && flags.filter.length > 0) {
|
|
12
12
|
filters = parseFilters(flags.filter);
|
|
13
13
|
}
|
|
14
|
-
const data = await this.spin('Fetching summary', () => client.
|
|
14
|
+
const data = await this.spin('Fetching summary', () => client.spans.getSpansSummary({
|
|
15
|
+
Authorization: this.getAuthHeader(),
|
|
15
16
|
start_time: flags['start-time'],
|
|
16
17
|
end_time: flags['end-time'],
|
|
17
18
|
is_test: flags['is-test'],
|
|
18
19
|
all_envs: flags['all-envs'],
|
|
19
|
-
filters,
|
|
20
|
+
filters: filters,
|
|
20
21
|
}));
|
|
21
22
|
this.log(JSON.stringify(data, null, 2));
|
|
22
23
|
}
|
|
@@ -14,17 +14,17 @@ class PromptsCreateVersion extends BaseCommand {
|
|
|
14
14
|
this.error('Invalid JSON for --messages');
|
|
15
15
|
}
|
|
16
16
|
// createVersion requires prompt_id, messages (string[]), and model (required)
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const messageList = Array.isArray(messages)
|
|
18
|
+
? messages
|
|
19
|
+
: [{ role: 'user', content: String(messages) }];
|
|
20
|
+
const data = await this.spin('Creating prompt version', () => client.prompts.createPromptVersion({
|
|
21
|
+
Authorization: this.getAuthHeader(),
|
|
19
22
|
prompt_id: args['prompt-id'],
|
|
20
|
-
messages:
|
|
23
|
+
messages: messageList,
|
|
21
24
|
model: flags.model || 'gpt-4o',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (flags['max-tokens'])
|
|
26
|
-
createBody.max_tokens = flags['max-tokens'];
|
|
27
|
-
const data = await this.spin('Creating prompt version', () => client.prompts.createVersion(createBody));
|
|
25
|
+
...(flags.temperature ? { temperature: parseFloat(flags.temperature) } : {}),
|
|
26
|
+
...(flags['max-tokens'] !== undefined ? { max_tokens: flags['max-tokens'] } : {}),
|
|
27
|
+
}));
|
|
28
28
|
this.log(JSON.stringify(data, null, 2));
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
@@ -6,10 +6,11 @@ class PromptsCreate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const data = await this.spin('Creating prompt', () => client.prompts.createPrompt({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
11
|
+
name: flags.name,
|
|
12
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
13
|
+
}));
|
|
13
14
|
this.log(JSON.stringify(data, null, 2));
|
|
14
15
|
}
|
|
15
16
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class PromptsGet extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching prompt', () => client.prompts.
|
|
9
|
+
const data = await this.spin('Fetching prompt', () => client.prompts.retrievePrompt({ Authorization: this.getAuthHeader(), prompt_id: args.id }));
|
|
10
10
|
this.log(JSON.stringify(data, null, 2));
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,7 +6,7 @@ class PromptsList extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching prompts', () => client.prompts.
|
|
9
|
+
const data = await this.spin('Fetching prompts', () => client.prompts.listPrompts({ Authorization: this.getAuthHeader(), page_size: flags.limit }));
|
|
10
10
|
this.outputResult(data, ['id', 'name', 'description', 'is_active', 'current_version', 'updated_at']);
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
@@ -6,14 +6,11 @@ class PromptsUpdate extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const updateBody = {};
|
|
10
|
-
if (flags.name)
|
|
11
|
-
updateBody.name = flags.name;
|
|
12
|
-
if (flags.description)
|
|
13
|
-
updateBody.description = flags.description;
|
|
14
9
|
const data = await this.spin('Updating prompt', () => client.prompts.updatePrompt({
|
|
10
|
+
Authorization: this.getAuthHeader(),
|
|
15
11
|
prompt_id: args.id,
|
|
16
|
-
|
|
12
|
+
...(flags.name ? { name: flags.name } : {}),
|
|
13
|
+
...(flags.description ? { description: flags.description } : {}),
|
|
17
14
|
}));
|
|
18
15
|
this.log(JSON.stringify(data, null, 2));
|
|
19
16
|
}
|
|
@@ -6,7 +6,7 @@ class PromptsVersions extends BaseCommand {
|
|
|
6
6
|
this.globalFlags = flags;
|
|
7
7
|
try {
|
|
8
8
|
const client = this.getClient();
|
|
9
|
-
const data = await this.spin('Fetching prompt versions', () => client.prompts.
|
|
9
|
+
const data = await this.spin('Fetching prompt versions', () => client.prompts.listPromptVersions({ Authorization: this.getAuthHeader(), prompt_id: args['prompt-id'] }));
|
|
10
10
|
this.outputResult(data, ['id', 'version', 'is_active', 'created_at']);
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|