mistralai 1.9.7__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-1.9.7.dist-info → mistralai-1.9.8.dist-info}/METADATA +1 -1
- {mistralai-1.9.7.dist-info → mistralai-1.9.8.dist-info}/RECORD +40 -29
- 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.7.dist-info → mistralai-1.9.8.dist-info}/LICENSE +0 -0
- {mistralai-1.9.7.dist-info → mistralai-1.9.8.dist-info}/WHEEL +0 -0
mistralai_azure/utils/forms.py
CHANGED
|
@@ -86,11 +86,39 @@ def _populate_form(
|
|
|
86
86
|
return form
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]:
|
|
90
|
+
"""Extract file name, content, and content type from a file object."""
|
|
91
|
+
file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields
|
|
92
|
+
|
|
93
|
+
file_name = ""
|
|
94
|
+
content = None
|
|
95
|
+
content_type = None
|
|
96
|
+
|
|
97
|
+
for file_field_name in file_fields:
|
|
98
|
+
file_field = file_fields[file_field_name]
|
|
99
|
+
|
|
100
|
+
file_metadata = find_field_metadata(file_field, MultipartFormMetadata)
|
|
101
|
+
if file_metadata is None:
|
|
102
|
+
continue
|
|
103
|
+
|
|
104
|
+
if file_metadata.content:
|
|
105
|
+
content = getattr(file_obj, file_field_name, None)
|
|
106
|
+
elif file_field_name == "content_type":
|
|
107
|
+
content_type = getattr(file_obj, file_field_name, None)
|
|
108
|
+
else:
|
|
109
|
+
file_name = getattr(file_obj, file_field_name)
|
|
110
|
+
|
|
111
|
+
if file_name == "" or content is None:
|
|
112
|
+
raise ValueError("invalid multipart/form-data file")
|
|
113
|
+
|
|
114
|
+
return file_name, content, content_type
|
|
115
|
+
|
|
116
|
+
|
|
89
117
|
def serialize_multipart_form(
|
|
90
118
|
media_type: str, request: Any
|
|
91
|
-
) -> Tuple[str, Dict[str, Any],
|
|
119
|
+
) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]:
|
|
92
120
|
form: Dict[str, Any] = {}
|
|
93
|
-
files:
|
|
121
|
+
files: List[Tuple[str, Any]] = []
|
|
94
122
|
|
|
95
123
|
if not isinstance(request, BaseModel):
|
|
96
124
|
raise TypeError("invalid request body type")
|
|
@@ -112,39 +140,32 @@ def serialize_multipart_form(
|
|
|
112
140
|
f_name = field.alias if field.alias else name
|
|
113
141
|
|
|
114
142
|
if field_metadata.file:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
file_field = file_fields[file_field_name]
|
|
143
|
+
if isinstance(val, List):
|
|
144
|
+
# Handle array of files
|
|
145
|
+
for file_obj in val:
|
|
146
|
+
if not _is_set(file_obj):
|
|
147
|
+
continue
|
|
148
|
+
|
|
149
|
+
file_name, content, content_type = _extract_file_properties(file_obj)
|
|
123
150
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
if content_type is not None:
|
|
152
|
+
files.append((f_name + "[]", (file_name, content, content_type)))
|
|
153
|
+
else:
|
|
154
|
+
files.append((f_name + "[]", (file_name, content)))
|
|
155
|
+
else:
|
|
156
|
+
# Handle single file
|
|
157
|
+
file_name, content, content_type = _extract_file_properties(val)
|
|
127
158
|
|
|
128
|
-
if
|
|
129
|
-
|
|
130
|
-
elif file_field_name == "content_type":
|
|
131
|
-
content_type = getattr(val, file_field_name, None)
|
|
159
|
+
if content_type is not None:
|
|
160
|
+
files.append((f_name, (file_name, content, content_type)))
|
|
132
161
|
else:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if file_name == "" or content is None:
|
|
136
|
-
raise ValueError("invalid multipart/form-data file")
|
|
137
|
-
|
|
138
|
-
if content_type is not None:
|
|
139
|
-
files[f_name] = (file_name, content, content_type)
|
|
140
|
-
else:
|
|
141
|
-
files[f_name] = (file_name, content)
|
|
162
|
+
files.append((f_name, (file_name, content)))
|
|
142
163
|
elif field_metadata.json:
|
|
143
|
-
files
|
|
164
|
+
files.append((f_name, (
|
|
144
165
|
None,
|
|
145
166
|
marshal_json(val, request_field_types[name]),
|
|
146
167
|
"application/json",
|
|
147
|
-
)
|
|
168
|
+
)))
|
|
148
169
|
else:
|
|
149
170
|
if isinstance(val, List):
|
|
150
171
|
values = []
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from decimal import Decimal
|
|
4
|
+
import functools
|
|
4
5
|
import json
|
|
5
|
-
|
|
6
|
-
import
|
|
6
|
+
import typing
|
|
7
|
+
from typing import Any, Dict, List, Tuple, Union, get_args
|
|
8
|
+
import typing_extensions
|
|
7
9
|
from typing_extensions import get_origin
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
8
12
|
from pydantic import ConfigDict, create_model
|
|
9
13
|
from pydantic_core import from_json
|
|
10
|
-
from typing_inspection.typing_objects import is_union
|
|
11
14
|
|
|
12
15
|
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
|
13
16
|
|
|
@@ -185,6 +188,13 @@ def is_nullable(field):
|
|
|
185
188
|
return False
|
|
186
189
|
|
|
187
190
|
|
|
191
|
+
def is_union(obj: object) -> bool:
|
|
192
|
+
"""
|
|
193
|
+
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
|
194
|
+
"""
|
|
195
|
+
return any(obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union"))
|
|
196
|
+
|
|
197
|
+
|
|
188
198
|
def stream_to_text(stream: httpx.Response) -> str:
|
|
189
199
|
return "".join(stream.iter_text())
|
|
190
200
|
|
|
@@ -217,3 +227,22 @@ def _contains_pydantic_model(data: Any) -> bool:
|
|
|
217
227
|
return any(_contains_pydantic_model(value) for value in data.values())
|
|
218
228
|
|
|
219
229
|
return False
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@functools.cache
|
|
233
|
+
def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
|
234
|
+
"""
|
|
235
|
+
Get typing objects by name from typing and typing_extensions.
|
|
236
|
+
Reference: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types
|
|
237
|
+
"""
|
|
238
|
+
result = tuple(
|
|
239
|
+
getattr(module, name)
|
|
240
|
+
for module in (typing, typing_extensions)
|
|
241
|
+
if hasattr(module, name)
|
|
242
|
+
)
|
|
243
|
+
if not result:
|
|
244
|
+
raise ValueError(
|
|
245
|
+
f"Neither typing nor typing_extensions has an object called {name!r}"
|
|
246
|
+
)
|
|
247
|
+
return result
|
|
248
|
+
|
|
File without changes
|
|
File without changes
|