mistralai 1.7.0__py3-none-any.whl → 1.7.1__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 +3 -3
- mistralai/extra/utils/_pydantic_helper.py +2 -1
- mistralai/models/ocrimageobject.py +7 -1
- mistralai/models/ocrrequest.py +15 -0
- mistralai/models/ocrresponse.py +38 -2
- mistralai/ocr.py +28 -0
- {mistralai-1.7.0.dist-info → mistralai-1.7.1.dist-info}/METADATA +1 -1
- {mistralai-1.7.0.dist-info → mistralai-1.7.1.dist-info}/RECORD +10 -10
- {mistralai-1.7.0.dist-info → mistralai-1.7.1.dist-info}/WHEEL +1 -1
- {mistralai-1.7.0.dist-info → mistralai-1.7.1.dist-info}/LICENSE +0 -0
mistralai/_version.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "mistralai"
|
|
6
|
-
__version__: str = "1.7.
|
|
7
|
-
__openapi_doc_version__: str = "0.0
|
|
6
|
+
__version__: str = "1.7.1"
|
|
7
|
+
__openapi_doc_version__: str = "1.0.0"
|
|
8
8
|
__gen_version__: str = "2.548.6"
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 1.7.
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 1.7.1 2.548.6 1.0.0 mistralai"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def rec_strict_json_schema(schema_node: Any) -> Any:
|
|
4
5
|
"""
|
|
5
6
|
Recursively set the additionalProperties property to False for all objects in the JSON Schema.
|
|
6
7
|
This makes the JSON Schema strict (i.e. no additional properties are allowed).
|
|
7
8
|
"""
|
|
8
|
-
if isinstance(schema_node, (str, bool)):
|
|
9
|
+
if isinstance(schema_node, (str, bool)) or schema_node is None:
|
|
9
10
|
return schema_node
|
|
10
11
|
if isinstance(schema_node, dict):
|
|
11
12
|
if "type" in schema_node and schema_node["type"] == "object":
|
|
@@ -19,6 +19,8 @@ class OCRImageObjectTypedDict(TypedDict):
|
|
|
19
19
|
r"""Y coordinate of bottom-right corner of the extracted image"""
|
|
20
20
|
image_base64: NotRequired[Nullable[str]]
|
|
21
21
|
r"""Base64 string of the extracted image"""
|
|
22
|
+
image_annotation: NotRequired[Nullable[str]]
|
|
23
|
+
r"""Annotation of the extracted image in json str"""
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class OCRImageObject(BaseModel):
|
|
@@ -40,15 +42,19 @@ class OCRImageObject(BaseModel):
|
|
|
40
42
|
image_base64: OptionalNullable[str] = UNSET
|
|
41
43
|
r"""Base64 string of the extracted image"""
|
|
42
44
|
|
|
45
|
+
image_annotation: OptionalNullable[str] = UNSET
|
|
46
|
+
r"""Annotation of the extracted image in json str"""
|
|
47
|
+
|
|
43
48
|
@model_serializer(mode="wrap")
|
|
44
49
|
def serialize_model(self, handler):
|
|
45
|
-
optional_fields = ["image_base64"]
|
|
50
|
+
optional_fields = ["image_base64", "image_annotation"]
|
|
46
51
|
nullable_fields = [
|
|
47
52
|
"top_left_x",
|
|
48
53
|
"top_left_y",
|
|
49
54
|
"bottom_right_x",
|
|
50
55
|
"bottom_right_y",
|
|
51
56
|
"image_base64",
|
|
57
|
+
"image_annotation",
|
|
52
58
|
]
|
|
53
59
|
null_default_fields = []
|
|
54
60
|
|
mistralai/models/ocrrequest.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
|
|
5
5
|
from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
|
|
6
|
+
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
6
7
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
8
|
from pydantic import model_serializer
|
|
8
9
|
from typing import List, Optional, Union
|
|
@@ -32,6 +33,10 @@ class OCRRequestTypedDict(TypedDict):
|
|
|
32
33
|
r"""Max images to extract"""
|
|
33
34
|
image_min_size: NotRequired[Nullable[int]]
|
|
34
35
|
r"""Minimum height and width of image to extract"""
|
|
36
|
+
bbox_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
37
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
38
|
+
document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
39
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
35
40
|
|
|
36
41
|
|
|
37
42
|
class OCRRequest(BaseModel):
|
|
@@ -54,6 +59,12 @@ class OCRRequest(BaseModel):
|
|
|
54
59
|
image_min_size: OptionalNullable[int] = UNSET
|
|
55
60
|
r"""Minimum height and width of image to extract"""
|
|
56
61
|
|
|
62
|
+
bbox_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
63
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
64
|
+
|
|
65
|
+
document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
66
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
67
|
+
|
|
57
68
|
@model_serializer(mode="wrap")
|
|
58
69
|
def serialize_model(self, handler):
|
|
59
70
|
optional_fields = [
|
|
@@ -62,6 +73,8 @@ class OCRRequest(BaseModel):
|
|
|
62
73
|
"include_image_base64",
|
|
63
74
|
"image_limit",
|
|
64
75
|
"image_min_size",
|
|
76
|
+
"bbox_annotation_format",
|
|
77
|
+
"document_annotation_format",
|
|
65
78
|
]
|
|
66
79
|
nullable_fields = [
|
|
67
80
|
"model",
|
|
@@ -69,6 +82,8 @@ class OCRRequest(BaseModel):
|
|
|
69
82
|
"include_image_base64",
|
|
70
83
|
"image_limit",
|
|
71
84
|
"image_min_size",
|
|
85
|
+
"bbox_annotation_format",
|
|
86
|
+
"document_annotation_format",
|
|
72
87
|
]
|
|
73
88
|
null_default_fields = []
|
|
74
89
|
|
mistralai/models/ocrresponse.py
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
|
|
5
5
|
from .ocrusageinfo import OCRUsageInfo, OCRUsageInfoTypedDict
|
|
6
|
-
from mistralai.types import BaseModel
|
|
6
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
|
+
from pydantic import model_serializer
|
|
7
8
|
from typing import List
|
|
8
|
-
from typing_extensions import TypedDict
|
|
9
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class OCRResponseTypedDict(TypedDict):
|
|
@@ -14,6 +15,8 @@ class OCRResponseTypedDict(TypedDict):
|
|
|
14
15
|
model: str
|
|
15
16
|
r"""The model used to generate the OCR."""
|
|
16
17
|
usage_info: OCRUsageInfoTypedDict
|
|
18
|
+
document_annotation: NotRequired[Nullable[str]]
|
|
19
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
class OCRResponse(BaseModel):
|
|
@@ -24,3 +27,36 @@ class OCRResponse(BaseModel):
|
|
|
24
27
|
r"""The model used to generate the OCR."""
|
|
25
28
|
|
|
26
29
|
usage_info: OCRUsageInfo
|
|
30
|
+
|
|
31
|
+
document_annotation: OptionalNullable[str] = UNSET
|
|
32
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
33
|
+
|
|
34
|
+
@model_serializer(mode="wrap")
|
|
35
|
+
def serialize_model(self, handler):
|
|
36
|
+
optional_fields = ["document_annotation"]
|
|
37
|
+
nullable_fields = ["document_annotation"]
|
|
38
|
+
null_default_fields = []
|
|
39
|
+
|
|
40
|
+
serialized = handler(self)
|
|
41
|
+
|
|
42
|
+
m = {}
|
|
43
|
+
|
|
44
|
+
for n, f in 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
|
mistralai/ocr.py
CHANGED
|
@@ -21,6 +21,12 @@ class Ocr(BaseSDK):
|
|
|
21
21
|
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
22
22
|
image_limit: OptionalNullable[int] = UNSET,
|
|
23
23
|
image_min_size: OptionalNullable[int] = UNSET,
|
|
24
|
+
bbox_annotation_format: OptionalNullable[
|
|
25
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
26
|
+
] = UNSET,
|
|
27
|
+
document_annotation_format: OptionalNullable[
|
|
28
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
29
|
+
] = UNSET,
|
|
24
30
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
25
31
|
server_url: Optional[str] = None,
|
|
26
32
|
timeout_ms: Optional[int] = None,
|
|
@@ -35,6 +41,8 @@ class Ocr(BaseSDK):
|
|
|
35
41
|
:param include_image_base64: Include image URLs in response
|
|
36
42
|
:param image_limit: Max images to extract
|
|
37
43
|
:param image_min_size: Minimum height and width of image to extract
|
|
44
|
+
:param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
|
|
45
|
+
:param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
|
|
38
46
|
:param retries: Override the default retry configuration for this method
|
|
39
47
|
:param server_url: Override the default server URL for this method
|
|
40
48
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -58,6 +66,12 @@ class Ocr(BaseSDK):
|
|
|
58
66
|
include_image_base64=include_image_base64,
|
|
59
67
|
image_limit=image_limit,
|
|
60
68
|
image_min_size=image_min_size,
|
|
69
|
+
bbox_annotation_format=utils.get_pydantic_model(
|
|
70
|
+
bbox_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
71
|
+
),
|
|
72
|
+
document_annotation_format=utils.get_pydantic_model(
|
|
73
|
+
document_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
74
|
+
),
|
|
61
75
|
)
|
|
62
76
|
|
|
63
77
|
req = self._build_request(
|
|
@@ -139,6 +153,12 @@ class Ocr(BaseSDK):
|
|
|
139
153
|
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
140
154
|
image_limit: OptionalNullable[int] = UNSET,
|
|
141
155
|
image_min_size: OptionalNullable[int] = UNSET,
|
|
156
|
+
bbox_annotation_format: OptionalNullable[
|
|
157
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
158
|
+
] = UNSET,
|
|
159
|
+
document_annotation_format: OptionalNullable[
|
|
160
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
161
|
+
] = UNSET,
|
|
142
162
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
143
163
|
server_url: Optional[str] = None,
|
|
144
164
|
timeout_ms: Optional[int] = None,
|
|
@@ -153,6 +173,8 @@ class Ocr(BaseSDK):
|
|
|
153
173
|
:param include_image_base64: Include image URLs in response
|
|
154
174
|
:param image_limit: Max images to extract
|
|
155
175
|
:param image_min_size: Minimum height and width of image to extract
|
|
176
|
+
:param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
|
|
177
|
+
:param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
|
|
156
178
|
:param retries: Override the default retry configuration for this method
|
|
157
179
|
:param server_url: Override the default server URL for this method
|
|
158
180
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -176,6 +198,12 @@ class Ocr(BaseSDK):
|
|
|
176
198
|
include_image_base64=include_image_base64,
|
|
177
199
|
image_limit=image_limit,
|
|
178
200
|
image_min_size=image_min_size,
|
|
201
|
+
bbox_annotation_format=utils.get_pydantic_model(
|
|
202
|
+
bbox_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
203
|
+
),
|
|
204
|
+
document_annotation_format=utils.get_pydantic_model(
|
|
205
|
+
document_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
206
|
+
),
|
|
179
207
|
)
|
|
180
208
|
|
|
181
209
|
req = self._build_request_async(
|
|
@@ -139,7 +139,7 @@ mistralai/_hooks/deprecation_warning.py,sha256=eyEOf7-o9uqqNWJnufD2RXp3dYrGV4in9
|
|
|
139
139
|
mistralai/_hooks/registration.py,sha256=ML0W-XbE4WYdJ4eGks_XxF2aLCJTaIWjQATFGzFwvyU,861
|
|
140
140
|
mistralai/_hooks/sdkhooks.py,sha256=s-orhdvnV89TmI3QiPC2LWQtYeM9RrsG1CTll-fYZmQ,2559
|
|
141
141
|
mistralai/_hooks/types.py,sha256=z3AUFDpRJHj2m3h5PklvUeEcGohY0cfph4jL6-nGIzs,2812
|
|
142
|
-
mistralai/_version.py,sha256=
|
|
142
|
+
mistralai/_version.py,sha256=SPvJqmP-liALw_gV7djYQ0NmHgy9bNFtTsm0WPhGtQM,460
|
|
143
143
|
mistralai/agents.py,sha256=o_apyuwiDzxv-U252T84ynAHCb5fn1q7MMXqrZ4oHLo,32652
|
|
144
144
|
mistralai/async_client.py,sha256=KUdYxIIqoD6L7vB0EGwUR6lQ0NK5iCTHjnLVR9CVcJY,355
|
|
145
145
|
mistralai/basesdk.py,sha256=GsU5bp8O5fBCl34tKxaYmeYSIIM971eAPeFBBC_BpFo,12191
|
|
@@ -155,7 +155,7 @@ mistralai/extra/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
|
155
155
|
mistralai/extra/tests/test_struct_chat.py,sha256=WT6GGfcbXCok8UkEny19u4q1g2QOgkekvmAb3ZinQZ8,4343
|
|
156
156
|
mistralai/extra/tests/test_utils.py,sha256=VesGDR_IiE6u0iY7yOi1iERd7esdJgi2aL4xZp0vKVI,5113
|
|
157
157
|
mistralai/extra/utils/__init__.py,sha256=SExo5t_hx0ybiQhVJIG3r3hOA-Pfny3lIO_WsqNXlN8,116
|
|
158
|
-
mistralai/extra/utils/_pydantic_helper.py,sha256=
|
|
158
|
+
mistralai/extra/utils/_pydantic_helper.py,sha256=_mzrbZGU07M96CzcxgjcV25NtIGu5EUfotaN8NDUoFc,883
|
|
159
159
|
mistralai/extra/utils/response_format.py,sha256=uDNpvOHhk2se3JTXweWYMbnkyOcOqhMe2yxZ2lYNe1k,913
|
|
160
160
|
mistralai/files.py,sha256=uejTIBoumK7wMp51e9F2TZsiRDXX9NRnBGgMuaM21eg,45763
|
|
161
161
|
mistralai/fim.py,sha256=UMx-bFYbaSyANZug8VrCabHsqePdiHoYQO1YMKB2MvY,27935
|
|
@@ -258,11 +258,11 @@ mistralai/models/modelcapabilities.py,sha256=No-Dl09zT1sG4MxsWnx4s8Yo1tUeMQ7k-HR
|
|
|
258
258
|
mistralai/models/modellist.py,sha256=D4Y784kQkx0ARhofFrpEqGLfxa-jTY8ev0TQMrD_n8I,995
|
|
259
259
|
mistralai/models/moderationobject.py,sha256=mmzFEcccsT7G9PjmQrsYMijmICbfBtUpVN_ZisuhYbY,655
|
|
260
260
|
mistralai/models/moderationresponse.py,sha256=kxIRI3UJdddj2Hz-E9q21gKQAbacxZoG4hdoZjrae5M,508
|
|
261
|
-
mistralai/models/ocrimageobject.py,sha256=
|
|
261
|
+
mistralai/models/ocrimageobject.py,sha256=vnBLzA3p7KlpfNYMq1QJYiyA6YDpmWmL2J4SX3CIdQs,2802
|
|
262
262
|
mistralai/models/ocrpagedimensions.py,sha256=oP4v80I8d6ZELSZt6cRoECd6uIONgdyCeeFalm-4OvM,609
|
|
263
263
|
mistralai/models/ocrpageobject.py,sha256=s0OzcCA0cLTFYahNOr0-r4ds7WOsXYhEx-QcNLngW7M,2085
|
|
264
|
-
mistralai/models/ocrrequest.py,sha256=
|
|
265
|
-
mistralai/models/ocrresponse.py,sha256=
|
|
264
|
+
mistralai/models/ocrrequest.py,sha256=leCP781cr_ruG_QFtvgn84iDa_CIGEQh-N5xpB0hld0,4242
|
|
265
|
+
mistralai/models/ocrresponse.py,sha256=yFjiKSEtdyYkswhEW3lA51Fg2yAWk0s_tJV_QsYMxR0,2042
|
|
266
266
|
mistralai/models/ocrusageinfo.py,sha256=cWtxHxXyJn3U1qJgG-XU-1xfC7poGHvhVtPqdrFrfII,1571
|
|
267
267
|
mistralai/models/prediction.py,sha256=BgWbbeSi1eD9Rh1xk8srXlRgD7Xooj8nLsbSQ21pNRo,718
|
|
268
268
|
mistralai/models/referencechunk.py,sha256=A9vV5pZv-tUqGlswdu0HOyCYy0Q-UIJY0Oc9ZfM6XJA,519
|
|
@@ -292,7 +292,7 @@ mistralai/models/validationerror.py,sha256=DouDBJmBhbW4KPsF5rZEyBdnB_adC-l32kuHC
|
|
|
292
292
|
mistralai/models/wandbintegration.py,sha256=X8V86L3EwheoI-0LI7zwmTtn_4SKz5s62SJN3x5BTxE,2153
|
|
293
293
|
mistralai/models/wandbintegrationout.py,sha256=wohSfHGF8Y9OfIhM1qr9mssLRg63b3CMLDpi4TQKYEk,2111
|
|
294
294
|
mistralai/models_.py,sha256=2tiJEMwjixY0Rz5dDt4gDQNEu9peecly2zWmi7YeQhQ,46398
|
|
295
|
-
mistralai/ocr.py,sha256=
|
|
295
|
+
mistralai/ocr.py,sha256=GvG5SMy85s3xUTGLSnQ3h9GkNYw9KBy8umBnkC9Ciho,11991
|
|
296
296
|
mistralai/py.typed,sha256=zrp19r0G21lr2yRiMC0f8MFkQFGj9wMpSbboePMg8KM,59
|
|
297
297
|
mistralai/sdk.py,sha256=q18oi4qj0PU6fsB_5BaWy-18bGzLxOgMlkSvEgCW4MY,6453
|
|
298
298
|
mistralai/sdkconfiguration.py,sha256=88GOgda6cRq40OSFI5FIarLvGNrMaHTzinPI_GyqTvk,1873
|
|
@@ -314,7 +314,7 @@ mistralai/utils/serializers.py,sha256=EGH40Pgp3sSK9uM4PxL7_SYzSHtmo-Uy6QIE5xLVg6
|
|
|
314
314
|
mistralai/utils/url.py,sha256=BgGPgcTA6MRK4bF8fjP2dUopN3NzEzxWMXPBVg8NQUA,5254
|
|
315
315
|
mistralai/utils/values.py,sha256=CcaCXEa3xHhkUDROyXZocN8f0bdITftv9Y0P9lTf0YM,3517
|
|
316
316
|
mistralai/version.py,sha256=iosXhlXclBwBqlADFKEilxAC2wWKbtuBKi87AmPi7s8,196
|
|
317
|
-
mistralai-1.7.
|
|
318
|
-
mistralai-1.7.
|
|
319
|
-
mistralai-1.7.
|
|
320
|
-
mistralai-1.7.
|
|
317
|
+
mistralai-1.7.1.dist-info/LICENSE,sha256=rUtQ_9GD0OyLPlb-2uWVdfE87hzudMRmsW-tS-0DK-0,11340
|
|
318
|
+
mistralai-1.7.1.dist-info/METADATA,sha256=izeRtogP3xYzTKTnFXa8BLUylIaTAiUZbRJaU6Dtgl4,30328
|
|
319
|
+
mistralai-1.7.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
320
|
+
mistralai-1.7.1.dist-info/RECORD,,
|
|
File without changes
|