@mistralai/mistralai 1.9.17 → 1.9.19
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/jsr.json +1 -1
- package/lib/config.d.ts +2 -2
- package/lib/config.js +2 -2
- package/models/components/apiendpoint.d.ts +5 -0
- package/models/components/apiendpoint.d.ts.map +1 -1
- package/models/components/apiendpoint.js +5 -0
- package/models/components/apiendpoint.js.map +1 -1
- package/models/components/embeddingrequest.d.ts +3 -0
- package/models/components/embeddingrequest.d.ts.map +1 -1
- package/models/components/embeddingrequest.js +5 -0
- package/models/components/embeddingrequest.js.map +1 -1
- package/models/components/encodingformat.d.ts +28 -0
- package/models/components/encodingformat.d.ts.map +1 -0
- package/models/components/encodingformat.js +50 -0
- package/models/components/encodingformat.js.map +1 -0
- package/models/components/index.d.ts +2 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +2 -0
- package/models/components/index.js.map +1 -1
- package/models/components/messageinputcontentchunks.d.ts +3 -2
- package/models/components/messageinputcontentchunks.d.ts.map +1 -1
- package/models/components/messageinputcontentchunks.js +3 -0
- package/models/components/messageinputcontentchunks.js.map +1 -1
- package/models/components/systemmessage.d.ts +5 -5
- package/models/components/systemmessage.d.ts.map +1 -1
- package/models/components/systemmessage.js +11 -5
- package/models/components/systemmessage.js.map +1 -1
- package/models/components/systemmessagecontentchunks.d.ts +35 -0
- package/models/components/systemmessagecontentchunks.d.ts.map +1 -0
- package/models/components/systemmessagecontentchunks.js +67 -0
- package/models/components/systemmessagecontentchunks.js.map +1 -0
- package/package.json +1 -1
- package/packages/mistralai-azure/jsr.json +1 -1
- package/packages/mistralai-azure/package-lock.json +2 -2
- package/packages/mistralai-azure/package.json +1 -1
- package/packages/mistralai-azure/src/funcs/ocrProcess.ts +160 -0
- package/packages/mistralai-azure/src/lib/config.ts +3 -3
- package/packages/mistralai-azure/src/models/components/chatcompletionrequest.ts +14 -0
- package/packages/mistralai-azure/src/models/components/chatcompletionresponse.ts +8 -8
- package/packages/mistralai-azure/src/models/components/chatcompletionstreamrequest.ts +14 -0
- package/packages/mistralai-azure/src/models/components/documenturlchunk.ts +115 -0
- package/packages/mistralai-azure/src/models/components/filechunk.ts +75 -0
- package/packages/mistralai-azure/src/models/components/index.ts +9 -0
- package/packages/mistralai-azure/src/models/components/mistralpromptmode.ts +47 -0
- package/packages/mistralai-azure/src/models/components/ocrimageobject.ts +126 -0
- package/packages/mistralai-azure/src/models/components/ocrpagedimensions.ts +83 -0
- package/packages/mistralai-azure/src/models/components/ocrpageobject.ts +98 -0
- package/packages/mistralai-azure/src/models/components/ocrrequest.ts +229 -0
- package/packages/mistralai-azure/src/models/components/ocrresponse.ts +106 -0
- package/packages/mistralai-azure/src/models/components/ocrusageinfo.ts +83 -0
- package/packages/mistralai-azure/src/models/components/usageinfo.ts +37 -17
- package/packages/mistralai-azure/src/sdk/ocr.ts +24 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/apiendpoint.ts +5 -0
- package/src/models/components/embeddingrequest.ts +11 -0
- package/src/models/components/encodingformat.ts +33 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/components/messageinputcontentchunks.ts +10 -0
- package/src/models/components/systemmessage.ts +21 -13
- package/src/models/components/systemmessagecontentchunks.ts +92 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export type OCRImageObject = {
|
|
12
|
+
/**
|
|
13
|
+
* Image ID for extracted image in a page
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* X coordinate of top-left corner of the extracted image
|
|
18
|
+
*/
|
|
19
|
+
topLeftX: number | null;
|
|
20
|
+
/**
|
|
21
|
+
* Y coordinate of top-left corner of the extracted image
|
|
22
|
+
*/
|
|
23
|
+
topLeftY: number | null;
|
|
24
|
+
/**
|
|
25
|
+
* X coordinate of bottom-right corner of the extracted image
|
|
26
|
+
*/
|
|
27
|
+
bottomRightX: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Y coordinate of bottom-right corner of the extracted image
|
|
30
|
+
*/
|
|
31
|
+
bottomRightY: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Base64 string of the extracted image
|
|
34
|
+
*/
|
|
35
|
+
imageBase64?: string | null | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Annotation of the extracted image in json str
|
|
38
|
+
*/
|
|
39
|
+
imageAnnotation?: string | null | undefined;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** @internal */
|
|
43
|
+
export const OCRImageObject$inboundSchema: z.ZodType<
|
|
44
|
+
OCRImageObject,
|
|
45
|
+
z.ZodTypeDef,
|
|
46
|
+
unknown
|
|
47
|
+
> = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
top_left_x: z.nullable(z.number().int()),
|
|
50
|
+
top_left_y: z.nullable(z.number().int()),
|
|
51
|
+
bottom_right_x: z.nullable(z.number().int()),
|
|
52
|
+
bottom_right_y: z.nullable(z.number().int()),
|
|
53
|
+
image_base64: z.nullable(z.string()).optional(),
|
|
54
|
+
image_annotation: z.nullable(z.string()).optional(),
|
|
55
|
+
}).transform((v) => {
|
|
56
|
+
return remap$(v, {
|
|
57
|
+
"top_left_x": "topLeftX",
|
|
58
|
+
"top_left_y": "topLeftY",
|
|
59
|
+
"bottom_right_x": "bottomRightX",
|
|
60
|
+
"bottom_right_y": "bottomRightY",
|
|
61
|
+
"image_base64": "imageBase64",
|
|
62
|
+
"image_annotation": "imageAnnotation",
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/** @internal */
|
|
67
|
+
export type OCRImageObject$Outbound = {
|
|
68
|
+
id: string;
|
|
69
|
+
top_left_x: number | null;
|
|
70
|
+
top_left_y: number | null;
|
|
71
|
+
bottom_right_x: number | null;
|
|
72
|
+
bottom_right_y: number | null;
|
|
73
|
+
image_base64?: string | null | undefined;
|
|
74
|
+
image_annotation?: string | null | undefined;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** @internal */
|
|
78
|
+
export const OCRImageObject$outboundSchema: z.ZodType<
|
|
79
|
+
OCRImageObject$Outbound,
|
|
80
|
+
z.ZodTypeDef,
|
|
81
|
+
OCRImageObject
|
|
82
|
+
> = z.object({
|
|
83
|
+
id: z.string(),
|
|
84
|
+
topLeftX: z.nullable(z.number().int()),
|
|
85
|
+
topLeftY: z.nullable(z.number().int()),
|
|
86
|
+
bottomRightX: z.nullable(z.number().int()),
|
|
87
|
+
bottomRightY: z.nullable(z.number().int()),
|
|
88
|
+
imageBase64: z.nullable(z.string()).optional(),
|
|
89
|
+
imageAnnotation: z.nullable(z.string()).optional(),
|
|
90
|
+
}).transform((v) => {
|
|
91
|
+
return remap$(v, {
|
|
92
|
+
topLeftX: "top_left_x",
|
|
93
|
+
topLeftY: "top_left_y",
|
|
94
|
+
bottomRightX: "bottom_right_x",
|
|
95
|
+
bottomRightY: "bottom_right_y",
|
|
96
|
+
imageBase64: "image_base64",
|
|
97
|
+
imageAnnotation: "image_annotation",
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
104
|
+
*/
|
|
105
|
+
export namespace OCRImageObject$ {
|
|
106
|
+
/** @deprecated use `OCRImageObject$inboundSchema` instead. */
|
|
107
|
+
export const inboundSchema = OCRImageObject$inboundSchema;
|
|
108
|
+
/** @deprecated use `OCRImageObject$outboundSchema` instead. */
|
|
109
|
+
export const outboundSchema = OCRImageObject$outboundSchema;
|
|
110
|
+
/** @deprecated use `OCRImageObject$Outbound` instead. */
|
|
111
|
+
export type Outbound = OCRImageObject$Outbound;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function ocrImageObjectToJSON(ocrImageObject: OCRImageObject): string {
|
|
115
|
+
return JSON.stringify(OCRImageObject$outboundSchema.parse(ocrImageObject));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function ocrImageObjectFromJSON(
|
|
119
|
+
jsonString: string,
|
|
120
|
+
): SafeParseResult<OCRImageObject, SDKValidationError> {
|
|
121
|
+
return safeParse(
|
|
122
|
+
jsonString,
|
|
123
|
+
(x) => OCRImageObject$inboundSchema.parse(JSON.parse(x)),
|
|
124
|
+
`Failed to parse 'OCRImageObject' from JSON`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type OCRPageDimensions = {
|
|
11
|
+
/**
|
|
12
|
+
* Dots per inch of the page-image
|
|
13
|
+
*/
|
|
14
|
+
dpi: number;
|
|
15
|
+
/**
|
|
16
|
+
* Height of the image in pixels
|
|
17
|
+
*/
|
|
18
|
+
height: number;
|
|
19
|
+
/**
|
|
20
|
+
* Width of the image in pixels
|
|
21
|
+
*/
|
|
22
|
+
width: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
export const OCRPageDimensions$inboundSchema: z.ZodType<
|
|
27
|
+
OCRPageDimensions,
|
|
28
|
+
z.ZodTypeDef,
|
|
29
|
+
unknown
|
|
30
|
+
> = z.object({
|
|
31
|
+
dpi: z.number().int(),
|
|
32
|
+
height: z.number().int(),
|
|
33
|
+
width: z.number().int(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export type OCRPageDimensions$Outbound = {
|
|
38
|
+
dpi: number;
|
|
39
|
+
height: number;
|
|
40
|
+
width: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @internal */
|
|
44
|
+
export const OCRPageDimensions$outboundSchema: z.ZodType<
|
|
45
|
+
OCRPageDimensions$Outbound,
|
|
46
|
+
z.ZodTypeDef,
|
|
47
|
+
OCRPageDimensions
|
|
48
|
+
> = z.object({
|
|
49
|
+
dpi: z.number().int(),
|
|
50
|
+
height: z.number().int(),
|
|
51
|
+
width: z.number().int(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
57
|
+
*/
|
|
58
|
+
export namespace OCRPageDimensions$ {
|
|
59
|
+
/** @deprecated use `OCRPageDimensions$inboundSchema` instead. */
|
|
60
|
+
export const inboundSchema = OCRPageDimensions$inboundSchema;
|
|
61
|
+
/** @deprecated use `OCRPageDimensions$outboundSchema` instead. */
|
|
62
|
+
export const outboundSchema = OCRPageDimensions$outboundSchema;
|
|
63
|
+
/** @deprecated use `OCRPageDimensions$Outbound` instead. */
|
|
64
|
+
export type Outbound = OCRPageDimensions$Outbound;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function ocrPageDimensionsToJSON(
|
|
68
|
+
ocrPageDimensions: OCRPageDimensions,
|
|
69
|
+
): string {
|
|
70
|
+
return JSON.stringify(
|
|
71
|
+
OCRPageDimensions$outboundSchema.parse(ocrPageDimensions),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function ocrPageDimensionsFromJSON(
|
|
76
|
+
jsonString: string,
|
|
77
|
+
): SafeParseResult<OCRPageDimensions, SDKValidationError> {
|
|
78
|
+
return safeParse(
|
|
79
|
+
jsonString,
|
|
80
|
+
(x) => OCRPageDimensions$inboundSchema.parse(JSON.parse(x)),
|
|
81
|
+
`Failed to parse 'OCRPageDimensions' from JSON`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
OCRImageObject,
|
|
11
|
+
OCRImageObject$inboundSchema,
|
|
12
|
+
OCRImageObject$Outbound,
|
|
13
|
+
OCRImageObject$outboundSchema,
|
|
14
|
+
} from "./ocrimageobject.js";
|
|
15
|
+
import {
|
|
16
|
+
OCRPageDimensions,
|
|
17
|
+
OCRPageDimensions$inboundSchema,
|
|
18
|
+
OCRPageDimensions$Outbound,
|
|
19
|
+
OCRPageDimensions$outboundSchema,
|
|
20
|
+
} from "./ocrpagedimensions.js";
|
|
21
|
+
|
|
22
|
+
export type OCRPageObject = {
|
|
23
|
+
/**
|
|
24
|
+
* The page index in a pdf document starting from 0
|
|
25
|
+
*/
|
|
26
|
+
index: number;
|
|
27
|
+
/**
|
|
28
|
+
* The markdown string response of the page
|
|
29
|
+
*/
|
|
30
|
+
markdown: string;
|
|
31
|
+
/**
|
|
32
|
+
* List of all extracted images in the page
|
|
33
|
+
*/
|
|
34
|
+
images: Array<OCRImageObject>;
|
|
35
|
+
/**
|
|
36
|
+
* The dimensions of the PDF Page's screenshot image
|
|
37
|
+
*/
|
|
38
|
+
dimensions: OCRPageDimensions | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** @internal */
|
|
42
|
+
export const OCRPageObject$inboundSchema: z.ZodType<
|
|
43
|
+
OCRPageObject,
|
|
44
|
+
z.ZodTypeDef,
|
|
45
|
+
unknown
|
|
46
|
+
> = z.object({
|
|
47
|
+
index: z.number().int(),
|
|
48
|
+
markdown: z.string(),
|
|
49
|
+
images: z.array(OCRImageObject$inboundSchema),
|
|
50
|
+
dimensions: z.nullable(OCRPageDimensions$inboundSchema),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/** @internal */
|
|
54
|
+
export type OCRPageObject$Outbound = {
|
|
55
|
+
index: number;
|
|
56
|
+
markdown: string;
|
|
57
|
+
images: Array<OCRImageObject$Outbound>;
|
|
58
|
+
dimensions: OCRPageDimensions$Outbound | null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** @internal */
|
|
62
|
+
export const OCRPageObject$outboundSchema: z.ZodType<
|
|
63
|
+
OCRPageObject$Outbound,
|
|
64
|
+
z.ZodTypeDef,
|
|
65
|
+
OCRPageObject
|
|
66
|
+
> = z.object({
|
|
67
|
+
index: z.number().int(),
|
|
68
|
+
markdown: z.string(),
|
|
69
|
+
images: z.array(OCRImageObject$outboundSchema),
|
|
70
|
+
dimensions: z.nullable(OCRPageDimensions$outboundSchema),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @internal
|
|
75
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
76
|
+
*/
|
|
77
|
+
export namespace OCRPageObject$ {
|
|
78
|
+
/** @deprecated use `OCRPageObject$inboundSchema` instead. */
|
|
79
|
+
export const inboundSchema = OCRPageObject$inboundSchema;
|
|
80
|
+
/** @deprecated use `OCRPageObject$outboundSchema` instead. */
|
|
81
|
+
export const outboundSchema = OCRPageObject$outboundSchema;
|
|
82
|
+
/** @deprecated use `OCRPageObject$Outbound` instead. */
|
|
83
|
+
export type Outbound = OCRPageObject$Outbound;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function ocrPageObjectToJSON(ocrPageObject: OCRPageObject): string {
|
|
87
|
+
return JSON.stringify(OCRPageObject$outboundSchema.parse(ocrPageObject));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function ocrPageObjectFromJSON(
|
|
91
|
+
jsonString: string,
|
|
92
|
+
): SafeParseResult<OCRPageObject, SDKValidationError> {
|
|
93
|
+
return safeParse(
|
|
94
|
+
jsonString,
|
|
95
|
+
(x) => OCRPageObject$inboundSchema.parse(JSON.parse(x)),
|
|
96
|
+
`Failed to parse 'OCRPageObject' from JSON`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
DocumentURLChunk,
|
|
12
|
+
DocumentURLChunk$inboundSchema,
|
|
13
|
+
DocumentURLChunk$Outbound,
|
|
14
|
+
DocumentURLChunk$outboundSchema,
|
|
15
|
+
} from "./documenturlchunk.js";
|
|
16
|
+
import {
|
|
17
|
+
FileChunk,
|
|
18
|
+
FileChunk$inboundSchema,
|
|
19
|
+
FileChunk$Outbound,
|
|
20
|
+
FileChunk$outboundSchema,
|
|
21
|
+
} from "./filechunk.js";
|
|
22
|
+
import {
|
|
23
|
+
ImageURLChunk,
|
|
24
|
+
ImageURLChunk$inboundSchema,
|
|
25
|
+
ImageURLChunk$Outbound,
|
|
26
|
+
ImageURLChunk$outboundSchema,
|
|
27
|
+
} from "./imageurlchunk.js";
|
|
28
|
+
import {
|
|
29
|
+
ResponseFormat,
|
|
30
|
+
ResponseFormat$inboundSchema,
|
|
31
|
+
ResponseFormat$Outbound,
|
|
32
|
+
ResponseFormat$outboundSchema,
|
|
33
|
+
} from "./responseformat.js";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Document to run OCR on
|
|
37
|
+
*/
|
|
38
|
+
export type Document = FileChunk | ImageURLChunk | DocumentURLChunk;
|
|
39
|
+
|
|
40
|
+
export type OCRRequest = {
|
|
41
|
+
model: string | null;
|
|
42
|
+
id?: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Document to run OCR on
|
|
45
|
+
*/
|
|
46
|
+
document: FileChunk | ImageURLChunk | DocumentURLChunk;
|
|
47
|
+
/**
|
|
48
|
+
* Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0
|
|
49
|
+
*/
|
|
50
|
+
pages?: Array<number> | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Include image URLs in response
|
|
53
|
+
*/
|
|
54
|
+
includeImageBase64?: boolean | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Max images to extract
|
|
57
|
+
*/
|
|
58
|
+
imageLimit?: number | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Minimum height and width of image to extract
|
|
61
|
+
*/
|
|
62
|
+
imageMinSize?: number | null | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
|
|
65
|
+
*/
|
|
66
|
+
bboxAnnotationFormat?: ResponseFormat | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
|
|
69
|
+
*/
|
|
70
|
+
documentAnnotationFormat?: ResponseFormat | null | undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** @internal */
|
|
74
|
+
export const Document$inboundSchema: z.ZodType<
|
|
75
|
+
Document,
|
|
76
|
+
z.ZodTypeDef,
|
|
77
|
+
unknown
|
|
78
|
+
> = z.union([
|
|
79
|
+
FileChunk$inboundSchema,
|
|
80
|
+
ImageURLChunk$inboundSchema,
|
|
81
|
+
DocumentURLChunk$inboundSchema,
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
/** @internal */
|
|
85
|
+
export type Document$Outbound =
|
|
86
|
+
| FileChunk$Outbound
|
|
87
|
+
| ImageURLChunk$Outbound
|
|
88
|
+
| DocumentURLChunk$Outbound;
|
|
89
|
+
|
|
90
|
+
/** @internal */
|
|
91
|
+
export const Document$outboundSchema: z.ZodType<
|
|
92
|
+
Document$Outbound,
|
|
93
|
+
z.ZodTypeDef,
|
|
94
|
+
Document
|
|
95
|
+
> = z.union([
|
|
96
|
+
FileChunk$outboundSchema,
|
|
97
|
+
ImageURLChunk$outboundSchema,
|
|
98
|
+
DocumentURLChunk$outboundSchema,
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
104
|
+
*/
|
|
105
|
+
export namespace Document$ {
|
|
106
|
+
/** @deprecated use `Document$inboundSchema` instead. */
|
|
107
|
+
export const inboundSchema = Document$inboundSchema;
|
|
108
|
+
/** @deprecated use `Document$outboundSchema` instead. */
|
|
109
|
+
export const outboundSchema = Document$outboundSchema;
|
|
110
|
+
/** @deprecated use `Document$Outbound` instead. */
|
|
111
|
+
export type Outbound = Document$Outbound;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function documentToJSON(document: Document): string {
|
|
115
|
+
return JSON.stringify(Document$outboundSchema.parse(document));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function documentFromJSON(
|
|
119
|
+
jsonString: string,
|
|
120
|
+
): SafeParseResult<Document, SDKValidationError> {
|
|
121
|
+
return safeParse(
|
|
122
|
+
jsonString,
|
|
123
|
+
(x) => Document$inboundSchema.parse(JSON.parse(x)),
|
|
124
|
+
`Failed to parse 'Document' from JSON`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @internal */
|
|
129
|
+
export const OCRRequest$inboundSchema: z.ZodType<
|
|
130
|
+
OCRRequest,
|
|
131
|
+
z.ZodTypeDef,
|
|
132
|
+
unknown
|
|
133
|
+
> = z.object({
|
|
134
|
+
model: z.nullable(z.string()),
|
|
135
|
+
id: z.string().optional(),
|
|
136
|
+
document: z.union([
|
|
137
|
+
FileChunk$inboundSchema,
|
|
138
|
+
ImageURLChunk$inboundSchema,
|
|
139
|
+
DocumentURLChunk$inboundSchema,
|
|
140
|
+
]),
|
|
141
|
+
pages: z.nullable(z.array(z.number().int())).optional(),
|
|
142
|
+
include_image_base64: z.nullable(z.boolean()).optional(),
|
|
143
|
+
image_limit: z.nullable(z.number().int()).optional(),
|
|
144
|
+
image_min_size: z.nullable(z.number().int()).optional(),
|
|
145
|
+
bbox_annotation_format: z.nullable(ResponseFormat$inboundSchema).optional(),
|
|
146
|
+
document_annotation_format: z.nullable(ResponseFormat$inboundSchema)
|
|
147
|
+
.optional(),
|
|
148
|
+
}).transform((v) => {
|
|
149
|
+
return remap$(v, {
|
|
150
|
+
"include_image_base64": "includeImageBase64",
|
|
151
|
+
"image_limit": "imageLimit",
|
|
152
|
+
"image_min_size": "imageMinSize",
|
|
153
|
+
"bbox_annotation_format": "bboxAnnotationFormat",
|
|
154
|
+
"document_annotation_format": "documentAnnotationFormat",
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
/** @internal */
|
|
159
|
+
export type OCRRequest$Outbound = {
|
|
160
|
+
model: string | null;
|
|
161
|
+
id?: string | undefined;
|
|
162
|
+
document:
|
|
163
|
+
| FileChunk$Outbound
|
|
164
|
+
| ImageURLChunk$Outbound
|
|
165
|
+
| DocumentURLChunk$Outbound;
|
|
166
|
+
pages?: Array<number> | null | undefined;
|
|
167
|
+
include_image_base64?: boolean | null | undefined;
|
|
168
|
+
image_limit?: number | null | undefined;
|
|
169
|
+
image_min_size?: number | null | undefined;
|
|
170
|
+
bbox_annotation_format?: ResponseFormat$Outbound | null | undefined;
|
|
171
|
+
document_annotation_format?: ResponseFormat$Outbound | null | undefined;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/** @internal */
|
|
175
|
+
export const OCRRequest$outboundSchema: z.ZodType<
|
|
176
|
+
OCRRequest$Outbound,
|
|
177
|
+
z.ZodTypeDef,
|
|
178
|
+
OCRRequest
|
|
179
|
+
> = z.object({
|
|
180
|
+
model: z.nullable(z.string()),
|
|
181
|
+
id: z.string().optional(),
|
|
182
|
+
document: z.union([
|
|
183
|
+
FileChunk$outboundSchema,
|
|
184
|
+
ImageURLChunk$outboundSchema,
|
|
185
|
+
DocumentURLChunk$outboundSchema,
|
|
186
|
+
]),
|
|
187
|
+
pages: z.nullable(z.array(z.number().int())).optional(),
|
|
188
|
+
includeImageBase64: z.nullable(z.boolean()).optional(),
|
|
189
|
+
imageLimit: z.nullable(z.number().int()).optional(),
|
|
190
|
+
imageMinSize: z.nullable(z.number().int()).optional(),
|
|
191
|
+
bboxAnnotationFormat: z.nullable(ResponseFormat$outboundSchema).optional(),
|
|
192
|
+
documentAnnotationFormat: z.nullable(ResponseFormat$outboundSchema)
|
|
193
|
+
.optional(),
|
|
194
|
+
}).transform((v) => {
|
|
195
|
+
return remap$(v, {
|
|
196
|
+
includeImageBase64: "include_image_base64",
|
|
197
|
+
imageLimit: "image_limit",
|
|
198
|
+
imageMinSize: "image_min_size",
|
|
199
|
+
bboxAnnotationFormat: "bbox_annotation_format",
|
|
200
|
+
documentAnnotationFormat: "document_annotation_format",
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @internal
|
|
206
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
207
|
+
*/
|
|
208
|
+
export namespace OCRRequest$ {
|
|
209
|
+
/** @deprecated use `OCRRequest$inboundSchema` instead. */
|
|
210
|
+
export const inboundSchema = OCRRequest$inboundSchema;
|
|
211
|
+
/** @deprecated use `OCRRequest$outboundSchema` instead. */
|
|
212
|
+
export const outboundSchema = OCRRequest$outboundSchema;
|
|
213
|
+
/** @deprecated use `OCRRequest$Outbound` instead. */
|
|
214
|
+
export type Outbound = OCRRequest$Outbound;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function ocrRequestToJSON(ocrRequest: OCRRequest): string {
|
|
218
|
+
return JSON.stringify(OCRRequest$outboundSchema.parse(ocrRequest));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function ocrRequestFromJSON(
|
|
222
|
+
jsonString: string,
|
|
223
|
+
): SafeParseResult<OCRRequest, SDKValidationError> {
|
|
224
|
+
return safeParse(
|
|
225
|
+
jsonString,
|
|
226
|
+
(x) => OCRRequest$inboundSchema.parse(JSON.parse(x)),
|
|
227
|
+
`Failed to parse 'OCRRequest' from JSON`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
OCRPageObject,
|
|
12
|
+
OCRPageObject$inboundSchema,
|
|
13
|
+
OCRPageObject$Outbound,
|
|
14
|
+
OCRPageObject$outboundSchema,
|
|
15
|
+
} from "./ocrpageobject.js";
|
|
16
|
+
import {
|
|
17
|
+
OCRUsageInfo,
|
|
18
|
+
OCRUsageInfo$inboundSchema,
|
|
19
|
+
OCRUsageInfo$Outbound,
|
|
20
|
+
OCRUsageInfo$outboundSchema,
|
|
21
|
+
} from "./ocrusageinfo.js";
|
|
22
|
+
|
|
23
|
+
export type OCRResponse = {
|
|
24
|
+
/**
|
|
25
|
+
* List of OCR info for pages.
|
|
26
|
+
*/
|
|
27
|
+
pages: Array<OCRPageObject>;
|
|
28
|
+
/**
|
|
29
|
+
* The model used to generate the OCR.
|
|
30
|
+
*/
|
|
31
|
+
model: string;
|
|
32
|
+
/**
|
|
33
|
+
* Formatted response in the request_format if provided in json str
|
|
34
|
+
*/
|
|
35
|
+
documentAnnotation?: string | null | undefined;
|
|
36
|
+
usageInfo: OCRUsageInfo;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** @internal */
|
|
40
|
+
export const OCRResponse$inboundSchema: z.ZodType<
|
|
41
|
+
OCRResponse,
|
|
42
|
+
z.ZodTypeDef,
|
|
43
|
+
unknown
|
|
44
|
+
> = z.object({
|
|
45
|
+
pages: z.array(OCRPageObject$inboundSchema),
|
|
46
|
+
model: z.string(),
|
|
47
|
+
document_annotation: z.nullable(z.string()).optional(),
|
|
48
|
+
usage_info: OCRUsageInfo$inboundSchema,
|
|
49
|
+
}).transform((v) => {
|
|
50
|
+
return remap$(v, {
|
|
51
|
+
"document_annotation": "documentAnnotation",
|
|
52
|
+
"usage_info": "usageInfo",
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/** @internal */
|
|
57
|
+
export type OCRResponse$Outbound = {
|
|
58
|
+
pages: Array<OCRPageObject$Outbound>;
|
|
59
|
+
model: string;
|
|
60
|
+
document_annotation?: string | null | undefined;
|
|
61
|
+
usage_info: OCRUsageInfo$Outbound;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** @internal */
|
|
65
|
+
export const OCRResponse$outboundSchema: z.ZodType<
|
|
66
|
+
OCRResponse$Outbound,
|
|
67
|
+
z.ZodTypeDef,
|
|
68
|
+
OCRResponse
|
|
69
|
+
> = z.object({
|
|
70
|
+
pages: z.array(OCRPageObject$outboundSchema),
|
|
71
|
+
model: z.string(),
|
|
72
|
+
documentAnnotation: z.nullable(z.string()).optional(),
|
|
73
|
+
usageInfo: OCRUsageInfo$outboundSchema,
|
|
74
|
+
}).transform((v) => {
|
|
75
|
+
return remap$(v, {
|
|
76
|
+
documentAnnotation: "document_annotation",
|
|
77
|
+
usageInfo: "usage_info",
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
84
|
+
*/
|
|
85
|
+
export namespace OCRResponse$ {
|
|
86
|
+
/** @deprecated use `OCRResponse$inboundSchema` instead. */
|
|
87
|
+
export const inboundSchema = OCRResponse$inboundSchema;
|
|
88
|
+
/** @deprecated use `OCRResponse$outboundSchema` instead. */
|
|
89
|
+
export const outboundSchema = OCRResponse$outboundSchema;
|
|
90
|
+
/** @deprecated use `OCRResponse$Outbound` instead. */
|
|
91
|
+
export type Outbound = OCRResponse$Outbound;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function ocrResponseToJSON(ocrResponse: OCRResponse): string {
|
|
95
|
+
return JSON.stringify(OCRResponse$outboundSchema.parse(ocrResponse));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function ocrResponseFromJSON(
|
|
99
|
+
jsonString: string,
|
|
100
|
+
): SafeParseResult<OCRResponse, SDKValidationError> {
|
|
101
|
+
return safeParse(
|
|
102
|
+
jsonString,
|
|
103
|
+
(x) => OCRResponse$inboundSchema.parse(JSON.parse(x)),
|
|
104
|
+
`Failed to parse 'OCRResponse' from JSON`,
|
|
105
|
+
);
|
|
106
|
+
}
|