@faces-sh/cli 1.1.0 → 1.2.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/README.md +64 -30
- package/dist/billing.js +11 -8
- package/dist/chat-command.d.ts +31 -0
- package/dist/chat-command.js +110 -0
- package/dist/chat.d.ts +47 -0
- package/dist/chat.js +157 -0
- package/dist/choices.d.ts +2 -5
- package/dist/choices.js +9 -8
- package/dist/commands/billing/llm-costs.js +9 -5
- package/dist/commands/billing/subscription/index.js +1 -1
- package/dist/commands/catalog/doctor.js +2 -2
- package/dist/commands/chat/chat.d.ts +31 -0
- package/dist/commands/chat/chat.js +31 -0
- package/dist/commands/chat/messages.d.ts +30 -0
- package/dist/commands/chat/messages.js +21 -0
- package/dist/commands/chat/responses.d.ts +30 -0
- package/dist/commands/chat/responses.js +22 -0
- package/dist/commands/{causes.d.ts → chat/thread.d.ts} +17 -12
- package/dist/commands/chat/thread.js +238 -0
- package/dist/commands/choices.d.ts +1 -2
- package/dist/commands/choices.js +20 -15
- package/dist/commands/conversation/compact.js +13 -16
- package/dist/commands/conversation/create.js +10 -9
- package/dist/commands/decide.d.ts +1 -4
- package/dist/commands/decide.js +53 -81
- package/dist/commands/face/get.js +1 -1
- package/dist/commands/fidelity/pick.js +2 -2
- package/dist/commands/fidelity/run.d.ts +20 -0
- package/dist/commands/fidelity/run.js +99 -0
- package/dist/commands/fidelity/start.d.ts +17 -0
- package/dist/commands/fidelity/start.js +56 -0
- package/dist/commands/fidelity/turn.d.ts +17 -0
- package/dist/commands/fidelity/turn.js +48 -0
- package/dist/commands/group/add.js +1 -1
- package/dist/commands/media/list.d.ts +12 -0
- package/dist/commands/media/list.js +35 -0
- package/dist/commands/models/list.js +13 -6
- package/dist/commands/session/compact.js +5 -8
- package/dist/commands/session/create.js +9 -8
- package/dist/commands/style/make.js +1 -1
- package/dist/commands/style/upload.js +1 -1
- package/dist/decisions.d.ts +0 -5
- package/dist/decisions.js +0 -18
- package/dist/fidelity.js +3 -3
- package/dist/media.d.ts +8 -0
- package/dist/media.js +12 -0
- package/dist/model.d.ts +11 -0
- package/dist/model.js +53 -0
- package/dist/routing.d.ts +1 -4
- package/dist/routing.js +4 -40
- package/dist/utils.d.ts +1 -25
- package/dist/utils.js +10 -108
- package/oclif.manifest.json +1616 -818
- package/package.json +6 -3
- package/dist/commands/causes.js +0 -146
|
@@ -5,7 +5,7 @@ import { table, usd } from '../../utils.js';
|
|
|
5
5
|
import { llmCostLab } from '../../billing.js';
|
|
6
6
|
export default class BillingLlmCosts extends BaseCommand {
|
|
7
7
|
static description = 'List available LLMs, their per-token costs and what you have spent on each. Models are listed once, ' +
|
|
8
|
-
'under the id their lab gives them.
|
|
8
|
+
'under the id their lab gives them. Maestro and compile prices, and what each plan includes, are listed ' +
|
|
9
9
|
'after the table. For the full catalog, with endpoints and which models are Codex-eligible, see faces models:list.';
|
|
10
10
|
static flags = {
|
|
11
11
|
...BaseCommand.baseFlags,
|
|
@@ -65,7 +65,7 @@ export default class BillingLlmCosts extends BaseCommand {
|
|
|
65
65
|
async facesPrices(client) {
|
|
66
66
|
let models;
|
|
67
67
|
try {
|
|
68
|
-
const raw = (await client.get('/v1/models', { params: { kind: 'compile
|
|
68
|
+
const raw = (await client.get('/v1/models', { params: { kind: 'upstream,compile' } }));
|
|
69
69
|
models = (Array.isArray(raw) ? raw : (raw.data ?? []));
|
|
70
70
|
}
|
|
71
71
|
catch {
|
|
@@ -85,9 +85,13 @@ export default class BillingLlmCosts extends BaseCommand {
|
|
|
85
85
|
lines.push(`Compiling (${m.id}): $${per} per million source tokens compiled${markup}.` +
|
|
86
86
|
(plans.length > 0 ? ` Included each month: ${plans.join(', ')} tokens; past that, credits pay.` : ''));
|
|
87
87
|
}
|
|
88
|
-
else if (m.kind === '
|
|
89
|
-
const
|
|
90
|
-
lines.push(
|
|
88
|
+
else if (m.kind === 'upstream') {
|
|
89
|
+
const out = m.output_cost_per_million_tokens;
|
|
90
|
+
lines.push(`${m.id} on choices: $${per} per million input tokens${typeof out === 'number' ? `, $${out} per million output` : ''}${markup}.`);
|
|
91
|
+
const st = m.steering;
|
|
92
|
+
if (st && typeof st.input_cost_per_million_tokens === 'number') {
|
|
93
|
+
lines.push(`${m.id} steering chat and decisions: $${st.input_cost_per_million_tokens} per million input tokens plus $${st.cost_per_call_usd} a call, no output charge.`);
|
|
94
|
+
}
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
return lines.length > 0 ? ['', ...lines] : [];
|
|
@@ -3,7 +3,7 @@ import { FacesAPIError } from '../../../client.js';
|
|
|
3
3
|
import { allowanceLines, planName } from '../../../billing.js';
|
|
4
4
|
export default class BillingSubscription extends BaseCommand {
|
|
5
5
|
static description = 'Show your plan (free, connect or pro), renewal date, and on a paid plan how much of each ' +
|
|
6
|
-
'allowance is used:
|
|
6
|
+
'allowance is used: choices and steering over 5 hours, the week and the month, and compiling over the month';
|
|
7
7
|
static flags = {
|
|
8
8
|
...BaseCommand.baseFlags,
|
|
9
9
|
};
|
|
@@ -12,7 +12,7 @@ export default class CatalogDoctor extends BaseCommand {
|
|
|
12
12
|
...BaseCommand.baseFlags,
|
|
13
13
|
fix: Flags.boolean({ description: 'Rebuild missing or stale catalog entries from API', default: false }),
|
|
14
14
|
generate: Flags.boolean({
|
|
15
|
-
description: 'Retired
|
|
15
|
+
description: 'Retired. Write a description with faces face:edit <alias> --description.',
|
|
16
16
|
default: false,
|
|
17
17
|
hidden: true,
|
|
18
18
|
}),
|
|
@@ -21,7 +21,7 @@ export default class CatalogDoctor extends BaseCommand {
|
|
|
21
21
|
async run() {
|
|
22
22
|
const { flags } = await this.parse(CatalogDoctor);
|
|
23
23
|
if (flags.generate) {
|
|
24
|
-
this.error('--generate
|
|
24
|
+
this.error('--generate is retired. Nothing was sent.\n' +
|
|
25
25
|
'Write a description with: faces face:edit <alias> --description "..."\n' +
|
|
26
26
|
'To repair the catalog, which is free: faces catalog:doctor --fix');
|
|
27
27
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
2
|
+
export default class ChatChat extends ChatCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
responses: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
|
+
};
|
|
30
|
+
protected forcedEndpoint(flags: Record<string, unknown>): string | undefined;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { RESPONSES_ENDPOINT, chatFlags, MODEL_ARG_DESCRIPTION } from '../../chat.js';
|
|
4
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
5
|
+
export default class ChatChat extends ChatCommand {
|
|
6
|
+
static description = 'Chat with a face. Name the upstream model over the downstream model: @alice:maestro-1/gpt-5.4. The face ' +
|
|
7
|
+
'steers, and the downstream model writes the reply. Routes to /v1/chat/completions, /v1/responses or ' +
|
|
8
|
+
'/v1/messages from the model catalog (--responses forces /v1/responses). The face\'s style is chosen for ' +
|
|
9
|
+
'each request. Add --conversation to take the turn in a state (see faces state:create). The steering is ' +
|
|
10
|
+
'billed per input token plus a small fee per call (faces models:list --kind upstream), and the downstream ' +
|
|
11
|
+
'model at its listed price.';
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is virtue?"',
|
|
14
|
+
'<%= config.bin %> <%= command.id %> @head~socrates:maestro-1-flash/claude-sonnet-4-6 -m "What is virtue?"',
|
|
15
|
+
'<%= config.bin %> <%= command.id %> "(@socrates | @nietzsche):maestro-1/gpt-5.4" -m "What is virtue?"',
|
|
16
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1/gpt-5.4 -m "So what do I tell them tomorrow?" --conversation fs_STATE_ID',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1/gpt-5.4 -m "Is this vendor worth a closer look?" --conversation fs_STATE_ID ' +
|
|
18
|
+
'--premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
|
|
19
|
+
];
|
|
20
|
+
static args = {
|
|
21
|
+
model: Args.string({ description: MODEL_ARG_DESCRIPTION, required: true }),
|
|
22
|
+
};
|
|
23
|
+
static flags = {
|
|
24
|
+
...BaseCommand.baseFlags,
|
|
25
|
+
...chatFlags(),
|
|
26
|
+
responses: Flags.boolean({ description: 'Send it to /v1/responses whatever the catalog says (routing is automatic otherwise).', default: false }),
|
|
27
|
+
};
|
|
28
|
+
forcedEndpoint(flags) {
|
|
29
|
+
return flags.responses ? RESPONSES_ENDPOINT : undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
2
|
+
export default class ChatMessages extends ChatCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
|
+
};
|
|
29
|
+
protected forcedEndpoint(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { MESSAGES_ENDPOINT, chatFlags, MODEL_ARG_DESCRIPTION } from '../../chat.js';
|
|
4
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
5
|
+
export default class ChatMessages extends ChatCommand {
|
|
6
|
+
static description = 'Chat with a face in the Anthropic Messages format (/v1/messages), whatever the model. chat:chat routes ' +
|
|
7
|
+
'Anthropic models here on its own. Name the model as for chat:chat: @alice:maestro-1/claude-sonnet-4-6.';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/claude-sonnet-4-6 -m "What is virtue?" --max-tokens 400',
|
|
10
|
+
];
|
|
11
|
+
static args = {
|
|
12
|
+
model: Args.string({ description: MODEL_ARG_DESCRIPTION, required: true }),
|
|
13
|
+
};
|
|
14
|
+
static flags = {
|
|
15
|
+
...BaseCommand.baseFlags,
|
|
16
|
+
...chatFlags(),
|
|
17
|
+
};
|
|
18
|
+
forcedEndpoint() {
|
|
19
|
+
return MESSAGES_ENDPOINT;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
2
|
+
export default class ChatResponses extends ChatCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
|
+
};
|
|
29
|
+
protected forcedEndpoint(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { RESPONSES_ENDPOINT, chatFlags, MODEL_ARG_DESCRIPTION } from '../../chat.js';
|
|
4
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
5
|
+
export default class ChatResponses extends ChatCommand {
|
|
6
|
+
static description = 'Chat with a face in the OpenAI Responses format (/v1/responses). The same as chat:chat --responses. On ' +
|
|
7
|
+
'Connect and Pro with ChatGPT linked, Codex-eligible models (faces models:list --chatgpt) run on the ChatGPT plan.';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is virtue?"',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is virtue?" --oauth-only',
|
|
11
|
+
];
|
|
12
|
+
static args = {
|
|
13
|
+
model: Args.string({ description: MODEL_ARG_DESCRIPTION, required: true }),
|
|
14
|
+
};
|
|
15
|
+
static flags = {
|
|
16
|
+
...BaseCommand.baseFlags,
|
|
17
|
+
...chatFlags(),
|
|
18
|
+
};
|
|
19
|
+
forcedEndpoint() {
|
|
20
|
+
return RESPONSES_ENDPOINT;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import { BaseCommand } from '
|
|
2
|
-
export default class
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class ChatThread extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
list: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
show: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
13
|
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
14
|
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
15
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
16
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
17
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
18
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
-
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
-
question: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
-
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
-
option: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
level: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
19
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
-
|
|
20
|
+
message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
26
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
27
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
28
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
29
|
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
30
|
};
|
|
29
31
|
static args: {
|
|
30
|
-
|
|
32
|
+
model: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
31
33
|
};
|
|
32
34
|
run(): Promise<unknown>;
|
|
35
|
+
private handleList;
|
|
36
|
+
private handleDelete;
|
|
37
|
+
private handleShow;
|
|
33
38
|
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { BaseCommand } from '../../base.js';
|
|
7
|
+
import { FacesAPIError } from '../../client.js';
|
|
8
|
+
import { conversationFields, conversationTurnFlags } from '../../conversation.js';
|
|
9
|
+
import { MODEL_ARG_DESCRIPTION, chatModelProblem, chatPayload, sendChat } from '../../chat.js';
|
|
10
|
+
import { parseModel } from '../../model.js';
|
|
11
|
+
import { resolveEndpoint } from '../../routing.js';
|
|
12
|
+
import { COMPACTION_FLAG_DESCRIPTION, SESSION_FLAG_DESCRIPTION, STREAM_FLAG_DESCRIPTION, parseTemperature } from '../../utils.js';
|
|
13
|
+
import { chatRefusal } from '../../chat-command.js';
|
|
14
|
+
const THREADS_DIR = path.join(os.homedir(), '.faces', 'threads');
|
|
15
|
+
function newThreadId() {
|
|
16
|
+
return 't_' + crypto.randomBytes(6).toString('hex');
|
|
17
|
+
}
|
|
18
|
+
function threadPath(id) {
|
|
19
|
+
if (!/^[A-Za-z0-9_-]+$/.test(id))
|
|
20
|
+
throw new Error(`"${id}" is not a thread id. List them with: faces chat:thread --list`);
|
|
21
|
+
return path.join(THREADS_DIR, `${id}.json`);
|
|
22
|
+
}
|
|
23
|
+
function loadThread(id) {
|
|
24
|
+
const p = threadPath(id);
|
|
25
|
+
if (!fs.existsSync(p))
|
|
26
|
+
return null;
|
|
27
|
+
return JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
28
|
+
}
|
|
29
|
+
function saveThread(t) {
|
|
30
|
+
if (!fs.existsSync(THREADS_DIR))
|
|
31
|
+
fs.mkdirSync(THREADS_DIR, { recursive: true, mode: 0o700 });
|
|
32
|
+
t.updated_at = new Date().toISOString();
|
|
33
|
+
fs.writeFileSync(threadPath(t.id), JSON.stringify(t, null, 2), { mode: 0o600 });
|
|
34
|
+
}
|
|
35
|
+
function listThreads() {
|
|
36
|
+
if (!fs.existsSync(THREADS_DIR))
|
|
37
|
+
return [];
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const f of fs.readdirSync(THREADS_DIR)) {
|
|
40
|
+
if (!f.endsWith('.json'))
|
|
41
|
+
continue;
|
|
42
|
+
try {
|
|
43
|
+
out.push(JSON.parse(fs.readFileSync(path.join(THREADS_DIR, f), 'utf8')));
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
46
|
+
}
|
|
47
|
+
out.sort((a, b) => (b.updated_at ?? '').localeCompare(a.updated_at ?? ''));
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
export default class ChatThread extends BaseCommand {
|
|
51
|
+
static description = 'A multi-turn chat with a face, kept under ~/.faces/threads/<id>.json. Start one with the model ' +
|
|
52
|
+
'(@alice:maestro-1/gpt-5.4) and a message, then go on with --id. The whole thread is sent each turn, ' +
|
|
53
|
+
'unless the turn is in a state (--conversation), which holds the history: then only the new message goes.';
|
|
54
|
+
static examples = [
|
|
55
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is justice?"',
|
|
56
|
+
'<%= config.bin %> <%= command.id %> --id t_abc123 -m "Say more about that"',
|
|
57
|
+
'<%= config.bin %> <%= command.id %> --list',
|
|
58
|
+
'<%= config.bin %> <%= command.id %> --id t_abc123 --show',
|
|
59
|
+
'<%= config.bin %> <%= command.id %> --id t_abc123 --delete',
|
|
60
|
+
];
|
|
61
|
+
static flags = {
|
|
62
|
+
...BaseCommand.baseFlags,
|
|
63
|
+
id: Flags.string({ description: 'Go on with a saved thread, by id.' }),
|
|
64
|
+
message: Flags.string({ char: 'm', description: 'Your message.' }),
|
|
65
|
+
file: Flags.string({ description: 'Read the message from a file.' }),
|
|
66
|
+
system: Flags.string({ description: 'System prompt (only when starting a thread).' }),
|
|
67
|
+
'max-tokens': Flags.integer({ description: 'The most tokens the reply may take (at least 1).', min: 1 }),
|
|
68
|
+
temperature: Flags.string({ description: 'Temperature (0.0-2.0).' }),
|
|
69
|
+
stream: Flags.boolean({ description: STREAM_FLAG_DESCRIPTION, default: true, allowNo: true }),
|
|
70
|
+
...conversationTurnFlags({ suffix: 'For this turn only. Only the new message is sent: the state holds the rest.' }),
|
|
71
|
+
session: Flags.string({ description: `${SESSION_FLAG_DESCRIPTION} For this turn only.` }),
|
|
72
|
+
compaction: Flags.string({ description: `${COMPACTION_FLAG_DESCRIPTION} For this turn only.` }),
|
|
73
|
+
'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits.', default: false }),
|
|
74
|
+
list: Flags.boolean({ description: 'List saved threads.', default: false }),
|
|
75
|
+
show: Flags.boolean({ description: 'Show a thread (needs --id).', default: false }),
|
|
76
|
+
delete: Flags.boolean({ description: 'Delete a thread (needs --id).', default: false }),
|
|
77
|
+
yes: Flags.boolean({ description: 'Skip the confirmation for --delete.', default: false }),
|
|
78
|
+
};
|
|
79
|
+
static args = {
|
|
80
|
+
model: Args.string({ description: `${MODEL_ARG_DESCRIPTION} Needed to start a thread; a saved thread keeps its own.`, required: false }),
|
|
81
|
+
};
|
|
82
|
+
async run() {
|
|
83
|
+
const { args, flags } = await this.parse(ChatThread);
|
|
84
|
+
if (flags.list)
|
|
85
|
+
return this.handleList();
|
|
86
|
+
if (flags.delete)
|
|
87
|
+
return this.handleDelete(flags.id, flags.yes);
|
|
88
|
+
if (flags.show)
|
|
89
|
+
return this.handleShow(flags.id);
|
|
90
|
+
let message;
|
|
91
|
+
if (flags.file) {
|
|
92
|
+
if (!fs.existsSync(flags.file))
|
|
93
|
+
this.error(`File not found: ${flags.file}`);
|
|
94
|
+
message = fs.readFileSync(flags.file, 'utf8');
|
|
95
|
+
}
|
|
96
|
+
else if (flags.message) {
|
|
97
|
+
message = flags.message;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.error('Provide --message/-m or --file.');
|
|
101
|
+
}
|
|
102
|
+
let turn;
|
|
103
|
+
try {
|
|
104
|
+
turn = conversationFields(flags);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
108
|
+
}
|
|
109
|
+
const newOnly = Boolean(flags.conversation || flags.session);
|
|
110
|
+
let thread;
|
|
111
|
+
if (flags.id) {
|
|
112
|
+
let existing;
|
|
113
|
+
try {
|
|
114
|
+
existing = loadThread(flags.id);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
118
|
+
}
|
|
119
|
+
if (!existing)
|
|
120
|
+
this.error(`Thread not found: ${flags.id}`);
|
|
121
|
+
thread = existing;
|
|
122
|
+
if (args.model && args.model.trim() !== thread.model)
|
|
123
|
+
this.warn(`A thread keeps its model; going on with ${thread.model}.`);
|
|
124
|
+
if (flags.system)
|
|
125
|
+
this.warn('--system is ignored when going on with a thread.');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (!args.model)
|
|
129
|
+
this.error('Name the model to start a thread (e.g. faces chat:thread @socrates:maestro-1/gpt-5.4 -m "..."), or --id to go on with one.');
|
|
130
|
+
const now = new Date().toISOString();
|
|
131
|
+
thread = { id: newThreadId(), model: args.model.trim(), system: flags.system, created_at: now, updated_at: now, messages: [] };
|
|
132
|
+
}
|
|
133
|
+
const problem = chatModelProblem(thread.model);
|
|
134
|
+
if (problem)
|
|
135
|
+
this.error(`${problem}\nThis thread was saved with the old form; start a new one with the new model.`);
|
|
136
|
+
const client = this.makeClient(flags);
|
|
137
|
+
if (!thread.endpoint)
|
|
138
|
+
thread.endpoint = (await resolveEndpoint(client, parseModel(thread.model).downstream)).endpoint;
|
|
139
|
+
const endpoint = thread.endpoint;
|
|
140
|
+
thread.messages.push({ role: 'user', content: message, ts: new Date().toISOString() });
|
|
141
|
+
const sent = newOnly ? thread.messages.slice(-1) : thread.messages;
|
|
142
|
+
const json = this.jsonEnabled();
|
|
143
|
+
let payload;
|
|
144
|
+
try {
|
|
145
|
+
payload = chatPayload(endpoint, thread.model, sent.map((m) => ({ role: m.role, content: m.content })), {
|
|
146
|
+
system: thread.system,
|
|
147
|
+
maxTokens: flags['max-tokens'],
|
|
148
|
+
temperature: flags.temperature === undefined ? undefined : parseTemperature(flags.temperature, (m) => this.error(m)),
|
|
149
|
+
stream: flags.stream && !json,
|
|
150
|
+
oauthOnly: flags['oauth-only'],
|
|
151
|
+
session: flags.session,
|
|
152
|
+
compaction: flags.compaction,
|
|
153
|
+
turn,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const res = await sendChat(client, endpoint, payload, (d) => process.stdout.write(d), json);
|
|
161
|
+
if (!res.text)
|
|
162
|
+
this.error('No answer came back. Run it again with --no-stream to see what the server said.');
|
|
163
|
+
thread.messages.push({ role: 'assistant', content: res.text, ts: new Date().toISOString() });
|
|
164
|
+
saveThread(thread);
|
|
165
|
+
if (json)
|
|
166
|
+
return { thread_id: thread.id, model: thread.model, endpoint, assistant: res.text, turns: thread.messages.length };
|
|
167
|
+
if (payload.stream)
|
|
168
|
+
process.stdout.write('\n');
|
|
169
|
+
else
|
|
170
|
+
this.log(res.text);
|
|
171
|
+
this.log(`\n[thread ${thread.id} · ${thread.messages.length} turns]`);
|
|
172
|
+
return { thread_id: thread.id, assistant: res.text };
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
if (err instanceof FacesAPIError)
|
|
176
|
+
this.error(await chatRefusal(err, thread.model, endpoint, false, client));
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
handleList() {
|
|
181
|
+
const threads = listThreads();
|
|
182
|
+
if (this.jsonEnabled()) {
|
|
183
|
+
return threads.map((t) => ({ id: t.id, model: t.model, turns: t.messages.length, created_at: t.created_at, updated_at: t.updated_at }));
|
|
184
|
+
}
|
|
185
|
+
if (threads.length === 0) {
|
|
186
|
+
this.log('(no threads)');
|
|
187
|
+
return {};
|
|
188
|
+
}
|
|
189
|
+
for (const t of threads) {
|
|
190
|
+
const last = t.messages.at(-1);
|
|
191
|
+
this.log(`${t.id} ${t.model} (${t.messages.length} turns, updated ${t.updated_at})`);
|
|
192
|
+
if (last)
|
|
193
|
+
this.log(` ${last.role}: ${last.content.slice(0, 60).replace(/\s+/g, ' ')}${last.content.length > 60 ? '…' : ''}`);
|
|
194
|
+
}
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
async handleDelete(id, yes) {
|
|
198
|
+
if (!id)
|
|
199
|
+
this.error('--delete needs --id <thread-id>');
|
|
200
|
+
let p;
|
|
201
|
+
try {
|
|
202
|
+
p = threadPath(id);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
206
|
+
}
|
|
207
|
+
if (!fs.existsSync(p))
|
|
208
|
+
this.error(`Thread not found: ${id}`);
|
|
209
|
+
await this.confirmOrRefuse(`Delete thread ${id} and its history?`, yes);
|
|
210
|
+
fs.unlinkSync(p);
|
|
211
|
+
if (!this.jsonEnabled())
|
|
212
|
+
this.log(`Deleted thread ${id}`);
|
|
213
|
+
return { deleted: id };
|
|
214
|
+
}
|
|
215
|
+
handleShow(id) {
|
|
216
|
+
if (!id)
|
|
217
|
+
this.error('--show needs --id <thread-id>');
|
|
218
|
+
let t;
|
|
219
|
+
try {
|
|
220
|
+
t = loadThread(id);
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
224
|
+
}
|
|
225
|
+
if (!t)
|
|
226
|
+
this.error(`Thread not found: ${id}`);
|
|
227
|
+
if (this.jsonEnabled())
|
|
228
|
+
return t;
|
|
229
|
+
this.log(`Thread ${t.id} (${t.model})`);
|
|
230
|
+
this.log(`Created: ${t.created_at}`);
|
|
231
|
+
this.log(`Updated: ${t.updated_at}`);
|
|
232
|
+
if (t.system)
|
|
233
|
+
this.log(`---\nsystem: ${t.system}`);
|
|
234
|
+
for (const m of t.messages)
|
|
235
|
+
this.log(`---\n${m.role} [${m.ts}]:\n${m.content}`);
|
|
236
|
+
return t;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -7,7 +7,6 @@ export default class Choices extends BaseCommand {
|
|
|
7
7
|
state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'state-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
model: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
10
|
'max-choices': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
11
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
12
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -15,7 +14,7 @@ export default class Choices extends BaseCommand {
|
|
|
15
14
|
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
15
|
};
|
|
17
16
|
static args: {
|
|
18
|
-
|
|
17
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
19
18
|
};
|
|
20
19
|
run(): Promise<unknown>;
|
|
21
20
|
}
|
package/dist/commands/choices.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { BaseCommand } from '../base.js';
|
|
3
3
|
import { FacesAPIError } from '../client.js';
|
|
4
|
-
import {
|
|
4
|
+
import { CHOICES_PATH, MAX_CHOICES, choicesHint, choicesLines } from '../choices.js';
|
|
5
|
+
import { modelProblem } from '../model.js';
|
|
5
6
|
import { heldDecisionError, readStateFlags } from '../decisions.js';
|
|
6
7
|
import { retryOnceOnWarmUp, sayWarmUp } from '../utils.js';
|
|
7
8
|
export default class Choices extends BaseCommand {
|
|
8
|
-
static description = 'Ask a face what it would do (POST /v1/choices).
|
|
9
|
+
static description = 'Ask a face what it would do (POST /v1/choices). Name the upstream model, a face and its maestro: ' +
|
|
10
|
+
'@alice:maestro-1, @dana~alice:maestro-1 for a face shared with you, or a composite such as ' +
|
|
11
|
+
'"(@alice | @bob):maestro-1". maestro-1-flash answers sooner and costs 10 times more. ' +
|
|
12
|
+
'Describe the situation with --state (prose, at most ' +
|
|
9
13
|
'3,000 tokens) or --state-id (a state from faces state:create), ask with --question, and the face proposes ' +
|
|
10
14
|
'the options it would weigh, strongest first. Leave --question out and it proposes the question it would ask. ' +
|
|
11
|
-
'Billed on the tokens it processes (see faces models:list --kind
|
|
15
|
+
'Billed on the tokens it processes (see faces models:list --kind upstream). Takes about 10 to 30 seconds.';
|
|
12
16
|
static examples = [
|
|
13
|
-
'<%= config.bin %> <%= command.id %> alice --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"',
|
|
14
|
-
'<%= config.bin %> <%= command.id %> head:
|
|
15
|
-
'<%= config.bin %> <%= command.id %> alice --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3',
|
|
16
|
-
'<%= config.bin %> <%= command.id %> "(alice | bob)" --state-file situation.txt -q "What next?" --
|
|
17
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1 --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> @head~socrates:maestro-1 --state "A chain bakery opened across the street."',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1 --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> "(@alice | @bob):maestro-1-flash" --state-file situation.txt -q "What next?" --json',
|
|
17
21
|
];
|
|
18
22
|
static flags = {
|
|
19
23
|
...BaseCommand.baseFlags,
|
|
@@ -24,12 +28,12 @@ export default class Choices extends BaseCommand {
|
|
|
24
28
|
description: 'A state (from faces state:create) as the situation. With --state, the prose is an addendum for this call only: ' +
|
|
25
29
|
'read with the state, never saved to it. Write anything that should persist with faces state:add --premise.',
|
|
26
30
|
}),
|
|
27
|
-
model: Flags.string({ description: 'The choices model. maestro-1-flash answers sooner and costs 10 times more when a question is asked.', options: [...CHOICES_MODELS], default: CHOICES_MODELS[0] }),
|
|
28
31
|
'max-choices': Flags.integer({ description: `The most options to return, 1 to ${MAX_CHOICES}. Default 8.`, min: 1, max: MAX_CHOICES }),
|
|
29
32
|
};
|
|
30
33
|
static args = {
|
|
31
|
-
|
|
32
|
-
description: 'The
|
|
34
|
+
model: Args.string({
|
|
35
|
+
description: 'The upstream model: @<face>:<maestro>, e.g. @alice:maestro-1. Another account\'s face is @owner~face; ' +
|
|
36
|
+
'a composite is "(@a | @b):maestro-1" (operators | & - ^). No model after it: on choices the upstream model answers.',
|
|
33
37
|
required: true,
|
|
34
38
|
}),
|
|
35
39
|
};
|
|
@@ -37,10 +41,11 @@ export default class Choices extends BaseCommand {
|
|
|
37
41
|
const { args, flags } = await this.parse(Choices);
|
|
38
42
|
const client = this.makeClient(flags);
|
|
39
43
|
const json = this.jsonEnabled();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const model = args.model.trim();
|
|
45
|
+
const problem = modelProblem(model, 'upstream');
|
|
46
|
+
if (problem)
|
|
47
|
+
this.error(problem);
|
|
48
|
+
const body = { model };
|
|
44
49
|
const fail = (m) => this.error(m);
|
|
45
50
|
if (flags.state !== undefined || flags['state-file'] !== undefined) {
|
|
46
51
|
const state = readStateFlags(flags, fail);
|
|
@@ -72,7 +77,7 @@ export default class Choices extends BaseCommand {
|
|
|
72
77
|
}
|
|
73
78
|
catch (err) {
|
|
74
79
|
if (err instanceof FacesAPIError) {
|
|
75
|
-
const hint = choicesHint(err.statusCode, err.message,
|
|
80
|
+
const hint = choicesHint(err.statusCode, err.message, model);
|
|
76
81
|
this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
|
|
77
82
|
}
|
|
78
83
|
throw err;
|