@faces-sh/cli 1.0.2 → 1.1.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 +71 -51
- package/dist/choices.d.ts +23 -0
- package/dist/choices.js +48 -0
- package/dist/commands/auth/connect.js +2 -2
- package/dist/commands/catalog/doctor.js +9 -68
- package/dist/commands/causes.d.ts +2 -0
- package/dist/commands/causes.js +2 -2
- package/dist/commands/{fidelity/run.d.ts → choices.d.ts} +9 -8
- package/dist/commands/choices.js +86 -0
- package/dist/commands/conversation/add.d.ts +2 -0
- package/dist/commands/conversation/add.js +21 -10
- package/dist/commands/conversation/close.js +5 -5
- package/dist/commands/conversation/compact.js +9 -9
- package/dist/commands/conversation/create.d.ts +2 -0
- package/dist/commands/conversation/create.js +14 -12
- package/dist/commands/conversation/get.js +4 -4
- package/dist/commands/conversation/items.js +19 -8
- package/dist/commands/decide.d.ts +3 -0
- package/dist/commands/decide.js +20 -3
- package/dist/commands/face/get.js +1 -1
- package/dist/commands/fidelity/pick.js +2 -2
- package/dist/commands/models/list.js +7 -3
- package/dist/commands/session/close.js +1 -1
- package/dist/commands/session/compact.js +2 -2
- package/dist/commands/session/create.js +2 -2
- package/dist/commands/session/get.js +1 -1
- package/dist/commands/state/add.d.ts +3 -0
- package/dist/commands/state/add.js +3 -0
- package/dist/commands/state/close.d.ts +3 -0
- package/dist/commands/state/close.js +3 -0
- package/dist/commands/state/compact.d.ts +3 -0
- package/dist/commands/state/compact.js +3 -0
- package/dist/commands/state/create.d.ts +3 -0
- package/dist/commands/state/create.js +3 -0
- package/dist/commands/state/get.d.ts +3 -0
- package/dist/commands/state/get.js +3 -0
- package/dist/commands/state/items.d.ts +3 -0
- package/dist/commands/state/items.js +3 -0
- package/dist/commands/style/make.js +2 -6
- package/dist/conversation.d.ts +27 -2
- package/dist/conversation.js +100 -16
- package/dist/fidelity.js +3 -3
- package/oclif.manifest.json +1100 -1493
- package/package.json +9 -9
- package/dist/commands/chat/chat.d.ts +0 -47
- package/dist/commands/chat/chat.js +0 -376
- package/dist/commands/chat/messages.d.ts +0 -30
- package/dist/commands/chat/messages.js +0 -148
- package/dist/commands/chat/responses.d.ts +0 -31
- package/dist/commands/chat/responses.js +0 -159
- package/dist/commands/chat/thread.d.ts +0 -50
- package/dist/commands/chat/thread.js +0 -472
- package/dist/commands/fidelity/run.js +0 -99
- package/dist/commands/fidelity/start.d.ts +0 -17
- package/dist/commands/fidelity/start.js +0 -56
- package/dist/commands/fidelity/turn.d.ts +0 -17
- package/dist/commands/fidelity/turn.js +0 -48
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Faces CLI
|
|
2
2
|
|
|
3
3
|
Command-line interface for [Faces](https://faces.sh). Faces are causal models: compile one from an
|
|
4
|
-
author's source texts, and
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
author's source texts, then describe a situation and ask it what it would do: it proposes the options
|
|
5
|
+
it would weigh, strongest first. It also returns a **cause**, the principal *why* behind that author's
|
|
6
|
+
response in context, and typed decisions.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -28,13 +28,15 @@ faces face:create --name "Alice" --alias alice --default-model gpt-5.4-mini \
|
|
|
28
28
|
faces compile:doc alice --file essay.txt --medium essay
|
|
29
29
|
faces compile:upload alice --file interview.txt --kind thread --face-speaker Alice
|
|
30
30
|
|
|
31
|
+
# Ask what it would do: the options it would weigh, strongest first
|
|
32
|
+
faces choices alice --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"
|
|
33
|
+
|
|
34
|
+
# Or let it propose the question it would ask
|
|
35
|
+
faces choices alice --state "A startup offers me a lead role at a lower salary."
|
|
36
|
+
|
|
31
37
|
# The cause alone
|
|
32
38
|
faces causes alice -m "Should I take the offer?"
|
|
33
39
|
|
|
34
|
-
# Chat: the face's cause steers the model's answer
|
|
35
|
-
faces chat:chat alice -m "What matters most to you?"
|
|
36
|
-
faces chat:chat alice -m "Tell me more" --llm claude-sonnet-4-6 --show-cause
|
|
37
|
-
|
|
38
40
|
# Decide: typed answers, with a cause per question
|
|
39
41
|
faces decide alice --state "A colleague asks you to sign a proposal you have not read." \
|
|
40
42
|
--question "Does the speaker sign?"
|
|
@@ -55,11 +57,12 @@ faces face:diff / neighbors / lock / unlock / publish / unpublish / share / unsh
|
|
|
55
57
|
faces face:avatar:list / get / make / upload / delete
|
|
56
58
|
faces face:tag:add / list / remove / set / all
|
|
57
59
|
|
|
60
|
+
faces choices # what a face would do: its options, or the question it would ask
|
|
58
61
|
faces causes # a face's cause alone
|
|
59
|
-
faces chat:chat / messages / responses / thread
|
|
60
62
|
faces decide # what a face would decide: yes/no, a choice, or a score
|
|
61
|
-
faces
|
|
62
|
-
faces
|
|
63
|
+
faces state:create / get / items / add / compact / close
|
|
64
|
+
faces conversation:create / ... # the old name for state:*
|
|
65
|
+
faces session:create / get / compact / close # an older name
|
|
63
66
|
|
|
64
67
|
faces compile:doc / compile:doc:create / list / get / edit / make / pause / reset / delete
|
|
65
68
|
faces compile:thread:create / list / get / edit / message / replace / make / pause / reset / delete
|
|
@@ -69,7 +72,7 @@ faces style:upload / make / status / versions / revert / delete
|
|
|
69
72
|
|
|
70
73
|
faces models:list # the models you can name; --kind takes a list, or all
|
|
71
74
|
faces benchmark:start / get / list
|
|
72
|
-
faces fidelity:
|
|
75
|
+
faces fidelity:get / pick / save-thread # starting a run is retired with chat
|
|
73
76
|
|
|
74
77
|
faces group:create / list / get / edit / delete / members / add / remove
|
|
75
78
|
faces group:tag:add / list / remove / set
|
|
@@ -107,56 +110,70 @@ faces compile:upload alice --file podcast.mp3 --kind thread --face-speaker A
|
|
|
107
110
|
A labelled dialogue uploaded as a document is read as entirely the face's own words, other
|
|
108
111
|
speakers included. The document commands warn when a text file reads as a transcript.
|
|
109
112
|
|
|
110
|
-
##
|
|
113
|
+
## Choices
|
|
111
114
|
|
|
112
|
-
|
|
115
|
+
`faces choices` asks a face what it would do (`POST /v1/choices`). Describe the situation with
|
|
116
|
+
`--state` (prose, at most 3,000 tokens) or `--state-id` (a [state](#states)), and ask with
|
|
117
|
+
`--question`:
|
|
113
118
|
|
|
114
119
|
```bash
|
|
115
|
-
faces
|
|
116
|
-
faces
|
|
120
|
+
faces choices alice --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"
|
|
121
|
+
faces choices head:socrates --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3
|
|
122
|
+
faces choices "(alice | bob)" --state-file situation.txt -q "What next?" --model maestro-1-flash
|
|
117
123
|
```
|
|
118
124
|
|
|
119
|
-
`--
|
|
120
|
-
|
|
125
|
+
With both `--state-id` and `--state`, the prose is an addendum for that one call: read with the
|
|
126
|
+
state, never saved to it. Anything that should persist goes in the state as premises, with
|
|
127
|
+
`faces state:add --premise`.
|
|
128
|
+
|
|
129
|
+
The face proposes the options it would weigh, strongest first. Leave `--question` out and it
|
|
130
|
+
proposes the question it would ask. `--model` is `maestro-1` (the default) or `maestro-1-flash`,
|
|
131
|
+
which answers sooner and costs 10 times more when a question is asked. Prices:
|
|
132
|
+
`faces models:list --kind choices`.
|
|
133
|
+
|
|
134
|
+
## Chat is retired
|
|
121
135
|
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
The API's chat endpoints answer `410`, so the `chat:*` commands are removed, and so are
|
|
137
|
+
`fidelity:start`, `fidelity:turn` and `fidelity:run`. Use `faces choices` to ask a face. Runs made
|
|
138
|
+
before can still be read with `fidelity:get` and saved with `fidelity:save-thread`. `style:*` still
|
|
139
|
+
builds styles, which no route applies now, and `catalog:doctor --generate` is retired.
|
|
124
140
|
|
|
125
|
-
##
|
|
141
|
+
## States
|
|
126
142
|
|
|
127
|
-
A
|
|
128
|
-
|
|
129
|
-
|
|
143
|
+
A state keeps the situation your agent builds on the server: **premises** (named facts, each with
|
|
144
|
+
a status and what it depends on), the decisions faces made, and your messages. Hand it to a face
|
|
145
|
+
with `faces choices --state-id`, or pass it to `decide` and `causes` with `--conversation`.
|
|
130
146
|
|
|
131
147
|
```bash
|
|
132
|
-
faces
|
|
133
|
-
faces
|
|
134
|
-
--premise
|
|
135
|
-
faces
|
|
136
|
-
--
|
|
137
|
-
faces conversation
|
|
138
|
-
--
|
|
139
|
-
faces
|
|
140
|
-
faces
|
|
141
|
-
faces
|
|
148
|
+
faces state:create alice
|
|
149
|
+
faces state:add fs_STATE_ID --premise rent_rises='"12% in March"' --premise-status rent_rises=assumed \
|
|
150
|
+
--premise-description rent_rises="the landlord says rent goes up 12% in March"
|
|
151
|
+
faces state:add fs_STATE_ID --premise can_afford=false --premise-depends-on can_afford=rent_rises \
|
|
152
|
+
--premise-description can_afford="the shop can carry the higher rent"
|
|
153
|
+
faces decide alice --conversation fs_STATE_ID --depends-on can_afford \
|
|
154
|
+
--state "Decide about the lease." --question "Move the shop to a cheaper street?"
|
|
155
|
+
faces state:add fs_STATE_ID --premise rent_rises='"no rise this year"' --premise-status rent_rises=invalidated
|
|
156
|
+
faces choices alice --state-id fs_STATE_ID --question "What should the shop do?"
|
|
157
|
+
faces state:items fs_STATE_ID
|
|
142
158
|
```
|
|
143
159
|
|
|
144
|
-
`--conversation`, `--premise` and `--premise-description` work on `chat:chat`, `chat:messages`,
|
|
145
|
-
`chat:responses`, `chat:thread`, `decide` and `causes`.
|
|
146
|
-
|
|
147
160
|
A premise is `--premise key=value`, repeatable. The key is 1 to 64 letters, digits, `_` or `-`. The
|
|
148
161
|
value is read as JSON when it is JSON (`50000`, `true`, `null`, `["a","b"]`) and as text otherwise;
|
|
149
162
|
quote it to keep a number as text: `--premise 'code="007"'`. The first time a key is used it needs
|
|
150
|
-
a description
|
|
151
|
-
replaces it from then on, and `conversation:add` lists every earlier decision made under the old
|
|
152
|
-
value. Nothing is decided again for you.
|
|
163
|
+
a description: `--premise-description key="what it means"`.
|
|
153
164
|
|
|
154
|
-
|
|
155
|
-
`
|
|
156
|
-
|
|
165
|
+
`--premise-status key=status` is `stated` (the default), `verified`, `assumed`, `unresolved` or
|
|
166
|
+
`invalidated`. `--premise-depends-on key=a,b` names the premise keys and decision ids it rests on
|
|
167
|
+
(`key=` clears it). An invalidated premise invalidates everything that depends on it, and setting it
|
|
168
|
+
to another status restores them: `state:add` prints every status that changed, and every earlier
|
|
169
|
+
decision that rested on a value you changed. Nothing is decided again for you. `decide
|
|
170
|
+
--depends-on` says what a decision rests on, and prints its decision id to name in a later one.
|
|
157
171
|
|
|
158
|
-
|
|
159
|
-
|
|
172
|
+
`--conversation`, `--premise`, `--premise-description`, `--premise-status` and
|
|
173
|
+
`--premise-depends-on` work on `decide` and `causes`.
|
|
174
|
+
|
|
175
|
+
States were called conversations, and before that sessions. The `conversation:*` and `session:*`
|
|
176
|
+
commands, and `--session`, still work and name the same thing.
|
|
160
177
|
|
|
161
178
|
## Authentication
|
|
162
179
|
|
|
@@ -171,13 +188,16 @@ export FACES_BASE_URL=https://api.faces.sh # optional override
|
|
|
171
188
|
## Plans
|
|
172
189
|
|
|
173
190
|
- **Free**: a $5 activation, added as credits. Everything is paid as it goes, from credits.
|
|
174
|
-
- **Connect** ($17/month) and
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
and `
|
|
191
|
+
- **Connect** ($17/month): 25M choices and cause tokens a month (6.25M a week, 1.6M per 5 hours) and
|
|
192
|
+
500k compile source tokens.
|
|
193
|
+
- **Pro** ($49/month): 75M choices and cause tokens a month (18.75M a week, 4.8M per 5 hours) and
|
|
194
|
+
1.5M compile source tokens.
|
|
195
|
+
|
|
196
|
+
Past an allowance, work is paid from credits only with `api_fallback` on (`faces account:preferences`).
|
|
197
|
+
Choices cost $0.42 per million input tokens and $1.00 per million output tokens on `maestro-1`;
|
|
198
|
+
compiling costs $16 per million source tokens, $21 for a rush. Link a ChatGPT account with
|
|
199
|
+
`faces auth:connect openai` and interviews and style builds run on the ChatGPT plan. Current prices:
|
|
200
|
+
`faces models:list --kind all`.
|
|
181
201
|
|
|
182
202
|
## License
|
|
183
203
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const CHOICES_PATH = "/v1/choices";
|
|
2
|
+
export declare const CHOICES_MODELS: readonly ["maestro-1", "maestro-1-flash"];
|
|
3
|
+
export declare const MAX_CHOICES = 32;
|
|
4
|
+
export declare const MAX_STATE_TOKENS = 3000;
|
|
5
|
+
export interface ChoicesResponse {
|
|
6
|
+
object?: string;
|
|
7
|
+
view?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
choices?: Array<{
|
|
11
|
+
name?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}>;
|
|
14
|
+
question?: string;
|
|
15
|
+
alternatives?: string[];
|
|
16
|
+
usage?: {
|
|
17
|
+
input_tokens?: number;
|
|
18
|
+
output_tokens?: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare function asView(face: string): string;
|
|
22
|
+
export declare function choicesLines(data: ChoicesResponse): string[];
|
|
23
|
+
export declare function choicesHint(status: number, message: string, face: string): string | undefined;
|
package/dist/choices.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const CHOICES_PATH = '/v1/choices';
|
|
2
|
+
export const CHOICES_MODELS = ['maestro-1', 'maestro-1-flash'];
|
|
3
|
+
export const MAX_CHOICES = 32;
|
|
4
|
+
export const MAX_STATE_TOKENS = 3000;
|
|
5
|
+
export function asView(face) {
|
|
6
|
+
const f = face.trim();
|
|
7
|
+
return f.startsWith('@') ? f : `@${f}`;
|
|
8
|
+
}
|
|
9
|
+
export function choicesLines(data) {
|
|
10
|
+
const lines = [];
|
|
11
|
+
if (data.object === 'choices.question') {
|
|
12
|
+
lines.push(`${data.view ?? 'The face'} would ask: ${data.question ?? '-'}`);
|
|
13
|
+
const alts = data.alternatives ?? [];
|
|
14
|
+
if (alts.length > 0) {
|
|
15
|
+
lines.push('', 'Or:');
|
|
16
|
+
for (const a of alts)
|
|
17
|
+
lines.push(` - ${a}`);
|
|
18
|
+
}
|
|
19
|
+
lines.push('', 'Ask it with --question to get the options.');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const choices = data.choices ?? [];
|
|
23
|
+
if (choices.length === 0)
|
|
24
|
+
lines.push('No options.');
|
|
25
|
+
choices.forEach((c, i) => {
|
|
26
|
+
lines.push(`${i + 1}. ${c.name ?? '-'}`);
|
|
27
|
+
if (c.description)
|
|
28
|
+
lines.push(` ${c.description}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const u = data.usage;
|
|
32
|
+
if (u && (typeof u.input_tokens === 'number' || typeof u.output_tokens === 'number')) {
|
|
33
|
+
lines.push('', `${data.model ?? 'model'}: ${(u.input_tokens ?? 0).toLocaleString('en-US')} input, ${(u.output_tokens ?? 0).toLocaleString('en-US')} output tokens`);
|
|
34
|
+
}
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
export function choicesHint(status, message, face) {
|
|
38
|
+
if (status === 422 && /at most 3,000/.test(message)) {
|
|
39
|
+
return 'Put the situation in a state, one premise per fact (faces state:create, then faces state:add), and pass --state-id.';
|
|
40
|
+
}
|
|
41
|
+
if (status === 409 && /nothing compiled/i.test(message))
|
|
42
|
+
return `Give it a first source: faces compile:upload ${face.replace(/^@/, '')} --file <file>.`;
|
|
43
|
+
if (status === 409 && /compiled before/i.test(message))
|
|
44
|
+
return `Recompile one of its sources (list them with: faces face:sources ${face.replace(/^@/, '')}).`;
|
|
45
|
+
if (status === 404 && /state/i.test(message))
|
|
46
|
+
return 'A state expires 30 days after it was last used. Start another with: faces state:create';
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
@@ -17,7 +17,7 @@ function planLabel(plan) {
|
|
|
17
17
|
return plan.charAt(0).toUpperCase() + plan.slice(1);
|
|
18
18
|
}
|
|
19
19
|
export default class AuthConnect extends BaseCommand {
|
|
20
|
-
static description = 'Link your ChatGPT account by device-code authorization (Connect and Pro).
|
|
20
|
+
static description = 'Link your ChatGPT account by device-code authorization (Connect and Pro). Interviews and style builds then run on the ChatGPT plan instead of credits.';
|
|
21
21
|
static args = {
|
|
22
22
|
provider: Args.string({
|
|
23
23
|
description: 'OAuth provider to connect',
|
|
@@ -128,7 +128,7 @@ export default class AuthConnect extends BaseCommand {
|
|
|
128
128
|
this.log('⚠️ Your ChatGPT plan may not include API access. Connecting requires a paid plan (Plus/Pro/Team, etc.).');
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
this.log('
|
|
131
|
+
this.log('Interviews and style builds now run on your ChatGPT plan where the model allows it.');
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
return output;
|
|
@@ -3,32 +3,27 @@ import path from 'node:path';
|
|
|
3
3
|
import { Flags } from '@oclif/core';
|
|
4
4
|
import { BaseCommand } from '../../base.js';
|
|
5
5
|
import { FacesAPIError } from '../../client.js';
|
|
6
|
-
import {
|
|
7
|
-
import { unquoteYaml, seg, postChat } from '../../utils.js';
|
|
6
|
+
import { unquoteYaml, seg } from '../../utils.js';
|
|
8
7
|
import { CatalogService, CATALOG_DIR } from '../../catalog.js';
|
|
9
8
|
import { GroupCatalogService, GROUPS_DIR, slugifyGroupName } from '../../group-catalog.js';
|
|
10
|
-
import { resolveEndpoint, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT } from '../../routing.js';
|
|
11
9
|
export default class CatalogDoctor extends BaseCommand {
|
|
12
|
-
static description = 'Diagnose and repair the local face and group catalog.
|
|
10
|
+
static description = 'Diagnose and repair the local face and group catalog.';
|
|
13
11
|
static flags = {
|
|
14
12
|
...BaseCommand.baseFlags,
|
|
15
13
|
fix: Flags.boolean({ description: 'Rebuild missing or stale catalog entries from API', default: false }),
|
|
16
14
|
generate: Flags.boolean({
|
|
17
|
-
description: '
|
|
18
|
-
'is a chat on gpt-5-nano (or the catalog_model you set), charged to credits. Needs --allow-paid.',
|
|
19
|
-
default: false,
|
|
20
|
-
}),
|
|
21
|
-
'allow-paid': Flags.boolean({
|
|
22
|
-
description: 'Permit the charge for --generate. Without this flag --generate sends nothing and nothing is charged.',
|
|
15
|
+
description: 'Retired: descriptions were written by chatting with each face, and chat is retired. Write one with faces face:edit <alias> --description.',
|
|
23
16
|
default: false,
|
|
17
|
+
hidden: true,
|
|
24
18
|
}),
|
|
19
|
+
'allow-paid': Flags.boolean({ description: 'Retired with --generate.', default: false, hidden: true }),
|
|
25
20
|
};
|
|
26
21
|
async run() {
|
|
27
22
|
const { flags } = await this.parse(CatalogDoctor);
|
|
28
|
-
if (flags.generate
|
|
29
|
-
this.error('
|
|
30
|
-
'
|
|
31
|
-
'To repair the catalog
|
|
23
|
+
if (flags.generate) {
|
|
24
|
+
this.error('--generate wrote descriptions by chatting with each face, and chat is retired. Nothing was sent.\n' +
|
|
25
|
+
'Write a description with: faces face:edit <alias> --description "..."\n' +
|
|
26
|
+
'To repair the catalog, which is free: faces catalog:doctor --fix');
|
|
32
27
|
}
|
|
33
28
|
const client = this.makeClient(flags);
|
|
34
29
|
const catalog = new CatalogService();
|
|
@@ -236,60 +231,6 @@ export default class CatalogDoctor extends BaseCommand {
|
|
|
236
231
|
if (!groupsFetched) {
|
|
237
232
|
this.log('Could not reach the groups API, so local groups were not checked against the server.');
|
|
238
233
|
}
|
|
239
|
-
if (flags.generate && noDescription.length > 0) {
|
|
240
|
-
const cfg = loadConfig();
|
|
241
|
-
const catalogModel = cfg.catalog_model ?? 'gpt-5-nano';
|
|
242
|
-
this.log(`Generating descriptions for ${noDescription.length} face(s) via ${catalogModel}...`);
|
|
243
|
-
const { endpoint: descEndpoint } = await resolveEndpoint(client, `_@${catalogModel}`);
|
|
244
|
-
let generated = 0;
|
|
245
|
-
for (const alias of noDescription) {
|
|
246
|
-
const remote = remoteByAlias.get(alias);
|
|
247
|
-
if (!remote)
|
|
248
|
-
continue;
|
|
249
|
-
try {
|
|
250
|
-
const prompt = 'Describe yourself in one paragraph. Who are you, what do you care about, and what kind of questions are you best suited to answer?';
|
|
251
|
-
const faceModel = `${alias}@${catalogModel}`;
|
|
252
|
-
let text;
|
|
253
|
-
if (descEndpoint === MESSAGES_ENDPOINT) {
|
|
254
|
-
const resp = (await postChat(client, '/v1/messages', { model: faceModel, messages: [{ role: 'user', content: prompt }], max_tokens: 256 })).data;
|
|
255
|
-
text = resp.content?.find((b) => b.type === 'text')?.text;
|
|
256
|
-
}
|
|
257
|
-
else if (descEndpoint === RESPONSES_ENDPOINT) {
|
|
258
|
-
const resp = (await postChat(client, '/v1/responses', { model: faceModel, input: [{ role: 'user', content: prompt }], max_output_tokens: 256 })).data;
|
|
259
|
-
let out = '';
|
|
260
|
-
for (const item of resp.output ?? []) {
|
|
261
|
-
for (const block of item.content ?? []) {
|
|
262
|
-
if (block.type === 'output_text')
|
|
263
|
-
out += block.text ?? '';
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
text = out || undefined;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
const resp = (await postChat(client, '/v1/chat/completions', { model: faceModel, messages: [{ role: 'user', content: prompt }], max_tokens: 256 })).data;
|
|
270
|
-
text = resp.choices?.[0]?.message?.content;
|
|
271
|
-
}
|
|
272
|
-
if (text) {
|
|
273
|
-
const desc = text.trim();
|
|
274
|
-
catalog.writeFace({ ...remote, description: desc });
|
|
275
|
-
try {
|
|
276
|
-
await client.patch(`/v1/faces/${seg(alias)}`, { body: { description: desc } });
|
|
277
|
-
}
|
|
278
|
-
catch { }
|
|
279
|
-
generated++;
|
|
280
|
-
this.log(` ${alias}: done`);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
this.log(` ${alias}: no response`);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
catch (err) {
|
|
287
|
-
const msg = err instanceof FacesAPIError ? `HTTP ${err.statusCode}: ${err.message}` : String(err);
|
|
288
|
-
this.log(` ${alias}: failed: ${msg}`);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
this.log(`Generated ${generated} description(s).`);
|
|
292
|
-
}
|
|
293
234
|
catalog.rebuildIndex();
|
|
294
235
|
return {
|
|
295
236
|
fixed,
|
|
@@ -8,6 +8,8 @@ export default class Causes extends BaseCommand {
|
|
|
8
8
|
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
14
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
package/dist/commands/causes.js
CHANGED
|
@@ -10,7 +10,7 @@ export default class Causes extends BaseCommand {
|
|
|
10
10
|
static description = 'Get a face\'s cause alone, with no answering model: the principal why behind its response in this ' +
|
|
11
11
|
'context (POST /v1/causes). Send a conversation with -m, or a situation with --state, optionally with ' +
|
|
12
12
|
'questions for one cause per question. Billed at the cause rate only (see faces models:list --kind cause). ' +
|
|
13
|
-
'A cause takes about 10 seconds.
|
|
13
|
+
'A cause takes about 10 seconds. For the options a face would weigh, use choices; for typed answers, decide.';
|
|
14
14
|
static examples = [
|
|
15
15
|
'<%= config.bin %> <%= command.id %> alice -m "Should I take the offer?"',
|
|
16
16
|
'<%= config.bin %> <%= command.id %> alice --state "A fund offers $80k to change a finding before it is published."',
|
|
@@ -65,7 +65,7 @@ export default class Causes extends BaseCommand {
|
|
|
65
65
|
const json = this.jsonEnabled();
|
|
66
66
|
const face = args.face.trim();
|
|
67
67
|
if (face.includes('@')) {
|
|
68
|
-
this.error(`A cause is the face's alone, so leave the model off: ${face.slice(0, face.lastIndexOf('@'))}\
|
|
68
|
+
this.error(`A cause is the face's alone, so leave the model off: ${face.slice(0, face.lastIndexOf('@'))}\nFor the options a face would weigh, use faces choices.`);
|
|
69
69
|
}
|
|
70
70
|
const fail = (m) => this.error(m);
|
|
71
71
|
let turn = {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { BaseCommand } from '
|
|
2
|
-
export default class
|
|
1
|
+
import { BaseCommand } from '../base.js';
|
|
2
|
+
export default class Choices extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
question: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
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
|
+
'max-choices': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
12
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
13
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
14
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
15
|
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
16
|
};
|
|
14
17
|
static args: {
|
|
15
|
-
|
|
18
|
+
face: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
19
|
};
|
|
17
|
-
private rl?;
|
|
18
20
|
run(): Promise<unknown>;
|
|
19
|
-
private ask;
|
|
20
21
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../base.js';
|
|
3
|
+
import { FacesAPIError } from '../client.js';
|
|
4
|
+
import { CHOICES_MODELS, CHOICES_PATH, MAX_CHOICES, asView, choicesHint, choicesLines } from '../choices.js';
|
|
5
|
+
import { heldDecisionError, readStateFlags } from '../decisions.js';
|
|
6
|
+
import { retryOnceOnWarmUp, sayWarmUp } from '../utils.js';
|
|
7
|
+
export default class Choices extends BaseCommand {
|
|
8
|
+
static description = 'Ask a face what it would do (POST /v1/choices). Describe the situation with --state (prose, at most ' +
|
|
9
|
+
'3,000 tokens) or --state-id (a state from faces state:create), ask with --question, and the face proposes ' +
|
|
10
|
+
'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 choices). Takes about 10 to 30 seconds.';
|
|
12
|
+
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:socrates --state "A chain bakery opened across the street."',
|
|
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?" --model maestro-1-flash --json',
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
question: Flags.string({ char: 'q', description: 'The question. Leave it out to have the face propose the question it would ask.' }),
|
|
21
|
+
state: Flags.string({ description: 'The situation, as prose: at most 3,000 tokens.', exclusive: ['state-file'] }),
|
|
22
|
+
'state-file': Flags.string({ description: 'Read the situation from this file.', exclusive: ['state'] }),
|
|
23
|
+
'state-id': Flags.string({
|
|
24
|
+
description: 'A state (from faces state:create) as the situation. With --state, the prose is an addendum for this call only: ' +
|
|
25
|
+
'read with the state, never saved to it. Write anything that should persist with faces state:add --premise.',
|
|
26
|
+
}),
|
|
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
|
+
'max-choices': Flags.integer({ description: `The most options to return, 1 to ${MAX_CHOICES}. Default 8.`, min: 1, max: MAX_CHOICES }),
|
|
29
|
+
};
|
|
30
|
+
static args = {
|
|
31
|
+
face: Args.string({
|
|
32
|
+
description: 'The face: an alias, owner:alias for a face shared with you or a system face, or a composite such as "(a | b)". A leading @ is optional.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { args, flags } = await this.parse(Choices);
|
|
38
|
+
const client = this.makeClient(flags);
|
|
39
|
+
const json = this.jsonEnabled();
|
|
40
|
+
const view = asView(args.face);
|
|
41
|
+
if (view.includes('@', 1))
|
|
42
|
+
this.error(`Name the face alone, with no model after it: ${view.slice(0, view.indexOf('@', 1))}. Pick the choices model with --model.`);
|
|
43
|
+
const body = { view, model: flags.model };
|
|
44
|
+
const fail = (m) => this.error(m);
|
|
45
|
+
if (flags.state !== undefined || flags['state-file'] !== undefined) {
|
|
46
|
+
const state = readStateFlags(flags, fail);
|
|
47
|
+
if (typeof state === 'string' && state.trim() === '')
|
|
48
|
+
this.error('The situation is empty.');
|
|
49
|
+
body.state = state;
|
|
50
|
+
}
|
|
51
|
+
if (flags['state-id'])
|
|
52
|
+
body.state_id = flags['state-id'];
|
|
53
|
+
if (body.state === undefined && body.state_id === undefined) {
|
|
54
|
+
this.error('Describe the situation: --state "..." (or --state-file), or --state-id fs_... for a state.');
|
|
55
|
+
}
|
|
56
|
+
if (flags.question !== undefined) {
|
|
57
|
+
if (flags.question.trim() === '')
|
|
58
|
+
this.error('--question is empty. Leave it out to have the face propose the question.');
|
|
59
|
+
body.instructions = flags.question;
|
|
60
|
+
}
|
|
61
|
+
if (flags['max-choices'] !== undefined)
|
|
62
|
+
body.max_choices = flags['max-choices'];
|
|
63
|
+
let data;
|
|
64
|
+
try {
|
|
65
|
+
data = (await retryOnceOnWarmUp(async () => {
|
|
66
|
+
const res = await client.post(CHOICES_PATH, { body });
|
|
67
|
+
const held = heldDecisionError(res);
|
|
68
|
+
if (held)
|
|
69
|
+
throw held;
|
|
70
|
+
return res;
|
|
71
|
+
}, json ? undefined : sayWarmUp));
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
if (err instanceof FacesAPIError) {
|
|
75
|
+
const hint = choicesHint(err.statusCode, err.message, view);
|
|
76
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
|
|
77
|
+
}
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
if (json)
|
|
81
|
+
return data;
|
|
82
|
+
for (const line of choicesLines(data))
|
|
83
|
+
this.log(line);
|
|
84
|
+
return data;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -6,6 +6,8 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
6
6
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
11
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { BaseCommand } from '../../base.js';
|
|
3
3
|
import { FacesAPIError } from '../../client.js';
|
|
4
|
-
import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, clientItems, conversationHint, itemLines, parsePremises, premiseLines, staleDecisionLines, } from '../../conversation.js';
|
|
4
|
+
import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_FLAG_DESCRIPTION, clientItems, conversationHint, itemLines, parsePremises, premiseLines, staleDecisionLines, statusChangeLines, } from '../../conversation.js';
|
|
5
5
|
import { seg } from '../../utils.js';
|
|
6
6
|
export default class ConversationAdd extends BaseCommand {
|
|
7
|
-
static description = 'Add your own
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
|
|
7
|
+
static description = 'Add your own premises and messages to a state, without a face answering. Premises go in first, then ' +
|
|
8
|
+
'messages. A newer value of a key replaces it from here on. Every status the write changes is listed ' +
|
|
9
|
+
'(an invalidated premise invalidates what depends on it), and so is every earlier decision that rested on ' +
|
|
10
|
+
'a value you changed, so you can choose which to ask again: nothing is decided again for you. ' +
|
|
11
|
+
`At most ${MAX_CONVERSATION_ITEMS} at a time. Free.`;
|
|
11
12
|
static examples = [
|
|
12
|
-
'<%= config.bin %> <%= command.id %>
|
|
13
|
-
'<%= config.bin %> <%= command.id %>
|
|
14
|
-
'<%= config.bin %> <%= command.id %>
|
|
13
|
+
'<%= config.bin %> <%= command.id %> fs_STATE_ID --premise vendor_certified=false',
|
|
14
|
+
'<%= config.bin %> <%= command.id %> fs_STATE_ID --premise rent_rises="no rise" --premise-status rent_rises=invalidated',
|
|
15
|
+
'<%= config.bin %> <%= command.id %> fs_STATE_ID --premise can_afford=false --premise-description can_afford="we can carry the rent" --premise-depends-on can_afford=rent_rises',
|
|
16
|
+
'<%= config.bin %> <%= command.id %> fs_STATE_ID --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> fs_STATE_ID -m "The vendor sent their audit report."',
|
|
15
18
|
];
|
|
16
19
|
static flags = {
|
|
17
20
|
...BaseCommand.baseFlags,
|
|
18
21
|
message: Flags.string({ char: 'm', description: 'A message of yours (repeatable, kept in order).', multiple: true }),
|
|
19
22
|
premise: Flags.string({ description: PREMISE_FLAG_DESCRIPTION, multiple: true }),
|
|
20
23
|
'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
|
|
24
|
+
'premise-status': Flags.string({ description: PREMISE_STATUS_FLAG_DESCRIPTION, multiple: true }),
|
|
25
|
+
'premise-depends-on': Flags.string({ description: PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, multiple: true }),
|
|
21
26
|
};
|
|
22
27
|
static args = {
|
|
23
|
-
conversation_id: Args.string({ description: '
|
|
28
|
+
conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
|
|
24
29
|
};
|
|
25
30
|
async run() {
|
|
26
31
|
const { args, flags } = await this.parse(ConversationAdd);
|
|
27
32
|
const client = this.makeClient(flags);
|
|
28
33
|
let items;
|
|
29
34
|
try {
|
|
30
|
-
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description']));
|
|
35
|
+
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on']));
|
|
31
36
|
}
|
|
32
37
|
catch (err) {
|
|
33
38
|
this.error(err instanceof Error ? err.message : String(err));
|
|
@@ -54,6 +59,12 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
54
59
|
this.log('');
|
|
55
60
|
for (const line of premiseLines(data.premises))
|
|
56
61
|
this.log(line);
|
|
62
|
+
const changes = statusChangeLines(data.status_changes);
|
|
63
|
+
if (changes.length > 0) {
|
|
64
|
+
this.log('');
|
|
65
|
+
for (const line of changes)
|
|
66
|
+
this.log(line);
|
|
67
|
+
}
|
|
57
68
|
const stale = staleDecisionLines(data.decisions_made_under_old_values);
|
|
58
69
|
if (stale.length > 0) {
|
|
59
70
|
this.log('');
|