@faces-sh/cli 1.1.0 → 1.3.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 +106 -54
- package/dist/billing.js +11 -8
- package/dist/chat-command.d.ts +33 -0
- package/dist/chat-command.js +110 -0
- package/dist/chat.d.ts +49 -0
- package/dist/chat.js +157 -0
- package/dist/choices.d.ts +11 -5
- package/dist/choices.js +26 -9
- package/dist/client.d.ts +8 -0
- package/dist/client.js +37 -0
- 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/{causes.d.ts → chat/chat.d.ts} +14 -14
- package/dist/commands/chat/chat.js +31 -0
- package/dist/commands/chat/messages.d.ts +32 -0
- package/dist/commands/chat/messages.js +21 -0
- package/dist/commands/chat/responses.d.ts +32 -0
- package/dist/commands/chat/responses.js +22 -0
- package/dist/commands/chat/thread.d.ts +40 -0
- package/dist/commands/chat/thread.js +238 -0
- package/dist/commands/choices.d.ts +4 -2
- package/dist/commands/choices.js +56 -15
- package/dist/commands/conversation/add.d.ts +2 -0
- package/dist/commands/conversation/add.js +5 -2
- package/dist/commands/conversation/compact.js +13 -16
- package/dist/commands/conversation/create.d.ts +2 -0
- package/dist/commands/conversation/create.js +14 -11
- package/dist/commands/decide.d.ts +32 -4
- package/dist/commands/decide.js +135 -83
- package/dist/commands/face/get.js +1 -1
- package/dist/commands/face/list.d.ts +2 -0
- package/dist/commands/face/list.js +23 -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/premise/add.d.ts +30 -0
- package/dist/commands/premise/add.js +86 -0
- package/dist/commands/premise/choices.d.ts +21 -0
- package/dist/commands/premise/choices.js +68 -0
- package/dist/commands/premise/claim.d.ts +20 -0
- package/dist/commands/premise/claim.js +38 -0
- package/dist/commands/premise/decide.d.ts +18 -0
- package/dist/commands/premise/decide.js +36 -0
- package/dist/commands/premise/delete.d.ts +17 -0
- package/dist/commands/premise/delete.js +17 -0
- package/dist/commands/premise/edit.d.ts +28 -0
- package/dist/commands/premise/edit.js +51 -0
- package/dist/commands/premise/get.d.ts +22 -0
- package/dist/commands/premise/get.js +37 -0
- package/dist/commands/premise/refine.d.ts +20 -0
- package/dist/commands/premise/refine.js +80 -0
- package/dist/commands/session/compact.js +5 -8
- package/dist/commands/session/create.js +9 -8
- package/dist/commands/state/create.d.ts +13 -2
- package/dist/commands/state/create.js +55 -2
- package/dist/commands/state/get.d.ts +19 -2
- package/dist/commands/state/get.js +30 -2
- package/dist/commands/state/use.d.ts +16 -0
- package/dist/commands/state/use.js +25 -0
- package/dist/commands/style/make.js +1 -1
- package/dist/commands/style/upload.js +1 -1
- package/dist/conversation.d.ts +30 -3
- package/dist/conversation.js +202 -18
- package/dist/decisions.d.ts +0 -5
- package/dist/decisions.js +0 -18
- package/dist/fidelity.js +3 -3
- package/dist/foreman.d.ts +47 -0
- package/dist/foreman.js +115 -0
- 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/refine.d.ts +106 -0
- package/dist/refine.js +601 -0
- package/dist/routing.d.ts +1 -4
- package/dist/routing.js +4 -40
- package/dist/synopsis.d.ts +49 -0
- package/dist/synopsis.js +43 -0
- package/dist/utils.d.ts +1 -25
- package/dist/utils.js +10 -108
- package/oclif.manifest.json +3939 -1835
- package/package.json +10 -4
- package/dist/commands/causes.js +0 -146
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Command-line interface for [Faces](https://faces.sh). Faces are causal models: compile one from an
|
|
4
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.
|
|
6
|
-
|
|
5
|
+
it would weigh, strongest first. A face also steers any chat model's replies, and a decision model's
|
|
6
|
+
typed decisions.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -29,16 +29,16 @@ 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
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?"
|
|
32
|
+
faces choices @alice:maestro-1 --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"
|
|
33
33
|
|
|
34
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."
|
|
35
|
+
faces choices @alice:maestro-1 --state "A startup offers me a lead role at a lower salary."
|
|
36
36
|
|
|
37
|
-
#
|
|
38
|
-
faces
|
|
37
|
+
# Chat: the face steers, gpt-5.4 writes the reply
|
|
38
|
+
faces chat:chat @alice:maestro-1/gpt-5.4 -m "Should I take the offer?"
|
|
39
39
|
|
|
40
|
-
# Decide: typed answers
|
|
41
|
-
faces decide alice --state "A colleague asks you to sign a proposal you have not read." \
|
|
40
|
+
# Decide: typed answers from a decision model, steered by the face
|
|
41
|
+
faces decide @alice:maestro-1/jev-latest --state "A colleague asks you to sign a proposal you have not read." \
|
|
42
42
|
--question "Does the speaker sign?"
|
|
43
43
|
|
|
44
44
|
# Compare and compose
|
|
@@ -58,9 +58,12 @@ faces face:avatar:list / get / make / upload / delete
|
|
|
58
58
|
faces face:tag:add / list / remove / set / all
|
|
59
59
|
|
|
60
60
|
faces choices # what a face would do: its options, or the question it would ask
|
|
61
|
-
faces
|
|
61
|
+
faces chat:chat / messages / responses / thread # chat with a face on any chat model
|
|
62
62
|
faces decide # what a face would decide: yes/no, a choice, or a score
|
|
63
|
-
faces state:create /
|
|
63
|
+
faces state:create --use / use / get # a state for this directory (.faces/state) and its proof
|
|
64
|
+
faces premise:add / edit / get / delete / claim
|
|
65
|
+
faces premise:refine / choices / decide # billed: refine a premise with a face, its candidates, their ranking
|
|
66
|
+
faces state:items / add / compact / close # the older premise-list commands, still served
|
|
64
67
|
faces conversation:create / ... # the old name for state:*
|
|
65
68
|
faces session:create / get / compact / close # an older name
|
|
66
69
|
|
|
@@ -71,8 +74,9 @@ faces compile:upload / import / all / status / stats
|
|
|
71
74
|
faces style:upload / make / status / versions / revert / delete
|
|
72
75
|
|
|
73
76
|
faces models:list # the models you can name; --kind takes a list, or all
|
|
77
|
+
faces media:list # the media a document can be, with what each covers
|
|
74
78
|
faces benchmark:start / get / list
|
|
75
|
-
faces fidelity:
|
|
79
|
+
faces fidelity:start / turn / pick / get / run / save-thread
|
|
76
80
|
|
|
77
81
|
faces group:create / list / get / edit / delete / members / add / remove
|
|
78
82
|
faces group:tag:add / list / remove / set
|
|
@@ -107,9 +111,32 @@ faces compile:upload alice --file interview.txt --kind thread --face-speaker Ali
|
|
|
107
111
|
faces compile:upload alice --file podcast.mp3 --kind thread --face-speaker A
|
|
108
112
|
```
|
|
109
113
|
|
|
114
|
+
A document's `--medium` is one of the 25 media `faces media:list` shows, each with what it
|
|
115
|
+
covers: a keynote is a `speech`, a diary a `journal entry`. A subcategory is not accepted.
|
|
116
|
+
|
|
110
117
|
A labelled dialogue uploaded as a document is read as entirely the face's own words, other
|
|
111
118
|
speakers included. The document commands warn when a text file reads as a transcript.
|
|
112
119
|
|
|
120
|
+
## Naming a model
|
|
121
|
+
|
|
122
|
+
Every command that runs a face takes one `model`, written the way the API takes it: our
|
|
123
|
+
**upstream** model (a face and its maestro) over a **downstream** model (the model that writes the
|
|
124
|
+
answer), as a fraction:
|
|
125
|
+
|
|
126
|
+
| `model` | Command |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `@alice:maestro-1` | `faces choices` (the upstream model answers) |
|
|
129
|
+
| `@alice:maestro-1/gpt-5.4` | `faces chat:*` |
|
|
130
|
+
| `@alice:maestro-1/jev-latest` | `faces decide` |
|
|
131
|
+
| `@dana~alice:maestro-1/gpt-5.4` | another account's face, published or shared with you |
|
|
132
|
+
| `(@alice \| @bob):maestro-1-flash/gpt-5.4` | a composite, with `\|`, `&`, `-` and `^` |
|
|
133
|
+
|
|
134
|
+
Your own face is `@alice`; another account's is `@owner~alice` (a system face is `@head~socrates`).
|
|
135
|
+
`maestro-1-flash` answers sooner and costs 10 times more on the upstream part. Everything after the
|
|
136
|
+
first `/` is the downstream model's id as `faces models:list` lists it. Quote a composite, because
|
|
137
|
+
the shell reads `|` and `&`. A plain model with no face is not served, and the old forms
|
|
138
|
+
(`alice@gpt-5.4`, a bare alias, `owner:alias`) are refused with the new form to use.
|
|
139
|
+
|
|
113
140
|
## Choices
|
|
114
141
|
|
|
115
142
|
`faces choices` asks a face what it would do (`POST /v1/choices`). Describe the situation with
|
|
@@ -117,63 +144,86 @@ speakers included. The document commands warn when a text file reads as a transc
|
|
|
117
144
|
`--question`:
|
|
118
145
|
|
|
119
146
|
```bash
|
|
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:
|
|
122
|
-
faces choices "(alice | bob)" --state-file situation.txt -q "What next?"
|
|
147
|
+
faces choices @alice:maestro-1 --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"
|
|
148
|
+
faces choices @head~socrates:maestro-1 --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3
|
|
149
|
+
faces choices "(@alice | @bob):maestro-1-flash" --state-file situation.txt -q "What next?"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
With `--state-id`, `--depends-on` names what the options rest on, comma separated: premise
|
|
153
|
+
keys, decision ids, option ids and choices ids in the state. The face is shown each of them, and
|
|
154
|
+
the premises each directly depends on, in full, and the options written into the state record
|
|
155
|
+
it:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
faces choices @alice:maestro-1 --state-id fs_STATE_ID --question "How do we get there?" --depends-on goal,budget
|
|
123
159
|
```
|
|
124
160
|
|
|
125
161
|
With both `--state-id` and `--state`, the prose is an addendum for that one call: read with the
|
|
126
162
|
state, never saved to it. Anything that should persist goes in the state as premises, with
|
|
127
|
-
`faces
|
|
163
|
+
`faces premise:add`.
|
|
128
164
|
|
|
129
165
|
The face proposes the options it would weigh, strongest first. Leave `--question` out and it
|
|
130
|
-
proposes the question it would ask. `--
|
|
131
|
-
|
|
132
|
-
|
|
166
|
+
proposes the question it would ask. With `--state-id` and a question, the options are also added
|
|
167
|
+
to the state: each is printed with its id (`opt_...`), and the list with its own (`cho_...`). A
|
|
168
|
+
premise or a decision that rests on an option names its id in `--premise-depends-on` or
|
|
169
|
+
`--depends-on` (the list's id names all of its options), and a decision resting on it, directly or
|
|
170
|
+
through a premise, is shown why the face proposed it. Prices: `faces models:list --kind upstream`.
|
|
133
171
|
|
|
134
|
-
## Chat
|
|
172
|
+
## Chat
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
174
|
+
`faces chat:chat` sends your message to a face: the face steers, and the downstream model writes
|
|
175
|
+
the reply. It picks `/v1/chat/completions`, `/v1/responses` or `/v1/messages` from the model
|
|
176
|
+
catalog; `chat:messages` and `chat:responses` force one. `chat:thread` keeps a multi-turn
|
|
177
|
+
conversation under `~/.faces/threads`.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
faces chat:chat @alice:maestro-1/gpt-5.4 -m "What matters most to you in your work?"
|
|
181
|
+
faces chat:chat "(@socrates | @nietzsche):maestro-1/claude-sonnet-4-6" -m "What is virtue?"
|
|
182
|
+
faces chat:thread @alice:maestro-1/gpt-5.4 -m "Should I take the offer?"
|
|
183
|
+
faces chat:thread --id t_THREAD_ID -m "And if they raise the salary?"
|
|
184
|
+
faces chat:chat @alice:maestro-1/gpt-5.4 -m "So what now?" --conversation fs_STATE_ID
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The face's style is chosen for each request, from the face's built styles. `style:*` builds them.
|
|
140
188
|
|
|
141
189
|
## States
|
|
142
190
|
|
|
143
|
-
A state
|
|
144
|
-
|
|
145
|
-
|
|
191
|
+
A state is a proof in progress, kept on the server: a tree of premises joined by AND and OR,
|
|
192
|
+
each box proved `[x]`, open `[ ]` or refuted `[-]`, and a last line that names what still stands
|
|
193
|
+
between you and a proved goal. `faces state:create --use` makes one for this directory (its id
|
|
194
|
+
goes in `.faces/state`), and every `premise:*` and `state:*` command here or below works on it.
|
|
146
195
|
|
|
147
196
|
```bash
|
|
148
|
-
faces state:create
|
|
149
|
-
faces
|
|
150
|
-
|
|
151
|
-
faces
|
|
152
|
-
|
|
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
|
|
197
|
+
faces state:create --use
|
|
198
|
+
faces premise:add "the dinner is planned" "A dinner party for six" --role goal --said "Plan a dinner party for six."
|
|
199
|
+
faces premise:add "the guests" "Six, one vegan" --and "the dinner is planned"
|
|
200
|
+
faces premise:refine "the dinner is planned" --face alice
|
|
201
|
+
faces state:get
|
|
158
202
|
```
|
|
159
203
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
204
|
+
`premise:add` writes a box: `--role goal` or `--role test` (none is a fact), under a parent with
|
|
205
|
+
`--and` (all such children must hold) or `--or` (one candidate is enough), reading inputs with
|
|
206
|
+
`--on a,b`. `premise:edit` changes one: a new value, a status, a test's run (`--status verified
|
|
207
|
+
--tested "<candidate>" --evidence "..."`), or what it waits on (`--await human`). `premise:get`
|
|
208
|
+
shows one box, its branch and its messages; `premise:delete` removes one. Writing and reading a
|
|
209
|
+
state are free.
|
|
210
|
+
|
|
211
|
+
`premise:refine "<key>" --face <alias>` asks the face to refine a premise: it decides whether
|
|
212
|
+
the premise needs conditions (AND), a pinned meaning (OR, its candidates ranked), one test, or
|
|
213
|
+
the human's answer, and writes one tier of children (`-r` goes on down, `--depth N|all`).
|
|
214
|
+
`premise:choices` asks the face for candidates, and `premise:decide` ranks them; a ranking never
|
|
215
|
+
rules a candidate out, only a failed test or the human does. These three are billed per call.
|
|
164
216
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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.
|
|
217
|
+
Several agents can work one state: `premise:claim "<key>" <name>` gives a branch to one of them,
|
|
218
|
+
and writes into it by anyone else are refused until it is released (`--release`) or expires.
|
|
219
|
+
Every write takes `--as <name>`.
|
|
171
220
|
|
|
172
|
-
|
|
173
|
-
|
|
221
|
+
The whole guide, with how to read the tree and the hooks that show it to your agent, is in the
|
|
222
|
+
Faces skill: [STATES.md](https://github.com/faces-sh/skill/blob/main/skills/faces/references/STATES.md).
|
|
174
223
|
|
|
175
|
-
|
|
176
|
-
|
|
224
|
+
The older premise-list commands (`state:add --premise`, `state:items`, `state:compact`,
|
|
225
|
+
`state:close`) still work. States were called conversations, and before that sessions: the
|
|
226
|
+
`conversation:*` and `session:*` commands still name the same thing.
|
|
177
227
|
|
|
178
228
|
## Authentication
|
|
179
229
|
|
|
@@ -188,14 +238,16 @@ export FACES_BASE_URL=https://api.faces.sh # optional override
|
|
|
188
238
|
## Plans
|
|
189
239
|
|
|
190
240
|
- **Free**: a $5 activation, added as credits. Everything is paid as it goes, from credits.
|
|
191
|
-
- **Connect** ($17/month): 25M choices and
|
|
241
|
+
- **Connect** ($17/month): 25M choices and steering tokens a month (6.25M a week, 1.6M per 5 hours) and
|
|
192
242
|
500k compile source tokens.
|
|
193
|
-
- **Pro** ($49/month): 75M choices and
|
|
243
|
+
- **Pro** ($49/month): 75M choices and steering tokens a month (18.75M a week, 4.8M per 5 hours) and
|
|
194
244
|
1.5M compile source tokens.
|
|
195
245
|
|
|
196
246
|
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
|
-
|
|
247
|
+
Choices cost $0.42 per million input tokens and $1.00 per million output tokens on `maestro-1`.
|
|
248
|
+
On chat and decisions the steering costs $0.42 per million input tokens plus $0.00042 a call, with no
|
|
249
|
+
output charge, and the downstream model its listed price plus 5%. `maestro-1-flash` is 10 times the
|
|
250
|
+
`maestro-1` price, on the upstream part only. Compiling costs $16 per million source tokens, $21 for a rush. Link a ChatGPT account with
|
|
199
251
|
`faces auth:connect openai` and interviews and style builds run on the ChatGPT plan. Current prices:
|
|
200
252
|
`faces models:list --kind all`.
|
|
201
253
|
|
package/dist/billing.js
CHANGED
|
@@ -8,9 +8,9 @@ export function planName(plan) {
|
|
|
8
8
|
return p ? p[0].toUpperCase() + p.slice(1) : 'unknown';
|
|
9
9
|
}
|
|
10
10
|
const ALLOWANCES = [
|
|
11
|
-
['
|
|
12
|
-
['
|
|
13
|
-
['
|
|
11
|
+
['upstream_5h', 'choices and steering, rolling 5 hours'],
|
|
12
|
+
['upstream_week', 'choices and steering, this week'],
|
|
13
|
+
['upstream_month', 'choices and steering, this month'],
|
|
14
14
|
['compile_month', 'compile, this month'],
|
|
15
15
|
];
|
|
16
16
|
export function tokens(n) {
|
|
@@ -77,15 +77,18 @@ export function allowanceLines(sub) {
|
|
|
77
77
|
if (!unlimited) {
|
|
78
78
|
const rates = sub.rates;
|
|
79
79
|
let past = 'Past an allowance, api_fallback on pays from your credits; off refuses with a 429 until it resets.';
|
|
80
|
-
if (rates && typeof rates.
|
|
81
|
-
const added = typeof rates.cause_added_tokens === 'number' && rates.cause_added_tokens > 0
|
|
82
|
-
? `, each cause counting its input tokens plus ${rates.cause_added_tokens.toLocaleString('en-US')},`
|
|
83
|
-
: '';
|
|
80
|
+
if (rates && typeof rates.compile_usd_per_million_source_tokens === 'number') {
|
|
84
81
|
const rush = typeof rates.compile_rush_usd_per_million_source_tokens === 'number'
|
|
85
82
|
? ` ($${rates.compile_rush_usd_per_million_source_tokens} for a rush)`
|
|
86
83
|
: '';
|
|
84
|
+
const steer = typeof rates.steering_usd_per_million_input_tokens === 'number' && typeof rates.steering_usd_per_call === 'number'
|
|
85
|
+
? `$${rates.steering_usd_per_million_input_tokens} per million steering tokens plus $${rates.steering_usd_per_call} a call, `
|
|
86
|
+
: '';
|
|
87
|
+
const choices = typeof rates.choices_usd_per_million_input_tokens === 'number' && typeof rates.choices_usd_per_million_output_tokens === 'number'
|
|
88
|
+
? `$${rates.choices_usd_per_million_input_tokens} and $${rates.choices_usd_per_million_output_tokens} per million choices input and output tokens, `
|
|
89
|
+
: '';
|
|
87
90
|
past +=
|
|
88
|
-
` Credits pay
|
|
91
|
+
` Credits pay ${steer}${choices}on maestro-1 (10 times on maestro-1-flash), and ` +
|
|
89
92
|
`$${rates.compile_usd_per_million_source_tokens} per million compile tokens${rush}.`;
|
|
90
93
|
}
|
|
91
94
|
lines.push(` ${past}`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseCommand } from './base.js';
|
|
2
|
+
import { FacesAPIError, FacesClient } from './client.js';
|
|
3
|
+
export declare abstract class ChatCommand extends BaseCommand {
|
|
4
|
+
static flags: {
|
|
5
|
+
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
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>;
|
|
13
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
|
+
};
|
|
27
|
+
static args: {
|
|
28
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
29
|
+
};
|
|
30
|
+
protected abstract forcedEndpoint(flags: Record<string, unknown>): string | undefined;
|
|
31
|
+
run(): Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
export declare function chatRefusal(err: FacesAPIError, model: string, endpoint: string, freeWhenConnected: boolean, client: FacesClient): Promise<string>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { BaseCommand } from './base.js';
|
|
4
|
+
import { FacesAPIError } from './client.js';
|
|
5
|
+
import { conversationFields } from './conversation.js';
|
|
6
|
+
import { chatgptLinked } from './style.js';
|
|
7
|
+
import { CHAT_COMPLETIONS_ENDPOINT, MODEL_ARG_DESCRIPTION, RESPONSES_ENDPOINT, chatFlags, chatMeta, chatModelProblem, chatPayload, sendChat, } from './chat.js';
|
|
8
|
+
import { parseModel } from './model.js';
|
|
9
|
+
import { resolveEndpoint } from './routing.js';
|
|
10
|
+
import { faceRefusalHint, parseTemperature } from './utils.js';
|
|
11
|
+
export class ChatCommand extends BaseCommand {
|
|
12
|
+
static flags = {
|
|
13
|
+
...BaseCommand.baseFlags,
|
|
14
|
+
...chatFlags(),
|
|
15
|
+
};
|
|
16
|
+
static args = {
|
|
17
|
+
model: Args.string({ description: MODEL_ARG_DESCRIPTION, required: true }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(this.constructor);
|
|
21
|
+
const client = this.makeClient(flags);
|
|
22
|
+
const json = this.jsonEnabled();
|
|
23
|
+
const model = args.model.trim();
|
|
24
|
+
const problem = chatModelProblem(model);
|
|
25
|
+
if (problem)
|
|
26
|
+
this.error(problem);
|
|
27
|
+
const turns = [];
|
|
28
|
+
if (flags.file) {
|
|
29
|
+
if (!fs.existsSync(flags.file))
|
|
30
|
+
this.error(`File not found: ${flags.file}`);
|
|
31
|
+
turns.push({ role: 'user', content: fs.readFileSync(flags.file, 'utf8') });
|
|
32
|
+
}
|
|
33
|
+
for (const m of flags.message ?? [])
|
|
34
|
+
turns.push({ role: 'user', content: m });
|
|
35
|
+
if (turns.length === 0)
|
|
36
|
+
this.error('Provide at least one --message/-m or --file.');
|
|
37
|
+
let turn;
|
|
38
|
+
try {
|
|
39
|
+
turn = conversationFields(flags);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
43
|
+
}
|
|
44
|
+
const downstream = parseModel(model).downstream;
|
|
45
|
+
const route = await resolveEndpoint(client, downstream);
|
|
46
|
+
const endpoint = this.forcedEndpoint(flags) ?? route.endpoint;
|
|
47
|
+
const temperature = flags.temperature === undefined ? undefined : parseTemperature(flags.temperature, (m) => this.error(m));
|
|
48
|
+
let payload;
|
|
49
|
+
try {
|
|
50
|
+
payload = chatPayload(endpoint, model, turns, {
|
|
51
|
+
system: flags.system,
|
|
52
|
+
maxTokens: flags['max-tokens'],
|
|
53
|
+
temperature,
|
|
54
|
+
stream: flags.stream && !json,
|
|
55
|
+
oauthOnly: flags['oauth-only'],
|
|
56
|
+
session: flags.session,
|
|
57
|
+
compaction: flags.compaction,
|
|
58
|
+
turn,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const res = await sendChat(client, endpoint, payload, (d) => process.stdout.write(d), json);
|
|
66
|
+
if (payload.stream) {
|
|
67
|
+
if (!res.text)
|
|
68
|
+
this.error('The reply stream ended with no answer. Run it again with --no-stream to see what the server said.');
|
|
69
|
+
process.stdout.write('\n');
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
if (json) {
|
|
73
|
+
const body = res.body ?? {};
|
|
74
|
+
body._meta = chatMeta(res.headers ?? {}, endpoint, model);
|
|
75
|
+
return body;
|
|
76
|
+
}
|
|
77
|
+
this.log(res.text);
|
|
78
|
+
return res.body;
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (err instanceof FacesAPIError)
|
|
82
|
+
this.error(await chatRefusal(err, model, endpoint, route.freeWhenConnected, client));
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export async function chatRefusal(err, model, endpoint, freeWhenConnected, client) {
|
|
88
|
+
if (err.errorCode === 'oauth_rejected') {
|
|
89
|
+
const hints = [];
|
|
90
|
+
const linked = await chatgptLinked(client);
|
|
91
|
+
if (linked === false)
|
|
92
|
+
hints.push('No ChatGPT account is linked. Link one with: faces auth:connect openai');
|
|
93
|
+
else
|
|
94
|
+
hints.push('If the ChatGPT link has lapsed, link it again with: faces auth:connect openai');
|
|
95
|
+
if (endpoint === RESPONSES_ENDPOINT && freeWhenConnected && linked === false)
|
|
96
|
+
hints.push('This model is free once it is linked.');
|
|
97
|
+
hints.push(err.fallbackAvailable
|
|
98
|
+
? 'Or allow paid fallback: faces account:preferences api_fallback true'
|
|
99
|
+
: 'Or add credits (faces billing:topup --amount <usd>) and allow paid fallback: faces account:preferences api_fallback true');
|
|
100
|
+
return `OAuth failed: ${err.message}\n${hints.join('\n')}`;
|
|
101
|
+
}
|
|
102
|
+
if (err.errorCode === 'model_not_supported') {
|
|
103
|
+
return `${err.message}\nYour ChatGPT plan does not serve this model. Name another after the /, or let it run on credits: faces account:preferences api_fallback true`;
|
|
104
|
+
}
|
|
105
|
+
if (err.errorCode === 'use_responses_for_free_oauth' && endpoint === CHAT_COMPLETIONS_ENDPOINT) {
|
|
106
|
+
return `HTTP ${err.statusCode}: ${err.message}\nRun it on your ChatGPT plan with --responses (or faces chat:responses).`;
|
|
107
|
+
}
|
|
108
|
+
const hint = faceRefusalHint(err, model);
|
|
109
|
+
return `HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`;
|
|
110
|
+
}
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FacesClient } from './client.js';
|
|
2
|
+
import { CHAT_COMPLETIONS_ENDPOINT, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT } from './routing.js';
|
|
3
|
+
export type ChatEndpoint = typeof CHAT_COMPLETIONS_ENDPOINT | typeof RESPONSES_ENDPOINT | typeof MESSAGES_ENDPOINT;
|
|
4
|
+
export interface Turn {
|
|
5
|
+
role: 'user' | 'assistant';
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ChatOptions {
|
|
9
|
+
system?: string;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
temperature?: number;
|
|
12
|
+
stream: boolean;
|
|
13
|
+
oauthOnly?: boolean;
|
|
14
|
+
session?: string;
|
|
15
|
+
compaction?: string;
|
|
16
|
+
turn?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare const MODEL_ARG_DESCRIPTION: string;
|
|
19
|
+
export declare function chatFlags(): {
|
|
20
|
+
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
31
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
36
|
+
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
37
|
+
};
|
|
38
|
+
export declare function chatModelProblem(model: string): string | undefined;
|
|
39
|
+
export declare function chatPayload(endpoint: string, model: string, turns: Turn[], o: ChatOptions): Record<string, unknown>;
|
|
40
|
+
export declare function replyText(body: Record<string, unknown>, endpoint: string): string;
|
|
41
|
+
export declare function chatMeta(headers: Record<string, string>, endpoint: string, model: string): Record<string, string>;
|
|
42
|
+
export interface ChatResult {
|
|
43
|
+
text: string;
|
|
44
|
+
body?: Record<string, unknown>;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
export declare function sendChat(client: FacesClient, endpoint: string, payload: Record<string, unknown>, onDelta: (text: string) => void, quiet?: boolean): Promise<ChatResult>;
|
|
48
|
+
export declare function faceOfModel(model: string): string;
|
|
49
|
+
export { CHAT_COMPLETIONS_ENDPOINT, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT };
|
package/dist/chat.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { FacesAPIError } from './client.js';
|
|
3
|
+
import { conversationTurnFlags } from './conversation.js';
|
|
4
|
+
import { modelProblem, parseModel } from './model.js';
|
|
5
|
+
import { CHAT_COMPLETIONS_ENDPOINT, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT } from './routing.js';
|
|
6
|
+
import { CHAT_PARAM_FLAGS, COMPACTION_FLAG_DESCRIPTION, MIN_MAX_OUTPUT_TOKENS, SESSION_FLAG_DESCRIPTION, STREAM_FLAG_DESCRIPTION, extractStreamDelta, isMaxTokensRenameError, postChat, retryOnceOnWarmUp, sayWarmUp, streamChat, warnDroppedParams, } from './utils.js';
|
|
7
|
+
export const MODEL_ARG_DESCRIPTION = 'The upstream model over the downstream model: @<face>:<maestro>/<model>, e.g. @alice:maestro-1/gpt-5.4. ' +
|
|
8
|
+
'Another account\'s face is @owner~face; a composite is "(@a | @b):maestro-1/<model>" (operators | & - ^). ' +
|
|
9
|
+
'maestro-1-flash steers sooner, at 10 times the steering price. The model after the / is any chat model ' +
|
|
10
|
+
'in faces models:list, written as it is listed.';
|
|
11
|
+
export function chatFlags() {
|
|
12
|
+
return {
|
|
13
|
+
message: Flags.string({ char: 'm', description: 'Your message (repeatable, sent in order).', multiple: true }),
|
|
14
|
+
file: Flags.string({ description: 'Read the message from a file.' }),
|
|
15
|
+
system: Flags.string({ description: 'System prompt (instructions on /v1/responses).' }),
|
|
16
|
+
stream: Flags.boolean({ description: STREAM_FLAG_DESCRIPTION, default: true, allowNo: true }),
|
|
17
|
+
'max-tokens': Flags.integer({ description: 'The most tokens the reply may take (at least 1; 16 on /v1/responses).', min: 1 }),
|
|
18
|
+
temperature: Flags.string({ description: 'Temperature (0.0-2.0).' }),
|
|
19
|
+
...conversationTurnFlags(),
|
|
20
|
+
session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
|
|
21
|
+
compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
|
|
22
|
+
'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits.', default: false }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function chatModelProblem(model) {
|
|
26
|
+
return modelProblem(model, 'both');
|
|
27
|
+
}
|
|
28
|
+
export function chatPayload(endpoint, model, turns, o) {
|
|
29
|
+
let payload;
|
|
30
|
+
if (endpoint === MESSAGES_ENDPOINT) {
|
|
31
|
+
payload = { model, messages: turns.map((t) => ({ role: t.role, content: t.content })), max_tokens: o.maxTokens ?? 1024, stream: o.stream };
|
|
32
|
+
if (o.system)
|
|
33
|
+
payload.system = o.system;
|
|
34
|
+
}
|
|
35
|
+
else if (endpoint === RESPONSES_ENDPOINT) {
|
|
36
|
+
payload = { model, input: turns.map((t) => ({ role: t.role, content: t.content })), stream: o.stream };
|
|
37
|
+
if (o.system)
|
|
38
|
+
payload.instructions = o.system;
|
|
39
|
+
if (o.maxTokens !== undefined) {
|
|
40
|
+
if (o.maxTokens < MIN_MAX_OUTPUT_TOKENS) {
|
|
41
|
+
throw new Error(`--max-tokens must be at least ${MIN_MAX_OUTPUT_TOKENS} on /v1/responses (got ${o.maxTokens}).`);
|
|
42
|
+
}
|
|
43
|
+
payload.max_output_tokens = o.maxTokens;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const messages = [];
|
|
48
|
+
if (o.system)
|
|
49
|
+
messages.push({ role: 'system', content: o.system });
|
|
50
|
+
for (const t of turns)
|
|
51
|
+
messages.push({ role: t.role, content: t.content });
|
|
52
|
+
payload = { model, messages, stream: o.stream };
|
|
53
|
+
if (o.maxTokens !== undefined)
|
|
54
|
+
payload.max_tokens = o.maxTokens;
|
|
55
|
+
}
|
|
56
|
+
if (o.temperature !== undefined)
|
|
57
|
+
payload.temperature = o.temperature;
|
|
58
|
+
if (o.session)
|
|
59
|
+
payload.session = o.session;
|
|
60
|
+
if (o.compaction)
|
|
61
|
+
payload.compaction = o.compaction;
|
|
62
|
+
if (o.turn)
|
|
63
|
+
Object.assign(payload, o.turn);
|
|
64
|
+
if (o.oauthOnly)
|
|
65
|
+
payload.oauth_only = true;
|
|
66
|
+
return payload;
|
|
67
|
+
}
|
|
68
|
+
export function replyText(body, endpoint) {
|
|
69
|
+
if (endpoint === MESSAGES_ENDPOINT) {
|
|
70
|
+
let text = '';
|
|
71
|
+
for (const block of body.content ?? []) {
|
|
72
|
+
if (block.type === 'text')
|
|
73
|
+
text += String(block.text ?? '');
|
|
74
|
+
}
|
|
75
|
+
return text;
|
|
76
|
+
}
|
|
77
|
+
if (endpoint === RESPONSES_ENDPOINT) {
|
|
78
|
+
let text = '';
|
|
79
|
+
for (const item of body.output ?? []) {
|
|
80
|
+
for (const block of item.content ?? []) {
|
|
81
|
+
if (block.type === 'output_text')
|
|
82
|
+
text += String(block.text ?? '');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return text;
|
|
86
|
+
}
|
|
87
|
+
const choices = body.choices;
|
|
88
|
+
return String(choices?.[0]?.message?.content ?? '');
|
|
89
|
+
}
|
|
90
|
+
export function chatMeta(headers, endpoint, model) {
|
|
91
|
+
const meta = {};
|
|
92
|
+
if (headers['x-faces-provider'])
|
|
93
|
+
meta.provider = headers['x-faces-provider'];
|
|
94
|
+
if (headers['x-faces-cost-usd'])
|
|
95
|
+
meta.cost_usd = headers['x-faces-cost-usd'];
|
|
96
|
+
if (headers['x-faces-billing'])
|
|
97
|
+
meta.billing = headers['x-faces-billing'];
|
|
98
|
+
meta.endpoint = endpoint;
|
|
99
|
+
meta.model = model;
|
|
100
|
+
return meta;
|
|
101
|
+
}
|
|
102
|
+
export async function sendChat(client, endpoint, payload, onDelta, quiet = false) {
|
|
103
|
+
if (payload.stream) {
|
|
104
|
+
let text = '';
|
|
105
|
+
const onHeaders = (headers) => warnDroppedParams(headers, CHAT_PARAM_FLAGS);
|
|
106
|
+
for await (const line of streamChat(client, endpoint, payload, onHeaders)) {
|
|
107
|
+
if (!line.startsWith('data: '))
|
|
108
|
+
continue;
|
|
109
|
+
const chunk = line.slice(6).trim();
|
|
110
|
+
if (chunk === '[DONE]' || chunk === '')
|
|
111
|
+
continue;
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = JSON.parse(chunk);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const error = parsed.error;
|
|
120
|
+
if (parsed.type === 'error' || (error && typeof error === 'object' && !parsed.choices)) {
|
|
121
|
+
const inner = (error ?? parsed);
|
|
122
|
+
const status = Number(inner.status ?? parsed.status ?? 500);
|
|
123
|
+
throw new FacesAPIError(status, String(inner.message ?? parsed.message ?? 'The stream ended with an error.'));
|
|
124
|
+
}
|
|
125
|
+
const delta = extractStreamDelta(parsed);
|
|
126
|
+
if (delta) {
|
|
127
|
+
text += delta;
|
|
128
|
+
onDelta(delta);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { text };
|
|
132
|
+
}
|
|
133
|
+
const say = quiet ? undefined : sayWarmUp;
|
|
134
|
+
let res;
|
|
135
|
+
try {
|
|
136
|
+
res = await retryOnceOnWarmUp(() => postChat(client, endpoint, payload), say);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
if (err instanceof FacesAPIError && isMaxTokensRenameError(err.message) && payload.max_tokens !== undefined) {
|
|
140
|
+
payload.max_completion_tokens = payload.max_tokens;
|
|
141
|
+
delete payload.max_tokens;
|
|
142
|
+
res = await retryOnceOnWarmUp(() => postChat(client, endpoint, payload), say);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!quiet)
|
|
149
|
+
warnDroppedParams(res.headers, CHAT_PARAM_FLAGS);
|
|
150
|
+
const body = res.data;
|
|
151
|
+
return { text: replyText(body, endpoint), body, headers: res.headers };
|
|
152
|
+
}
|
|
153
|
+
export function faceOfModel(model) {
|
|
154
|
+
const faces = parseModel(model).faces ?? model;
|
|
155
|
+
return faces.replace(/^@/, '').replace('~', ':');
|
|
156
|
+
}
|
|
157
|
+
export { CHAT_COMPLETIONS_ENDPOINT, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT };
|