@ocno/oryn-sdk 0.0.0-stage → 0.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/CONTRIBUTING.md +3 -0
- package/LICENSE +21 -0
- package/README.md +184 -2
- package/SECURITY.md +3 -0
- package/dist/index.d.ts +800 -0
- package/dist/index.js +1773 -0
- package/docs/api-reference.md +280 -0
- package/docs/images/request-lifecycle.png +0 -0
- package/docs/images/request-lifecycle.svg +59 -0
- package/docs/recipes.md +288 -0
- package/package.json +34 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1773 @@
|
|
|
1
|
+
// src/shared-tasks.ts
|
|
2
|
+
var SHARED_TASK_CONTRACTS = [
|
|
3
|
+
"unconditional-image-generation-v1",
|
|
4
|
+
"audio-question-answering-v1",
|
|
5
|
+
"audio-transformation-v1",
|
|
6
|
+
"multimodal-generation-v1",
|
|
7
|
+
"image-text-to-video-v1",
|
|
8
|
+
"video-editing-v1",
|
|
9
|
+
"tabular-classification-v1",
|
|
10
|
+
"tabular-regression-v1",
|
|
11
|
+
"time-series-forecasting-v1",
|
|
12
|
+
"pose-estimation-v1",
|
|
13
|
+
"visual-document-retrieval-v1",
|
|
14
|
+
"table-question-answering-v1",
|
|
15
|
+
"document-question-answering-v1",
|
|
16
|
+
"keypoint-detection-v1",
|
|
17
|
+
"video-classification-v1",
|
|
18
|
+
"video-question-answering-v1",
|
|
19
|
+
"voice-activity-detection-v1",
|
|
20
|
+
"image-editing-v1",
|
|
21
|
+
"image-layers-v1",
|
|
22
|
+
"zero-shot-classification-v1",
|
|
23
|
+
"image-embeddings-v1",
|
|
24
|
+
"image-segmentation-v1",
|
|
25
|
+
"mask-generation-v1",
|
|
26
|
+
"zero-shot-object-detection-v1",
|
|
27
|
+
"image-to-text-v1",
|
|
28
|
+
"visual-question-answering-v1"
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// src/shared-task-schemas.ts
|
|
32
|
+
var sharedTaskSchemas = {
|
|
33
|
+
"unconditional-image-generation-v1": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"width": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"minimum": 8,
|
|
40
|
+
"maximum": 1024,
|
|
41
|
+
"multipleOf": 8,
|
|
42
|
+
"default": 256
|
|
43
|
+
},
|
|
44
|
+
"height": {
|
|
45
|
+
"type": "integer",
|
|
46
|
+
"minimum": 8,
|
|
47
|
+
"maximum": 1024,
|
|
48
|
+
"multipleOf": 8,
|
|
49
|
+
"default": 256
|
|
50
|
+
},
|
|
51
|
+
"steps": {
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"minimum": 1,
|
|
54
|
+
"maximum": 1e3,
|
|
55
|
+
"default": 50
|
|
56
|
+
},
|
|
57
|
+
"seed": {
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"minimum": 0,
|
|
60
|
+
"maximum": 2147483647,
|
|
61
|
+
"default": 0
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": []
|
|
65
|
+
},
|
|
66
|
+
"audio-question-answering-v1": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"additionalProperties": false,
|
|
69
|
+
"properties": {
|
|
70
|
+
"audioArtifactId": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
73
|
+
},
|
|
74
|
+
"instruction": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"minLength": 1,
|
|
77
|
+
"maxLength": 2048,
|
|
78
|
+
"pattern": "\\S"
|
|
79
|
+
},
|
|
80
|
+
"maxTokens": {
|
|
81
|
+
"type": "integer",
|
|
82
|
+
"minimum": 1,
|
|
83
|
+
"maximum": 256,
|
|
84
|
+
"default": 128
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"required": [
|
|
88
|
+
"audioArtifactId",
|
|
89
|
+
"instruction"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"audio-transformation-v1": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"additionalProperties": false,
|
|
95
|
+
"properties": {
|
|
96
|
+
"operation": {
|
|
97
|
+
"enum": [
|
|
98
|
+
"enhance",
|
|
99
|
+
"separate",
|
|
100
|
+
"voice-conversion",
|
|
101
|
+
"encode",
|
|
102
|
+
"decode",
|
|
103
|
+
"vocode"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"audioArtifactId": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
109
|
+
},
|
|
110
|
+
"referenceAudioArtifactId": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
113
|
+
},
|
|
114
|
+
"codes": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "array",
|
|
118
|
+
"items": {
|
|
119
|
+
"type": "integer",
|
|
120
|
+
"minimum": 0,
|
|
121
|
+
"maximum": 65535
|
|
122
|
+
},
|
|
123
|
+
"minItems": 1,
|
|
124
|
+
"maxItems": 32
|
|
125
|
+
},
|
|
126
|
+
"minItems": 1,
|
|
127
|
+
"maxItems": 2048
|
|
128
|
+
},
|
|
129
|
+
"spectrogram": {
|
|
130
|
+
"type": "array",
|
|
131
|
+
"items": {
|
|
132
|
+
"type": "array",
|
|
133
|
+
"items": {
|
|
134
|
+
"type": "number",
|
|
135
|
+
"minimum": -1e3,
|
|
136
|
+
"maximum": 1e3
|
|
137
|
+
},
|
|
138
|
+
"minItems": 1,
|
|
139
|
+
"maxItems": 128
|
|
140
|
+
},
|
|
141
|
+
"minItems": 1,
|
|
142
|
+
"maxItems": 512
|
|
143
|
+
},
|
|
144
|
+
"sampleRate": {
|
|
145
|
+
"type": "integer",
|
|
146
|
+
"minimum": 8e3,
|
|
147
|
+
"maximum": 48e3
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"required": [
|
|
151
|
+
"operation"
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
"multimodal-generation-v1": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"additionalProperties": false,
|
|
157
|
+
"properties": {
|
|
158
|
+
"instruction": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"minLength": 1,
|
|
161
|
+
"maxLength": 2048,
|
|
162
|
+
"pattern": "\\S"
|
|
163
|
+
},
|
|
164
|
+
"imageArtifactId": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
167
|
+
},
|
|
168
|
+
"audioArtifactId": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
171
|
+
},
|
|
172
|
+
"inputMode": {
|
|
173
|
+
"enum": [
|
|
174
|
+
"image",
|
|
175
|
+
"audio",
|
|
176
|
+
"image-and-audio"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
"outputMode": {
|
|
180
|
+
"enum": [
|
|
181
|
+
"text",
|
|
182
|
+
"audio",
|
|
183
|
+
"text-and-audio"
|
|
184
|
+
],
|
|
185
|
+
"default": "text"
|
|
186
|
+
},
|
|
187
|
+
"maxTokens": {
|
|
188
|
+
"type": "integer",
|
|
189
|
+
"minimum": 1,
|
|
190
|
+
"maximum": 256,
|
|
191
|
+
"default": 128
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"required": [
|
|
195
|
+
"instruction",
|
|
196
|
+
"inputMode"
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
"image-text-to-video-v1": {
|
|
200
|
+
"type": "object",
|
|
201
|
+
"additionalProperties": false,
|
|
202
|
+
"properties": {
|
|
203
|
+
"imageArtifactId": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
206
|
+
},
|
|
207
|
+
"prompt": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"minLength": 1,
|
|
210
|
+
"maxLength": 2048,
|
|
211
|
+
"pattern": "\\S"
|
|
212
|
+
},
|
|
213
|
+
"width": {
|
|
214
|
+
"type": "integer",
|
|
215
|
+
"minimum": 64,
|
|
216
|
+
"maximum": 1024,
|
|
217
|
+
"multipleOf": 16,
|
|
218
|
+
"default": 256
|
|
219
|
+
},
|
|
220
|
+
"height": {
|
|
221
|
+
"type": "integer",
|
|
222
|
+
"minimum": 64,
|
|
223
|
+
"maximum": 1024,
|
|
224
|
+
"multipleOf": 16,
|
|
225
|
+
"default": 256
|
|
226
|
+
},
|
|
227
|
+
"frames": {
|
|
228
|
+
"type": "integer",
|
|
229
|
+
"minimum": 1,
|
|
230
|
+
"maximum": 360,
|
|
231
|
+
"default": 17
|
|
232
|
+
},
|
|
233
|
+
"fps": {
|
|
234
|
+
"type": "integer",
|
|
235
|
+
"minimum": 1,
|
|
236
|
+
"maximum": 30,
|
|
237
|
+
"default": 8
|
|
238
|
+
},
|
|
239
|
+
"steps": {
|
|
240
|
+
"type": "integer",
|
|
241
|
+
"minimum": 1,
|
|
242
|
+
"maximum": 100,
|
|
243
|
+
"default": 20
|
|
244
|
+
},
|
|
245
|
+
"guidanceScale": {
|
|
246
|
+
"type": "number",
|
|
247
|
+
"minimum": 0,
|
|
248
|
+
"maximum": 30,
|
|
249
|
+
"default": 6
|
|
250
|
+
},
|
|
251
|
+
"seed": {
|
|
252
|
+
"type": "integer",
|
|
253
|
+
"minimum": 0,
|
|
254
|
+
"maximum": 2147483647,
|
|
255
|
+
"default": 0
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"required": [
|
|
259
|
+
"imageArtifactId",
|
|
260
|
+
"prompt"
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
"video-editing-v1": {
|
|
264
|
+
"type": "object",
|
|
265
|
+
"additionalProperties": false,
|
|
266
|
+
"properties": {
|
|
267
|
+
"videoArtifactId": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
270
|
+
},
|
|
271
|
+
"prompt": {
|
|
272
|
+
"type": "string",
|
|
273
|
+
"minLength": 1,
|
|
274
|
+
"maxLength": 2048,
|
|
275
|
+
"pattern": "\\S"
|
|
276
|
+
},
|
|
277
|
+
"maskVideoArtifactId": {
|
|
278
|
+
"type": "string",
|
|
279
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
280
|
+
},
|
|
281
|
+
"operation": {
|
|
282
|
+
"enum": [
|
|
283
|
+
"edit",
|
|
284
|
+
"restore"
|
|
285
|
+
],
|
|
286
|
+
"default": "edit"
|
|
287
|
+
},
|
|
288
|
+
"startSeconds": {
|
|
289
|
+
"type": "number",
|
|
290
|
+
"minimum": 0,
|
|
291
|
+
"maximum": 30,
|
|
292
|
+
"default": 0
|
|
293
|
+
},
|
|
294
|
+
"durationSeconds": {
|
|
295
|
+
"type": "number",
|
|
296
|
+
"minimum": 0.01,
|
|
297
|
+
"maximum": 30,
|
|
298
|
+
"default": 1
|
|
299
|
+
},
|
|
300
|
+
"width": {
|
|
301
|
+
"type": "integer",
|
|
302
|
+
"minimum": 64,
|
|
303
|
+
"maximum": 1024,
|
|
304
|
+
"multipleOf": 16,
|
|
305
|
+
"default": 256
|
|
306
|
+
},
|
|
307
|
+
"height": {
|
|
308
|
+
"type": "integer",
|
|
309
|
+
"minimum": 64,
|
|
310
|
+
"maximum": 1024,
|
|
311
|
+
"multipleOf": 16,
|
|
312
|
+
"default": 256
|
|
313
|
+
},
|
|
314
|
+
"frames": {
|
|
315
|
+
"type": "integer",
|
|
316
|
+
"minimum": 1,
|
|
317
|
+
"maximum": 129,
|
|
318
|
+
"default": 17
|
|
319
|
+
},
|
|
320
|
+
"fps": {
|
|
321
|
+
"type": "integer",
|
|
322
|
+
"minimum": 1,
|
|
323
|
+
"maximum": 30,
|
|
324
|
+
"default": 8
|
|
325
|
+
},
|
|
326
|
+
"steps": {
|
|
327
|
+
"type": "integer",
|
|
328
|
+
"minimum": 1,
|
|
329
|
+
"maximum": 100,
|
|
330
|
+
"default": 20
|
|
331
|
+
},
|
|
332
|
+
"guidanceScale": {
|
|
333
|
+
"type": "number",
|
|
334
|
+
"minimum": 0,
|
|
335
|
+
"maximum": 30,
|
|
336
|
+
"default": 6
|
|
337
|
+
},
|
|
338
|
+
"seed": {
|
|
339
|
+
"type": "integer",
|
|
340
|
+
"minimum": 0,
|
|
341
|
+
"maximum": 2147483647,
|
|
342
|
+
"default": 0
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
"required": [
|
|
346
|
+
"videoArtifactId"
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
"tabular-classification-v1": {
|
|
350
|
+
"type": "object",
|
|
351
|
+
"additionalProperties": false,
|
|
352
|
+
"properties": {
|
|
353
|
+
"columns": {
|
|
354
|
+
"type": "array",
|
|
355
|
+
"items": {
|
|
356
|
+
"type": "object",
|
|
357
|
+
"additionalProperties": false,
|
|
358
|
+
"properties": {
|
|
359
|
+
"name": {
|
|
360
|
+
"type": "string",
|
|
361
|
+
"minLength": 1,
|
|
362
|
+
"maxLength": 128,
|
|
363
|
+
"pattern": "\\S"
|
|
364
|
+
},
|
|
365
|
+
"type": {
|
|
366
|
+
"enum": [
|
|
367
|
+
"numeric",
|
|
368
|
+
"categorical"
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"required": [
|
|
373
|
+
"name",
|
|
374
|
+
"type"
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
"minItems": 1,
|
|
378
|
+
"maxItems": 32
|
|
379
|
+
},
|
|
380
|
+
"trainingRows": {
|
|
381
|
+
"type": "array",
|
|
382
|
+
"items": {
|
|
383
|
+
"type": "array",
|
|
384
|
+
"items": {
|
|
385
|
+
"anyOf": [
|
|
386
|
+
{
|
|
387
|
+
"type": "number",
|
|
388
|
+
"minimum": -1e12,
|
|
389
|
+
"maximum": 1e12
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"type": "string",
|
|
393
|
+
"maxLength": 256
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"type": "null"
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
"minItems": 1,
|
|
401
|
+
"maxItems": 32
|
|
402
|
+
},
|
|
403
|
+
"minItems": 2,
|
|
404
|
+
"maxItems": 256
|
|
405
|
+
},
|
|
406
|
+
"queryRows": {
|
|
407
|
+
"type": "array",
|
|
408
|
+
"items": {
|
|
409
|
+
"type": "array",
|
|
410
|
+
"items": {
|
|
411
|
+
"anyOf": [
|
|
412
|
+
{
|
|
413
|
+
"type": "number",
|
|
414
|
+
"minimum": -1e12,
|
|
415
|
+
"maximum": 1e12
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"type": "string",
|
|
419
|
+
"maxLength": 256
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"type": "null"
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
"minItems": 1,
|
|
427
|
+
"maxItems": 32
|
|
428
|
+
},
|
|
429
|
+
"minItems": 1,
|
|
430
|
+
"maxItems": 64
|
|
431
|
+
},
|
|
432
|
+
"targets": {
|
|
433
|
+
"type": "array",
|
|
434
|
+
"items": {
|
|
435
|
+
"type": "string",
|
|
436
|
+
"minLength": 1,
|
|
437
|
+
"maxLength": 128,
|
|
438
|
+
"pattern": "\\S"
|
|
439
|
+
},
|
|
440
|
+
"minItems": 2,
|
|
441
|
+
"maxItems": 256
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
"required": [
|
|
445
|
+
"columns",
|
|
446
|
+
"trainingRows",
|
|
447
|
+
"queryRows",
|
|
448
|
+
"targets"
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
"tabular-regression-v1": {
|
|
452
|
+
"type": "object",
|
|
453
|
+
"additionalProperties": false,
|
|
454
|
+
"properties": {
|
|
455
|
+
"columns": {
|
|
456
|
+
"type": "array",
|
|
457
|
+
"items": {
|
|
458
|
+
"type": "object",
|
|
459
|
+
"additionalProperties": false,
|
|
460
|
+
"properties": {
|
|
461
|
+
"name": {
|
|
462
|
+
"type": "string",
|
|
463
|
+
"minLength": 1,
|
|
464
|
+
"maxLength": 128,
|
|
465
|
+
"pattern": "\\S"
|
|
466
|
+
},
|
|
467
|
+
"type": {
|
|
468
|
+
"enum": [
|
|
469
|
+
"numeric",
|
|
470
|
+
"categorical"
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
"required": [
|
|
475
|
+
"name",
|
|
476
|
+
"type"
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
"minItems": 1,
|
|
480
|
+
"maxItems": 32
|
|
481
|
+
},
|
|
482
|
+
"trainingRows": {
|
|
483
|
+
"type": "array",
|
|
484
|
+
"items": {
|
|
485
|
+
"type": "array",
|
|
486
|
+
"items": {
|
|
487
|
+
"anyOf": [
|
|
488
|
+
{
|
|
489
|
+
"type": "number",
|
|
490
|
+
"minimum": -1e12,
|
|
491
|
+
"maximum": 1e12
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"type": "string",
|
|
495
|
+
"maxLength": 256
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"type": "null"
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
},
|
|
502
|
+
"minItems": 1,
|
|
503
|
+
"maxItems": 32
|
|
504
|
+
},
|
|
505
|
+
"minItems": 2,
|
|
506
|
+
"maxItems": 256
|
|
507
|
+
},
|
|
508
|
+
"queryRows": {
|
|
509
|
+
"type": "array",
|
|
510
|
+
"items": {
|
|
511
|
+
"type": "array",
|
|
512
|
+
"items": {
|
|
513
|
+
"anyOf": [
|
|
514
|
+
{
|
|
515
|
+
"type": "number",
|
|
516
|
+
"minimum": -1e12,
|
|
517
|
+
"maximum": 1e12
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"type": "string",
|
|
521
|
+
"maxLength": 256
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"type": "null"
|
|
525
|
+
}
|
|
526
|
+
]
|
|
527
|
+
},
|
|
528
|
+
"minItems": 1,
|
|
529
|
+
"maxItems": 32
|
|
530
|
+
},
|
|
531
|
+
"minItems": 1,
|
|
532
|
+
"maxItems": 64
|
|
533
|
+
},
|
|
534
|
+
"targets": {
|
|
535
|
+
"type": "array",
|
|
536
|
+
"items": {
|
|
537
|
+
"type": "number",
|
|
538
|
+
"minimum": -1e12,
|
|
539
|
+
"maximum": 1e12
|
|
540
|
+
},
|
|
541
|
+
"minItems": 2,
|
|
542
|
+
"maxItems": 256
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
"required": [
|
|
546
|
+
"columns",
|
|
547
|
+
"trainingRows",
|
|
548
|
+
"queryRows",
|
|
549
|
+
"targets"
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
"time-series-forecasting-v1": {
|
|
553
|
+
"type": "object",
|
|
554
|
+
"additionalProperties": false,
|
|
555
|
+
"properties": {
|
|
556
|
+
"context": {
|
|
557
|
+
"type": "array",
|
|
558
|
+
"items": {
|
|
559
|
+
"type": "number",
|
|
560
|
+
"minimum": -1e12,
|
|
561
|
+
"maximum": 1e12
|
|
562
|
+
},
|
|
563
|
+
"minItems": 2,
|
|
564
|
+
"maxItems": 2048
|
|
565
|
+
},
|
|
566
|
+
"horizon": {
|
|
567
|
+
"type": "integer",
|
|
568
|
+
"minimum": 1,
|
|
569
|
+
"maximum": 512,
|
|
570
|
+
"default": 16
|
|
571
|
+
},
|
|
572
|
+
"quantiles": {
|
|
573
|
+
"type": "array",
|
|
574
|
+
"items": {
|
|
575
|
+
"type": "number",
|
|
576
|
+
"minimum": 0.01,
|
|
577
|
+
"maximum": 0.99
|
|
578
|
+
},
|
|
579
|
+
"minItems": 1,
|
|
580
|
+
"maxItems": 19,
|
|
581
|
+
"uniqueItems": true
|
|
582
|
+
},
|
|
583
|
+
"timestamps": {
|
|
584
|
+
"type": "array",
|
|
585
|
+
"items": {
|
|
586
|
+
"type": "integer",
|
|
587
|
+
"minimum": 0,
|
|
588
|
+
"maximum": 864e13
|
|
589
|
+
},
|
|
590
|
+
"minItems": 2,
|
|
591
|
+
"maxItems": 2048
|
|
592
|
+
},
|
|
593
|
+
"frequencyMilliseconds": {
|
|
594
|
+
"type": "integer",
|
|
595
|
+
"minimum": 1,
|
|
596
|
+
"maximum": 31536e6
|
|
597
|
+
},
|
|
598
|
+
"pastCovariates": {
|
|
599
|
+
"type": "array",
|
|
600
|
+
"items": {
|
|
601
|
+
"type": "array",
|
|
602
|
+
"items": {
|
|
603
|
+
"type": "number",
|
|
604
|
+
"minimum": -1e12,
|
|
605
|
+
"maximum": 1e12
|
|
606
|
+
},
|
|
607
|
+
"minItems": 1,
|
|
608
|
+
"maxItems": 16
|
|
609
|
+
},
|
|
610
|
+
"minItems": 2,
|
|
611
|
+
"maxItems": 2048
|
|
612
|
+
},
|
|
613
|
+
"futureCovariates": {
|
|
614
|
+
"type": "array",
|
|
615
|
+
"items": {
|
|
616
|
+
"type": "array",
|
|
617
|
+
"items": {
|
|
618
|
+
"type": "number",
|
|
619
|
+
"minimum": -1e12,
|
|
620
|
+
"maximum": 1e12
|
|
621
|
+
},
|
|
622
|
+
"minItems": 1,
|
|
623
|
+
"maxItems": 16
|
|
624
|
+
},
|
|
625
|
+
"minItems": 1,
|
|
626
|
+
"maxItems": 512
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
"required": [
|
|
630
|
+
"context"
|
|
631
|
+
]
|
|
632
|
+
},
|
|
633
|
+
"pose-estimation-v1": {
|
|
634
|
+
"type": "object",
|
|
635
|
+
"additionalProperties": false,
|
|
636
|
+
"properties": {
|
|
637
|
+
"imageArtifactId": {
|
|
638
|
+
"type": "string",
|
|
639
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
640
|
+
},
|
|
641
|
+
"boxes": {
|
|
642
|
+
"type": "array",
|
|
643
|
+
"items": {
|
|
644
|
+
"type": "array",
|
|
645
|
+
"items": {
|
|
646
|
+
"type": "number",
|
|
647
|
+
"minimum": 0,
|
|
648
|
+
"maximum": 1
|
|
649
|
+
},
|
|
650
|
+
"minItems": 4,
|
|
651
|
+
"maxItems": 4
|
|
652
|
+
},
|
|
653
|
+
"minItems": 1,
|
|
654
|
+
"maxItems": 8
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
"required": [
|
|
658
|
+
"imageArtifactId",
|
|
659
|
+
"boxes"
|
|
660
|
+
]
|
|
661
|
+
},
|
|
662
|
+
"visual-document-retrieval-v1": {
|
|
663
|
+
"type": "object",
|
|
664
|
+
"additionalProperties": false,
|
|
665
|
+
"properties": {
|
|
666
|
+
"imageArtifactId": {
|
|
667
|
+
"type": "string",
|
|
668
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
669
|
+
},
|
|
670
|
+
"queries": {
|
|
671
|
+
"type": "array",
|
|
672
|
+
"items": {
|
|
673
|
+
"type": "string",
|
|
674
|
+
"minLength": 1,
|
|
675
|
+
"maxLength": 256,
|
|
676
|
+
"pattern": "\\S"
|
|
677
|
+
},
|
|
678
|
+
"minItems": 1,
|
|
679
|
+
"maxItems": 2
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
"required": [
|
|
683
|
+
"imageArtifactId",
|
|
684
|
+
"queries"
|
|
685
|
+
]
|
|
686
|
+
},
|
|
687
|
+
"table-question-answering-v1": {
|
|
688
|
+
"type": "object",
|
|
689
|
+
"additionalProperties": false,
|
|
690
|
+
"properties": {
|
|
691
|
+
"question": {
|
|
692
|
+
"type": "string",
|
|
693
|
+
"minLength": 1,
|
|
694
|
+
"maxLength": 2048,
|
|
695
|
+
"pattern": "\\S"
|
|
696
|
+
},
|
|
697
|
+
"columns": {
|
|
698
|
+
"type": "array",
|
|
699
|
+
"items": {
|
|
700
|
+
"type": "string",
|
|
701
|
+
"minLength": 1,
|
|
702
|
+
"maxLength": 128,
|
|
703
|
+
"pattern": "\\S"
|
|
704
|
+
},
|
|
705
|
+
"minItems": 1,
|
|
706
|
+
"maxItems": 32
|
|
707
|
+
},
|
|
708
|
+
"rows": {
|
|
709
|
+
"type": "array",
|
|
710
|
+
"items": {
|
|
711
|
+
"type": "array",
|
|
712
|
+
"items": {
|
|
713
|
+
"type": "string",
|
|
714
|
+
"maxLength": 1024
|
|
715
|
+
},
|
|
716
|
+
"minItems": 1,
|
|
717
|
+
"maxItems": 32
|
|
718
|
+
},
|
|
719
|
+
"minItems": 1,
|
|
720
|
+
"maxItems": 128
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
"required": [
|
|
724
|
+
"question",
|
|
725
|
+
"columns",
|
|
726
|
+
"rows"
|
|
727
|
+
]
|
|
728
|
+
},
|
|
729
|
+
"document-question-answering-v1": {
|
|
730
|
+
"type": "object",
|
|
731
|
+
"additionalProperties": false,
|
|
732
|
+
"properties": {
|
|
733
|
+
"imageArtifactId": {
|
|
734
|
+
"type": "string",
|
|
735
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
736
|
+
},
|
|
737
|
+
"question": {
|
|
738
|
+
"type": "string",
|
|
739
|
+
"minLength": 1,
|
|
740
|
+
"maxLength": 2048,
|
|
741
|
+
"pattern": "\\S"
|
|
742
|
+
},
|
|
743
|
+
"words": {
|
|
744
|
+
"type": "array",
|
|
745
|
+
"items": {
|
|
746
|
+
"type": "string",
|
|
747
|
+
"minLength": 1,
|
|
748
|
+
"maxLength": 128,
|
|
749
|
+
"pattern": "\\S"
|
|
750
|
+
},
|
|
751
|
+
"minItems": 1,
|
|
752
|
+
"maxItems": 512
|
|
753
|
+
},
|
|
754
|
+
"boxes": {
|
|
755
|
+
"type": "array",
|
|
756
|
+
"items": {
|
|
757
|
+
"type": "array",
|
|
758
|
+
"items": {
|
|
759
|
+
"type": "number",
|
|
760
|
+
"minimum": 0,
|
|
761
|
+
"maximum": 1
|
|
762
|
+
},
|
|
763
|
+
"minItems": 4,
|
|
764
|
+
"maxItems": 4
|
|
765
|
+
},
|
|
766
|
+
"minItems": 1,
|
|
767
|
+
"maxItems": 512
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
"required": [
|
|
771
|
+
"imageArtifactId",
|
|
772
|
+
"question",
|
|
773
|
+
"words",
|
|
774
|
+
"boxes"
|
|
775
|
+
]
|
|
776
|
+
},
|
|
777
|
+
"keypoint-detection-v1": {
|
|
778
|
+
"type": "object",
|
|
779
|
+
"additionalProperties": false,
|
|
780
|
+
"properties": {
|
|
781
|
+
"imageArtifactId": {
|
|
782
|
+
"type": "string",
|
|
783
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
784
|
+
},
|
|
785
|
+
"threshold": {
|
|
786
|
+
"type": "number",
|
|
787
|
+
"minimum": 0,
|
|
788
|
+
"maximum": 1,
|
|
789
|
+
"default": 5e-3
|
|
790
|
+
},
|
|
791
|
+
"maxKeypoints": {
|
|
792
|
+
"type": "integer",
|
|
793
|
+
"minimum": 1,
|
|
794
|
+
"maximum": 1024,
|
|
795
|
+
"default": 256
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
"required": [
|
|
799
|
+
"imageArtifactId"
|
|
800
|
+
]
|
|
801
|
+
},
|
|
802
|
+
"video-classification-v1": {
|
|
803
|
+
"type": "object",
|
|
804
|
+
"additionalProperties": false,
|
|
805
|
+
"properties": {
|
|
806
|
+
"videoArtifactId": {
|
|
807
|
+
"type": "string",
|
|
808
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
809
|
+
},
|
|
810
|
+
"startSeconds": {
|
|
811
|
+
"type": "number",
|
|
812
|
+
"minimum": 0,
|
|
813
|
+
"maximum": 30
|
|
814
|
+
},
|
|
815
|
+
"durationSeconds": {
|
|
816
|
+
"type": "number",
|
|
817
|
+
"minimum": 0,
|
|
818
|
+
"maximum": 30,
|
|
819
|
+
"exclusiveMinimum": 0
|
|
820
|
+
},
|
|
821
|
+
"topK": {
|
|
822
|
+
"type": "integer",
|
|
823
|
+
"minimum": 1,
|
|
824
|
+
"maximum": 20,
|
|
825
|
+
"default": 5
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
"required": [
|
|
829
|
+
"videoArtifactId"
|
|
830
|
+
]
|
|
831
|
+
},
|
|
832
|
+
"video-question-answering-v1": {
|
|
833
|
+
"type": "object",
|
|
834
|
+
"additionalProperties": false,
|
|
835
|
+
"properties": {
|
|
836
|
+
"videoArtifactId": {
|
|
837
|
+
"type": "string",
|
|
838
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
839
|
+
},
|
|
840
|
+
"startSeconds": {
|
|
841
|
+
"type": "number",
|
|
842
|
+
"minimum": 0,
|
|
843
|
+
"maximum": 30
|
|
844
|
+
},
|
|
845
|
+
"durationSeconds": {
|
|
846
|
+
"type": "number",
|
|
847
|
+
"minimum": 0,
|
|
848
|
+
"maximum": 30,
|
|
849
|
+
"exclusiveMinimum": 0
|
|
850
|
+
},
|
|
851
|
+
"question": {
|
|
852
|
+
"type": "string",
|
|
853
|
+
"minLength": 1,
|
|
854
|
+
"maxLength": 2048,
|
|
855
|
+
"pattern": "\\S"
|
|
856
|
+
},
|
|
857
|
+
"maxTokens": {
|
|
858
|
+
"type": "integer",
|
|
859
|
+
"minimum": 1,
|
|
860
|
+
"maximum": 256,
|
|
861
|
+
"default": 128
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
"required": [
|
|
865
|
+
"videoArtifactId",
|
|
866
|
+
"question"
|
|
867
|
+
]
|
|
868
|
+
},
|
|
869
|
+
"voice-activity-detection-v1": {
|
|
870
|
+
"type": "object",
|
|
871
|
+
"additionalProperties": false,
|
|
872
|
+
"properties": {
|
|
873
|
+
"audioArtifactId": {
|
|
874
|
+
"type": "string",
|
|
875
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
876
|
+
},
|
|
877
|
+
"threshold": {
|
|
878
|
+
"type": "number",
|
|
879
|
+
"minimum": 0.01,
|
|
880
|
+
"maximum": 0.99,
|
|
881
|
+
"default": 0.5
|
|
882
|
+
},
|
|
883
|
+
"minSpeechSeconds": {
|
|
884
|
+
"type": "number",
|
|
885
|
+
"minimum": 0.032,
|
|
886
|
+
"maximum": 2,
|
|
887
|
+
"default": 0.25
|
|
888
|
+
},
|
|
889
|
+
"minSilenceSeconds": {
|
|
890
|
+
"type": "number",
|
|
891
|
+
"minimum": 0.032,
|
|
892
|
+
"maximum": 2,
|
|
893
|
+
"default": 0.1
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
"required": [
|
|
897
|
+
"audioArtifactId"
|
|
898
|
+
]
|
|
899
|
+
},
|
|
900
|
+
"image-editing-v1": {
|
|
901
|
+
"type": "object",
|
|
902
|
+
"additionalProperties": false,
|
|
903
|
+
"required": [
|
|
904
|
+
"imageArtifactId",
|
|
905
|
+
"prompt"
|
|
906
|
+
],
|
|
907
|
+
"properties": {
|
|
908
|
+
"imageArtifactId": {
|
|
909
|
+
"type": "string",
|
|
910
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
911
|
+
},
|
|
912
|
+
"prompt": {
|
|
913
|
+
"type": "string",
|
|
914
|
+
"minLength": 1,
|
|
915
|
+
"maxLength": 4096
|
|
916
|
+
},
|
|
917
|
+
"negativePrompt": {
|
|
918
|
+
"type": "string",
|
|
919
|
+
"maxLength": 4096
|
|
920
|
+
},
|
|
921
|
+
"steps": {
|
|
922
|
+
"type": "integer",
|
|
923
|
+
"minimum": 1,
|
|
924
|
+
"maximum": 50
|
|
925
|
+
},
|
|
926
|
+
"guidanceScale": {
|
|
927
|
+
"type": "number",
|
|
928
|
+
"minimum": 0,
|
|
929
|
+
"maximum": 10
|
|
930
|
+
},
|
|
931
|
+
"seed": {
|
|
932
|
+
"type": "integer",
|
|
933
|
+
"minimum": 0,
|
|
934
|
+
"maximum": 4294967295
|
|
935
|
+
},
|
|
936
|
+
"width": {
|
|
937
|
+
"type": "integer",
|
|
938
|
+
"minimum": 64,
|
|
939
|
+
"maximum": 1024,
|
|
940
|
+
"multipleOf": 16
|
|
941
|
+
},
|
|
942
|
+
"height": {
|
|
943
|
+
"type": "integer",
|
|
944
|
+
"minimum": 64,
|
|
945
|
+
"maximum": 1024,
|
|
946
|
+
"multipleOf": 16
|
|
947
|
+
},
|
|
948
|
+
"referenceImageArtifactIds": {
|
|
949
|
+
"type": "array",
|
|
950
|
+
"maxItems": 2,
|
|
951
|
+
"uniqueItems": true,
|
|
952
|
+
"items": {
|
|
953
|
+
"type": "string",
|
|
954
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
},
|
|
959
|
+
"image-layers-v1": {
|
|
960
|
+
"type": "object",
|
|
961
|
+
"additionalProperties": false,
|
|
962
|
+
"required": [
|
|
963
|
+
"imageArtifactId",
|
|
964
|
+
"prompt"
|
|
965
|
+
],
|
|
966
|
+
"properties": {
|
|
967
|
+
"imageArtifactId": {
|
|
968
|
+
"type": "string",
|
|
969
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
970
|
+
},
|
|
971
|
+
"prompt": {
|
|
972
|
+
"type": "string",
|
|
973
|
+
"minLength": 1,
|
|
974
|
+
"maxLength": 4096
|
|
975
|
+
},
|
|
976
|
+
"negativePrompt": {
|
|
977
|
+
"type": "string",
|
|
978
|
+
"maxLength": 4096
|
|
979
|
+
},
|
|
980
|
+
"steps": {
|
|
981
|
+
"type": "integer",
|
|
982
|
+
"minimum": 1,
|
|
983
|
+
"maximum": 50
|
|
984
|
+
},
|
|
985
|
+
"guidanceScale": {
|
|
986
|
+
"type": "number",
|
|
987
|
+
"minimum": 0,
|
|
988
|
+
"maximum": 10
|
|
989
|
+
},
|
|
990
|
+
"seed": {
|
|
991
|
+
"type": "integer",
|
|
992
|
+
"minimum": 0,
|
|
993
|
+
"maximum": 4294967295
|
|
994
|
+
},
|
|
995
|
+
"resolution": {
|
|
996
|
+
"type": "integer",
|
|
997
|
+
"enum": [
|
|
998
|
+
640,
|
|
999
|
+
1024
|
|
1000
|
+
]
|
|
1001
|
+
},
|
|
1002
|
+
"layers": {
|
|
1003
|
+
"type": "integer",
|
|
1004
|
+
"minimum": 1,
|
|
1005
|
+
"maximum": 4
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
"zero-shot-classification-v1": {
|
|
1010
|
+
"type": "object",
|
|
1011
|
+
"additionalProperties": false,
|
|
1012
|
+
"properties": {
|
|
1013
|
+
"text": {
|
|
1014
|
+
"type": "string",
|
|
1015
|
+
"minLength": 1,
|
|
1016
|
+
"maxLength": 8192,
|
|
1017
|
+
"pattern": "\\S"
|
|
1018
|
+
},
|
|
1019
|
+
"labels": {
|
|
1020
|
+
"type": "array",
|
|
1021
|
+
"minItems": 2,
|
|
1022
|
+
"maxItems": 32,
|
|
1023
|
+
"uniqueItems": true,
|
|
1024
|
+
"items": {
|
|
1025
|
+
"type": "string",
|
|
1026
|
+
"minLength": 1,
|
|
1027
|
+
"maxLength": 128,
|
|
1028
|
+
"pattern": "\\S"
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
"multiLabel": {
|
|
1032
|
+
"type": "boolean"
|
|
1033
|
+
}
|
|
1034
|
+
},
|
|
1035
|
+
"required": [
|
|
1036
|
+
"text",
|
|
1037
|
+
"labels"
|
|
1038
|
+
]
|
|
1039
|
+
},
|
|
1040
|
+
"image-embeddings-v1": {
|
|
1041
|
+
"type": "object",
|
|
1042
|
+
"additionalProperties": false,
|
|
1043
|
+
"properties": {
|
|
1044
|
+
"imageArtifactId": {
|
|
1045
|
+
"type": "string",
|
|
1046
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1047
|
+
},
|
|
1048
|
+
"normalize": {
|
|
1049
|
+
"type": "boolean"
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
"required": [
|
|
1053
|
+
"imageArtifactId"
|
|
1054
|
+
]
|
|
1055
|
+
},
|
|
1056
|
+
"image-segmentation-v1": {
|
|
1057
|
+
"type": "object",
|
|
1058
|
+
"additionalProperties": false,
|
|
1059
|
+
"properties": {
|
|
1060
|
+
"imageArtifactId": {
|
|
1061
|
+
"type": "string",
|
|
1062
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
"required": [
|
|
1066
|
+
"imageArtifactId"
|
|
1067
|
+
]
|
|
1068
|
+
},
|
|
1069
|
+
"mask-generation-v1": {
|
|
1070
|
+
"type": "object",
|
|
1071
|
+
"additionalProperties": false,
|
|
1072
|
+
"properties": {
|
|
1073
|
+
"imageArtifactId": {
|
|
1074
|
+
"type": "string",
|
|
1075
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1076
|
+
},
|
|
1077
|
+
"points": {
|
|
1078
|
+
"type": "array",
|
|
1079
|
+
"minItems": 1,
|
|
1080
|
+
"maxItems": 16,
|
|
1081
|
+
"items": {
|
|
1082
|
+
"type": "object",
|
|
1083
|
+
"additionalProperties": false,
|
|
1084
|
+
"properties": {
|
|
1085
|
+
"x": {
|
|
1086
|
+
"type": "number",
|
|
1087
|
+
"minimum": 0,
|
|
1088
|
+
"maximum": 1
|
|
1089
|
+
},
|
|
1090
|
+
"y": {
|
|
1091
|
+
"type": "number",
|
|
1092
|
+
"minimum": 0,
|
|
1093
|
+
"maximum": 1
|
|
1094
|
+
},
|
|
1095
|
+
"label": {
|
|
1096
|
+
"enum": [
|
|
1097
|
+
0,
|
|
1098
|
+
1
|
|
1099
|
+
],
|
|
1100
|
+
"type": "integer"
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
"required": [
|
|
1104
|
+
"x",
|
|
1105
|
+
"y",
|
|
1106
|
+
"label"
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
"contains": {
|
|
1110
|
+
"type": "object",
|
|
1111
|
+
"properties": {
|
|
1112
|
+
"label": {
|
|
1113
|
+
"const": 1
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
"required": [
|
|
1117
|
+
"label"
|
|
1118
|
+
]
|
|
1119
|
+
},
|
|
1120
|
+
"minContains": 1
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
"required": [
|
|
1124
|
+
"imageArtifactId",
|
|
1125
|
+
"points"
|
|
1126
|
+
]
|
|
1127
|
+
},
|
|
1128
|
+
"zero-shot-object-detection-v1": {
|
|
1129
|
+
"type": "object",
|
|
1130
|
+
"additionalProperties": false,
|
|
1131
|
+
"properties": {
|
|
1132
|
+
"imageArtifactId": {
|
|
1133
|
+
"type": "string",
|
|
1134
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1135
|
+
},
|
|
1136
|
+
"labels": {
|
|
1137
|
+
"type": "array",
|
|
1138
|
+
"minItems": 2,
|
|
1139
|
+
"maxItems": 32,
|
|
1140
|
+
"uniqueItems": true,
|
|
1141
|
+
"items": {
|
|
1142
|
+
"type": "string",
|
|
1143
|
+
"minLength": 1,
|
|
1144
|
+
"maxLength": 128,
|
|
1145
|
+
"pattern": "\\S"
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
"threshold": {
|
|
1149
|
+
"type": "number",
|
|
1150
|
+
"minimum": 0,
|
|
1151
|
+
"maximum": 1
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
"required": [
|
|
1155
|
+
"imageArtifactId",
|
|
1156
|
+
"labels"
|
|
1157
|
+
]
|
|
1158
|
+
},
|
|
1159
|
+
"image-to-text-v1": {
|
|
1160
|
+
"type": "object",
|
|
1161
|
+
"additionalProperties": false,
|
|
1162
|
+
"properties": {
|
|
1163
|
+
"imageArtifactId": {
|
|
1164
|
+
"type": "string",
|
|
1165
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1166
|
+
},
|
|
1167
|
+
"maxTokens": {
|
|
1168
|
+
"type": "integer",
|
|
1169
|
+
"minimum": 1,
|
|
1170
|
+
"maximum": 256
|
|
1171
|
+
}
|
|
1172
|
+
},
|
|
1173
|
+
"required": [
|
|
1174
|
+
"imageArtifactId"
|
|
1175
|
+
]
|
|
1176
|
+
},
|
|
1177
|
+
"visual-question-answering-v1": {
|
|
1178
|
+
"type": "object",
|
|
1179
|
+
"additionalProperties": false,
|
|
1180
|
+
"properties": {
|
|
1181
|
+
"imageArtifactId": {
|
|
1182
|
+
"type": "string",
|
|
1183
|
+
"pattern": "^artifact_[A-Za-z0-9_-]{20,80}$"
|
|
1184
|
+
},
|
|
1185
|
+
"question": {
|
|
1186
|
+
"type": "string",
|
|
1187
|
+
"minLength": 1,
|
|
1188
|
+
"maxLength": 2048,
|
|
1189
|
+
"pattern": "\\S"
|
|
1190
|
+
},
|
|
1191
|
+
"maxTokens": {
|
|
1192
|
+
"type": "integer",
|
|
1193
|
+
"minimum": 1,
|
|
1194
|
+
"maximum": 256
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1197
|
+
"required": [
|
|
1198
|
+
"imageArtifactId",
|
|
1199
|
+
"question"
|
|
1200
|
+
]
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
// src/sprint61-relations.ts
|
|
1205
|
+
function validSprint61Input(contract, value) {
|
|
1206
|
+
if (contract === "image-editing-v1") return !value.referenceImageArtifactIds?.includes(value.imageArtifactId);
|
|
1207
|
+
if (contract === "speech-synthesis-v1") {
|
|
1208
|
+
const reference = Object.hasOwn(value, "audioArtifactId");
|
|
1209
|
+
return (value.voice ?? (reference ? "reference" : "af_heart")) === "reference" === reference;
|
|
1210
|
+
}
|
|
1211
|
+
if (contract === "pose-estimation-v1") return value.boxes.every((b) => b[0] < b[2] && b[1] < b[3]);
|
|
1212
|
+
if (contract === "tabular-classification-v1" || contract === "tabular-regression-v1") {
|
|
1213
|
+
const columns = value.columns;
|
|
1214
|
+
const targets = value.targets;
|
|
1215
|
+
const training = value.trainingRows;
|
|
1216
|
+
const queries = value.queryRows;
|
|
1217
|
+
return new Set(columns.map((c) => c.name.trim())).size === columns.length && targets.length === training.length && [...training, ...queries].every((row) => row.length === columns.length && row.every((cell, i) => cell === null || typeof cell === (columns[i].type === "numeric" ? "number" : "string"))) && (contract !== "tabular-classification-v1" || new Set(targets).size >= 2 && new Set(targets).size <= 64);
|
|
1218
|
+
}
|
|
1219
|
+
if (contract === "time-series-forecasting-v1") {
|
|
1220
|
+
const context = value.context;
|
|
1221
|
+
const horizon = Number(value.horizon ?? 16);
|
|
1222
|
+
const times = value.timestamps;
|
|
1223
|
+
const frequency = value.frequencyMilliseconds;
|
|
1224
|
+
const quantiles = value.quantiles;
|
|
1225
|
+
const past = value.pastCovariates;
|
|
1226
|
+
const future = value.futureCovariates;
|
|
1227
|
+
return times === void 0 === (frequency === void 0) && (!times || times.length === context.length && times.every((t, i) => i === 0 || t - times[i - 1] === frequency) && times.at(-1) + horizon * frequency <= 864e13) && (!quantiles || quantiles.every((q, i) => i === 0 || q > quantiles[i - 1])) && past === void 0 === (future === void 0) && (!past || past.length === context.length && future.length === horizon && [...past, ...future].every((row) => row.length === past[0].length));
|
|
1228
|
+
}
|
|
1229
|
+
if (contract === "audio-transformation-v1") {
|
|
1230
|
+
const sources = ["audioArtifactId", "referenceAudioArtifactId", "codes", "spectrogram"];
|
|
1231
|
+
const required = {
|
|
1232
|
+
enhance: ["audioArtifactId"],
|
|
1233
|
+
separate: ["audioArtifactId"],
|
|
1234
|
+
"voice-conversion": ["audioArtifactId", "referenceAudioArtifactId"],
|
|
1235
|
+
encode: ["audioArtifactId"],
|
|
1236
|
+
decode: ["codes"],
|
|
1237
|
+
vocode: ["spectrogram"]
|
|
1238
|
+
};
|
|
1239
|
+
const fields = required[String(value.operation)];
|
|
1240
|
+
return sources.every((s) => Object.hasOwn(value, s) === fields.includes(s)) && ["codes", "spectrogram"].every((field) => !value[field] || value[field].every((row) => row.length === value[field][0].length));
|
|
1241
|
+
}
|
|
1242
|
+
if (contract === "multimodal-generation-v1") {
|
|
1243
|
+
const required = { image: ["imageArtifactId"], audio: ["audioArtifactId"], "image-and-audio": ["imageArtifactId", "audioArtifactId"] };
|
|
1244
|
+
return ["imageArtifactId", "audioArtifactId"].every((field) => Object.hasOwn(value, field) === required[String(value.inputMode)].includes(field));
|
|
1245
|
+
}
|
|
1246
|
+
if (contract === "video-editing-v1") return Number(value.startSeconds ?? 0) + Number(value.durationSeconds ?? 1) <= 30 && (value.operation === "restore" ? !Object.hasOwn(value, "prompt") && !Object.hasOwn(value, "maskVideoArtifactId") : Object.hasOwn(value, "prompt"));
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
// src/task-relations.ts
|
|
1251
|
+
function validTaskRelations(contract, input) {
|
|
1252
|
+
if (!validSprint61Input(contract, input)) return false;
|
|
1253
|
+
if (contract === "embeddings-v1" && input.inputType === "query" && input.contextual === true)
|
|
1254
|
+
return false;
|
|
1255
|
+
if (contract === "table-question-answering-v1") {
|
|
1256
|
+
const columns = input.columns;
|
|
1257
|
+
return new Set(columns.map((v) => v.trim())).size === columns.length && input.rows.every((row) => row.length === columns.length);
|
|
1258
|
+
}
|
|
1259
|
+
if (contract === "document-question-answering-v1") {
|
|
1260
|
+
const boxes = input.boxes;
|
|
1261
|
+
return boxes.length === input.words.length && boxes.every(([x0, y0, x1, y1]) => x0 <= x1 && y0 <= y1);
|
|
1262
|
+
}
|
|
1263
|
+
if (contract === "video-classification-v1" || contract === "video-question-answering-v1") {
|
|
1264
|
+
return Number(input.startSeconds ?? 0) < 30 && Number(input.startSeconds ?? 0) + Number(input.durationSeconds ?? 0) <= 30;
|
|
1265
|
+
}
|
|
1266
|
+
return true;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// src/shared-task-validation.ts
|
|
1270
|
+
var SHARED_MODEL_TASK_CONTRACTS = Object.freeze({
|
|
1271
|
+
"visual-document-retrieval": "visual-document-retrieval-v1",
|
|
1272
|
+
"zero-shot-classification": "zero-shot-classification-v1",
|
|
1273
|
+
"image-feature-extraction": "image-embeddings-v1",
|
|
1274
|
+
"image-segmentation": "image-segmentation-v1",
|
|
1275
|
+
"mask-generation": "mask-generation-v1",
|
|
1276
|
+
"zero-shot-object-detection": "zero-shot-object-detection-v1",
|
|
1277
|
+
"image-to-text": "image-to-text-v1",
|
|
1278
|
+
"visual-question-answering": "visual-question-answering-v1",
|
|
1279
|
+
"table-question-answering": "table-question-answering-v1",
|
|
1280
|
+
"document-question-answering": "document-question-answering-v1",
|
|
1281
|
+
"keypoint-detection": "keypoint-detection-v1",
|
|
1282
|
+
"video-classification": "video-classification-v1",
|
|
1283
|
+
"video-text-to-text": "video-question-answering-v1",
|
|
1284
|
+
"voice-activity-detection": "voice-activity-detection-v1",
|
|
1285
|
+
"unconditional-image-generation": "unconditional-image-generation-v1",
|
|
1286
|
+
"audio-text-to-text": "audio-question-answering-v1",
|
|
1287
|
+
"audio-to-audio": "audio-transformation-v1",
|
|
1288
|
+
"any-to-any": "multimodal-generation-v1",
|
|
1289
|
+
"image-text-to-video": "image-text-to-video-v1",
|
|
1290
|
+
"video-to-video": "video-editing-v1",
|
|
1291
|
+
"tabular-classification": "tabular-classification-v1",
|
|
1292
|
+
"tabular-regression": "tabular-regression-v1",
|
|
1293
|
+
"time-series-forecasting": "time-series-forecasting-v1",
|
|
1294
|
+
"pose-estimation": "pose-estimation-v1"
|
|
1295
|
+
});
|
|
1296
|
+
function validateSharedTaskInput(contract, input) {
|
|
1297
|
+
if (!SHARED_TASK_CONTRACTS.includes(contract) || !record(input) || !matches(sharedTaskSchemas[contract], input) || !validTaskRelations(contract, input)) invalid();
|
|
1298
|
+
if (Array.isArray(input.labels) && new Set(input.labels.map((v) => String(v).trim())).size !== input.labels.length) invalid();
|
|
1299
|
+
if (new TextEncoder().encode(JSON.stringify(input)).byteLength > 256 * 1024) invalid();
|
|
1300
|
+
return input;
|
|
1301
|
+
}
|
|
1302
|
+
function matches(raw, value) {
|
|
1303
|
+
if (!record(raw)) return false;
|
|
1304
|
+
if ("const" in raw && value !== raw.const) return false;
|
|
1305
|
+
if (Array.isArray(raw.enum) && !raw.enum.includes(value)) return false;
|
|
1306
|
+
if (Array.isArray(raw.anyOf)) return raw.anyOf.some((schema) => matches(schema, value));
|
|
1307
|
+
switch (raw.type) {
|
|
1308
|
+
case "object": {
|
|
1309
|
+
if (!record(value) || raw.properties !== void 0 && !record(raw.properties)) return false;
|
|
1310
|
+
const properties = raw.properties ?? {};
|
|
1311
|
+
if (raw.additionalProperties === false && Object.keys(value).some((key) => !Object.hasOwn(properties, key))) return false;
|
|
1312
|
+
if (Array.isArray(raw.required) && raw.required.some((key) => typeof key !== "string" || !Object.hasOwn(value, key))) return false;
|
|
1313
|
+
return Object.entries(value).every(([key, item]) => !Object.hasOwn(properties, key) || matches(properties[key], item));
|
|
1314
|
+
}
|
|
1315
|
+
case "array": {
|
|
1316
|
+
if (!Array.isArray(value) || value.length < Number(raw.minItems ?? 0) || value.length > Number(raw.maxItems ?? Infinity)) return false;
|
|
1317
|
+
if (raw.uniqueItems && new Set(value.map((item) => JSON.stringify(item))).size !== value.length) return false;
|
|
1318
|
+
if (raw.contains && value.filter((item) => matches(raw.contains, item)).length < Number(raw.minContains ?? 1)) return false;
|
|
1319
|
+
return value.every((item) => matches(raw.items, item));
|
|
1320
|
+
}
|
|
1321
|
+
case "string":
|
|
1322
|
+
return typeof value === "string" && [...value].length >= Number(raw.minLength ?? 0) && [...value].length <= Number(raw.maxLength ?? Infinity) && (typeof raw.pattern !== "string" || new RegExp(raw.pattern, "u").test(value));
|
|
1323
|
+
case "integer":
|
|
1324
|
+
case "number":
|
|
1325
|
+
return typeof value === "number" && Number.isFinite(value) && (raw.type !== "integer" || Number.isInteger(value)) && value >= Number(raw.minimum ?? -Infinity) && value <= Number(raw.maximum ?? Infinity) && value > Number(raw.exclusiveMinimum ?? -Infinity) && (raw.multipleOf === void 0 || value % Number(raw.multipleOf) === 0);
|
|
1326
|
+
case "boolean":
|
|
1327
|
+
return typeof value === "boolean";
|
|
1328
|
+
case "null":
|
|
1329
|
+
return value === null;
|
|
1330
|
+
case void 0:
|
|
1331
|
+
return "const" in raw || Array.isArray(raw.enum);
|
|
1332
|
+
default:
|
|
1333
|
+
return false;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function record(value) {
|
|
1337
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
1338
|
+
}
|
|
1339
|
+
function invalid() {
|
|
1340
|
+
throw new TypeError("Task input is invalid or unavailable.");
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/task-contract-revisions.ts
|
|
1344
|
+
var TASK_CONTRACT_REVISIONS = {
|
|
1345
|
+
"chat-v1": 1,
|
|
1346
|
+
"transcription-v1": 1,
|
|
1347
|
+
"embeddings-v1": 1,
|
|
1348
|
+
"reranking-v1": 1,
|
|
1349
|
+
"forced-alignment-v1": 1,
|
|
1350
|
+
"text-to-music-v1": 1,
|
|
1351
|
+
"speech-synthesis-v1": 1,
|
|
1352
|
+
"text-to-image-v1": 1,
|
|
1353
|
+
"image-to-image-v1": 1,
|
|
1354
|
+
"text-to-video-v1": 1,
|
|
1355
|
+
"image-to-video-v1": 1,
|
|
1356
|
+
"text-classification-v1": 1,
|
|
1357
|
+
"fill-mask-v1": 1,
|
|
1358
|
+
"token-classification-v1": 1,
|
|
1359
|
+
"translation-v1": 1,
|
|
1360
|
+
"summarization-v1": 1,
|
|
1361
|
+
"question-answering-v1": 1,
|
|
1362
|
+
"image-classification-v1": 1,
|
|
1363
|
+
"audio-classification-v1": 1,
|
|
1364
|
+
"object-detection-v1": 1,
|
|
1365
|
+
"depth-estimation-v1": 1,
|
|
1366
|
+
"zero-shot-image-classification-v1": 1,
|
|
1367
|
+
"zero-shot-classification-v1": 1,
|
|
1368
|
+
"image-embeddings-v1": 1,
|
|
1369
|
+
"image-segmentation-v1": 1,
|
|
1370
|
+
"mask-generation-v1": 1,
|
|
1371
|
+
"zero-shot-object-detection-v1": 1,
|
|
1372
|
+
"image-to-text-v1": 1,
|
|
1373
|
+
"visual-question-answering-v1": 1,
|
|
1374
|
+
"image-editing-v1": 1,
|
|
1375
|
+
"image-layers-v1": 1,
|
|
1376
|
+
"media-audio-extract-v1": 1,
|
|
1377
|
+
"audio-source-separation-v1": 1,
|
|
1378
|
+
"subtitle-export-v1": 1,
|
|
1379
|
+
"table-question-answering-v1": 1,
|
|
1380
|
+
"document-question-answering-v1": 1,
|
|
1381
|
+
"keypoint-detection-v1": 1,
|
|
1382
|
+
"video-classification-v1": 1,
|
|
1383
|
+
"video-question-answering-v1": 1,
|
|
1384
|
+
"voice-activity-detection-v1": 1,
|
|
1385
|
+
"visual-document-retrieval-v1": 1,
|
|
1386
|
+
"unconditional-image-generation-v1": 1,
|
|
1387
|
+
"audio-question-answering-v1": 1,
|
|
1388
|
+
"audio-transformation-v1": 1,
|
|
1389
|
+
"multimodal-generation-v1": 1,
|
|
1390
|
+
"image-text-to-video-v1": 1,
|
|
1391
|
+
"video-editing-v1": 1,
|
|
1392
|
+
"tabular-classification-v1": 1,
|
|
1393
|
+
"tabular-regression-v1": 1,
|
|
1394
|
+
"time-series-forecasting-v1": 1,
|
|
1395
|
+
"pose-estimation-v1": 1
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
// src/client.ts
|
|
1399
|
+
var SDK_VERSION = "0.1.0";
|
|
1400
|
+
var LocalAIError = class extends Error {
|
|
1401
|
+
code;
|
|
1402
|
+
details;
|
|
1403
|
+
constructor(error) {
|
|
1404
|
+
super(error.message);
|
|
1405
|
+
this.name = "LocalAIError";
|
|
1406
|
+
this.code = error.code;
|
|
1407
|
+
this.details = error.details;
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
function unavailableCapabilities() {
|
|
1411
|
+
return {
|
|
1412
|
+
runtimeAvailable: false,
|
|
1413
|
+
runtimeState: "unavailable",
|
|
1414
|
+
sdkVersion: SDK_VERSION,
|
|
1415
|
+
supportedModelProviders: [],
|
|
1416
|
+
features: {
|
|
1417
|
+
modelRequests: false,
|
|
1418
|
+
modelSubstitution: false,
|
|
1419
|
+
streaming: false,
|
|
1420
|
+
artifacts: false,
|
|
1421
|
+
artifactUrls: false,
|
|
1422
|
+
cancellation: false,
|
|
1423
|
+
queueing: false,
|
|
1424
|
+
multipleSubmittedJobs: false
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
function injectedClient() {
|
|
1429
|
+
if (typeof window === "undefined") {
|
|
1430
|
+
return void 0;
|
|
1431
|
+
}
|
|
1432
|
+
return window.localAI;
|
|
1433
|
+
}
|
|
1434
|
+
function createLocalAIClient(options = {}) {
|
|
1435
|
+
if (options.showOrynBrowserAlert === true) scheduleOrynBrowserAlert();
|
|
1436
|
+
const sessionTasks = /* @__PURE__ */ new Map();
|
|
1437
|
+
return {
|
|
1438
|
+
sdkVersion: SDK_VERSION,
|
|
1439
|
+
async getCapabilities() {
|
|
1440
|
+
const client = injectedClient();
|
|
1441
|
+
if (!client) {
|
|
1442
|
+
return unavailableCapabilities();
|
|
1443
|
+
}
|
|
1444
|
+
return client.getCapabilities();
|
|
1445
|
+
},
|
|
1446
|
+
models: {
|
|
1447
|
+
async request(request, options2) {
|
|
1448
|
+
const client = injectedClient();
|
|
1449
|
+
if (!client?.requestModel) throw unavailableError();
|
|
1450
|
+
if (options2?.signal?.aborted) throw abortedError();
|
|
1451
|
+
if (request.selection || request.preferredModel?.files) {
|
|
1452
|
+
if (!(await client.getCapabilities()).features.modelSelection) {
|
|
1453
|
+
throw new LocalAIError({ code: "MODEL_NOT_EXECUTABLE", message: "This Oryn browser does not support model selection intents or exact file pins." });
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
if (request.requirements?.contract || request.requirements?.requiredFeatures?.length || Object.keys(request.requirements?.parameterValues ?? {}).length) {
|
|
1457
|
+
if (!(await client.getCapabilities()).features.taskProfiles) {
|
|
1458
|
+
throw new LocalAIError({ code: "MODEL_NOT_EXECUTABLE", message: "This Oryn runtime does not support task contract negotiation." });
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
const operationId = createOperationId();
|
|
1462
|
+
const stopProgress = client.onModelRequestProgress(
|
|
1463
|
+
operationId,
|
|
1464
|
+
options2?.onProgress ?? (() => void 0)
|
|
1465
|
+
);
|
|
1466
|
+
const abort = () => void client.cancelModelRequest(operationId);
|
|
1467
|
+
options2?.signal?.addEventListener("abort", abort, { once: true });
|
|
1468
|
+
try {
|
|
1469
|
+
const result = await client.requestModel(operationId, request);
|
|
1470
|
+
const session = unwrap(result);
|
|
1471
|
+
if (session.capabilities.task) sessionTasks.set(session.sessionId, session.capabilities.task);
|
|
1472
|
+
const selected = session.taskProfile?.contract;
|
|
1473
|
+
if (selected && TASK_CONTRACT_REVISIONS[selected.id] !== selected.revision) {
|
|
1474
|
+
await client.releaseModelSession(session.sessionId);
|
|
1475
|
+
sessionTasks.delete(session.sessionId);
|
|
1476
|
+
throw new LocalAIError({ code: "MODEL_NOT_EXECUTABLE", message: "This SDK does not support the negotiated task contract revision." });
|
|
1477
|
+
}
|
|
1478
|
+
if (selected && SHARED_TASK_CONTRACTS.includes(selected.id))
|
|
1479
|
+
sessionTasks.set(session.sessionId, selected.id);
|
|
1480
|
+
return session;
|
|
1481
|
+
} finally {
|
|
1482
|
+
stopProgress();
|
|
1483
|
+
options2?.signal?.removeEventListener("abort", abort);
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1486
|
+
async releaseSession(sessionId) {
|
|
1487
|
+
const client = injectedClient();
|
|
1488
|
+
if (!client?.releaseModelSession) throw unavailableError();
|
|
1489
|
+
unwrap(await client.releaseModelSession(sessionId));
|
|
1490
|
+
sessionTasks.delete(sessionId);
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
artifacts: {
|
|
1494
|
+
async create(input, options2) {
|
|
1495
|
+
const client = injectedClient();
|
|
1496
|
+
if (!client?.beginArtifactCreate) throw unavailableError();
|
|
1497
|
+
if (!(input instanceof Blob)) {
|
|
1498
|
+
throw new LocalAIError({
|
|
1499
|
+
code: "ARTIFACT_INVALID",
|
|
1500
|
+
message: "Artifact input must be a Blob or File."
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
const fileName = options2?.name ?? (typeof File !== "undefined" && input instanceof File ? input.name : void 0);
|
|
1504
|
+
const begin = unwrap(
|
|
1505
|
+
await client.beginArtifactCreate({
|
|
1506
|
+
mimeType: input.type || "application/octet-stream",
|
|
1507
|
+
sizeBytes: input.size,
|
|
1508
|
+
name: fileName,
|
|
1509
|
+
lifetime: options2?.lifetime
|
|
1510
|
+
})
|
|
1511
|
+
);
|
|
1512
|
+
try {
|
|
1513
|
+
for (let offset = 0; offset < input.size; offset += ARTIFACT_CHUNK_BYTES) {
|
|
1514
|
+
const chunk = await input.slice(
|
|
1515
|
+
offset,
|
|
1516
|
+
Math.min(input.size, offset + ARTIFACT_CHUNK_BYTES)
|
|
1517
|
+
).arrayBuffer();
|
|
1518
|
+
unwrap(await client.appendArtifactChunk(begin.uploadId, chunk));
|
|
1519
|
+
}
|
|
1520
|
+
return unwrap(await client.finishArtifactCreate(begin.uploadId));
|
|
1521
|
+
} catch (error) {
|
|
1522
|
+
await client.abortArtifactCreate(begin.uploadId).catch(() => void 0);
|
|
1523
|
+
throw error;
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1526
|
+
async get(artifactId) {
|
|
1527
|
+
const client = injectedClient();
|
|
1528
|
+
if (!client?.getArtifact) throw unavailableError();
|
|
1529
|
+
return unwrap(await client.getArtifact(artifactId));
|
|
1530
|
+
},
|
|
1531
|
+
async getUrl(artifactId) {
|
|
1532
|
+
const client = injectedClient();
|
|
1533
|
+
if (!client?.getArtifactUrl) throw unavailableError();
|
|
1534
|
+
return unwrap(await client.getArtifactUrl(artifactId));
|
|
1535
|
+
},
|
|
1536
|
+
async readBlob(artifactId) {
|
|
1537
|
+
const client = injectedClient();
|
|
1538
|
+
if (!client?.getArtifactUrl) throw unavailableError();
|
|
1539
|
+
const url = unwrap(await client.getArtifactUrl(artifactId));
|
|
1540
|
+
const response = await fetch(url, {
|
|
1541
|
+
credentials: "omit",
|
|
1542
|
+
cache: "no-store"
|
|
1543
|
+
});
|
|
1544
|
+
if (!response.ok) {
|
|
1545
|
+
throw new LocalAIError({
|
|
1546
|
+
code: response.status === 404 ? "ARTIFACT_NOT_FOUND" : "ARTIFACT_ACCESS_DENIED",
|
|
1547
|
+
message: "The artifact could not be read."
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
return response.blob();
|
|
1551
|
+
},
|
|
1552
|
+
async saveAs(artifactId, options2) {
|
|
1553
|
+
const client = injectedClient();
|
|
1554
|
+
if (!client?.saveArtifactAs) throw unavailableError();
|
|
1555
|
+
unwrap(await client.saveArtifactAs(artifactId, options2));
|
|
1556
|
+
},
|
|
1557
|
+
async release(artifactId) {
|
|
1558
|
+
const client = injectedClient();
|
|
1559
|
+
if (!client?.releaseArtifact) throw unavailableError();
|
|
1560
|
+
unwrap(await client.releaseArtifact(artifactId));
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
async invoke(request) {
|
|
1564
|
+
const client = injectedClient();
|
|
1565
|
+
if (!client?.invokeJob) throw unavailableError();
|
|
1566
|
+
const task = sessionTasks.get(request.sessionId) ?? "";
|
|
1567
|
+
const contract = SHARED_TASK_CONTRACTS.includes(task) ? task : SHARED_MODEL_TASK_CONTRACTS[task];
|
|
1568
|
+
if (contract) validateSharedTaskInput(contract, request.input);
|
|
1569
|
+
return unwrap(await client.invokeJob(request));
|
|
1570
|
+
},
|
|
1571
|
+
async cancel(jobId) {
|
|
1572
|
+
const client = injectedClient();
|
|
1573
|
+
if (!client?.cancelJob) throw unavailableError();
|
|
1574
|
+
unwrap(await client.cancelJob(jobId));
|
|
1575
|
+
},
|
|
1576
|
+
subscribe(listener) {
|
|
1577
|
+
const client = injectedClient();
|
|
1578
|
+
return client?.onJobEvent ? client.onJobEvent(listener) : () => void 0;
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
var alertedDocuments = /* @__PURE__ */ new WeakSet();
|
|
1583
|
+
var ORYN_URL = "https://oryn.ocno.ai/";
|
|
1584
|
+
function scheduleOrynBrowserAlert() {
|
|
1585
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
1586
|
+
if (hasCallableOrynBridge(window)) return;
|
|
1587
|
+
const owner = document;
|
|
1588
|
+
if (alertedDocuments.has(owner)) return;
|
|
1589
|
+
alertedDocuments.add(owner);
|
|
1590
|
+
const mount = () => {
|
|
1591
|
+
if (owner !== document || !owner.body || hasCallableOrynBridge(window)) return;
|
|
1592
|
+
mountOrynBrowserAlert(owner);
|
|
1593
|
+
};
|
|
1594
|
+
if (owner.readyState === "loading") {
|
|
1595
|
+
owner.addEventListener("DOMContentLoaded", mount, { once: true });
|
|
1596
|
+
} else {
|
|
1597
|
+
queueMicrotask(mount);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
function hasCallableOrynBridge(value) {
|
|
1601
|
+
const bridge = value.localAI;
|
|
1602
|
+
if (typeof bridge !== "object" || bridge === null) return false;
|
|
1603
|
+
const candidate = bridge;
|
|
1604
|
+
return typeof candidate.getCapabilities === "function" && typeof candidate.requestModel === "function" && typeof candidate.invokeJob === "function";
|
|
1605
|
+
}
|
|
1606
|
+
function mountOrynBrowserAlert(owner) {
|
|
1607
|
+
const previousFocus = owner.activeElement instanceof HTMLElement ? owner.activeElement : null;
|
|
1608
|
+
const host = owner.createElement("div");
|
|
1609
|
+
host.dataset.orynBrowserAlert = "";
|
|
1610
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
1611
|
+
shadow.innerHTML = `<style>
|
|
1612
|
+
:host{all:initial;position:fixed;inset:0;z-index:2147483647;display:grid;place-items:center;padding:20px;box-sizing:border-box;background:rgba(8,10,16,.66);color-scheme:light dark;font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
|
|
1613
|
+
*,*:before,*:after{box-sizing:border-box}
|
|
1614
|
+
.card{width:min(430px,100%);padding:24px;border:1px solid #3d4350;border-radius:18px;background:#20232b;color:#f5f6fa;box-shadow:0 24px 70px rgba(0,0,0,.45)}
|
|
1615
|
+
.top{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.brand{font-size:13px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:#aeb7ff}
|
|
1616
|
+
h2{margin:0 0 10px;font-size:22px;line-height:1.2;letter-spacing:-.02em}p{margin:0;color:#c7cad3;font-size:15px;line-height:1.55}
|
|
1617
|
+
.actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:10px;margin-top:24px}button,a{min-height:40px;border-radius:10px;padding:9px 14px;font:600 14px/1 inherit;cursor:pointer}
|
|
1618
|
+
button{border:1px solid #454b59;background:#292d36;color:#f5f6fa}.close{min-width:40px;padding:7px;font-size:20px;line-height:1}
|
|
1619
|
+
a{display:inline-flex;align-items:center;text-decoration:none;border:1px solid #8994ff;background:#8994ff;color:#111522}
|
|
1620
|
+
button:focus-visible,a:focus-visible{outline:3px solid #cbd0ff;outline-offset:2px}
|
|
1621
|
+
@media (prefers-color-scheme:light){:host{background:rgba(20,23,32,.45)}.card{border-color:#d7dae4;background:#fff;color:#171923}.brand{color:#4c57bd}p{color:#555967}button{border-color:#d4d7e0;background:#f4f5f8;color:#171923}a{color:#111522}}
|
|
1622
|
+
@media (forced-colors:active){:host{background:Canvas}.card,button,a{border:1px solid CanvasText;background:Canvas;color:CanvasText}}
|
|
1623
|
+
@media (prefers-reduced-motion:no-preference){.card{animation:enter .14s ease-out}@keyframes enter{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}}
|
|
1624
|
+
@media (max-width:480px){:host{align-items:end;padding:12px}.card{padding:20px;border-radius:16px}.actions{flex-direction:column-reverse}.actions>*{justify-content:center;width:100%}}
|
|
1625
|
+
</style><section class="card" role="dialog" aria-modal="true" aria-labelledby="oryn-alert-title" aria-describedby="oryn-alert-copy">
|
|
1626
|
+
<div class="top"><span class="brand">Oryn Browser</span><button class="close" type="button" aria-label="Close">×</button></div>
|
|
1627
|
+
<h2 id="oryn-alert-title">This feature needs Oryn Browser</h2>
|
|
1628
|
+
<p id="oryn-alert-copy">Oryn runs compatible AI models locally and keeps model choice, downloads, and hardware use under your control.</p>
|
|
1629
|
+
<div class="actions"><button class="dismiss" type="button">Not now</button><a href="${ORYN_URL}" target="_blank" rel="noopener noreferrer">Learn about Oryn</a></div>
|
|
1630
|
+
</section>`;
|
|
1631
|
+
const dismissButton = shadow.querySelector(".dismiss");
|
|
1632
|
+
const closeButton = shadow.querySelector(".close");
|
|
1633
|
+
const link = shadow.querySelector("a");
|
|
1634
|
+
if (!dismissButton || !closeButton || !link) return;
|
|
1635
|
+
const controls = [closeButton, dismissButton, link];
|
|
1636
|
+
const dismiss = () => {
|
|
1637
|
+
owner.removeEventListener("keydown", onKeyDown, true);
|
|
1638
|
+
host.remove();
|
|
1639
|
+
previousFocus?.focus({ preventScroll: true });
|
|
1640
|
+
};
|
|
1641
|
+
const onKeyDown = (event) => {
|
|
1642
|
+
if (event.key === "Escape") {
|
|
1643
|
+
event.preventDefault();
|
|
1644
|
+
dismiss();
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
if (event.key !== "Tab") return;
|
|
1648
|
+
const activeIndex = controls.indexOf(shadow.activeElement);
|
|
1649
|
+
const direction = event.shiftKey ? -1 : 1;
|
|
1650
|
+
const next = (activeIndex + direction + controls.length) % controls.length;
|
|
1651
|
+
event.preventDefault();
|
|
1652
|
+
controls[next]?.focus();
|
|
1653
|
+
};
|
|
1654
|
+
closeButton.addEventListener("click", dismiss);
|
|
1655
|
+
dismissButton.addEventListener("click", dismiss);
|
|
1656
|
+
owner.addEventListener("keydown", onKeyDown, true);
|
|
1657
|
+
owner.body.append(host);
|
|
1658
|
+
dismissButton.focus({ preventScroll: true });
|
|
1659
|
+
}
|
|
1660
|
+
async function invokeAndWait(client, request, options = {}) {
|
|
1661
|
+
if (options.signal?.aborted) throw abortedJobError();
|
|
1662
|
+
let jobId;
|
|
1663
|
+
const buffered = [];
|
|
1664
|
+
let settle;
|
|
1665
|
+
const terminal = new Promise((resolve) => {
|
|
1666
|
+
settle = resolve;
|
|
1667
|
+
});
|
|
1668
|
+
const accept = (event) => {
|
|
1669
|
+
if (event.sessionId !== request.sessionId) return;
|
|
1670
|
+
if (!jobId) {
|
|
1671
|
+
buffered.push(event);
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
if (event.jobId !== jobId) return;
|
|
1675
|
+
options.onEvent?.(event);
|
|
1676
|
+
if (isTerminalEvent(event)) settle?.(event);
|
|
1677
|
+
};
|
|
1678
|
+
const unsubscribe = client.subscribe(accept);
|
|
1679
|
+
let abort = () => void 0;
|
|
1680
|
+
try {
|
|
1681
|
+
const job = await client.invoke(request);
|
|
1682
|
+
jobId = job.jobId;
|
|
1683
|
+
for (const event2 of buffered) accept(event2);
|
|
1684
|
+
abort = () => void client.cancel(job.jobId);
|
|
1685
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
1686
|
+
const event = await terminal;
|
|
1687
|
+
if (event.event === "job.completed") return event.data.result;
|
|
1688
|
+
if (event.event === "job.failed") throw new LocalAIError(event.data.error);
|
|
1689
|
+
throw abortedJobError();
|
|
1690
|
+
} finally {
|
|
1691
|
+
options.signal?.removeEventListener("abort", abort);
|
|
1692
|
+
unsubscribe();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
async function* invokeStream(client, request, options = {}) {
|
|
1696
|
+
if (options.signal?.aborted) throw abortedJobError();
|
|
1697
|
+
const pending = [];
|
|
1698
|
+
let wake;
|
|
1699
|
+
let jobId;
|
|
1700
|
+
const listener = (event) => {
|
|
1701
|
+
if (event.sessionId !== request.sessionId) return;
|
|
1702
|
+
if (jobId && event.jobId !== jobId) return;
|
|
1703
|
+
pending.push(event);
|
|
1704
|
+
wake?.();
|
|
1705
|
+
wake = void 0;
|
|
1706
|
+
};
|
|
1707
|
+
const unsubscribe = client.subscribe(listener);
|
|
1708
|
+
let abort = () => void 0;
|
|
1709
|
+
try {
|
|
1710
|
+
const job = await client.invoke(request);
|
|
1711
|
+
jobId = job.jobId;
|
|
1712
|
+
for (let index = pending.length - 1; index >= 0; index -= 1) {
|
|
1713
|
+
if (pending[index]?.jobId !== jobId) pending.splice(index, 1);
|
|
1714
|
+
}
|
|
1715
|
+
abort = () => void client.cancel(job.jobId);
|
|
1716
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
1717
|
+
while (true) {
|
|
1718
|
+
if (pending.length === 0) {
|
|
1719
|
+
await new Promise((resolve) => {
|
|
1720
|
+
wake = resolve;
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
const event = pending.shift();
|
|
1724
|
+
if (!event) continue;
|
|
1725
|
+
yield event;
|
|
1726
|
+
if (isTerminalEvent(event)) return;
|
|
1727
|
+
}
|
|
1728
|
+
} finally {
|
|
1729
|
+
options.signal?.removeEventListener("abort", abort);
|
|
1730
|
+
unsubscribe();
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
function unwrap(result) {
|
|
1734
|
+
if (result.ok) return result.value;
|
|
1735
|
+
throw new LocalAIError(result.error);
|
|
1736
|
+
}
|
|
1737
|
+
function unavailableError() {
|
|
1738
|
+
return new LocalAIError({
|
|
1739
|
+
code: "RUNTIME_NOT_AVAILABLE",
|
|
1740
|
+
message: "Local AI is not available in this browser."
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
function abortedError() {
|
|
1744
|
+
return new LocalAIError({
|
|
1745
|
+
code: "REQUEST_ABORTED",
|
|
1746
|
+
message: "The model request was aborted."
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
function abortedJobError() {
|
|
1750
|
+
return new LocalAIError({
|
|
1751
|
+
code: "REQUEST_ABORTED",
|
|
1752
|
+
message: "The Local AI job was cancelled."
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
function isTerminalEvent(event) {
|
|
1756
|
+
return ["job.completed", "job.failed", "job.cancelled"].includes(event.event);
|
|
1757
|
+
}
|
|
1758
|
+
var operationSequence = 0;
|
|
1759
|
+
var ARTIFACT_CHUNK_BYTES = 256 * 1024;
|
|
1760
|
+
function createOperationId() {
|
|
1761
|
+
operationSequence += 1;
|
|
1762
|
+
return `model_request_${Date.now().toString(36)}_${operationSequence.toString(36)}`;
|
|
1763
|
+
}
|
|
1764
|
+
export {
|
|
1765
|
+
LocalAIError,
|
|
1766
|
+
SDK_VERSION,
|
|
1767
|
+
SHARED_MODEL_TASK_CONTRACTS,
|
|
1768
|
+
SHARED_TASK_CONTRACTS,
|
|
1769
|
+
createLocalAIClient,
|
|
1770
|
+
invokeAndWait,
|
|
1771
|
+
invokeStream,
|
|
1772
|
+
validateSharedTaskInput
|
|
1773
|
+
};
|