@abhishek944/pi-classifier 0.5.1 → 0.7.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.
@@ -13,16 +13,16 @@ export const CLASSIFY_TREE_TOOL = "classify_tree";
13
13
  export const CLASSIFIER_BOX_TOOL = "classifier_box_image";
14
14
 
15
15
  export const CLASSIFY_TOOL_DESCRIPTION =
16
- "Ask a decision model typed questions about text, JSON, images and supported audio/video. Legacy image paths are shared; named path/url descriptors require explicit {$image:id} references. Jev supports images in instructions/criteria; OpenAI supports instruction images and hosted URLs. Unsupported placements fail locally. Returns bool probabilities, choices, scores, Perplexity locate spans, Liquid reads/estimates/multi-select answers and boxes, plus reported token usage and estimated USD cost (or an explicit unavailable reason). mode: web_grounding is an explicit Perplexity opt-in that sends question text and the start of state to web search and adds billed searches/fetches; cost.nonToken reports the documented fees. Experimental Jev box answers require explicit configuration. Provider/model are fixed by pi-classifier.default (or legacy defaultProvider/defaultModel); this tool cannot override them. API-key authentication is independent of Codex chat login. Only explicitly configured fallback routes may be used after a missing key or HTTP 401/404/429 before any batch has completed; never after uncertainty, refusals, timeouts or network failures. Use /classifier list or status to inspect configuration.";
16
+ "Ask a decision model classification questions about text, JSON, images and supported audio/video: yes/no (bool), category (choice), multi-choice (multiple labels) and score. Extraction reads (text, numbers, dates, passages, box/boxes locations, locate offsets, estimates, Inception extract) are not classification and are rejected here; send the same question to classify_extract. Legacy image paths are shared; named path/url descriptors require explicit {$image:id} references. Jev supports images in instructions/criteria; OpenAI supports instruction images and hosted URLs. Unsupported placements fail locally. Returns bool probabilities, choices, multi-choice probabilities and scores, plus reported token usage and estimated USD cost (or an explicit unavailable reason). mode: web_grounding is an explicit Perplexity opt-in that sends question text and the start of state to web search and adds billed searches/fetches; cost.nonToken reports the documented fees. Provider/model are fixed by pi-classifier.default (or legacy defaultProvider/defaultModel); this tool cannot override them. API-key authentication is independent of Codex chat login. Only explicitly configured fallback routes may be used after a missing key or HTTP 401/404/429 before any batch has completed; never after uncertainty, refusals, timeouts or network failures. Use /classifier list or status to inspect configuration.";
17
17
 
18
18
  export const CLASSIFY_COMPARE_TOOL_DESCRIPTION =
19
- "Explicitly compare the same typed questions and state using exactly pi-classifier.compare provider/model pairs. Each entry makes potentially billable requests, including multiple requests when choice batching is configured. No fallback, default substitution, provider/model overrides, or default changes. Returns labeled results, duration, usage, estimated USD costs (or unavailable reasons) and safe per-entry failures; cancellation retains completed results and prevents later requests.";
19
+ "Explicitly compare the same classification questions and state using exactly pi-classifier.compare provider/model pairs. Each entry makes potentially billable requests, including multiple requests when choice batching is configured. No fallback, default substitution, provider/model overrides, or default changes. Returns labeled results, duration, usage, estimated USD costs (or unavailable reasons) and safe per-entry failures; cancellation retains completed results and prevents later requests.";
20
20
 
21
21
  export const CLASSIFY_TREE_TOOL_DESCRIPTION =
22
22
  "Classify text, JSON or supported images through a nested classification tree. tree is an inline roots/id/description/children object or a local JSON file inside cwd. Choose among siblings, automatically follow sole children without model calls, and return Level1/Level2/etc under levels with per-step provenance, total providerCalls, reported usage and estimated USD cost. NONE, batching and initial fallback follow configured settings; after a successful decision the route is pinned. no_match, ambiguous and refusal retain only the selected prefix. Automatic steps are structural, not model confirmation; greedy traversal is not a global best-path guarantee. No provider/model override or comparison.";
23
23
 
24
24
  export const CLASSIFIER_BOX_TOOL_DESCRIPTION =
