mistralai 1.9.6__py3-none-any.whl → 1.9.8__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/models/messageinputcontentchunks.py +3 -1
- {mistralai-1.9.6.dist-info → mistralai-1.9.8.dist-info}/METADATA +1 -1
- {mistralai-1.9.6.dist-info → mistralai-1.9.8.dist-info}/RECORD +41 -30
- 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/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.6.dist-info → mistralai-1.9.8.dist-info}/LICENSE +0 -0
- {mistralai-1.9.6.dist-info → mistralai-1.9.8.dist-info}/WHEEL +0 -0
|
@@ -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
|
|
@@ -1,19 +1,82 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from mistralai_azure.types import
|
|
5
|
-
|
|
4
|
+
from mistralai_azure.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
11
|
+
import pydantic
|
|
12
|
+
from pydantic import ConfigDict, model_serializer
|
|
13
|
+
from typing import Any, Dict, Optional
|
|
14
|
+
from typing_extensions import NotRequired, TypedDict
|
|
6
15
|
|
|
7
16
|
|
|
8
17
|
class UsageInfoTypedDict(TypedDict):
|
|
9
|
-
prompt_tokens: int
|
|
10
|
-
completion_tokens: int
|
|
11
|
-
total_tokens: int
|
|
18
|
+
prompt_tokens: NotRequired[int]
|
|
19
|
+
completion_tokens: NotRequired[int]
|
|
20
|
+
total_tokens: NotRequired[int]
|
|
21
|
+
prompt_audio_seconds: NotRequired[Nullable[int]]
|
|
12
22
|
|
|
13
23
|
|
|
14
24
|
class UsageInfo(BaseModel):
|
|
15
|
-
|
|
25
|
+
model_config = ConfigDict(
|
|
26
|
+
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
|
27
|
+
)
|
|
28
|
+
__pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False)
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
prompt_tokens: Optional[int] = 0
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
completion_tokens: Optional[int] = 0
|
|
33
|
+
|
|
34
|
+
total_tokens: Optional[int] = 0
|
|
35
|
+
|
|
36
|
+
prompt_audio_seconds: OptionalNullable[int] = UNSET
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def additional_properties(self):
|
|
40
|
+
return self.__pydantic_extra__
|
|
41
|
+
|
|
42
|
+
@additional_properties.setter
|
|
43
|
+
def additional_properties(self, value):
|
|
44
|
+
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
|
45
|
+
|
|
46
|
+
@model_serializer(mode="wrap")
|
|
47
|
+
def serialize_model(self, handler):
|
|
48
|
+
optional_fields = [
|
|
49
|
+
"prompt_tokens",
|
|
50
|
+
"completion_tokens",
|
|
51
|
+
"total_tokens",
|
|
52
|
+
"prompt_audio_seconds",
|
|
53
|
+
]
|
|
54
|
+
nullable_fields = ["prompt_audio_seconds"]
|
|
55
|
+
null_default_fields = []
|
|
56
|
+
|
|
57
|
+
serialized = handler(self)
|
|
58
|
+
|
|
59
|
+
m = {}
|
|
60
|
+
|
|
61
|
+
for n, f in type(self).model_fields.items():
|
|
62
|
+
k = f.alias or n
|
|
63
|
+
val = serialized.get(k)
|
|
64
|
+
serialized.pop(k, None)
|
|
65
|
+
|
|
66
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
67
|
+
is_set = (
|
|
68
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
69
|
+
or k in null_default_fields
|
|
70
|
+
) # pylint: disable=no-member
|
|
71
|
+
|
|
72
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
73
|
+
m[k] = val
|
|
74
|
+
elif val != UNSET_SENTINEL and (
|
|
75
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
76
|
+
):
|
|
77
|
+
m[k] = val
|
|
78
|
+
|
|
79
|
+
for k, v in serialized.items():
|
|
80
|
+
m[k] = v
|
|
81
|
+
|
|
82
|
+
return m
|