@abhishek944/pi-classifier 0.3.0 → 0.5.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/CHANGELOG.md +48 -0
- package/COMPUTER_USE.md +117 -0
- package/README.md +344 -30
- package/dist/auth.d.ts +4 -2
- package/dist/auth.js +18 -2
- package/dist/box-tool.d.ts +4 -0
- package/dist/box-tool.js +79 -0
- package/dist/box.d.ts +32 -0
- package/dist/box.js +148 -0
- package/dist/choices.js +35 -1
- package/dist/classify.d.ts +6 -0
- package/dist/classify.js +4 -4
- package/dist/computer-use-state.d.ts +9 -0
- package/dist/computer-use-state.js +160 -0
- package/dist/computer-use-tool.d.ts +52 -0
- package/dist/computer-use-tool.js +78 -0
- package/dist/computer-use-types.d.ts +132 -0
- package/dist/computer-use-types.js +1 -0
- package/dist/computer-use.d.ts +22 -0
- package/dist/computer-use.js +223 -0
- package/dist/config.d.ts +140 -3
- package/dist/config.js +405 -20
- package/dist/cost.js +42 -4
- package/dist/durable.d.ts +34 -0
- package/dist/durable.js +237 -0
- package/dist/extension.d.ts +2 -247
- package/dist/extension.js +53 -190
- package/dist/extract.d.ts +11 -0
- package/dist/extract.js +191 -0
- package/dist/http.d.ts +6 -1
- package/dist/http.js +64 -28
- package/dist/image-content.d.ts +12 -0
- package/dist/image-content.js +90 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +3 -0
- package/dist/inputs.d.ts +24 -2
- package/dist/inputs.js +565 -134
- package/dist/mcp-cli.d.ts +2 -0
- package/dist/mcp-cli.js +39 -0
- package/dist/mcp-server.d.ts +28 -0
- package/dist/mcp-server.js +121 -0
- package/dist/mcp-tool-definitions.d.ts +19 -0
- package/dist/mcp-tool-definitions.js +64 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1218 -124
- package/dist/tool-contracts.d.ts +785 -0
- package/dist/tool-contracts.js +530 -0
- package/dist/tree.js +1 -1
- package/dist/types.d.ts +314 -20
- package/dist/validation.js +181 -44
- package/package.json +33 -5
- package/src/auth.ts +26 -2
- package/src/box-tool.ts +110 -0
- package/src/box.ts +253 -0
- package/src/choices.ts +44 -2
- package/src/classify.ts +10 -6
- package/src/computer-use-state.ts +145 -0
- package/src/computer-use-tool.ts +76 -0
- package/src/computer-use-types.ts +127 -0
- package/src/computer-use.ts +216 -0
- package/src/config.ts +454 -23
- package/src/cost.ts +42 -4
- package/src/durable.ts +298 -0
- package/src/extension.ts +79 -265
- package/src/extract.ts +228 -0
- package/src/http.ts +63 -32
- package/src/image-content.ts +77 -0
- package/src/index.ts +25 -0
- package/src/inputs.ts +603 -184
- package/src/mcp-cli.ts +44 -0
- package/src/mcp-server.ts +179 -0
- package/src/mcp-tool-definitions.ts +104 -0
- package/src/providers.ts +1398 -144
- package/src/tool-contracts.ts +785 -0
- package/src/tree.ts +1 -1
- package/src/types.ts +248 -11
- package/src/validation.ts +169 -96
package/dist/types.d.ts
CHANGED
|
@@ -1,22 +1,133 @@
|
|
|
1
|
-
export type ApiStyle = "openai-decisions" | "perplexity-decisions" | "system-one" | "cloudflare-system-one" | "microsoft-system-one";
|
|
1
|
+
export type ApiStyle = "openai-decisions" | "openrouter-decisions" | "gemini-decisions" | "inception-decisions" | "parallel-decisions" | "local-system-one" | "perplexity-decisions" | "sarvam-system-one" | "system-one" | "liquid-system-one" | "cloudflare-system-one" | "cloudflare-clairic" | "openrouter-extractions" | "litellm-extraction" | "microsoft-system-one";
|
|
2
|
+
/** Explicit references are resolved only from the request's named images. */
|
|
3
|
+
export type ImageReference = {
|
|
4
|
+
$image: string;
|
|
5
|
+
};
|
|
6
|
+
export type QuestionContent = string | (string | ImageReference)[];
|
|
7
|
+
export type ImageInput = string | {
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
} | {
|
|
11
|
+
id: string;
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
export type MediaInput = {
|
|
15
|
+
type: "audio" | "video";
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
export type CharSpan = [number, number];
|
|
19
|
+
export type BoxEdges = {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
left: number;
|
|
23
|
+
right: number;
|
|
24
|
+
};
|
|
2
25
|
export type Question = {
|
|
3
26
|
type: "bool";
|
|
4
|
-
instructions:
|
|
27
|
+
instructions: QuestionContent;
|
|
5
28
|
criteria?: {
|
|
6
|
-
true?:
|
|
7
|
-
false?:
|
|
29
|
+
true?: QuestionContent;
|
|
30
|
+
false?: QuestionContent;
|
|
8
31
|
};
|
|
9
32
|
} | {
|
|
10
33
|
type: "choice";
|
|
11
|
-
instructions:
|
|
12
|
-
criteria: Record<string,
|
|
34
|
+
instructions: QuestionContent;
|
|
35
|
+
criteria: Record<string, QuestionContent>;
|
|
36
|
+
booleanValues?: boolean;
|
|
13
37
|
} | {
|
|
14
38
|
type: "score";
|
|
15
|
-
instructions:
|
|
16
|
-
criteria:
|
|
39
|
+
instructions: QuestionContent;
|
|
40
|
+
criteria: QuestionContent[];
|
|
41
|
+
descriptions?: string[];
|
|
42
|
+
} | {
|
|
43
|
+
type: "extract";
|
|
44
|
+
instructions?: QuestionContent;
|
|
45
|
+
criteria: Record<string, QuestionContent>;
|
|
46
|
+
source?: string;
|
|
47
|
+
threshold?: number;
|
|
48
|
+
snapToWords?: boolean;
|
|
49
|
+
debug?: boolean;
|
|
17
50
|
} | {
|
|
18
51
|
type: "box";
|
|
19
|
-
instructions:
|
|
52
|
+
instructions: QuestionContent;
|
|
53
|
+
} | {
|
|
54
|
+
type: "locate";
|
|
55
|
+
instructions: QuestionContent;
|
|
56
|
+
} | {
|
|
57
|
+
type: "text";
|
|
58
|
+
instructions: QuestionContent;
|
|
59
|
+
} | {
|
|
60
|
+
type: "number";
|
|
61
|
+
instructions: QuestionContent;
|
|
62
|
+
unit?: string;
|
|
63
|
+
range?: CharSpan;
|
|
64
|
+
step?: number;
|
|
65
|
+
} | {
|
|
66
|
+
type: "date";
|
|
67
|
+
instructions: QuestionContent;
|
|
68
|
+
} | {
|
|
69
|
+
type: "spans";
|
|
70
|
+
instructions: QuestionContent;
|
|
71
|
+
max?: number;
|
|
72
|
+
} | {
|
|
73
|
+
type: "boxes";
|
|
74
|
+
instructions: QuestionContent;
|
|
75
|
+
max?: number;
|
|
76
|
+
} | {
|
|
77
|
+
type: "estimate";
|
|
78
|
+
instructions: QuestionContent;
|
|
79
|
+
range: CharSpan;
|
|
80
|
+
step?: number;
|
|
81
|
+
unit?: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: "multi_choice";
|
|
84
|
+
instructions: QuestionContent;
|
|
85
|
+
criteria: Record<string, QuestionContent>;
|
|
86
|
+
};
|
|
87
|
+
export type TextSpan = {
|
|
88
|
+
start: number;
|
|
89
|
+
end: number;
|
|
90
|
+
text: string;
|
|
91
|
+
score: number;
|
|
92
|
+
/** Index into webGrounding.searchResults when the span came from search evidence. */
|
|
93
|
+
searchResult?: number;
|
|
94
|
+
};
|
|
95
|
+
export type WebSearchResult = {
|
|
96
|
+
title: string;
|
|
97
|
+
url: string;
|
|
98
|
+
snippet: string;
|
|
99
|
+
date?: string;
|
|
100
|
+
lastUpdated?: string;
|
|
101
|
+
};
|
|
102
|
+
export type WebFetchedResult = {
|
|
103
|
+
title: string;
|
|
104
|
+
url: string;
|
|
105
|
+
snippet: string;
|
|
106
|
+
};
|
|
107
|
+
export type DecisionCitation = {
|
|
108
|
+
url: string;
|
|
109
|
+
title?: string;
|
|
110
|
+
excerpts?: string[];
|
|
111
|
+
};
|
|
112
|
+
export type NonTokenCost = {
|
|
113
|
+
currency: "USD";
|
|
114
|
+
webGrounding: {
|
|
115
|
+
status: "estimated_maximum";
|
|
116
|
+
/** One search is requested per question; duplicate queries and failed searches may not be billed. */
|
|
117
|
+
searchesRequested: number;
|
|
118
|
+
searchFeeMaximum: number;
|
|
119
|
+
/** A successful URL fetch is reported by the provider and is billable. */
|
|
120
|
+
successfulFetches: number;
|
|
121
|
+
fetchFee: number;
|
|
122
|
+
totalMaximum: number;
|
|
123
|
+
note: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export type ProviderCost = {
|
|
127
|
+
currency: "USD";
|
|
128
|
+
total: number;
|
|
129
|
+
source: "provider" | "gateway";
|
|
130
|
+
note?: string;
|
|
20
131
|
};
|
|
21
132
|
export type Answer = {
|
|
22
133
|
type: "bool";
|
|
@@ -36,13 +147,66 @@ export type Answer = {
|
|
|
36
147
|
probabilities?: Record<string, number>;
|
|
37
148
|
} | {
|
|
38
149
|
type: "box";
|
|
39
|
-
box:
|
|
40
|
-
top: number;
|
|
41
|
-
bottom: number;
|
|
42
|
-
left: number;
|
|
43
|
-
right: number;
|
|
44
|
-
};
|
|
150
|
+
box: BoxEdges;
|
|
45
151
|
confidence: number;
|
|
152
|
+
found?: number;
|
|
153
|
+
} | {
|
|
154
|
+
type: "locate";
|
|
155
|
+
spans: TextSpan[];
|
|
156
|
+
} | {
|
|
157
|
+
type: "extract";
|
|
158
|
+
spans: Record<string, TextSpan[]>;
|
|
159
|
+
notStated: Record<string, number>;
|
|
160
|
+
} | {
|
|
161
|
+
type: "text";
|
|
162
|
+
text: string;
|
|
163
|
+
span?: CharSpan | null;
|
|
164
|
+
found?: number;
|
|
165
|
+
path?: string;
|
|
166
|
+
} | {
|
|
167
|
+
type: "number";
|
|
168
|
+
value: number | null;
|
|
169
|
+
unit?: string | null;
|
|
170
|
+
text?: string | null;
|
|
171
|
+
span?: CharSpan | null;
|
|
172
|
+
found?: number;
|
|
173
|
+
path?: string;
|
|
174
|
+
} | {
|
|
175
|
+
type: "date";
|
|
176
|
+
date: string | null;
|
|
177
|
+
text?: string | null;
|
|
178
|
+
span?: CharSpan | null;
|
|
179
|
+
found?: number;
|
|
180
|
+
path?: string;
|
|
181
|
+
} | {
|
|
182
|
+
type: "spans";
|
|
183
|
+
spans: {
|
|
184
|
+
text: string;
|
|
185
|
+
span: CharSpan;
|
|
186
|
+
found: number;
|
|
187
|
+
}[];
|
|
188
|
+
count: number;
|
|
189
|
+
atLeast: boolean;
|
|
190
|
+
presence: number[];
|
|
191
|
+
} | {
|
|
192
|
+
type: "boxes";
|
|
193
|
+
boxes: {
|
|
194
|
+
box: BoxEdges;
|
|
195
|
+
found: number;
|
|
196
|
+
confidence: number;
|
|
197
|
+
}[];
|
|
198
|
+
count: number;
|
|
199
|
+
atLeast: boolean;
|
|
200
|
+
presence: number[];
|
|
201
|
+
} | {
|
|
202
|
+
type: "estimate";
|
|
203
|
+
value: number;
|
|
204
|
+
interval: CharSpan;
|
|
205
|
+
unit?: string | null;
|
|
206
|
+
} | {
|
|
207
|
+
type: "multi_choice";
|
|
208
|
+
choices: string[];
|
|
209
|
+
probabilities: Record<string, number>;
|
|
46
210
|
} | {
|
|
47
211
|
type: "refusal";
|
|
48
212
|
} | {
|
|
@@ -53,8 +217,23 @@ export type Answer = {
|
|
|
53
217
|
export interface ClassifyParams {
|
|
54
218
|
state: string | Record<string, unknown> | unknown[];
|
|
55
219
|
questions: Record<string, Question>;
|
|
56
|
-
/**
|
|
57
|
-
images?:
|
|
220
|
+
/** Legacy paths are shared in order. Named images require explicit {$image:id} references. */
|
|
221
|
+
images?: ImageInput[];
|
|
222
|
+
/** Shared audio/video inputs for providers that document media support. */
|
|
223
|
+
media?: MediaInput[];
|
|
224
|
+
/** OpenAI Decisions input items: messages, function calls/outputs and custom tool calls/outputs. */
|
|
225
|
+
conversation?: unknown[];
|
|
226
|
+
/** Explicit opt-in to Perplexity web search and page fetching. This can upload state text and incur per-search fees. */
|
|
227
|
+
mode?: "web_grounding";
|
|
228
|
+
/** Image detail hint for adapters that publish one; ignored by routes without a documented field. */
|
|
229
|
+
imageDetail?: "auto" | "low" | "high" | "original";
|
|
230
|
+
/** OpenAI-compatible prompt-cache controls; rejected by routes without a documented contract. */
|
|
231
|
+
promptCache?: {
|
|
232
|
+
key?: string;
|
|
233
|
+
mode?: "implicit" | "explicit";
|
|
234
|
+
ttl?: "30m";
|
|
235
|
+
breakpoints?: boolean;
|
|
236
|
+
};
|
|
58
237
|
}
|
|
59
238
|
export type ClassificationTreeNode = {
|
|
60
239
|
id: string;
|
|
@@ -68,7 +247,7 @@ export type ClassifyTreeParams = {
|
|
|
68
247
|
state: ClassifyParams["state"];
|
|
69
248
|
tree: string | ClassificationTree;
|
|
70
249
|
instructions?: string;
|
|
71
|
-
images?:
|
|
250
|
+
images?: ImageInput[];
|
|
72
251
|
};
|
|
73
252
|
export type TreeStep = {
|
|
74
253
|
level: number;
|
|
@@ -92,7 +271,7 @@ export type ClassifierTreeResult = {
|
|
|
92
271
|
export interface ModelDefinition {
|
|
93
272
|
id: string;
|
|
94
273
|
name?: string;
|
|
95
|
-
input?: ("text" | "image")[];
|
|
274
|
+
input?: ("text" | "image" | "audio" | "video")[];
|
|
96
275
|
box?: boolean;
|
|
97
276
|
}
|
|
98
277
|
/** USD per million tokens. Cache counts, when reported, are part of input tokens. */
|
|
@@ -110,6 +289,7 @@ export type ClassifierCost = {
|
|
|
110
289
|
total: number;
|
|
111
290
|
source: "builtin" | "configured";
|
|
112
291
|
rates: TokenPricing;
|
|
292
|
+
nonToken?: NonTokenCost;
|
|
113
293
|
} | {
|
|
114
294
|
status: "estimated";
|
|
115
295
|
currency: "USD";
|
|
@@ -117,22 +297,37 @@ export type ClassifierCost = {
|
|
|
117
297
|
output: number;
|
|
118
298
|
total: number;
|
|
119
299
|
source: "aggregated";
|
|
300
|
+
nonToken?: NonTokenCost;
|
|
120
301
|
} | {
|
|
121
302
|
status: "unavailable";
|
|
122
303
|
currency: "USD";
|
|
123
304
|
reason: "unknown_pricing" | "missing_usage" | "invalid_usage" | "missing_cache_pricing" | "calculation_overflow";
|
|
124
305
|
};
|
|
306
|
+
export type RouteLimits = {
|
|
307
|
+
maxQuestions: number;
|
|
308
|
+
maxImages: number;
|
|
309
|
+
maxAudio: number;
|
|
310
|
+
maxVideo: number;
|
|
311
|
+
};
|
|
125
312
|
export interface ProviderSettings {
|
|
126
313
|
apiKey?: string;
|
|
127
314
|
baseUrl?: string;
|
|
128
315
|
headers?: Record<string, string>;
|
|
129
316
|
accountId?: string;
|
|
317
|
+
/** Cloudflare AI Gateway selection; emitted as `cf-aig-gateway-id`. */
|
|
318
|
+
gatewayId?: string;
|
|
130
319
|
experimentalImages?: boolean;
|
|
131
320
|
experimentalBox?: boolean;
|
|
321
|
+
/** Microsoft Foundry accepts API-key or Entra bearer credentials on the same endpoint. */
|
|
322
|
+
authMode?: "api-key" | "bearer" | "google-api-key" | "parallel-api-key" | "none";
|
|
323
|
+
/** TypeSafe Jev long-context opt-in; sends `TypeSafe-Danger-Zone-Long-Context: true`. */
|
|
324
|
+
longContext?: boolean;
|
|
132
325
|
/** Model ID (or Azure deployment name) to explicit token rates. */
|
|
133
326
|
pricing?: Record<string, TokenPricing>;
|
|
134
327
|
/** Verified wire choice limit; needed for batching on endpoints without a known limit. */
|
|
135
328
|
maxChoices?: number;
|
|
329
|
+
/** Verified per-request envelope overrides for custom or account-specific endpoints. */
|
|
330
|
+
limits?: Partial<RouteLimits>;
|
|
136
331
|
}
|
|
137
332
|
export interface CustomProviderSettings extends ProviderSettings {
|
|
138
333
|
api: ApiStyle;
|
|
@@ -143,6 +338,7 @@ export type ClassifierRoute = {
|
|
|
143
338
|
model: string;
|
|
144
339
|
};
|
|
145
340
|
export interface ClassifierSettings {
|
|
341
|
+
computerUse?: import("./computer-use-types.js").ComputerUseSettings;
|
|
146
342
|
none_of_above_choice?: boolean;
|
|
147
343
|
remove_choice_limits?: boolean;
|
|
148
344
|
default?: ClassifierRoute;
|
|
@@ -159,31 +355,55 @@ export interface ResolvedModel {
|
|
|
159
355
|
provider: string;
|
|
160
356
|
model: string;
|
|
161
357
|
api: ApiStyle;
|
|
358
|
+
/** Provider wire format used by the selected route. */
|
|
359
|
+
mediaFormat: "jev-assets" | "base64-object" | "openrouter-parts";
|
|
162
360
|
baseUrl: string;
|
|
163
361
|
headers: Record<string, string>;
|
|
362
|
+
gatewayId?: string;
|
|
164
363
|
configuredApiKey?: string;
|
|
165
364
|
credentialProvider: string;
|
|
166
365
|
envVar?: string;
|
|
167
366
|
images: boolean;
|
|
367
|
+
audio: boolean;
|
|
368
|
+
video: boolean;
|
|
168
369
|
box: boolean;
|
|
169
370
|
experimentalImages: boolean;
|
|
371
|
+
authMode: "api-key" | "bearer" | "subscription-key" | "google-api-key" | "parallel-api-key" | "none";
|
|
372
|
+
longContext: boolean;
|
|
170
373
|
requestTimeoutMs: number;
|
|
374
|
+
/** Envelope used before a request; values come from verified route contracts or explicit settings. */
|
|
375
|
+
limits: RouteLimits;
|
|
171
376
|
pricing?: {
|
|
172
377
|
rates: TokenPricing;
|
|
173
378
|
source: "builtin" | "configured";
|
|
174
379
|
};
|
|
175
380
|
maxChoices?: number;
|
|
176
381
|
}
|
|
177
|
-
export interface
|
|
382
|
+
export interface PreparedLocalImage {
|
|
178
383
|
data: string;
|
|
179
384
|
mimeType: "image/png" | "image/jpeg" | "image/webp";
|
|
180
385
|
width: number;
|
|
181
386
|
height: number;
|
|
182
387
|
}
|
|
388
|
+
export type PreparedImage = (PreparedLocalImage | {
|
|
389
|
+
url: string;
|
|
390
|
+
}) & {
|
|
391
|
+
id?: string;
|
|
392
|
+
};
|
|
393
|
+
export type PreparedMedia = {
|
|
394
|
+
type: "audio" | "video";
|
|
395
|
+
mimeType: string;
|
|
396
|
+
data: string;
|
|
397
|
+
};
|
|
183
398
|
export interface PreparedInput {
|
|
184
399
|
state: ClassifyParams["state"];
|
|
185
400
|
questions: Record<string, Question>;
|
|
186
401
|
images: PreparedImage[];
|
|
402
|
+
media: PreparedMedia[];
|
|
403
|
+
mode?: ClassifyParams["mode"];
|
|
404
|
+
conversation?: ClassifyParams["conversation"];
|
|
405
|
+
imageDetail?: ClassifyParams["imageDetail"];
|
|
406
|
+
promptCache?: ClassifyParams["promptCache"];
|
|
187
407
|
}
|
|
188
408
|
export type ClassifierResult = {
|
|
189
409
|
provider: string;
|
|
@@ -200,7 +420,16 @@ export type ClassifierResult = {
|
|
|
200
420
|
providerCalls?: number;
|
|
201
421
|
/** Estimate for completed requests in this result, not an invoice or total of failed attempts. */
|
|
202
422
|
cost: ClassifierCost;
|
|
423
|
+
/** Gateway/provider-reported charge when the API exposes one; never substituted for the token estimate. */
|
|
424
|
+
providerCost?: ProviderCost;
|
|
425
|
+
/** Request-wide web evidence returned by grounded Decision APIs such as Parallel. */
|
|
426
|
+
citations?: DecisionCitation[];
|
|
203
427
|
requestId?: string;
|
|
428
|
+
/** Evidence returned by Perplexity web grounding, with the same order and counts as the provider response. */
|
|
429
|
+
webGrounding?: {
|
|
430
|
+
searchResults: WebSearchResult[];
|
|
431
|
+
fetchedResults?: WebFetchedResult[];
|
|
432
|
+
};
|
|
204
433
|
attemptedRoutes?: ClassifierRoute[];
|
|
205
434
|
};
|
|
206
435
|
export type ClassifierComparisonEntry = ClassifierRoute & {
|
|
@@ -226,3 +455,68 @@ export declare class ClassifierError extends Error {
|
|
|
226
455
|
}
|
|
227
456
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
228
457
|
export declare function userError(error: unknown): string;
|
|
458
|
+
/** Cloudflare Clairic field specifications. Keys use the provider's documented names. */
|
|
459
|
+
export type ExtractionField = {
|
|
460
|
+
type: "text" | "number" | "compute" | "date" | "time" | "datetime" | "duration" | "boolean" | "enum" | "object" | "list" | "estimate" | "forecast";
|
|
461
|
+
instructions?: string;
|
|
462
|
+
nullable?: boolean;
|
|
463
|
+
unit?: string;
|
|
464
|
+
integer?: boolean;
|
|
465
|
+
decimals?: number;
|
|
466
|
+
minimum?: number;
|
|
467
|
+
maximum?: number;
|
|
468
|
+
exclusiveMinimum?: number;
|
|
469
|
+
exclusiveMaximum?: number;
|
|
470
|
+
minLength?: number;
|
|
471
|
+
maxLength?: number;
|
|
472
|
+
pattern?: string;
|
|
473
|
+
enum?: unknown[];
|
|
474
|
+
knowledge?: boolean;
|
|
475
|
+
source_only?: boolean;
|
|
476
|
+
null_threshold?: number;
|
|
477
|
+
properties?: Record<string, ExtractionField>;
|
|
478
|
+
items?: "text" | "number" | "date" | {
|
|
479
|
+
type: "object";
|
|
480
|
+
properties: Record<string, ExtractionField>;
|
|
481
|
+
};
|
|
482
|
+
max_items?: number;
|
|
483
|
+
min?: number | string;
|
|
484
|
+
max?: number | string;
|
|
485
|
+
step?: number | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
486
|
+
scale?: "linear" | "log";
|
|
487
|
+
horizon?: number;
|
|
488
|
+
interval?: "step" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
489
|
+
};
|
|
490
|
+
export type ExtractParams = {
|
|
491
|
+
state?: ClassifyParams["state"];
|
|
492
|
+
fields: Record<string, ExtractionField>;
|
|
493
|
+
images?: (string | {
|
|
494
|
+
path: string;
|
|
495
|
+
rotation?: 0 | 90 | 180 | 270;
|
|
496
|
+
})[];
|
|
497
|
+
documents?: string[];
|
|
498
|
+
referenceDate?: string;
|
|
499
|
+
options?: {
|
|
500
|
+
includeQuantiles?: boolean;
|
|
501
|
+
returnStateText?: boolean;
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
export type JsonLike = string | number | boolean | null | JsonLike[] | {
|
|
505
|
+
[key: string]: JsonLike;
|
|
506
|
+
};
|
|
507
|
+
export type ExtractionAnswer = {
|
|
508
|
+
type: string;
|
|
509
|
+
value: JsonLike;
|
|
510
|
+
[key: string]: JsonLike;
|
|
511
|
+
};
|
|
512
|
+
export type ExtractResult = {
|
|
513
|
+
provider: string;
|
|
514
|
+
model: string;
|
|
515
|
+
answers: Record<string, ExtractionAnswer>;
|
|
516
|
+
truncated: boolean;
|
|
517
|
+
usage?: NonNullable<ClassifierResult["usage"]>;
|
|
518
|
+
cost: ClassifierCost;
|
|
519
|
+
providerCost?: ProviderCost;
|
|
520
|
+
requestId?: string;
|
|
521
|
+
stateText?: string;
|
|
522
|
+
};
|