Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit ef3fd3b

Browse files
committed
chore: update arguments and their descriptions for a better onboarding exp
1 parent 41ac15a commit ef3fd3b

14 files changed

+119
-45
lines changed

cortex-js/src/infrastructure/commanders/benchmark.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class BenchmarkCommand extends CommandRunner {
1414
}
1515

1616
async run(
17-
_input: string[],
17+
passedParams: string[],
1818
options?: Partial<BenchmarkConfig>,
1919
): Promise<void> {
2020
return this.benchmarkUsecases.benchmark(options ?? {});

cortex-js/src/infrastructure/commanders/chat.command.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ type ChatOptions = {
1616
attach: boolean;
1717
};
1818

19-
@SubCommand({ name: 'chat', description: 'Send a chat request to a model' })
19+
@SubCommand({
20+
name: 'chat',
21+
description: 'Send a chat request to a model',
22+
arguments: '[model_id] [message]',
23+
argsDescription: {
24+
model_id:
25+
'Model ID to chat with. If there is no model_id provided, it will prompt to select from running models.',
26+
message: 'Message to send to the model',
27+
},
28+
})
2029
export class ChatCommand extends CommandRunner {
2130
constructor(
2231
private readonly inquirerService: InquirerService,
@@ -27,17 +36,19 @@ export class ChatCommand extends CommandRunner {
2736
super();
2837
}
2938

30-
async run(_input: string[], options: ChatOptions): Promise<void> {
31-
let modelId = _input[0];
39+
async run(passedParams: string[], options: ChatOptions): Promise<void> {
40+
let modelId = passedParams[0];
3241
// First attempt to get message from input or options
3342
// Extract input from 1 to end of array
34-
let message = options.message ?? _input.slice(1).join(' ');
43+
let message = options.message ?? passedParams.slice(1).join(' ');
3544

3645
// Check for model existing
3746
if (!modelId || !(await this.modelsUsecases.findOne(modelId))) {
3847
// Model ID is not provided
3948
// first input might be message input
40-
message = _input.length ? _input.join(' ') : options.message ?? '';
49+
message = passedParams.length
50+
? passedParams.join(' ')
51+
: options.message ?? '';
4152
// If model ID is not provided, prompt user to select from running models
4253
const models = await this.psCliUsecases.getModels();
4354
if (models.length === 1) {

cortex-js/src/infrastructure/commanders/cortex-command.commander.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ interface CortexCommandOptions {
3232
description: 'Cortex CLI',
3333
})
3434
export class CortexCommand extends CommandRunner {
35-
async run(input: string[], option: CortexCommandOptions): Promise<void> {
35+
async run(
36+
passedParams: string[],
37+
option: CortexCommandOptions,
38+
): Promise<void> {
3639
if (option.version) console.log(pkg.version);
3740
else this.command?.help();
3841
}

cortex-js/src/infrastructure/commanders/embeddings.command.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ interface EmbeddingCommandOptions {
1818

1919
@SubCommand({
2020
name: 'embeddings',
21+
arguments: '[model_id]',
2122
description: 'Creates an embedding vector representing the input text.',
23+
argsDescription: {
24+
model_id:
25+
'Model to use for embedding. If not provided, it will prompt to select from running models.',
26+
},
2227
})
2328
export class EmbeddingCommand extends CommandRunner {
2429
constructor(
@@ -29,16 +34,19 @@ export class EmbeddingCommand extends CommandRunner {
2934
) {
3035
super();
3136
}
32-
async run(_input: string[], options: EmbeddingCommandOptions): Promise<void> {
33-
let modelId = _input[0];
37+
async run(
38+
passedParams: string[],
39+
options: EmbeddingCommandOptions,
40+
): Promise<void> {
41+
let modelId = passedParams[0];
3442
// First attempt to get message from input or options
35-
let input: string | string[] = options.input ?? _input.splice(1);
43+
let input: string | string[] = options.input ?? passedParams.splice(1);
3644

3745
// Check for model existing
3846
if (!modelId || !(await this.modelsUsecases.findOne(modelId))) {
3947
// Model ID is not provided
4048
// first input might be message input
41-
input = _input ?? options.input;
49+
input = passedParams ?? options.input;
4250
// If model ID is not provided, prompt user to select from running models
4351
const models = await this.psCliUsecases.getModels();
4452
if (models.length === 1) {

cortex-js/src/infrastructure/commanders/init.command.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import { InitOptions } from './types/init-options.interface';
1010
@SubCommand({
1111
name: 'init',
1212
aliases: ['setup'],
13+
arguments: '[version]',
1314
description: "Init settings and download cortex's dependencies",
15+
argsDescription: {
16+
version: 'Version of cortex engine',
17+
},
1418
})
1519
export class InitCommand extends CommandRunner {
1620
constructor(
@@ -20,16 +24,19 @@ export class InitCommand extends CommandRunner {
2024
super();
2125
}
2226

23-
async run(input: string[], options?: InitOptions): Promise<void> {
27+
async run(passedParams: string[], options?: InitOptions): Promise<void> {
2428
if (options?.silent) {
25-
return this.initSilently(input);
29+
return this.initSilently(passedParams);
2630
} else {
27-
return this.initPrompts(input, options);
31+
return this.initPrompts(passedParams, options);
2832
}
2933
}
3034

31-
private initSilently = async (input: string[], options: InitOptions = {}) => {
32-
const version = input[0] ?? 'latest';
35+
private initSilently = async (
36+
passedParams: string[],
37+
options: InitOptions = {},
38+
) => {
39+
const version = passedParams[0] ?? 'latest';
3340
if (process.platform === 'darwin') {
3441
const engineFileName = this.initUsecases.parseEngineFileName(options);
3542
return this.initUsecases.installEngine(engineFileName, version);

cortex-js/src/infrastructure/commanders/models/model-get.command.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ import { CommandRunner, SubCommand } from 'nest-commander';
22
import { ModelsCliUsecases } from '@commanders/usecases/models.cli.usecases';
33
import { exit } from 'node:process';
44

5-
@SubCommand({ name: 'get', description: 'Get a model by ID.' })
5+
@SubCommand({
6+
name: 'get',
7+
description: 'Get a model by ID.',
8+
arguments: '<model_id>',
9+
argsDescription: {
10+
model_id: 'Model ID to get information about.',
11+
},
12+
})
613
export class ModelGetCommand extends CommandRunner {
714
constructor(private readonly modelsCliUsecases: ModelsCliUsecases) {
815
super();
916
}
1017

11-
async run(input: string[]): Promise<void> {
12-
if (input.length === 0) {
18+
async run(passedParams: string[]): Promise<void> {
19+
if (passedParams.length === 0) {
1320
console.error('Model ID is required');
1421
exit(1);
1522
}
1623

17-
const model = await this.modelsCliUsecases.getModel(input[0]);
24+
const model = await this.modelsCliUsecases.getModel(passedParams[0]);
1825
if (!model) console.error('Model not found');
1926
else console.log(model);
2027
}

cortex-js/src/infrastructure/commanders/models/model-list.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ModelListCommand extends CommandRunner {
1010
super();
1111
}
1212

13-
async run(_input: string[], option: ModelListOptions): Promise<void> {
13+
async run(passedParams: string[], option: ModelListOptions): Promise<void> {
1414
const models = await this.modelsCliUsecases.listAllModels();
1515
option.format === 'table'
1616
? console.table(

cortex-js/src/infrastructure/commanders/models/model-pull.command.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@ import { ModelNotFoundException } from '@/infrastructure/exception/model-not-fou
66
@SubCommand({
77
name: 'pull',
88
aliases: ['download'],
9+
arguments: '<model_id>',
10+
argsDescription: { model_id: 'Model repo to pull' },
911
description: 'Download a model. Working with HuggingFace model id.',
1012
})
1113
export class ModelPullCommand extends CommandRunner {
1214
constructor(private readonly modelsCliUsecases: ModelsCliUsecases) {
1315
super();
1416
}
1517

16-
async run(input: string[]) {
17-
if (input.length < 1) {
18+
async run(passedParams: string[]) {
19+
if (passedParams.length < 1) {
1820
console.error('Model Id is required');
1921
exit(1);
2022
}
2123

22-
await this.modelsCliUsecases.pullModel(input[0]).catch((e: Error) => {
23-
if (e instanceof ModelNotFoundException)
24-
console.error('Model does not exist.');
25-
else console.error(e);
26-
exit(1);
27-
});
24+
await this.modelsCliUsecases
25+
.pullModel(passedParams[0])
26+
.catch((e: Error) => {
27+
if (e instanceof ModelNotFoundException)
28+
console.error('Model does not exist.');
29+
else console.error(e);
30+
exit(1);
31+
});
2832

2933
console.log('\nDownload complete!');
3034
exit(0);

cortex-js/src/infrastructure/commanders/models/model-remove.command.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ import { CommandRunner, SubCommand } from 'nest-commander';
22
import { ModelsCliUsecases } from '@commanders/usecases/models.cli.usecases';
33
import { exit } from 'node:process';
44

5-
@SubCommand({ name: 'remove', description: 'Remove a model by ID locally.' })
5+
@SubCommand({
6+
name: 'remove',
7+
description: 'Remove a model by ID locally.',
8+
arguments: '<model_id>',
9+
argsDescription: {
10+
model_id: 'Model to remove',
11+
},
12+
})
613
export class ModelRemoveCommand extends CommandRunner {
714
constructor(private readonly modelsCliUsecases: ModelsCliUsecases) {
815
super();
916
}
1017

11-
async run(input: string[]): Promise<void> {
12-
if (input.length === 0) {
18+
async run(passedParams: string[]): Promise<void> {
19+
if (passedParams.length === 0) {
1320
console.error('Model ID is required');
1421
exit(1);
1522
}
1623

17-
await this.modelsCliUsecases.removeModel(input[0]).then(console.log);
24+
await this.modelsCliUsecases.removeModel(passedParams[0]).then(console.log);
1825
}
1926
}

cortex-js/src/infrastructure/commanders/models/model-start.command.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ type ModelStartOptions = {
1212
attach: boolean;
1313
preset?: string;
1414
};
15-
@SubCommand({ name: 'start', description: 'Start a model by ID.' })
15+
@SubCommand({
16+
name: 'start',
17+
description: 'Start a model by ID.',
18+
arguments: '[model_id]',
19+
argsDescription: {
20+
model_id:
21+
'Model ID to start. If there is no model ID, it will prompt you to select from the available models.',
22+
},
23+
})
1624
export class ModelStartCommand extends CommandRunner {
1725
constructor(
1826
private readonly inquirerService: InquirerService,
@@ -22,8 +30,8 @@ export class ModelStartCommand extends CommandRunner {
2230
super();
2331
}
2432

25-
async run(input: string[], options: ModelStartOptions): Promise<void> {
26-
let modelId = input[0];
33+
async run(passedParams: string[], options: ModelStartOptions): Promise<void> {
34+
let modelId = passedParams[0];
2735
if (!modelId) {
2836
try {
2937
modelId = await this.modelInquiry();

0 commit comments

Comments
 (0)