25
- "Render a normalized bounding box on a local image, or crop to it, entirely locally. Use to inspect a box answer from classify. overlay keeps the image and draws a rectangle; crop returns only the clamped region. Returns a PNG plus exact source-pixel box metadata. No provider request, upload, resizing or disk write. A box is a localization hint, not proof that the object exists.";
25
+ "Render a normalized bounding box on a local image, or crop to it, entirely locally. Use to inspect a box value returned by classify_extract. overlay keeps the image and draws a rectangle; crop returns only the clamped region. Returns a PNG plus exact source-pixel box metadata. No provider request, upload, resizing or disk write. A box is a localization hint, not proof that the object exists.";
26
26
 
27
27
  const imageReference = Type.Object(
28
28
  { $image: Type.String({ pattern: "^[a-zA-Z0-9_-]{1,64}$" }) },
@@ -44,35 +44,9 @@ function imageContent(maxLength: number, nonempty = false) {
44
44
  const shortText = imageContent(4096);
45
45
  const instructionContent = imageContent(16384, true);
46
46
 
47
- const charSpan = Type.Tuple([
48
- Type.Integer({ minimum: 0 }),
49
- Type.Integer({ minimum: 0 }),
50
- ]);
51
-
52
47
  // Numeric estimation ranges may be negative or fractional; they are not text offsets.
53
48
  const numericRange = Type.Tuple([Type.Number(), Type.Number()]);
54
49
 
55
- const boxEdges = Type.Object(
56
- {
57
- top: Type.Number(),
58
- bottom: Type.Number(),
59
- left: Type.Number(),
60
- right: Type.Number(),
61
- },
62
- { additionalProperties: false },
63
- );
64
-
65
- const textSpan = Type.Object(
66
- {
67
- start: Type.Integer({ minimum: 0 }),
68
- end: Type.Integer({ minimum: 0 }),
69
- text: Type.String(),
70
- score: Type.Number({ minimum: 0, maximum: 1 }),
71
- searchResult: Type.Optional(Type.Integer({ minimum: 0 })),
72
- },
73
- { additionalProperties: false },
74
- );
75
-
76
50
  const webSearchResult = Type.Object(
77
51
  {
78
52
  title: Type.String(),
@@ -108,45 +82,7 @@ const nonTokenCost = Type.Object(
108
82
  { additionalProperties: false },
109
83
  );
110
84
 
111
- const question = Type.Union([
112
- Type.Object(
113
- {
114
- type: Type.Literal("bool"),
115
- instructions: instructionContent,
116
- criteria: Type.Optional(
117
- Type.Object(
118
- { true: Type.Optional(shortText), false: Type.Optional(shortText) },
119
- { additionalProperties: false },
120
- ),
121
- ),
122
- },
123
- { additionalProperties: false },
124
- ),
125
- Type.Object(
126
- {
127
- type: Type.Literal("choice"),
128
- instructions: instructionContent,
129
- criteria: Type.Record(
130
- Type.String({ minLength: 1, maxLength: 128 }),
131
- shortText,
132
- { minProperties: 1 },
133
- ),
134
- booleanValues: Type.Optional(Type.Boolean()),
135
- },
136
- { additionalProperties: false },
137
- ),
138
- Type.Object(
139
- {
140
- type: Type.Literal("score"),
141
- instructions: instructionContent,
142
- criteria: Type.Array(imageContent(4096, true), {
143
- minItems: 2,
144
- maxItems: 10,
145
- }),
146
- descriptions: Type.Optional(Type.Array(Type.String({ maxLength: 4096 }))),
147
- },
148
- { additionalProperties: false },
149
- ),
85
+ const extractionQuestion = Type.Union([
150
86
  Type.Object(
151
87
  {
152
88
  type: Type.Literal("box"),
@@ -217,6 +153,48 @@ const question = Type.Union([
217
153
  },
218
154
  { additionalProperties: false },
219
155
  ),
156
+ ]);
157
+
158
+ // Classification decisions are the only question family `classify` accepts.
159
+ const classificationQuestion = Type.Union([
160
+ Type.Object(
161
+ {
162
+ type: Type.Literal("bool"),
163
+ instructions: instructionContent,
164
+ criteria: Type.Optional(
165
+ Type.Object(
166
+ { true: Type.Optional(shortText), false: Type.Optional(shortText) },
167
+ { additionalProperties: false },
168
+ ),
169
+ ),
170
+ },
171
+ { additionalProperties: false },
172
+ ),
173
+ Type.Object(
174
+ {
175
+ type: Type.Literal("choice"),
176
+ instructions: instructionContent,
177
+ criteria: Type.Record(
178
+ Type.String({ minLength: 1, maxLength: 128 }),
179
+ shortText,
180
+ { minProperties: 1 },
181
+ ),
182
+ booleanValues: Type.Optional(Type.Boolean()),
183
+ },
184
+ { additionalProperties: false },
185
+ ),
186
+ Type.Object(
187
+ {
188
+ type: Type.Literal("score"),
189
+ instructions: instructionContent,
190
+ criteria: Type.Array(imageContent(4096, true), {
191
+ minItems: 2,
192
+ maxItems: 10,
193
+ }),
194
+ descriptions: Type.Optional(Type.Array(Type.String({ maxLength: 4096 }))),
195
+ },
196
+ { additionalProperties: false },
197
+ ),
220
198
  Type.Object(
221
199
  {
222
200
  type: Type.Literal("multi_choice"),
@@ -237,13 +215,18 @@ export const classifyParameters = Type.Object(
237
215
  ],
238
216
  {
239
217
  description:
240
- "Text or JSON data to classify. Use explicit {$image:id} objects to place named images in state on Jev, OpenAI or Perplexity. Other JSON remains data. All questions refer to this same state.",
218
+ "Text or JSON source material. Use explicit {$image:id} objects to place named images in state on supported routes. Other JSON remains data. All questions refer to this same state.",
241
219
  },
242
220
  ),
243
221
  questions: Type.Record(
244
222
  Type.String({ pattern: "^[a-zA-Z0-9_-]{1,64}$" }),
245
- question,
246
- { minProperties: 1, maxProperties: 1000 },
223
+ classificationQuestion,
224
+ {
225
+ minProperties: 1,
226
+ maxProperties: 1000,
227
+ description:
228
+ "Classification decisions only: bool, choice, multi_choice and score. Extraction reads (text, number, date, spans, box, boxes, locate, estimate, extract) belong to classify_extract and are rejected here.",
229
+ },
247
230
  ),
248
231
  mode: Type.Optional(
249
232
  Type.Literal("web_grounding"),
@@ -351,75 +334,6 @@ export const classifyOutput = Type.Object({
351
334
  Type.Record(Type.String(), Type.Number({ minimum: 0, maximum: 1 })),
352
335
  ),
353
336
  }),
354
- Type.Object({
355
- type: Type.Literal("box"),
356
- box: Type.Object({
357
- top: Type.Number(),
358
- bottom: Type.Number(),
359
- left: Type.Number(),
360
- right: Type.Number(),
361
- }),
362
- confidence: Type.Number({ minimum: 0, maximum: 1 }),
363
- found: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
364
- }),
365
- Type.Object({ type: Type.Literal("locate"), spans: Type.Array(textSpan) }),
366
- Type.Object({
367
- type: Type.Literal("extract"),
368
- spans: Type.Record(Type.String(), Type.Array(textSpan)),
369
- notStated: Type.Record(Type.String(), Type.Number({ minimum: 0, maximum: 1 })),
370
- }),
371
- Type.Object({
372
- type: Type.Literal("text"),
373
- text: Type.String(),
374
- span: Type.Optional(Type.Union([charSpan, Type.Null()])),
375
- found: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
376
- path: Type.Optional(Type.String()),
377
- }),
378
- Type.Object({
379
- type: Type.Literal("number"),
380
- value: Type.Union([Type.Number(), Type.Null()]),
381
- unit: Type.Optional(Type.Union([Type.String(), Type.Null()])),
382
- text: Type.Optional(Type.Union([Type.String(), Type.Null()])),
383
- span: Type.Optional(Type.Union([charSpan, Type.Null()])),
384
- found: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
385
- path: Type.Optional(Type.String()),
386
- }),
387
- Type.Object({
388
- type: Type.Literal("date"),
389
- date: Type.Union([Type.String(), Type.Null()]),
390
- text: Type.Optional(Type.Union([Type.String(), Type.Null()])),
391
- span: Type.Optional(Type.Union([charSpan, Type.Null()])),
392
- found: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
393
- path: Type.Optional(Type.String()),
394
- }),
395
- Type.Object({
396
- type: Type.Literal("spans"),
397
- spans: Type.Array(Type.Object({
398
- text: Type.String(),
399
- span: charSpan,
400
- found: Type.Number({ minimum: 0, maximum: 1 }),
401
- }, { additionalProperties: false })),
402
- count: Type.Integer({ minimum: 0 }),
403
- atLeast: Type.Boolean(),
404
- presence: Type.Array(Type.Number({ minimum: 0, maximum: 1 })),
405
- }),
406
- Type.Object({
407
- type: Type.Literal("boxes"),
408
- boxes: Type.Array(Type.Object({
409
- box: boxEdges,
410
- found: Type.Number({ minimum: 0, maximum: 1 }),
411
- confidence: Type.Number({ minimum: 0, maximum: 1 }),
412
- }, { additionalProperties: false })),
413
- count: Type.Integer({ minimum: 0 }),
414
- atLeast: Type.Boolean(),
415
- presence: Type.Array(Type.Number({ minimum: 0, maximum: 1 })),
416
- }),
417
- Type.Object({
418
- type: Type.Literal("estimate"),
419
- value: Type.Number(),
420
- interval: numericRange,
421
- unit: Type.Optional(Type.Union([Type.String(), Type.Null()])),
422
- }),
423
337
  Type.Object({
424
338
  type: Type.Literal("multi_choice"),
425
339
  choices: Type.Array(Type.String()),
@@ -652,7 +566,7 @@ export const boxOutput = Type.Object({
652
566
 
653
567
  export const CLASSIFY_EXTRACT_TOOL = "classify_extract";
654
568
  export const CLASSIFY_EXTRACT_TOOL_DESCRIPTION =
655
- "Extract typed fields with Cloudflare Clairic using the configured clairic-api route. fields maps names to provider field specifications such as text, number, date, enum, object, list, estimate and forecast; nested object/list fields are supported. State is text/JSON and optional images or embedded PDF paths are sent to the provider. Returns typed values with optional grounding metadata plus reported token usage and estimated USD cost. Rendering is provider-owned; truncated reports incomplete generated fields. The tool cannot override the provider or model.";
569
+ "Read values out of source material; this tool does not make classification decisions. Use fields for Clairic-shaped field specifications (text, number, date, enum, object, list, estimate, forecast) on clairic-api, openrouter-extractions-api or litellm-extraction-api, or questions for typed extraction reads (text, number, date, spans, box, boxes, locate, estimate and Inception extract) on the configured decision route, including direct liquid-api d1.2 and d1.2-ultra. Supply exactly one of fields or questions. State is text/JSON plus optional images; field mode also accepts PDF documents. Question answers return {type, value, ...metadata} such as span, found, path and confidence. Returns reported token usage and estimated USD cost; truncated reports incomplete generated field output. The tool cannot override the provider or model.";
656
570
 
657
571
  // The model-facing JSON schema avoids $ref: validation of nested fields is runtime-owned.
658
572
  const extractionFieldDefinition = Type.Object(
@@ -729,10 +643,28 @@ const extractionFieldDefinition = Type.Object(
729
643
  export const classifyExtractParameters = Type.Object(
730
644
  {
731
645
  state: Type.Optional(classifyParameters.properties.state),
732
- fields: Type.Record(
733
- Type.String({ pattern: "^[A-Za-z_][A-Za-z0-9_.-]{0,63}$" }),
734
- extractionFieldDefinition,
735
- { minProperties: 1 },
646
+ fields: Type.Optional(
647
+ Type.Record(
648
+ Type.String({ pattern: "^[A-Za-z_][A-Za-z0-9_.-]{0,63}$" }),
649
+ extractionFieldDefinition,
650
+ {
651
+ minProperties: 1,
652
+ description:
653
+ "Field specifications for clairic-api, openrouter-extractions-api or litellm-extraction-api. Supply exactly one of fields or questions.",
654
+ },
655
+ ),
656
+ ),
657
+ questions: Type.Optional(
658
+ Type.Record(
659
+ Type.String({ pattern: "^[a-zA-Z0-9_-]{1,64}$" }),
660
+ extractionQuestion,
661
+ {
662
+ minProperties: 1,
663
+ maxProperties: 1000,
664
+ description:
665
+ "Typed extraction reads on the configured decision route: text, number, date, spans, box, boxes, locate, estimate and Inception extract. Supply exactly one of fields or questions.",
666
+ },
667
+ ),
736
668
  ),
737
669
  images: Type.Optional(
738
670
  Type.Array(
@@ -740,18 +672,39 @@ export const classifyExtractParameters = Type.Object(
740
672
  Type.String({ minLength: 1, maxLength: 4096 }),
741
673
  Type.Object(
742
674
  {
675
+ id: Type.String({ pattern: "^[a-zA-Z0-9_-]{1,64}$" }),
743
676
  path: Type.String({ minLength: 1, maxLength: 4096 }),
744
- rotation: Type.Optional(Type.Union([
745
- Type.Literal(0), Type.Literal(90), Type.Literal(180), Type.Literal(270),
746
- ])),
677
+ },
678
+ { additionalProperties: false },
679
+ ),
680
+ Type.Object(
681
+ {
682
+ id: Type.String({ pattern: "^[a-zA-Z0-9_-]{1,64}$" }),
683
+ url: Type.String({ minLength: 1, maxLength: 4096 }),
684
+ },
685
+ { additionalProperties: false },
686
+ ),
687
+ Type.Object(
688
+ {
689
+ path: Type.String({ minLength: 1, maxLength: 4096 }),
690
+ rotation: Type.Optional(
691
+ Type.Union([
692
+ Type.Literal(0), Type.Literal(90), Type.Literal(180), Type.Literal(270),
693
+ ]),
694
+ ),
747
695
  },
748
696
  { additionalProperties: false },
749
697
  ),
750
698
  ]),
751
- { maxItems: 4 },
699
+ {
700
+ maxItems: 128,
701
+ description:
702
+ "Field mode: local path strings or {path, rotation}, where rotation is Clairic-only. Question mode: local paths or named {id, path}/{id, url} descriptors referenced with {$image:id}. The selected route enforces its own image limit.",
703
+ },
752
704
  ),
753
705
  ),
754
- documents: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 4096 }), { maxItems: 4 })),
706
+ media: classifyParameters.properties.media,
707
+ documents: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 4096 }), { maxItems: 4, description: "Field mode only: local unencrypted PDF paths inside cwd." })),
755
708
  referenceDate: Type.Optional(Type.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$" })),
756
709
  options: Type.Optional(
757
710
  Type.Object(
@@ -762,6 +715,7 @@ export const classifyExtractParameters = Type.Object(
762
715
  { additionalProperties: false },
763
716
  ),
764
717
  ),
718
+ mode: Type.Optional(Type.Literal("web_grounding")),
765
719
  },
766
720
  { additionalProperties: false },
767
721
  );
@@ -782,4 +736,7 @@ export const classifyExtractOutput = Type.Object({
782
736
  providerCost: classifyOutput.properties.providerCost,
783
737
  requestId: Type.Optional(Type.String()),
784
738
  stateText: Type.Optional(Type.String()),
739
+ citations: classifyOutput.properties.citations,
740
+ webGrounding: classifyOutput.properties.webGrounding,
741
+ attemptedRoutes: classifyOutput.properties.attemptedRoutes,
785
742
  });
package/src/types.ts CHANGED
@@ -13,7 +13,10 @@ export type ApiStyle =
13
13
  | "cloudflare-clairic"
14
14
  | "openrouter-extractions"
15
15
  | "litellm-extraction"
16
- | "microsoft-system-one";
16
+ | "microsoft-system-one"
17
+ | "subq-system-one"
18
+ | "alibaba-system-one"
19
+ | "fireworks-system-one";
17
20
 
18
21
  /** Explicit references are resolved only from the request's named images. */
19
22
  export type ImageReference = { $image: string };
@@ -27,7 +30,8 @@ export type MediaInput = { type: "audio" | "video"; path: string };
27
30
  export type CharSpan = [number, number];
28
31
  export type BoxEdges = { top: number; bottom: number; left: number; right: number };
29
32
 
30
- export type Question =
33
+ /** Classification decisions: the only question types the `classify` tool accepts. */
34
+ export type ClassificationQuestion =
31
35
  | {
32
36
  type: "bool";
33
37
  instructions: QuestionContent;
@@ -35,6 +39,10 @@ export type Question =
35
39
  }
36
40
  | { type: "choice"; instructions: QuestionContent; criteria: Record<string, QuestionContent>; booleanValues?: boolean }
37
41
  | { type: "score"; instructions: QuestionContent; criteria: QuestionContent[]; descriptions?: string[] }
42
+ | { type: "multi_choice"; instructions: QuestionContent; criteria: Record<string, QuestionContent> };
43
+
44
+ /** Extraction reads: accepted by `classify_extract` question mode, never by `classify`. */
45
+ export type ExtractionQuestion =
38
46
  | { type: "extract"; instructions?: QuestionContent; criteria: Record<string, QuestionContent>; source?: string; threshold?: number; snapToWords?: boolean; debug?: boolean }
39
47
  | { type: "box"; instructions: QuestionContent }
40
48
  | { type: "locate"; instructions: QuestionContent }
@@ -43,8 +51,10 @@ export type Question =
43
51
  | { type: "date"; instructions: QuestionContent }
44
52
  | { type: "spans"; instructions: QuestionContent; max?: number }
45
53
  | { type: "boxes"; instructions: QuestionContent; max?: number }
46
- | { type: "estimate"; instructions: QuestionContent; range: CharSpan; step?: number; unit?: string }
47
- | { type: "multi_choice"; instructions: QuestionContent; criteria: Record<string, QuestionContent> };
54
+ | { type: "estimate"; instructions: QuestionContent; range: CharSpan; step?: number; unit?: string };
55
+
56
+ /** Provider adapters accept both families; the two tools enforce the boundary. */
57
+ export type Question = ClassificationQuestion | ExtractionQuestion;
48
58
 
49
59
  export type TextSpan = {
50
60
  start: number;
@@ -145,7 +155,8 @@ export type Answer =
145
155
  | { type: "no_match" }
146
156
  | { type: "ambiguous" };
147
157
 
148
- export interface ClassifyParams {
158
+ /** Shared typed-question request; classification and typed extraction both prepare it identically. */
159
+ export interface DecisionInput {
149
160
  state: string | Record<string, unknown> | unknown[];
150
161
  questions: Record<string, Question>;
151
162
  /** Legacy paths are shared in order. Named images require explicit {$image:id} references. */
@@ -167,6 +178,11 @@ export interface ClassifyParams {
167
178
  };
168
179
  }
169
180
 
181
+ /** The `classify` tool: classification decisions only. */
182
+ export interface ClassifyParams extends Omit<DecisionInput, "questions"> {
183
+ questions: Record<string, ClassificationQuestion>;
184
+ }
185
+
170
186
  export type ClassificationTreeNode = {
171
187
  id: string;
172
188
  description?: string;
@@ -208,6 +224,8 @@ export interface ModelDefinition {
208
224
  name?: string;
209
225
  input?: ("text" | "image" | "audio" | "video")[];
210
226
  box?: boolean;
227
+ /** ISO date after which the provider stops serving this model; the route stays selectable until then. */
228
+ shutdown?: string;
211
229
  }
212
230
 
213
231
  /** USD per million tokens. Cache counts, when reported, are part of input tokens. */
@@ -449,13 +467,28 @@ export type ExtractionField = {
449
467
  interval?: "step" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
450
468
  };
451
469
 
470
+ /** The `classify_extract` tool: field specs or typed extraction questions, never both. */
452
471
  export type ExtractParams = {
453
472
  state?: ClassifyParams["state"];
454
- fields: Record<string, ExtractionField>;
455
- images?: (string | { path: string; rotation?: 0 | 90 | 180 | 270 })[];
473
+ /** Clairic-shaped field extraction on clairic-api, openrouter-extractions-api or litellm-extraction-api. */
474
+ fields?: Record<string, ExtractionField>;
475
+ /** Typed extraction questions on decision routes, including direct liquid-api. */
476
+ questions?: Record<string, ExtractionQuestion>;
477
+ images?: (
478
+ | string
479
+ | { id: string; path: string }
480
+ | { id: string; url: string }
481
+ | { path: string; rotation?: 0 | 90 | 180 | 270 }
482
+ )[];
483
+ /** Audio/video inputs for extraction question routes that document them. */
484
+ media?: MediaInput[];
485
+ /** PDF documents; field mode only. */
456
486
  documents?: string[];
487
+ /** Field mode only. */
457
488
  referenceDate?: string;
458
489
  options?: { includeQuantiles?: boolean; returnStateText?: boolean };
490
+ /** Extraction question mode: explicit Perplexity web grounding for locate reads. */
491
+ mode?: "web_grounding";
459
492
  };
460
493
 
461
494
  export type JsonLike =
@@ -476,10 +509,16 @@ export type ExtractResult = {
476
509
  provider: string;
477
510
  model: string;
478
511
  answers: Record<string, ExtractionAnswer>;
512
+ /** True only for generated field output; typed extraction questions never generate text. */
479
513
  truncated: boolean;
480
514
  usage?: NonNullable<ClassifierResult["usage"]>;
481
515
  cost: ClassifierCost;
482
516
  providerCost?: ProviderCost;
483
517
  requestId?: string;
484
518
  stateText?: string;
519
+ /** Request-wide citations from grounded extraction question routes. */
520
+ citations?: DecisionCitation[];
521
+ /** Web evidence for locate answers; each span's searchResult indexes searchResults. */
522
+ webGrounding?: NonNullable<ClassifierResult["webGrounding"]>;
523
+ attemptedRoutes?: ClassifierRoute[];
485
524
  };