palbase 0.0.0-stage → 0.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/LICENSE +27 -0
- package/README.md +2 -2
- package/dist/ai/index.js +17 -0
- package/dist/backend/engine.js +2 -0
- package/dist/backend/env.js +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/stack.js +1 -0
- package/dist/backend/test.js +2 -0
- package/dist/chunks/5W6XJM46.js +13 -0
- package/dist/chunks/6OPBXB7Z.js +2 -0
- package/dist/chunks/7LOMYBLN.js +20 -0
- package/dist/chunks/AN5LCF5K.js +55 -0
- package/dist/chunks/ECUYQ73P.js +2 -0
- package/dist/chunks/HDX6YUAB.js +2 -0
- package/dist/chunks/HVC2C35F.js +2 -0
- package/dist/chunks/I3JNX6MZ.js +4 -0
- package/dist/chunks/JEJ5CFTK.js +2 -0
- package/dist/chunks/K3C2IEDS.js +2 -0
- package/dist/chunks/KRBVYYME.js +2 -0
- package/dist/chunks/NIJHTHNF.js +2 -0
- package/dist/chunks/TL4H6V3P.js +2 -0
- package/dist/chunks/UTRQWCMD.js +6 -0
- package/dist/chunks/ZFPDYRRY.js +2 -0
- package/dist/cli.js +815 -0
- package/dist/refuse/ai.js +2 -0
- package/dist/refuse/backend.js +2 -0
- package/dist/refuse/server.js +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/testing.js +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/palbe.js +2 -0
- package/dist/web/paywall.js +2 -0
- package/dist/web/vite.js +3 -0
- package/package.json +111 -4
- package/types/ai/src/ai.d.ts +178 -0
- package/types/ai/src/index.d.ts +5 -0
- package/types/ai/src/partial.d.ts +1 -0
- package/types/ai/src/schema.d.ts +47 -0
- package/types/backend/src/bootstrap.d.ts +72 -0
- package/types/backend/src/cache.d.ts +32 -0
- package/types/backend/src/container.d.ts +49 -0
- package/types/backend/src/database.d.ts +148 -0
- package/types/backend/src/db-env.d.ts +4 -0
- package/types/backend/src/decorators.d.ts +293 -0
- package/types/backend/src/engine-db.d.ts +24 -0
- package/types/backend/src/engine-exports.d.ts +3 -0
- package/types/backend/src/engine.d.ts +124 -0
- package/types/backend/src/env.d.ts +27 -0
- package/types/backend/src/errors.d.ts +70 -0
- package/types/backend/src/i18n.d.ts +21 -0
- package/types/backend/src/index.d.ts +23 -0
- package/types/backend/src/openapi.d.ts +73 -0
- package/types/backend/src/platform-calls.d.ts +41 -0
- package/types/backend/src/requests.d.ts +81 -0
- package/types/backend/src/rooms.d.ts +168 -0
- package/types/backend/src/router.d.ts +22 -0
- package/types/backend/src/runtime.d.ts +56 -0
- package/types/backend/src/services.d.ts +262 -0
- package/types/backend/src/stack.d.ts +20 -0
- package/types/backend/src/strings-files.d.ts +3 -0
- package/types/backend/src/testing/index.d.ts +3 -0
- package/types/backend/src/testing/unit.d.ts +66 -0
- package/types/backend/src/upload.d.ts +125 -0
- package/types/backend/src/webhooks.d.ts +113 -0
- package/types/internal/src/event.d.ts +9 -0
- package/types/internal/src/modules/ai.d.ts +678 -0
- package/types/internal/src/modules/analytics.d.ts +1414 -0
- package/types/internal/src/modules/auth.d.ts +5660 -0
- package/types/internal/src/modules/cache.d.ts +158 -0
- package/types/internal/src/modules/events.d.ts +19 -0
- package/types/internal/src/modules/flags.d.ts +957 -0
- package/types/internal/src/modules/index.d.ts +13 -0
- package/types/internal/src/modules/machines.d.ts +1584 -0
- package/types/internal/src/modules/notify.d.ts +1450 -0
- package/types/internal/src/modules/purchases.d.ts +4113 -0
- package/types/internal/src/modules/realtime.d.ts +326 -0
- package/types/internal/src/modules/secrets.d.ts +275 -0
- package/types/internal/src/modules/storage.d.ts +691 -0
- package/types/internal/src/modules/stores.d.ts +1516 -0
- package/types/internal/src/retry.d.ts +14 -0
- package/types/internal/src/transport.d.ts +106 -0
- package/types/server/src/auth/dpop.d.ts +47 -0
- package/types/server/src/auth/jwt.d.ts +115 -0
- package/types/server/src/index.d.ts +9 -0
- package/types/server/src/pages.d.ts +4 -0
- package/types/server/src/purchases.d.ts +51 -0
- package/types/server/src/secrets-env.d.ts +22 -0
- package/types/server/src/server.d.ts +40 -0
- package/types/server/src/testing.d.ts +91 -0
- package/types/server/src/webhooks.d.ts +72 -0
- package/types/web/src/analytics.d.ts +87 -0
- package/types/web/src/auth.d.ts +155 -0
- package/types/web/src/backend-error.d.ts +38 -0
- package/types/web/src/backend-names.d.ts +25 -0
- package/types/web/src/backends.d.ts +84 -0
- package/types/web/src/client.d.ts +51 -0
- package/types/web/src/index.d.ts +13 -0
- package/types/web/src/palbe.d.ts +2 -0
- package/types/web/src/paywall/icons.d.ts +5 -0
- package/types/web/src/paywall/index.d.ts +5 -0
- package/types/web/src/paywall/placement.d.ts +85 -0
- package/types/web/src/paywall/prices.d.ts +40 -0
- package/types/web/src/paywall/render.d.ts +54 -0
- package/types/web/src/paywall/resolve.d.ts +149 -0
- package/types/web/src/purchases.d.ts +86 -0
- package/types/web/src/rooms.d.ts +61 -0
- package/types/web/src/session.d.ts +91 -0
- package/types/web/src/socket.d.ts +87 -0
- package/types/web/src/vite.d.ts +49 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { type Reply, type Transport } from '../transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* An embedding model.
|
|
4
|
+
*/
|
|
5
|
+
export type EmbeddingModel = {
|
|
6
|
+
/**
|
|
7
|
+
* Its vectors' length, and the most that can be asked for.
|
|
8
|
+
*/
|
|
9
|
+
dimensions: number;
|
|
10
|
+
/**
|
|
11
|
+
* List price of a million input tokens, in US dollars.
|
|
12
|
+
*/
|
|
13
|
+
input_usd_per_mtok: number;
|
|
14
|
+
/**
|
|
15
|
+
* The model, as provider:model.
|
|
16
|
+
*/
|
|
17
|
+
model: string;
|
|
18
|
+
/**
|
|
19
|
+
* The role that names it: default, or empty.
|
|
20
|
+
*/
|
|
21
|
+
role: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The vectors.
|
|
25
|
+
*/
|
|
26
|
+
export type Embeddings = {
|
|
27
|
+
/**
|
|
28
|
+
* What it cost at the list price, in billionths of a dollar.
|
|
29
|
+
*/
|
|
30
|
+
cost_nano_usd: number;
|
|
31
|
+
/**
|
|
32
|
+
* The vectors' length.
|
|
33
|
+
*/
|
|
34
|
+
dimensions: number;
|
|
35
|
+
/**
|
|
36
|
+
* Tokens read.
|
|
37
|
+
*/
|
|
38
|
+
input_tokens: number;
|
|
39
|
+
/**
|
|
40
|
+
* The model.
|
|
41
|
+
*/
|
|
42
|
+
model: string;
|
|
43
|
+
/**
|
|
44
|
+
* One vector per text, in order: little-endian float32, base64-encoded.
|
|
45
|
+
*/
|
|
46
|
+
vectors: string[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Texts to embed.
|
|
50
|
+
*/
|
|
51
|
+
export type EmbeddingsRequest = {
|
|
52
|
+
/**
|
|
53
|
+
* A shorter vector than the model's own (0 or absent: the model's).
|
|
54
|
+
*/
|
|
55
|
+
dimensions?: number;
|
|
56
|
+
/**
|
|
57
|
+
* The texts (1,024 at most, none empty).
|
|
58
|
+
*/
|
|
59
|
+
input: string[];
|
|
60
|
+
/**
|
|
61
|
+
* default, or a catalogue embedding model as provider:model.
|
|
62
|
+
*/
|
|
63
|
+
model?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ErrorResponse = {
|
|
66
|
+
/**
|
|
67
|
+
* Machine-readable error code (snake_case)
|
|
68
|
+
*/
|
|
69
|
+
error: string;
|
|
70
|
+
/**
|
|
71
|
+
* Human-readable explanation
|
|
72
|
+
*/
|
|
73
|
+
error_description: string;
|
|
74
|
+
/**
|
|
75
|
+
* Correlation ID
|
|
76
|
+
*/
|
|
77
|
+
request_id: string;
|
|
78
|
+
/**
|
|
79
|
+
* Seconds to wait before retrying, when the refusal ends with time.
|
|
80
|
+
*/
|
|
81
|
+
retry_after?: number;
|
|
82
|
+
/**
|
|
83
|
+
* HTTP status code
|
|
84
|
+
*/
|
|
85
|
+
status: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A picture job.
|
|
89
|
+
*/
|
|
90
|
+
export type Image = {
|
|
91
|
+
/**
|
|
92
|
+
* When it started.
|
|
93
|
+
*/
|
|
94
|
+
created_at: string;
|
|
95
|
+
error: ImageError;
|
|
96
|
+
/**
|
|
97
|
+
* When it and its pictures are forgotten.
|
|
98
|
+
*/
|
|
99
|
+
expires_at: string;
|
|
100
|
+
/**
|
|
101
|
+
* Its pictures, once completed.
|
|
102
|
+
*/
|
|
103
|
+
files: ImageFile[];
|
|
104
|
+
/**
|
|
105
|
+
* The job's id.
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* The model.
|
|
110
|
+
*/
|
|
111
|
+
model: string;
|
|
112
|
+
/**
|
|
113
|
+
* running, completed or failed.
|
|
114
|
+
*/
|
|
115
|
+
status: "running" | "completed" | "failed";
|
|
116
|
+
usage: ImageUsage;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Why a job failed; null when it did not.
|
|
120
|
+
*/
|
|
121
|
+
export type ImageError = ({
|
|
122
|
+
/**
|
|
123
|
+
* Why, as a stable code.
|
|
124
|
+
*/
|
|
125
|
+
code: string;
|
|
126
|
+
/**
|
|
127
|
+
* Why, in a sentence.
|
|
128
|
+
*/
|
|
129
|
+
message: string;
|
|
130
|
+
}) | null;
|
|
131
|
+
/**
|
|
132
|
+
* A picture of a finished job.
|
|
133
|
+
*/
|
|
134
|
+
export type ImageFile = {
|
|
135
|
+
/**
|
|
136
|
+
* Its size.
|
|
137
|
+
*/
|
|
138
|
+
bytes: number;
|
|
139
|
+
/**
|
|
140
|
+
* Its media type.
|
|
141
|
+
*/
|
|
142
|
+
media_type: string;
|
|
143
|
+
/**
|
|
144
|
+
* Where to read it (GET).
|
|
145
|
+
*/
|
|
146
|
+
path: string;
|
|
147
|
+
/**
|
|
148
|
+
* Its place in the job, from 0.
|
|
149
|
+
*/
|
|
150
|
+
position: number;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* A picture the caller sends.
|
|
154
|
+
*/
|
|
155
|
+
export type ImageInput = {
|
|
156
|
+
/**
|
|
157
|
+
* The picture's bytes, base64-encoded (20 MB at most).
|
|
158
|
+
*/
|
|
159
|
+
data: string;
|
|
160
|
+
/**
|
|
161
|
+
* image/png, image/jpeg or image/webp (a mask is image/png with an alpha channel).
|
|
162
|
+
*/
|
|
163
|
+
media_type: "image/png" | "image/jpeg" | "image/webp";
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* An image model.
|
|
167
|
+
*/
|
|
168
|
+
export type ImageModel = {
|
|
169
|
+
/**
|
|
170
|
+
* List price of a million reference picture tokens, in US dollars.
|
|
171
|
+
*/
|
|
172
|
+
image_input_usd_per_mtok: number;
|
|
173
|
+
/**
|
|
174
|
+
* List price of a million picture tokens, in US dollars.
|
|
175
|
+
*/
|
|
176
|
+
image_output_usd_per_mtok: number;
|
|
177
|
+
/**
|
|
178
|
+
* The model, as provider:model.
|
|
179
|
+
*/
|
|
180
|
+
model: string;
|
|
181
|
+
/**
|
|
182
|
+
* The role that names it: default, strong, or empty.
|
|
183
|
+
*/
|
|
184
|
+
role: string;
|
|
185
|
+
/**
|
|
186
|
+
* List price of a million prompt tokens, in US dollars.
|
|
187
|
+
*/
|
|
188
|
+
text_input_usd_per_mtok: number;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* A request for pictures.
|
|
192
|
+
*/
|
|
193
|
+
export type ImageRequest = {
|
|
194
|
+
/**
|
|
195
|
+
* auto, transparent or opaque; transparent needs png or webp.
|
|
196
|
+
*/
|
|
197
|
+
background?: string;
|
|
198
|
+
/**
|
|
199
|
+
* How many pictures (1–4, default 1).
|
|
200
|
+
*/
|
|
201
|
+
count?: number;
|
|
202
|
+
/**
|
|
203
|
+
* png (default), jpeg or webp.
|
|
204
|
+
*/
|
|
205
|
+
format?: string;
|
|
206
|
+
mask?: ImageInput;
|
|
207
|
+
/**
|
|
208
|
+
* default (fast), strong (precise edits), or a catalogue image model as provider:model.
|
|
209
|
+
*/
|
|
210
|
+
model?: string;
|
|
211
|
+
/**
|
|
212
|
+
* What to make.
|
|
213
|
+
*/
|
|
214
|
+
prompt: string;
|
|
215
|
+
/**
|
|
216
|
+
* auto, low, medium, high, xhigh or max.
|
|
217
|
+
*/
|
|
218
|
+
quality?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Pictures to work from (4 at most, each 8 MiB at most and — with the mask — 24 MiB together, as PNG, JPEG or WebP): with them the job is an edit.
|
|
221
|
+
*/
|
|
222
|
+
references?: ImageInput[];
|
|
223
|
+
/**
|
|
224
|
+
* auto, 1024x1024, 1536x1024, 1024x1536, or WIDTHxHEIGHT: sides multiples of 16, an aspect between 1:3 and 3:1, 655,360 to 8,294,400 pixels.
|
|
225
|
+
*/
|
|
226
|
+
size?: string;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* What a finished job cost; null until then.
|
|
230
|
+
*/
|
|
231
|
+
export type ImageUsage = ({
|
|
232
|
+
/**
|
|
233
|
+
* What it cost at the list price, in billionths of a dollar.
|
|
234
|
+
*/
|
|
235
|
+
cost_nano_usd: number;
|
|
236
|
+
/**
|
|
237
|
+
* Reference picture tokens.
|
|
238
|
+
*/
|
|
239
|
+
image_input_tokens: number;
|
|
240
|
+
/**
|
|
241
|
+
* Prompt tokens.
|
|
242
|
+
*/
|
|
243
|
+
input_tokens: number;
|
|
244
|
+
/**
|
|
245
|
+
* Picture tokens.
|
|
246
|
+
*/
|
|
247
|
+
output_tokens: number;
|
|
248
|
+
}) | null;
|
|
249
|
+
/**
|
|
250
|
+
* One turn of the conversation so far.
|
|
251
|
+
*/
|
|
252
|
+
export type Message = {
|
|
253
|
+
/**
|
|
254
|
+
* What was said.
|
|
255
|
+
*/
|
|
256
|
+
content: string;
|
|
257
|
+
/**
|
|
258
|
+
* Who said it.
|
|
259
|
+
*/
|
|
260
|
+
role: "user" | "assistant";
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* What a project may name.
|
|
264
|
+
*/
|
|
265
|
+
export type Models = {
|
|
266
|
+
/**
|
|
267
|
+
* Embedding models, with their list prices.
|
|
268
|
+
*/
|
|
269
|
+
embeddings: EmbeddingModel[];
|
|
270
|
+
/**
|
|
271
|
+
* Image models, with their list prices.
|
|
272
|
+
*/
|
|
273
|
+
images: ImageModel[];
|
|
274
|
+
/**
|
|
275
|
+
* The roles a text model is chosen by.
|
|
276
|
+
*/
|
|
277
|
+
text: TextModel[];
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* A provider the project connected with its own key.
|
|
281
|
+
*/
|
|
282
|
+
export type Provider = {
|
|
283
|
+
/**
|
|
284
|
+
* The provider.
|
|
285
|
+
*/
|
|
286
|
+
name: string;
|
|
287
|
+
/**
|
|
288
|
+
* The provider accepted the key when it was connected.
|
|
289
|
+
*/
|
|
290
|
+
verified: boolean;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* A provider key.
|
|
294
|
+
*/
|
|
295
|
+
export type ProviderKey = {
|
|
296
|
+
/**
|
|
297
|
+
* The provider's API key. It is never read back.
|
|
298
|
+
*/
|
|
299
|
+
key: string;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* The project's own provider keys.
|
|
303
|
+
*/
|
|
304
|
+
export type ProviderList = {
|
|
305
|
+
/**
|
|
306
|
+
* The project's providers.
|
|
307
|
+
*/
|
|
308
|
+
providers: Provider[];
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* A response.
|
|
312
|
+
*/
|
|
313
|
+
export type Response = {
|
|
314
|
+
/**
|
|
315
|
+
* When it was admitted.
|
|
316
|
+
*/
|
|
317
|
+
created_at: string;
|
|
318
|
+
error: ResponseError;
|
|
319
|
+
/**
|
|
320
|
+
* The response's id.
|
|
321
|
+
*/
|
|
322
|
+
id: string;
|
|
323
|
+
/**
|
|
324
|
+
* The caller's own labels (16 at most, snake_case keys): returned with the response and its event.
|
|
325
|
+
*/
|
|
326
|
+
metadata: {
|
|
327
|
+
[key: string]: string;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* The model that answered.
|
|
331
|
+
*/
|
|
332
|
+
model: string;
|
|
333
|
+
/**
|
|
334
|
+
* The parsed document of an answer to a schema; null otherwise.
|
|
335
|
+
*/
|
|
336
|
+
output: unknown;
|
|
337
|
+
/**
|
|
338
|
+
* Where it is: queued, in_progress, then completed, failed, canceled, timed_out or budget_exceeded.
|
|
339
|
+
*/
|
|
340
|
+
status: string;
|
|
341
|
+
/**
|
|
342
|
+
* The answer as the model wrote it; for a schema's answer, the JSON document.
|
|
343
|
+
*/
|
|
344
|
+
text: string | null;
|
|
345
|
+
usage: ResponseUsage;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Why a response did not complete; null when it did.
|
|
349
|
+
*/
|
|
350
|
+
export type ResponseError = ({
|
|
351
|
+
/**
|
|
352
|
+
* Why, as a stable code.
|
|
353
|
+
*/
|
|
354
|
+
code: string;
|
|
355
|
+
/**
|
|
356
|
+
* Why, in a sentence.
|
|
357
|
+
*/
|
|
358
|
+
message: string;
|
|
359
|
+
}) | null;
|
|
360
|
+
/**
|
|
361
|
+
* A background response ended.
|
|
362
|
+
*/
|
|
363
|
+
export type ResponseEvent = {
|
|
364
|
+
/**
|
|
365
|
+
* What it cost, in billionths of a dollar.
|
|
366
|
+
*/
|
|
367
|
+
cost_nano_usd: number;
|
|
368
|
+
/**
|
|
369
|
+
* The caller's own labels (16 at most, snake_case keys): returned with the response and its event.
|
|
370
|
+
*/
|
|
371
|
+
metadata: {
|
|
372
|
+
[key: string]: string;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* The model that answered.
|
|
376
|
+
*/
|
|
377
|
+
model: string;
|
|
378
|
+
/**
|
|
379
|
+
* The response.
|
|
380
|
+
*/
|
|
381
|
+
response_id: string;
|
|
382
|
+
/**
|
|
383
|
+
* How it ended.
|
|
384
|
+
*/
|
|
385
|
+
status: string;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* A question for a model: input, or messages.
|
|
389
|
+
*/
|
|
390
|
+
export type ResponseRequest = {
|
|
391
|
+
/**
|
|
392
|
+
* Answer at once; the response's end is the event ai.response.completed or ai.response.failed.
|
|
393
|
+
*/
|
|
394
|
+
background?: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* The question (2 MB at most). Give this, or messages.
|
|
397
|
+
*/
|
|
398
|
+
input?: string;
|
|
399
|
+
/**
|
|
400
|
+
* How the model should answer (256 KB at most).
|
|
401
|
+
*/
|
|
402
|
+
instructions?: string;
|
|
403
|
+
/**
|
|
404
|
+
* The conversation so far instead of one question (500 turns at most); its last turn is the user's.
|
|
405
|
+
*/
|
|
406
|
+
messages?: Message[];
|
|
407
|
+
/**
|
|
408
|
+
* The caller's own labels (16 at most, snake_case keys): returned with the response and its event.
|
|
409
|
+
*/
|
|
410
|
+
metadata?: {
|
|
411
|
+
[key: string]: string;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* A role — fast, default (the default), strong — or a catalogue model as provider:model. Name a role: when a provider retires a model, the role is bound to another and your code does not change.
|
|
415
|
+
*/
|
|
416
|
+
model?: string;
|
|
417
|
+
/**
|
|
418
|
+
* A JSON Schema the answer must be a document of. Its keywords are the provider's strict subset: type, properties, required, additionalProperties, items, enum, description, title, minimum, maximum, minLength, maxLength, minItems, maxItems — no $ref, at most 12 levels and 512 properties; every property required (a nullable one may be null). One outside the subset is refused, naming where it is.
|
|
419
|
+
*/
|
|
420
|
+
schema?: {
|
|
421
|
+
[key: string]: unknown;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* The schema's name, as the model is told it (letters, digits, _ and -; default answer).
|
|
425
|
+
*/
|
|
426
|
+
schema_name?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Answer with the response's live view (text/event-stream).
|
|
429
|
+
*/
|
|
430
|
+
stream?: boolean;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* What a response used.
|
|
434
|
+
*/
|
|
435
|
+
export type ResponseUsage = {
|
|
436
|
+
/**
|
|
437
|
+
* Tokens read.
|
|
438
|
+
*/
|
|
439
|
+
input_tokens: number;
|
|
440
|
+
/**
|
|
441
|
+
* Tokens written.
|
|
442
|
+
*/
|
|
443
|
+
output_tokens: number;
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* A role a text model is chosen by.
|
|
447
|
+
*/
|
|
448
|
+
export type TextModel = {
|
|
449
|
+
/**
|
|
450
|
+
* What it is for.
|
|
451
|
+
*/
|
|
452
|
+
description: string;
|
|
453
|
+
/**
|
|
454
|
+
* The role.
|
|
455
|
+
*/
|
|
456
|
+
role: string;
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* A page of uses.
|
|
460
|
+
*/
|
|
461
|
+
export type UsagePage = {
|
|
462
|
+
/**
|
|
463
|
+
* The cursor of the next page; absent on the last.
|
|
464
|
+
*/
|
|
465
|
+
next_cursor?: string;
|
|
466
|
+
/**
|
|
467
|
+
* Uses, newest first.
|
|
468
|
+
*/
|
|
469
|
+
usage: Use[];
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* One use of a model.
|
|
473
|
+
*/
|
|
474
|
+
export type Use = {
|
|
475
|
+
/**
|
|
476
|
+
* Whose connection paid: platform, or project (the project's own key).
|
|
477
|
+
*/
|
|
478
|
+
connection_owner: "platform" | "project" | "";
|
|
479
|
+
/**
|
|
480
|
+
* What it cost at the provider's list price, in billionths of a dollar.
|
|
481
|
+
*/
|
|
482
|
+
cost_nano_usd: number;
|
|
483
|
+
/**
|
|
484
|
+
* When.
|
|
485
|
+
*/
|
|
486
|
+
created_at: string;
|
|
487
|
+
/**
|
|
488
|
+
* The use's id.
|
|
489
|
+
*/
|
|
490
|
+
id: string;
|
|
491
|
+
/**
|
|
492
|
+
* Reference picture tokens.
|
|
493
|
+
*/
|
|
494
|
+
image_input_tokens: number;
|
|
495
|
+
/**
|
|
496
|
+
* Tokens read.
|
|
497
|
+
*/
|
|
498
|
+
input_tokens: number;
|
|
499
|
+
/**
|
|
500
|
+
* Texts embedded, or pictures made.
|
|
501
|
+
*/
|
|
502
|
+
items: number;
|
|
503
|
+
/**
|
|
504
|
+
* text, embedding or image.
|
|
505
|
+
*/
|
|
506
|
+
kind: "text" | "embedding" | "image";
|
|
507
|
+
/**
|
|
508
|
+
* The model.
|
|
509
|
+
*/
|
|
510
|
+
model: string;
|
|
511
|
+
/**
|
|
512
|
+
* Tokens written.
|
|
513
|
+
*/
|
|
514
|
+
output_tokens: number;
|
|
515
|
+
/**
|
|
516
|
+
* The response, for a text use.
|
|
517
|
+
*/
|
|
518
|
+
response_id: string | null;
|
|
519
|
+
};
|
|
520
|
+
/** The events this module sends the project's webhooks (x-palbase-events), by type: each one's payload, the event's data. */
|
|
521
|
+
export interface Events {
|
|
522
|
+
/**
|
|
523
|
+
* ai.response.completed: a response started with background: true completed; read its answer by its id.
|
|
524
|
+
*/
|
|
525
|
+
"ai.response.completed": ResponseEvent;
|
|
526
|
+
/**
|
|
527
|
+
* ai.response.failed: a response started with background: true ended without completing (failed, canceled, timed out, over its budget).
|
|
528
|
+
*/
|
|
529
|
+
"ai.response.failed": ResponseEvent;
|
|
530
|
+
}
|
|
531
|
+
/** Palbase ai */
|
|
532
|
+
export declare function client(t: Transport): {
|
|
533
|
+
/**
|
|
534
|
+
* Turn texts into vectors
|
|
535
|
+
*
|
|
536
|
+
* One vector per text, in the order of the input. Up to 1,024 texts per request — a longer list is several requests, and the SDK cuts it; the platform splits a request over the provider's own limits.
|
|
537
|
+
*/
|
|
538
|
+
createEmbeddings(input: {
|
|
539
|
+
body: EmbeddingsRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
540
|
+
signal?: AbortSignal;
|
|
541
|
+
}): Promise<Reply<200, Embeddings>>;
|
|
542
|
+
/**
|
|
543
|
+
* Make pictures
|
|
544
|
+
*
|
|
545
|
+
* Starts a picture job and answers at once: making a picture takes the provider minutes. With reference images it edits them; a mask marks the part of the first to change. Read the job by its id; its pictures are kept for a day — save what you keep in your storage.
|
|
546
|
+
*/
|
|
547
|
+
createImage(input: {
|
|
548
|
+
headers: {
|
|
549
|
+
"Idempotency-Key": string;
|
|
550
|
+
};
|
|
551
|
+
body: ImageRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
552
|
+
signal?: AbortSignal;
|
|
553
|
+
}): Promise<Reply<202, Image>>;
|
|
554
|
+
/**
|
|
555
|
+
* Read a picture job
|
|
556
|
+
*
|
|
557
|
+
* The job: running, its pictures, or why it failed.
|
|
558
|
+
*/
|
|
559
|
+
getImage(input: {
|
|
560
|
+
path: {
|
|
561
|
+
image_id: string;
|
|
562
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
563
|
+
signal?: AbortSignal;
|
|
564
|
+
}): Promise<Reply<200, Image>>;
|
|
565
|
+
/**
|
|
566
|
+
* Read a picture
|
|
567
|
+
*
|
|
568
|
+
* The bytes of one picture of a finished job, with its media type.
|
|
569
|
+
*/
|
|
570
|
+
getImageFile(input: {
|
|
571
|
+
path: {
|
|
572
|
+
image_id: string; /** The picture's place in the job, from 0. */
|
|
573
|
+
position: number;
|
|
574
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
575
|
+
signal?: AbortSignal;
|
|
576
|
+
}): Promise<Reply<200, Response>>;
|
|
577
|
+
/**
|
|
578
|
+
* What a project may name
|
|
579
|
+
*
|
|
580
|
+
* The roles a text model is chosen by, and the embedding and image models with their list prices.
|
|
581
|
+
*/
|
|
582
|
+
listModels(input?: {
|
|
583
|
+
signal?: AbortSignal;
|
|
584
|
+
}): Promise<Reply<200, Models>>;
|
|
585
|
+
/**
|
|
586
|
+
* The project's own provider keys
|
|
587
|
+
*
|
|
588
|
+
* The providers the project connected with its own key. A key is never read back.
|
|
589
|
+
*/
|
|
590
|
+
listProviders(input?: {
|
|
591
|
+
signal?: AbortSignal;
|
|
592
|
+
}): Promise<Reply<200, ProviderList>>;
|
|
593
|
+
/**
|
|
594
|
+
* Use the project's own provider key
|
|
595
|
+
*
|
|
596
|
+
* From now on every call that goes to this provider goes out with the project's own key and is billed by the provider to the project. The key is shown to the provider before it is kept: one the provider refuses is not kept.
|
|
597
|
+
*/
|
|
598
|
+
connectProvider(input: {
|
|
599
|
+
path: {
|
|
600
|
+
provider: string;
|
|
601
|
+
};
|
|
602
|
+
body: ProviderKey; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
603
|
+
signal?: AbortSignal;
|
|
604
|
+
}): Promise<Reply<200, Provider>>;
|
|
605
|
+
/**
|
|
606
|
+
* Stop using the project's own provider key
|
|
607
|
+
*
|
|
608
|
+
* The key is removed; calls to this provider go out with the platform's connection again.
|
|
609
|
+
*/
|
|
610
|
+
disconnectProvider(input: {
|
|
611
|
+
path: {
|
|
612
|
+
provider: string;
|
|
613
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
614
|
+
signal?: AbortSignal;
|
|
615
|
+
}): Promise<Reply<204, undefined>>;
|
|
616
|
+
/**
|
|
617
|
+
* Ask a model
|
|
618
|
+
*
|
|
619
|
+
* Admits a response: an answer to the input, as text or — with a schema — as a JSON document of that shape, validated before it is returned. With stream: true the answer is the response's live view (text/event-stream). With background: true it answers at once and the response's end is the event ai.response.completed (or ai.response.failed). Otherwise it answers at once with the response queued; read it by its id.
|
|
620
|
+
*/
|
|
621
|
+
createResponse(input: {
|
|
622
|
+
headers: {
|
|
623
|
+
"Idempotency-Key": string;
|
|
624
|
+
};
|
|
625
|
+
body: ResponseRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
626
|
+
signal?: AbortSignal;
|
|
627
|
+
}): Promise<Reply<200, Response> | Reply<202, Response>>;
|
|
628
|
+
/**
|
|
629
|
+
* Read a response
|
|
630
|
+
*
|
|
631
|
+
* A response as it stands: its status, and at its end its answer, its use and — when it did not complete — why.
|
|
632
|
+
*/
|
|
633
|
+
getResponse(input: {
|
|
634
|
+
path: {
|
|
635
|
+
response_id: string;
|
|
636
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
637
|
+
signal?: AbortSignal;
|
|
638
|
+
}): Promise<Reply<200, Response>>;
|
|
639
|
+
/**
|
|
640
|
+
* Stop a response
|
|
641
|
+
*
|
|
642
|
+
* Asks the model service to stop the response; it ends canceled, and what it used until then is recorded.
|
|
643
|
+
*/
|
|
644
|
+
cancelResponse(input: {
|
|
645
|
+
path: {
|
|
646
|
+
response_id: string;
|
|
647
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
648
|
+
signal?: AbortSignal;
|
|
649
|
+
}): Promise<Reply<200, Response>>;
|
|
650
|
+
/**
|
|
651
|
+
* Follow a response as it is produced
|
|
652
|
+
*
|
|
653
|
+
* The response's live view from a byte offset of its answer: every fragment as the model produces it, then the response at its end. A finished response answers its terminal at once.
|
|
654
|
+
*/
|
|
655
|
+
followResponse(input: {
|
|
656
|
+
path: {
|
|
657
|
+
response_id: string;
|
|
658
|
+
};
|
|
659
|
+
query?: {
|
|
660
|
+
offset?: number;
|
|
661
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
662
|
+
signal?: AbortSignal;
|
|
663
|
+
}): Promise<Reply<200, Response>>;
|
|
664
|
+
/**
|
|
665
|
+
* What the project's use of models cost
|
|
666
|
+
*
|
|
667
|
+
* Every use, newest first: a response's tokens, an embeddings call, a picture job — with its cost at the provider's list price and whose connection paid. A use under the project's own key is billed by the provider, not by Palbase.
|
|
668
|
+
*/
|
|
669
|
+
listUsage(input?: {
|
|
670
|
+
query?: {
|
|
671
|
+
limit?: number; /** The next_cursor of the previous page. */
|
|
672
|
+
cursor?: string; /** Only uses of this kind: text, embedding or image. */
|
|
673
|
+
kind?: "text" | "embedding" | "image";
|
|
674
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
675
|
+
signal?: AbortSignal;
|
|
676
|
+
}): Promise<Reply<200, UsagePage>>;
|
|
677
|
+
};
|
|
678
|
+
export type Client = ReturnType<typeof client>;
|