mistralai 1.9.7__py3-none-any.whl → 1.9.10__py3-none-any.whl
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.
- mistralai/_version.py +2 -2
- mistralai/embeddings.py +6 -0
- mistralai/models/__init__.py +11 -0
- mistralai/models/apiendpoint.py +5 -0
- mistralai/models/embeddingrequest.py +5 -1
- mistralai/models/encodingformat.py +7 -0
- mistralai/models/systemmessage.py +7 -3
- mistralai/models/systemmessagecontentchunks.py +21 -0
- {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/METADATA +1 -1
- {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/RECORD +48 -35
- mistralai_azure/_hooks/types.py +7 -0
- mistralai_azure/_version.py +3 -3
- mistralai_azure/basesdk.py +12 -20
- mistralai_azure/chat.py +16 -0
- mistralai_azure/httpclient.py +6 -16
- mistralai_azure/models/__init__.py +298 -103
- mistralai_azure/models/assistantmessage.py +1 -1
- mistralai_azure/models/chatcompletionrequest.py +20 -3
- mistralai_azure/models/chatcompletionresponse.py +6 -6
- mistralai_azure/models/chatcompletionstreamrequest.py +20 -3
- mistralai_azure/models/completionresponsestreamchoice.py +1 -1
- mistralai_azure/models/deltamessage.py +1 -1
- mistralai_azure/models/documenturlchunk.py +62 -0
- mistralai_azure/models/filechunk.py +23 -0
- mistralai_azure/models/imageurl.py +1 -1
- mistralai_azure/models/jsonschema.py +1 -1
- mistralai_azure/models/mistralpromptmode.py +8 -0
- mistralai_azure/models/ocrimageobject.py +89 -0
- mistralai_azure/models/ocrpagedimensions.py +25 -0
- mistralai_azure/models/ocrpageobject.py +64 -0
- mistralai_azure/models/ocrrequest.py +120 -0
- mistralai_azure/models/ocrresponse.py +68 -0
- mistralai_azure/models/ocrusageinfo.py +57 -0
- mistralai_azure/models/responseformat.py +1 -1
- mistralai_azure/models/toolmessage.py +1 -1
- mistralai_azure/models/usageinfo.py +71 -8
- mistralai_azure/models/usermessage.py +1 -1
- mistralai_azure/ocr.py +271 -0
- mistralai_azure/sdk.py +45 -17
- mistralai_azure/sdkconfiguration.py +0 -7
- mistralai_azure/types/basemodel.py +3 -3
- mistralai_azure/utils/__init__.py +130 -45
- mistralai_azure/utils/datetimes.py +23 -0
- mistralai_azure/utils/enums.py +67 -27
- mistralai_azure/utils/forms.py +49 -28
- mistralai_azure/utils/serializers.py +32 -3
- {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/LICENSE +0 -0
- {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/WHEEL +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
5
|
+
from .mistralpromptmode import MistralPromptMode
|
|
5
6
|
from .prediction import Prediction, PredictionTypedDict
|
|
6
7
|
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
7
8
|
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
@@ -17,8 +18,9 @@ from mistralai_azure.types import (
|
|
|
17
18
|
UNSET,
|
|
18
19
|
UNSET_SENTINEL,
|
|
19
20
|
)
|
|
20
|
-
from mistralai_azure.utils import get_discriminator
|
|
21
|
+
from mistralai_azure.utils import get_discriminator, validate_open_enum
|
|
21
22
|
from pydantic import Discriminator, Tag, model_serializer
|
|
23
|
+
from pydantic.functional_validators import PlainValidator
|
|
22
24
|
from typing import List, Optional, Union
|
|
23
25
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
24
26
|
|
|
@@ -91,6 +93,8 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
|
91
93
|
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
92
94
|
prediction: NotRequired[PredictionTypedDict]
|
|
93
95
|
parallel_tool_calls: NotRequired[bool]
|
|
96
|
+
prompt_mode: NotRequired[Nullable[MistralPromptMode]]
|
|
97
|
+
r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
|
|
94
98
|
safe_prompt: NotRequired[bool]
|
|
95
99
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
96
100
|
|
|
@@ -138,6 +142,11 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
138
142
|
|
|
139
143
|
parallel_tool_calls: Optional[bool] = None
|
|
140
144
|
|
|
145
|
+
prompt_mode: Annotated[
|
|
146
|
+
OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))
|
|
147
|
+
] = UNSET
|
|
148
|
+
r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
|
|
149
|
+
|
|
141
150
|
safe_prompt: Optional[bool] = None
|
|
142
151
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
143
152
|
|
|
@@ -159,16 +168,24 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
159
168
|
"n",
|
|
160
169
|
"prediction",
|
|
161
170
|
"parallel_tool_calls",
|
|
171
|
+
"prompt_mode",
|
|
162
172
|
"safe_prompt",
|
|
163
173
|
]
|
|
164
|
-
nullable_fields = [
|
|
174
|
+
nullable_fields = [
|
|
175
|
+
"temperature",
|
|
176
|
+
"max_tokens",
|
|
177
|
+
"random_seed",
|
|
178
|
+
"tools",
|
|
179
|
+
"n",
|
|
180
|
+
"prompt_mode",
|
|
181
|
+
]
|
|
165
182
|
null_default_fields = []
|
|
166
183
|
|
|
167
184
|
serialized = handler(self)
|
|
168
185
|
|
|
169
186
|
m = {}
|
|
170
187
|
|
|
171
|
-
for n, f in self.model_fields.items():
|
|
188
|
+
for n, f in type(self).model_fields.items():
|
|
172
189
|
k = f.alias or n
|
|
173
190
|
val = serialized.get(k)
|
|
174
191
|
serialized.pop(k, None)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
11
|
+
from pydantic import model_serializer
|
|
12
|
+
from typing import Literal, Optional
|
|
13
|
+
from typing_extensions import NotRequired, TypedDict
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
DocumentURLChunkType = Literal["document_url"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DocumentURLChunkTypedDict(TypedDict):
|
|
20
|
+
document_url: str
|
|
21
|
+
document_name: NotRequired[Nullable[str]]
|
|
22
|
+
r"""The filename of the document"""
|
|
23
|
+
type: NotRequired[DocumentURLChunkType]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DocumentURLChunk(BaseModel):
|
|
27
|
+
document_url: str
|
|
28
|
+
|
|
29
|
+
document_name: OptionalNullable[str] = UNSET
|
|
30
|
+
r"""The filename of the document"""
|
|
31
|
+
|
|
32
|
+
type: Optional[DocumentURLChunkType] = "document_url"
|
|
33
|
+
|
|
34
|
+
@model_serializer(mode="wrap")
|
|
35
|
+
def serialize_model(self, handler):
|
|
36
|
+
optional_fields = ["document_name", "type"]
|
|
37
|
+
nullable_fields = ["document_name"]
|
|
38
|
+
null_default_fields = []
|
|
39
|
+
|
|
40
|
+
serialized = handler(self)
|
|
41
|
+
|
|
42
|
+
m = {}
|
|
43
|
+
|
|
44
|
+
for n, f in type(self).model_fields.items():
|
|
45
|
+
k = f.alias or n
|
|
46
|
+
val = serialized.get(k)
|
|
47
|
+
serialized.pop(k, None)
|
|
48
|
+
|
|
49
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
50
|
+
is_set = (
|
|
51
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
52
|
+
or k in null_default_fields
|
|
53
|
+
) # pylint: disable=no-member
|
|
54
|
+
|
|
55
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
56
|
+
m[k] = val
|
|
57
|
+
elif val != UNSET_SENTINEL and (
|
|
58
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
59
|
+
):
|
|
60
|
+
m[k] = val
|
|
61
|
+
|
|
62
|
+
return m
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import BaseModel
|
|
5
|
+
from mistralai_azure.utils import validate_const
|
|
6
|
+
import pydantic
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal, Optional
|
|
9
|
+
from typing_extensions import Annotated, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FileChunkTypedDict(TypedDict):
|
|
13
|
+
file_id: str
|
|
14
|
+
type: Literal["file"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FileChunk(BaseModel):
|
|
18
|
+
file_id: str
|
|
19
|
+
|
|
20
|
+
TYPE: Annotated[
|
|
21
|
+
Annotated[Optional[Literal["file"]], AfterValidator(validate_const("file"))],
|
|
22
|
+
pydantic.Field(alias="type"),
|
|
23
|
+
] = "file"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
MistralPromptMode = Union[Literal["reasoning"], UnrecognizedStr]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
11
|
+
from pydantic import model_serializer
|
|
12
|
+
from typing_extensions import NotRequired, TypedDict
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OCRImageObjectTypedDict(TypedDict):
|
|
16
|
+
id: str
|
|
17
|
+
r"""Image ID for extracted image in a page"""
|
|
18
|
+
top_left_x: Nullable[int]
|
|
19
|
+
r"""X coordinate of top-left corner of the extracted image"""
|
|
20
|
+
top_left_y: Nullable[int]
|
|
21
|
+
r"""Y coordinate of top-left corner of the extracted image"""
|
|
22
|
+
bottom_right_x: Nullable[int]
|
|
23
|
+
r"""X coordinate of bottom-right corner of the extracted image"""
|
|
24
|
+
bottom_right_y: Nullable[int]
|
|
25
|
+
r"""Y coordinate of bottom-right corner of the extracted image"""
|
|
26
|
+
image_base64: NotRequired[Nullable[str]]
|
|
27
|
+
r"""Base64 string of the extracted image"""
|
|
28
|
+
image_annotation: NotRequired[Nullable[str]]
|
|
29
|
+
r"""Annotation of the extracted image in json str"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class OCRImageObject(BaseModel):
|
|
33
|
+
id: str
|
|
34
|
+
r"""Image ID for extracted image in a page"""
|
|
35
|
+
|
|
36
|
+
top_left_x: Nullable[int]
|
|
37
|
+
r"""X coordinate of top-left corner of the extracted image"""
|
|
38
|
+
|
|
39
|
+
top_left_y: Nullable[int]
|
|
40
|
+
r"""Y coordinate of top-left corner of the extracted image"""
|
|
41
|
+
|
|
42
|
+
bottom_right_x: Nullable[int]
|
|
43
|
+
r"""X coordinate of bottom-right corner of the extracted image"""
|
|
44
|
+
|
|
45
|
+
bottom_right_y: Nullable[int]
|
|
46
|
+
r"""Y coordinate of bottom-right corner of the extracted image"""
|
|
47
|
+
|
|
48
|
+
image_base64: OptionalNullable[str] = UNSET
|
|
49
|
+
r"""Base64 string of the extracted image"""
|
|
50
|
+
|
|
51
|
+
image_annotation: OptionalNullable[str] = UNSET
|
|
52
|
+
r"""Annotation of the extracted image in json str"""
|
|
53
|
+
|
|
54
|
+
@model_serializer(mode="wrap")
|
|
55
|
+
def serialize_model(self, handler):
|
|
56
|
+
optional_fields = ["image_base64", "image_annotation"]
|
|
57
|
+
nullable_fields = [
|
|
58
|
+
"top_left_x",
|
|
59
|
+
"top_left_y",
|
|
60
|
+
"bottom_right_x",
|
|
61
|
+
"bottom_right_y",
|
|
62
|
+
"image_base64",
|
|
63
|
+
"image_annotation",
|
|
64
|
+
]
|
|
65
|
+
null_default_fields = []
|
|
66
|
+
|
|
67
|
+
serialized = handler(self)
|
|
68
|
+
|
|
69
|
+
m = {}
|
|
70
|
+
|
|
71
|
+
for n, f in type(self).model_fields.items():
|
|
72
|
+
k = f.alias or n
|
|
73
|
+
val = serialized.get(k)
|
|
74
|
+
serialized.pop(k, None)
|
|
75
|
+
|
|
76
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
77
|
+
is_set = (
|
|
78
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
79
|
+
or k in null_default_fields
|
|
80
|
+
) # pylint: disable=no-member
|
|
81
|
+
|
|
82
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
83
|
+
m[k] = val
|
|
84
|
+
elif val != UNSET_SENTINEL and (
|
|
85
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
86
|
+
):
|
|
87
|
+
m[k] = val
|
|
88
|
+
|
|
89
|
+
return m
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import BaseModel
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OCRPageDimensionsTypedDict(TypedDict):
|
|
9
|
+
dpi: int
|
|
10
|
+
r"""Dots per inch of the page-image"""
|
|
11
|
+
height: int
|
|
12
|
+
r"""Height of the image in pixels"""
|
|
13
|
+
width: int
|
|
14
|
+
r"""Width of the image in pixels"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class OCRPageDimensions(BaseModel):
|
|
18
|
+
dpi: int
|
|
19
|
+
r"""Dots per inch of the page-image"""
|
|
20
|
+
|
|
21
|
+
height: int
|
|
22
|
+
r"""Height of the image in pixels"""
|
|
23
|
+
|
|
24
|
+
width: int
|
|
25
|
+
r"""Width of the image in pixels"""
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
|
|
5
|
+
from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
|
|
6
|
+
from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
7
|
+
from pydantic import model_serializer
|
|
8
|
+
from typing import List
|
|
9
|
+
from typing_extensions import TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class OCRPageObjectTypedDict(TypedDict):
|
|
13
|
+
index: int
|
|
14
|
+
r"""The page index in a pdf document starting from 0"""
|
|
15
|
+
markdown: str
|
|
16
|
+
r"""The markdown string response of the page"""
|
|
17
|
+
images: List[OCRImageObjectTypedDict]
|
|
18
|
+
r"""List of all extracted images in the page"""
|
|
19
|
+
dimensions: Nullable[OCRPageDimensionsTypedDict]
|
|
20
|
+
r"""The dimensions of the PDF Page's screenshot image"""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OCRPageObject(BaseModel):
|
|
24
|
+
index: int
|
|
25
|
+
r"""The page index in a pdf document starting from 0"""
|
|
26
|
+
|
|
27
|
+
markdown: str
|
|
28
|
+
r"""The markdown string response of the page"""
|
|
29
|
+
|
|
30
|
+
images: List[OCRImageObject]
|
|
31
|
+
r"""List of all extracted images in the page"""
|
|
32
|
+
|
|
33
|
+
dimensions: Nullable[OCRPageDimensions]
|
|
34
|
+
r"""The dimensions of the PDF Page's screenshot image"""
|
|
35
|
+
|
|
36
|
+
@model_serializer(mode="wrap")
|
|
37
|
+
def serialize_model(self, handler):
|
|
38
|
+
optional_fields = []
|
|
39
|
+
nullable_fields = ["dimensions"]
|
|
40
|
+
null_default_fields = []
|
|
41
|
+
|
|
42
|
+
serialized = handler(self)
|
|
43
|
+
|
|
44
|
+
m = {}
|
|
45
|
+
|
|
46
|
+
for n, f in type(self).model_fields.items():
|
|
47
|
+
k = f.alias or n
|
|
48
|
+
val = serialized.get(k)
|
|
49
|
+
serialized.pop(k, None)
|
|
50
|
+
|
|
51
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
52
|
+
is_set = (
|
|
53
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
54
|
+
or k in null_default_fields
|
|
55
|
+
) # pylint: disable=no-member
|
|
56
|
+
|
|
57
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
58
|
+
m[k] = val
|
|
59
|
+
elif val != UNSET_SENTINEL and (
|
|
60
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
61
|
+
):
|
|
62
|
+
m[k] = val
|
|
63
|
+
|
|
64
|
+
return m
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
|
|
5
|
+
from .filechunk import FileChunk, FileChunkTypedDict
|
|
6
|
+
from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
|
|
7
|
+
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
8
|
+
from mistralai_azure.types import (
|
|
9
|
+
BaseModel,
|
|
10
|
+
Nullable,
|
|
11
|
+
OptionalNullable,
|
|
12
|
+
UNSET,
|
|
13
|
+
UNSET_SENTINEL,
|
|
14
|
+
)
|
|
15
|
+
from pydantic import model_serializer
|
|
16
|
+
from typing import List, Optional, Union
|
|
17
|
+
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
DocumentTypedDict = TypeAliasType(
|
|
21
|
+
"DocumentTypedDict",
|
|
22
|
+
Union[FileChunkTypedDict, ImageURLChunkTypedDict, DocumentURLChunkTypedDict],
|
|
23
|
+
)
|
|
24
|
+
r"""Document to run OCR on"""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Document = TypeAliasType("Document", Union[FileChunk, ImageURLChunk, DocumentURLChunk])
|
|
28
|
+
r"""Document to run OCR on"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class OCRRequestTypedDict(TypedDict):
|
|
32
|
+
model: Nullable[str]
|
|
33
|
+
document: DocumentTypedDict
|
|
34
|
+
r"""Document to run OCR on"""
|
|
35
|
+
id: NotRequired[str]
|
|
36
|
+
pages: NotRequired[Nullable[List[int]]]
|
|
37
|
+
r"""Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0"""
|
|
38
|
+
include_image_base64: NotRequired[Nullable[bool]]
|
|
39
|
+
r"""Include image URLs in response"""
|
|
40
|
+
image_limit: NotRequired[Nullable[int]]
|
|
41
|
+
r"""Max images to extract"""
|
|
42
|
+
image_min_size: NotRequired[Nullable[int]]
|
|
43
|
+
r"""Minimum height and width of image to extract"""
|
|
44
|
+
bbox_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
45
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
46
|
+
document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
47
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class OCRRequest(BaseModel):
|
|
51
|
+
model: Nullable[str]
|
|
52
|
+
|
|
53
|
+
document: Document
|
|
54
|
+
r"""Document to run OCR on"""
|
|
55
|
+
|
|
56
|
+
id: Optional[str] = None
|
|
57
|
+
|
|
58
|
+
pages: OptionalNullable[List[int]] = UNSET
|
|
59
|
+
r"""Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0"""
|
|
60
|
+
|
|
61
|
+
include_image_base64: OptionalNullable[bool] = UNSET
|
|
62
|
+
r"""Include image URLs in response"""
|
|
63
|
+
|
|
64
|
+
image_limit: OptionalNullable[int] = UNSET
|
|
65
|
+
r"""Max images to extract"""
|
|
66
|
+
|
|
67
|
+
image_min_size: OptionalNullable[int] = UNSET
|
|
68
|
+
r"""Minimum height and width of image to extract"""
|
|
69
|
+
|
|
70
|
+
bbox_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
71
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
72
|
+
|
|
73
|
+
document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
74
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
75
|
+
|
|
76
|
+
@model_serializer(mode="wrap")
|
|
77
|
+
def serialize_model(self, handler):
|
|
78
|
+
optional_fields = [
|
|
79
|
+
"id",
|
|
80
|
+
"pages",
|
|
81
|
+
"include_image_base64",
|
|
82
|
+
"image_limit",
|
|
83
|
+
"image_min_size",
|
|
84
|
+
"bbox_annotation_format",
|
|
85
|
+
"document_annotation_format",
|
|
86
|
+
]
|
|
87
|
+
nullable_fields = [
|
|
88
|
+
"model",
|
|
89
|
+
"pages",
|
|
90
|
+
"include_image_base64",
|
|
91
|
+
"image_limit",
|
|
92
|
+
"image_min_size",
|
|
93
|
+
"bbox_annotation_format",
|
|
94
|
+
"document_annotation_format",
|
|
95
|
+
]
|
|
96
|
+
null_default_fields = []
|
|
97
|
+
|
|
98
|
+
serialized = handler(self)
|
|
99
|
+
|
|
100
|
+
m = {}
|
|
101
|
+
|
|
102
|
+
for n, f in type(self).model_fields.items():
|
|
103
|
+
k = f.alias or n
|
|
104
|
+
val = serialized.get(k)
|
|
105
|
+
serialized.pop(k, None)
|
|
106
|
+
|
|
107
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
108
|
+
is_set = (
|
|
109
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
110
|
+
or k in null_default_fields
|
|
111
|
+
) # pylint: disable=no-member
|
|
112
|
+
|
|
113
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
114
|
+
m[k] = val
|
|
115
|
+
elif val != UNSET_SENTINEL and (
|
|
116
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
117
|
+
):
|
|
118
|
+
m[k] = val
|
|
119
|
+
|
|
120
|
+
return m
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
|
|
5
|
+
from .ocrusageinfo import OCRUsageInfo, OCRUsageInfoTypedDict
|
|
6
|
+
from mistralai_azure.types import (
|
|
7
|
+
BaseModel,
|
|
8
|
+
Nullable,
|
|
9
|
+
OptionalNullable,
|
|
10
|
+
UNSET,
|
|
11
|
+
UNSET_SENTINEL,
|
|
12
|
+
)
|
|
13
|
+
from pydantic import model_serializer
|
|
14
|
+
from typing import List
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class OCRResponseTypedDict(TypedDict):
|
|
19
|
+
pages: List[OCRPageObjectTypedDict]
|
|
20
|
+
r"""List of OCR info for pages."""
|
|
21
|
+
model: str
|
|
22
|
+
r"""The model used to generate the OCR."""
|
|
23
|
+
usage_info: OCRUsageInfoTypedDict
|
|
24
|
+
document_annotation: NotRequired[Nullable[str]]
|
|
25
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class OCRResponse(BaseModel):
|
|
29
|
+
pages: List[OCRPageObject]
|
|
30
|
+
r"""List of OCR info for pages."""
|
|
31
|
+
|
|
32
|
+
model: str
|
|
33
|
+
r"""The model used to generate the OCR."""
|
|
34
|
+
|
|
35
|
+
usage_info: OCRUsageInfo
|
|
36
|
+
|
|
37
|
+
document_annotation: OptionalNullable[str] = UNSET
|
|
38
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
39
|
+
|
|
40
|
+
@model_serializer(mode="wrap")
|
|
41
|
+
def serialize_model(self, handler):
|
|
42
|
+
optional_fields = ["document_annotation"]
|
|
43
|
+
nullable_fields = ["document_annotation"]
|
|
44
|
+
null_default_fields = []
|
|
45
|
+
|
|
46
|
+
serialized = handler(self)
|
|
47
|
+
|
|
48
|
+
m = {}
|
|
49
|
+
|
|
50
|
+
for n, f in type(self).model_fields.items():
|
|
51
|
+
k = f.alias or n
|
|
52
|
+
val = serialized.get(k)
|
|
53
|
+
serialized.pop(k, None)
|
|
54
|
+
|
|
55
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
56
|
+
is_set = (
|
|
57
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
58
|
+
or k in null_default_fields
|
|
59
|
+
) # pylint: disable=no-member
|
|
60
|
+
|
|
61
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
62
|
+
m[k] = val
|
|
63
|
+
elif val != UNSET_SENTINEL and (
|
|
64
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
65
|
+
):
|
|
66
|
+
m[k] = val
|
|
67
|
+
|
|
68
|
+
return m
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai_azure.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
11
|
+
from pydantic import model_serializer
|
|
12
|
+
from typing_extensions import NotRequired, TypedDict
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OCRUsageInfoTypedDict(TypedDict):
|
|
16
|
+
pages_processed: int
|
|
17
|
+
r"""Number of pages processed"""
|
|
18
|
+
doc_size_bytes: NotRequired[Nullable[int]]
|
|
19
|
+
r"""Document size in bytes"""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class OCRUsageInfo(BaseModel):
|
|
23
|
+
pages_processed: int
|
|
24
|
+
r"""Number of pages processed"""
|
|
25
|
+
|
|
26
|
+
doc_size_bytes: OptionalNullable[int] = UNSET
|
|
27
|
+
r"""Document size in bytes"""
|
|
28
|
+
|
|
29
|
+
@model_serializer(mode="wrap")
|
|
30
|
+
def serialize_model(self, handler):
|
|
31
|
+
optional_fields = ["doc_size_bytes"]
|
|
32
|
+
nullable_fields = ["doc_size_bytes"]
|
|
33
|
+
null_default_fields = []
|
|
34
|
+
|
|
35
|
+
serialized = handler(self)
|
|
36
|
+
|
|
37
|
+
m = {}
|
|
38
|
+
|
|
39
|
+
for n, f in type(self).model_fields.items():
|
|
40
|
+
k = f.alias or n
|
|
41
|
+
val = serialized.get(k)
|
|
42
|
+
serialized.pop(k, None)
|
|
43
|
+
|
|
44
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
45
|
+
is_set = (
|
|
46
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
47
|
+
or k in null_default_fields
|
|
48
|
+
) # pylint: disable=no-member
|
|
49
|
+
|
|
50
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
51
|
+
m[k] = val
|
|
52
|
+
elif val != UNSET_SENTINEL and (
|
|
53
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
54
|
+
):
|
|
55
|
+
m[k] = val
|
|
56
|
+
|
|
57
|
+
return m
|