mistralai 1.5.0__py3-none-any.whl → 1.5.2rc1__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/_hooks/types.py +15 -3
- mistralai/_version.py +3 -3
- mistralai/agents.py +32 -12
- mistralai/basesdk.py +8 -0
- mistralai/chat.py +37 -17
- mistralai/classifiers.py +59 -37
- mistralai/embeddings.py +22 -18
- mistralai/extra/utils/response_format.py +3 -3
- mistralai/files.py +36 -0
- mistralai/fim.py +37 -17
- mistralai/httpclient.py +4 -2
- mistralai/jobs.py +30 -0
- mistralai/mistral_jobs.py +24 -0
- mistralai/models/__init__.py +43 -16
- mistralai/models/assistantmessage.py +2 -0
- mistralai/models/chatcompletionrequest.py +3 -10
- mistralai/models/chatcompletionstreamrequest.py +3 -10
- mistralai/models/chatmoderationrequest.py +86 -0
- mistralai/models/classificationrequest.py +7 -36
- mistralai/models/contentchunk.py +8 -1
- mistralai/models/documenturlchunk.py +56 -0
- mistralai/models/embeddingrequest.py +8 -44
- mistralai/models/filepurpose.py +1 -1
- mistralai/models/fimcompletionrequest.py +2 -3
- mistralai/models/fimcompletionstreamrequest.py +2 -3
- mistralai/models/ocrimageobject.py +77 -0
- mistralai/models/ocrpagedimensions.py +25 -0
- mistralai/models/ocrpageobject.py +64 -0
- mistralai/models/ocrrequest.py +97 -0
- mistralai/models/ocrresponse.py +26 -0
- mistralai/models/ocrusageinfo.py +51 -0
- mistralai/models/prediction.py +4 -5
- mistralai/models_.py +66 -18
- mistralai/ocr.py +248 -0
- mistralai/sdk.py +23 -3
- mistralai/sdkconfiguration.py +4 -2
- mistralai/utils/__init__.py +2 -0
- mistralai/utils/serializers.py +10 -6
- mistralai/utils/values.py +4 -1
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/METADATA +70 -19
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/RECORD +88 -76
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +10 -1
- mistralai_azure/_hooks/types.py +15 -3
- mistralai_azure/_version.py +3 -0
- mistralai_azure/basesdk.py +8 -0
- mistralai_azure/chat.py +88 -20
- mistralai_azure/httpclient.py +52 -0
- mistralai_azure/models/__init__.py +7 -0
- mistralai_azure/models/assistantmessage.py +2 -0
- mistralai_azure/models/chatcompletionrequest.py +8 -10
- mistralai_azure/models/chatcompletionstreamrequest.py +8 -10
- mistralai_azure/models/function.py +3 -0
- mistralai_azure/models/jsonschema.py +61 -0
- mistralai_azure/models/prediction.py +25 -0
- mistralai_azure/models/responseformat.py +42 -1
- mistralai_azure/models/responseformats.py +1 -1
- mistralai_azure/models/toolcall.py +3 -0
- mistralai_azure/sdk.py +56 -14
- mistralai_azure/sdkconfiguration.py +14 -6
- mistralai_azure/utils/__init__.py +2 -0
- mistralai_azure/utils/serializers.py +10 -6
- mistralai_azure/utils/values.py +4 -1
- mistralai_gcp/__init__.py +10 -1
- mistralai_gcp/_hooks/types.py +15 -3
- mistralai_gcp/_version.py +3 -0
- mistralai_gcp/basesdk.py +8 -0
- mistralai_gcp/chat.py +89 -21
- mistralai_gcp/fim.py +61 -21
- mistralai_gcp/httpclient.py +52 -0
- mistralai_gcp/models/__init__.py +7 -0
- mistralai_gcp/models/assistantmessage.py +2 -0
- mistralai_gcp/models/chatcompletionrequest.py +8 -10
- mistralai_gcp/models/chatcompletionstreamrequest.py +8 -10
- mistralai_gcp/models/fimcompletionrequest.py +2 -3
- mistralai_gcp/models/fimcompletionstreamrequest.py +2 -3
- mistralai_gcp/models/function.py +3 -0
- mistralai_gcp/models/jsonschema.py +61 -0
- mistralai_gcp/models/prediction.py +25 -0
- mistralai_gcp/models/responseformat.py +42 -1
- mistralai_gcp/models/responseformats.py +1 -1
- mistralai_gcp/models/toolcall.py +3 -0
- mistralai_gcp/sdk.py +63 -19
- mistralai_gcp/sdkconfiguration.py +14 -6
- mistralai_gcp/utils/__init__.py +2 -0
- mistralai_gcp/utils/serializers.py +10 -6
- mistralai_gcp/utils/values.py +4 -1
- mistralai/models/chatclassificationrequest.py +0 -113
- {mistralai-1.5.0.dist-info → mistralai-1.5.2rc1.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
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.types import BaseModel
|
|
7
|
+
from typing import List
|
|
8
|
+
from typing_extensions import TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OCRResponseTypedDict(TypedDict):
|
|
12
|
+
pages: List[OCRPageObjectTypedDict]
|
|
13
|
+
r"""List of OCR info for pages."""
|
|
14
|
+
model: str
|
|
15
|
+
r"""The model used to generate the OCR."""
|
|
16
|
+
usage_info: OCRUsageInfoTypedDict
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OCRResponse(BaseModel):
|
|
20
|
+
pages: List[OCRPageObject]
|
|
21
|
+
r"""List of OCR info for pages."""
|
|
22
|
+
|
|
23
|
+
model: str
|
|
24
|
+
r"""The model used to generate the OCR."""
|
|
25
|
+
|
|
26
|
+
usage_info: OCRUsageInfo
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
5
|
+
from pydantic import model_serializer
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OCRUsageInfoTypedDict(TypedDict):
|
|
10
|
+
pages_processed: int
|
|
11
|
+
r"""Number of pages processed"""
|
|
12
|
+
doc_size_bytes: NotRequired[Nullable[int]]
|
|
13
|
+
r"""Document size in bytes"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class OCRUsageInfo(BaseModel):
|
|
17
|
+
pages_processed: int
|
|
18
|
+
r"""Number of pages processed"""
|
|
19
|
+
|
|
20
|
+
doc_size_bytes: OptionalNullable[int] = UNSET
|
|
21
|
+
r"""Document size in bytes"""
|
|
22
|
+
|
|
23
|
+
@model_serializer(mode="wrap")
|
|
24
|
+
def serialize_model(self, handler):
|
|
25
|
+
optional_fields = ["doc_size_bytes"]
|
|
26
|
+
nullable_fields = ["doc_size_bytes"]
|
|
27
|
+
null_default_fields = []
|
|
28
|
+
|
|
29
|
+
serialized = handler(self)
|
|
30
|
+
|
|
31
|
+
m = {}
|
|
32
|
+
|
|
33
|
+
for n, f in self.model_fields.items():
|
|
34
|
+
k = f.alias or n
|
|
35
|
+
val = serialized.get(k)
|
|
36
|
+
serialized.pop(k, None)
|
|
37
|
+
|
|
38
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
39
|
+
is_set = (
|
|
40
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
41
|
+
or k in null_default_fields
|
|
42
|
+
) # pylint: disable=no-member
|
|
43
|
+
|
|
44
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
45
|
+
m[k] = val
|
|
46
|
+
elif val != UNSET_SENTINEL and (
|
|
47
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
48
|
+
):
|
|
49
|
+
m[k] = val
|
|
50
|
+
|
|
51
|
+
return m
|
mistralai/models/prediction.py
CHANGED
|
@@ -9,17 +9,16 @@ from typing import Literal, Optional
|
|
|
9
9
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
PredictionType = Literal["content"]
|
|
13
|
-
|
|
14
|
-
|
|
15
12
|
class PredictionTypedDict(TypedDict):
|
|
16
|
-
type:
|
|
13
|
+
type: Literal["content"]
|
|
17
14
|
content: NotRequired[str]
|
|
18
15
|
|
|
19
16
|
|
|
20
17
|
class Prediction(BaseModel):
|
|
21
18
|
TYPE: Annotated[
|
|
22
|
-
Annotated[
|
|
19
|
+
Annotated[
|
|
20
|
+
Optional[Literal["content"]], AfterValidator(validate_const("content"))
|
|
21
|
+
],
|
|
23
22
|
pydantic.Field(alias="type"),
|
|
24
23
|
] = "content"
|
|
25
24
|
|
mistralai/models_.py
CHANGED
|
@@ -35,6 +35,8 @@ class Models(BaseSDK):
|
|
|
35
35
|
|
|
36
36
|
if server_url is not None:
|
|
37
37
|
base_url = server_url
|
|
38
|
+
else:
|
|
39
|
+
base_url = self._get_url(base_url, url_variables)
|
|
38
40
|
req = self._build_request(
|
|
39
41
|
method="GET",
|
|
40
42
|
path="/v1/models",
|
|
@@ -61,6 +63,7 @@ class Models(BaseSDK):
|
|
|
61
63
|
|
|
62
64
|
http_res = self.do_request(
|
|
63
65
|
hook_ctx=HookContext(
|
|
66
|
+
base_url=base_url or "",
|
|
64
67
|
operation_id="list_models_v1_models_get",
|
|
65
68
|
oauth2_scopes=[],
|
|
66
69
|
security_source=get_security_from_env(
|
|
@@ -72,12 +75,14 @@ class Models(BaseSDK):
|
|
|
72
75
|
retry_config=retry_config,
|
|
73
76
|
)
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
response_data: Any = None
|
|
76
79
|
if utils.match_response(http_res, "200", "application/json"):
|
|
77
80
|
return utils.unmarshal_json(http_res.text, models.ModelList)
|
|
78
81
|
if utils.match_response(http_res, "422", "application/json"):
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
response_data = utils.unmarshal_json(
|
|
83
|
+
http_res.text, models.HTTPValidationErrorData
|
|
84
|
+
)
|
|
85
|
+
raise models.HTTPValidationError(data=response_data)
|
|
81
86
|
if utils.match_response(http_res, "4XX", "*"):
|
|
82
87
|
http_res_text = utils.stream_to_text(http_res)
|
|
83
88
|
raise models.SDKError(
|
|
@@ -122,6 +127,8 @@ class Models(BaseSDK):
|
|
|
122
127
|
|
|
123
128
|
if server_url is not None:
|
|
124
129
|
base_url = server_url
|
|
130
|
+
else:
|
|
131
|
+
base_url = self._get_url(base_url, url_variables)
|
|
125
132
|
req = self._build_request_async(
|
|
126
133
|
method="GET",
|
|
127
134
|
path="/v1/models",
|
|
@@ -148,6 +155,7 @@ class Models(BaseSDK):
|
|
|
148
155
|
|
|
149
156
|
http_res = await self.do_request_async(
|
|
150
157
|
hook_ctx=HookContext(
|
|
158
|
+
base_url=base_url or "",
|
|
151
159
|
operation_id="list_models_v1_models_get",
|
|
152
160
|
oauth2_scopes=[],
|
|
153
161
|
security_source=get_security_from_env(
|
|
@@ -159,12 +167,14 @@ class Models(BaseSDK):
|
|
|
159
167
|
retry_config=retry_config,
|
|
160
168
|
)
|
|
161
169
|
|
|
162
|
-
|
|
170
|
+
response_data: Any = None
|
|
163
171
|
if utils.match_response(http_res, "200", "application/json"):
|
|
164
172
|
return utils.unmarshal_json(http_res.text, models.ModelList)
|
|
165
173
|
if utils.match_response(http_res, "422", "application/json"):
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
response_data = utils.unmarshal_json(
|
|
175
|
+
http_res.text, models.HTTPValidationErrorData
|
|
176
|
+
)
|
|
177
|
+
raise models.HTTPValidationError(data=response_data)
|
|
168
178
|
if utils.match_response(http_res, "4XX", "*"):
|
|
169
179
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
170
180
|
raise models.SDKError(
|
|
@@ -211,6 +221,8 @@ class Models(BaseSDK):
|
|
|
211
221
|
|
|
212
222
|
if server_url is not None:
|
|
213
223
|
base_url = server_url
|
|
224
|
+
else:
|
|
225
|
+
base_url = self._get_url(base_url, url_variables)
|
|
214
226
|
|
|
215
227
|
request = models.RetrieveModelV1ModelsModelIDGetRequest(
|
|
216
228
|
model_id=model_id,
|
|
@@ -242,6 +254,7 @@ class Models(BaseSDK):
|
|
|
242
254
|
|
|
243
255
|
http_res = self.do_request(
|
|
244
256
|
hook_ctx=HookContext(
|
|
257
|
+
base_url=base_url or "",
|
|
245
258
|
operation_id="retrieve_model_v1_models__model_id__get",
|
|
246
259
|
oauth2_scopes=[],
|
|
247
260
|
security_source=get_security_from_env(
|
|
@@ -253,15 +266,17 @@ class Models(BaseSDK):
|
|
|
253
266
|
retry_config=retry_config,
|
|
254
267
|
)
|
|
255
268
|
|
|
256
|
-
|
|
269
|
+
response_data: Any = None
|
|
257
270
|
if utils.match_response(http_res, "200", "application/json"):
|
|
258
271
|
return utils.unmarshal_json(
|
|
259
272
|
http_res.text,
|
|
260
273
|
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet,
|
|
261
274
|
)
|
|
262
275
|
if utils.match_response(http_res, "422", "application/json"):
|
|
263
|
-
|
|
264
|
-
|
|
276
|
+
response_data = utils.unmarshal_json(
|
|
277
|
+
http_res.text, models.HTTPValidationErrorData
|
|
278
|
+
)
|
|
279
|
+
raise models.HTTPValidationError(data=response_data)
|
|
265
280
|
if utils.match_response(http_res, "4XX", "*"):
|
|
266
281
|
http_res_text = utils.stream_to_text(http_res)
|
|
267
282
|
raise models.SDKError(
|
|
@@ -308,6 +323,8 @@ class Models(BaseSDK):
|
|
|
308
323
|
|
|
309
324
|
if server_url is not None:
|
|
310
325
|
base_url = server_url
|
|
326
|
+
else:
|
|
327
|
+
base_url = self._get_url(base_url, url_variables)
|
|
311
328
|
|
|
312
329
|
request = models.RetrieveModelV1ModelsModelIDGetRequest(
|
|
313
330
|
model_id=model_id,
|
|
@@ -339,6 +356,7 @@ class Models(BaseSDK):
|
|
|
339
356
|
|
|
340
357
|
http_res = await self.do_request_async(
|
|
341
358
|
hook_ctx=HookContext(
|
|
359
|
+
base_url=base_url or "",
|
|
342
360
|
operation_id="retrieve_model_v1_models__model_id__get",
|
|
343
361
|
oauth2_scopes=[],
|
|
344
362
|
security_source=get_security_from_env(
|
|
@@ -350,15 +368,17 @@ class Models(BaseSDK):
|
|
|
350
368
|
retry_config=retry_config,
|
|
351
369
|
)
|
|
352
370
|
|
|
353
|
-
|
|
371
|
+
response_data: Any = None
|
|
354
372
|
if utils.match_response(http_res, "200", "application/json"):
|
|
355
373
|
return utils.unmarshal_json(
|
|
356
374
|
http_res.text,
|
|
357
375
|
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet,
|
|
358
376
|
)
|
|
359
377
|
if utils.match_response(http_res, "422", "application/json"):
|
|
360
|
-
|
|
361
|
-
|
|
378
|
+
response_data = utils.unmarshal_json(
|
|
379
|
+
http_res.text, models.HTTPValidationErrorData
|
|
380
|
+
)
|
|
381
|
+
raise models.HTTPValidationError(data=response_data)
|
|
362
382
|
if utils.match_response(http_res, "4XX", "*"):
|
|
363
383
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
364
384
|
raise models.SDKError(
|
|
@@ -405,6 +425,8 @@ class Models(BaseSDK):
|
|
|
405
425
|
|
|
406
426
|
if server_url is not None:
|
|
407
427
|
base_url = server_url
|
|
428
|
+
else:
|
|
429
|
+
base_url = self._get_url(base_url, url_variables)
|
|
408
430
|
|
|
409
431
|
request = models.DeleteModelV1ModelsModelIDDeleteRequest(
|
|
410
432
|
model_id=model_id,
|
|
@@ -436,6 +458,7 @@ class Models(BaseSDK):
|
|
|
436
458
|
|
|
437
459
|
http_res = self.do_request(
|
|
438
460
|
hook_ctx=HookContext(
|
|
461
|
+
base_url=base_url or "",
|
|
439
462
|
operation_id="delete_model_v1_models__model_id__delete",
|
|
440
463
|
oauth2_scopes=[],
|
|
441
464
|
security_source=get_security_from_env(
|
|
@@ -447,12 +470,14 @@ class Models(BaseSDK):
|
|
|
447
470
|
retry_config=retry_config,
|
|
448
471
|
)
|
|
449
472
|
|
|
450
|
-
|
|
473
|
+
response_data: Any = None
|
|
451
474
|
if utils.match_response(http_res, "200", "application/json"):
|
|
452
475
|
return utils.unmarshal_json(http_res.text, models.DeleteModelOut)
|
|
453
476
|
if utils.match_response(http_res, "422", "application/json"):
|
|
454
|
-
|
|
455
|
-
|
|
477
|
+
response_data = utils.unmarshal_json(
|
|
478
|
+
http_res.text, models.HTTPValidationErrorData
|
|
479
|
+
)
|
|
480
|
+
raise models.HTTPValidationError(data=response_data)
|
|
456
481
|
if utils.match_response(http_res, "4XX", "*"):
|
|
457
482
|
http_res_text = utils.stream_to_text(http_res)
|
|
458
483
|
raise models.SDKError(
|
|
@@ -499,6 +524,8 @@ class Models(BaseSDK):
|
|
|
499
524
|
|
|
500
525
|
if server_url is not None:
|
|
501
526
|
base_url = server_url
|
|
527
|
+
else:
|
|
528
|
+
base_url = self._get_url(base_url, url_variables)
|
|
502
529
|
|
|
503
530
|
request = models.DeleteModelV1ModelsModelIDDeleteRequest(
|
|
504
531
|
model_id=model_id,
|
|
@@ -530,6 +557,7 @@ class Models(BaseSDK):
|
|
|
530
557
|
|
|
531
558
|
http_res = await self.do_request_async(
|
|
532
559
|
hook_ctx=HookContext(
|
|
560
|
+
base_url=base_url or "",
|
|
533
561
|
operation_id="delete_model_v1_models__model_id__delete",
|
|
534
562
|
oauth2_scopes=[],
|
|
535
563
|
security_source=get_security_from_env(
|
|
@@ -541,12 +569,14 @@ class Models(BaseSDK):
|
|
|
541
569
|
retry_config=retry_config,
|
|
542
570
|
)
|
|
543
571
|
|
|
544
|
-
|
|
572
|
+
response_data: Any = None
|
|
545
573
|
if utils.match_response(http_res, "200", "application/json"):
|
|
546
574
|
return utils.unmarshal_json(http_res.text, models.DeleteModelOut)
|
|
547
575
|
if utils.match_response(http_res, "422", "application/json"):
|
|
548
|
-
|
|
549
|
-
|
|
576
|
+
response_data = utils.unmarshal_json(
|
|
577
|
+
http_res.text, models.HTTPValidationErrorData
|
|
578
|
+
)
|
|
579
|
+
raise models.HTTPValidationError(data=response_data)
|
|
550
580
|
if utils.match_response(http_res, "4XX", "*"):
|
|
551
581
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
552
582
|
raise models.SDKError(
|
|
@@ -597,6 +627,8 @@ class Models(BaseSDK):
|
|
|
597
627
|
|
|
598
628
|
if server_url is not None:
|
|
599
629
|
base_url = server_url
|
|
630
|
+
else:
|
|
631
|
+
base_url = self._get_url(base_url, url_variables)
|
|
600
632
|
|
|
601
633
|
request = models.JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(
|
|
602
634
|
model_id=model_id,
|
|
@@ -635,6 +667,7 @@ class Models(BaseSDK):
|
|
|
635
667
|
|
|
636
668
|
http_res = self.do_request(
|
|
637
669
|
hook_ctx=HookContext(
|
|
670
|
+
base_url=base_url or "",
|
|
638
671
|
operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model",
|
|
639
672
|
oauth2_scopes=[],
|
|
640
673
|
security_source=get_security_from_env(
|
|
@@ -698,6 +731,8 @@ class Models(BaseSDK):
|
|
|
698
731
|
|
|
699
732
|
if server_url is not None:
|
|
700
733
|
base_url = server_url
|
|
734
|
+
else:
|
|
735
|
+
base_url = self._get_url(base_url, url_variables)
|
|
701
736
|
|
|
702
737
|
request = models.JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(
|
|
703
738
|
model_id=model_id,
|
|
@@ -736,6 +771,7 @@ class Models(BaseSDK):
|
|
|
736
771
|
|
|
737
772
|
http_res = await self.do_request_async(
|
|
738
773
|
hook_ctx=HookContext(
|
|
774
|
+
base_url=base_url or "",
|
|
739
775
|
operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model",
|
|
740
776
|
oauth2_scopes=[],
|
|
741
777
|
security_source=get_security_from_env(
|
|
@@ -795,6 +831,8 @@ class Models(BaseSDK):
|
|
|
795
831
|
|
|
796
832
|
if server_url is not None:
|
|
797
833
|
base_url = server_url
|
|
834
|
+
else:
|
|
835
|
+
base_url = self._get_url(base_url, url_variables)
|
|
798
836
|
|
|
799
837
|
request = models.JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(
|
|
800
838
|
model_id=model_id,
|
|
@@ -826,6 +864,7 @@ class Models(BaseSDK):
|
|
|
826
864
|
|
|
827
865
|
http_res = self.do_request(
|
|
828
866
|
hook_ctx=HookContext(
|
|
867
|
+
base_url=base_url or "",
|
|
829
868
|
operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model",
|
|
830
869
|
oauth2_scopes=[],
|
|
831
870
|
security_source=get_security_from_env(
|
|
@@ -885,6 +924,8 @@ class Models(BaseSDK):
|
|
|
885
924
|
|
|
886
925
|
if server_url is not None:
|
|
887
926
|
base_url = server_url
|
|
927
|
+
else:
|
|
928
|
+
base_url = self._get_url(base_url, url_variables)
|
|
888
929
|
|
|
889
930
|
request = models.JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(
|
|
890
931
|
model_id=model_id,
|
|
@@ -916,6 +957,7 @@ class Models(BaseSDK):
|
|
|
916
957
|
|
|
917
958
|
http_res = await self.do_request_async(
|
|
918
959
|
hook_ctx=HookContext(
|
|
960
|
+
base_url=base_url or "",
|
|
919
961
|
operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model",
|
|
920
962
|
oauth2_scopes=[],
|
|
921
963
|
security_source=get_security_from_env(
|
|
@@ -975,6 +1017,8 @@ class Models(BaseSDK):
|
|
|
975
1017
|
|
|
976
1018
|
if server_url is not None:
|
|
977
1019
|
base_url = server_url
|
|
1020
|
+
else:
|
|
1021
|
+
base_url = self._get_url(base_url, url_variables)
|
|
978
1022
|
|
|
979
1023
|
request = models.JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(
|
|
980
1024
|
model_id=model_id,
|
|
@@ -1006,6 +1050,7 @@ class Models(BaseSDK):
|
|
|
1006
1050
|
|
|
1007
1051
|
http_res = self.do_request(
|
|
1008
1052
|
hook_ctx=HookContext(
|
|
1053
|
+
base_url=base_url or "",
|
|
1009
1054
|
operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model",
|
|
1010
1055
|
oauth2_scopes=[],
|
|
1011
1056
|
security_source=get_security_from_env(
|
|
@@ -1065,6 +1110,8 @@ class Models(BaseSDK):
|
|
|
1065
1110
|
|
|
1066
1111
|
if server_url is not None:
|
|
1067
1112
|
base_url = server_url
|
|
1113
|
+
else:
|
|
1114
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1068
1115
|
|
|
1069
1116
|
request = models.JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(
|
|
1070
1117
|
model_id=model_id,
|
|
@@ -1096,6 +1143,7 @@ class Models(BaseSDK):
|
|
|
1096
1143
|
|
|
1097
1144
|
http_res = await self.do_request_async(
|
|
1098
1145
|
hook_ctx=HookContext(
|
|
1146
|
+
base_url=base_url or "",
|
|
1099
1147
|
operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model",
|
|
1100
1148
|
oauth2_scopes=[],
|
|
1101
1149
|
security_source=get_security_from_env(
|
mistralai/ocr.py
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from mistralai import models, utils
|
|
5
|
+
from mistralai._hooks import HookContext
|
|
6
|
+
from mistralai.types import Nullable, OptionalNullable, UNSET
|
|
7
|
+
from mistralai.utils import get_security_from_env
|
|
8
|
+
from typing import Any, List, Mapping, Optional, Union
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Ocr(BaseSDK):
|
|
12
|
+
r"""OCR API"""
|
|
13
|
+
|
|
14
|
+
def process(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
model: Nullable[str],
|
|
18
|
+
document: Union[models.Document, models.DocumentTypedDict],
|
|
19
|
+
id: Optional[str] = None,
|
|
20
|
+
pages: OptionalNullable[List[int]] = UNSET,
|
|
21
|
+
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
22
|
+
image_limit: OptionalNullable[int] = UNSET,
|
|
23
|
+
image_min_size: OptionalNullable[int] = UNSET,
|
|
24
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
25
|
+
server_url: Optional[str] = None,
|
|
26
|
+
timeout_ms: Optional[int] = None,
|
|
27
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
28
|
+
) -> models.OCRResponse:
|
|
29
|
+
r"""OCR
|
|
30
|
+
|
|
31
|
+
:param model:
|
|
32
|
+
:param document: Document to run OCR on
|
|
33
|
+
:param id:
|
|
34
|
+
:param pages: Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0
|
|
35
|
+
:param include_image_base64: Include image URLs in response
|
|
36
|
+
:param image_limit: Max images to extract
|
|
37
|
+
:param image_min_size: Minimum height and width of image to extract
|
|
38
|
+
:param retries: Override the default retry configuration for this method
|
|
39
|
+
:param server_url: Override the default server URL for this method
|
|
40
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
41
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
42
|
+
"""
|
|
43
|
+
base_url = None
|
|
44
|
+
url_variables = None
|
|
45
|
+
if timeout_ms is None:
|
|
46
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
47
|
+
|
|
48
|
+
if server_url is not None:
|
|
49
|
+
base_url = server_url
|
|
50
|
+
else:
|
|
51
|
+
base_url = self._get_url(base_url, url_variables)
|
|
52
|
+
|
|
53
|
+
request = models.OCRRequest(
|
|
54
|
+
model=model,
|
|
55
|
+
id=id,
|
|
56
|
+
document=utils.get_pydantic_model(document, models.Document),
|
|
57
|
+
pages=pages,
|
|
58
|
+
include_image_base64=include_image_base64,
|
|
59
|
+
image_limit=image_limit,
|
|
60
|
+
image_min_size=image_min_size,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
req = self._build_request(
|
|
64
|
+
method="POST",
|
|
65
|
+
path="/v1/ocr",
|
|
66
|
+
base_url=base_url,
|
|
67
|
+
url_variables=url_variables,
|
|
68
|
+
request=request,
|
|
69
|
+
request_body_required=True,
|
|
70
|
+
request_has_path_params=False,
|
|
71
|
+
request_has_query_params=True,
|
|
72
|
+
user_agent_header="user-agent",
|
|
73
|
+
accept_header_value="application/json",
|
|
74
|
+
http_headers=http_headers,
|
|
75
|
+
security=self.sdk_configuration.security,
|
|
76
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
77
|
+
request, False, False, "json", models.OCRRequest
|
|
78
|
+
),
|
|
79
|
+
timeout_ms=timeout_ms,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if retries == UNSET:
|
|
83
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
84
|
+
retries = self.sdk_configuration.retry_config
|
|
85
|
+
|
|
86
|
+
retry_config = None
|
|
87
|
+
if isinstance(retries, utils.RetryConfig):
|
|
88
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
89
|
+
|
|
90
|
+
http_res = self.do_request(
|
|
91
|
+
hook_ctx=HookContext(
|
|
92
|
+
base_url=base_url or "",
|
|
93
|
+
operation_id="ocr_v1_ocr_post",
|
|
94
|
+
oauth2_scopes=[],
|
|
95
|
+
security_source=get_security_from_env(
|
|
96
|
+
self.sdk_configuration.security, models.Security
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
request=req,
|
|
100
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
101
|
+
retry_config=retry_config,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
response_data: Any = None
|
|
105
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
106
|
+
return utils.unmarshal_json(http_res.text, models.OCRResponse)
|
|
107
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
108
|
+
response_data = utils.unmarshal_json(
|
|
109
|
+
http_res.text, models.HTTPValidationErrorData
|
|
110
|
+
)
|
|
111
|
+
raise models.HTTPValidationError(data=response_data)
|
|
112
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
113
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
114
|
+
raise models.SDKError(
|
|
115
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
116
|
+
)
|
|
117
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
118
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
119
|
+
raise models.SDKError(
|
|
120
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
content_type = http_res.headers.get("Content-Type")
|
|
124
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
125
|
+
raise models.SDKError(
|
|
126
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
127
|
+
http_res.status_code,
|
|
128
|
+
http_res_text,
|
|
129
|
+
http_res,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
async def process_async(
|
|
133
|
+
self,
|
|
134
|
+
*,
|
|
135
|
+
model: Nullable[str],
|
|
136
|
+
document: Union[models.Document, models.DocumentTypedDict],
|
|
137
|
+
id: Optional[str] = None,
|
|
138
|
+
pages: OptionalNullable[List[int]] = UNSET,
|
|
139
|
+
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
140
|
+
image_limit: OptionalNullable[int] = UNSET,
|
|
141
|
+
image_min_size: OptionalNullable[int] = UNSET,
|
|
142
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
143
|
+
server_url: Optional[str] = None,
|
|
144
|
+
timeout_ms: Optional[int] = None,
|
|
145
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
146
|
+
) -> models.OCRResponse:
|
|
147
|
+
r"""OCR
|
|
148
|
+
|
|
149
|
+
:param model:
|
|
150
|
+
:param document: Document to run OCR on
|
|
151
|
+
:param id:
|
|
152
|
+
:param pages: Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0
|
|
153
|
+
:param include_image_base64: Include image URLs in response
|
|
154
|
+
:param image_limit: Max images to extract
|
|
155
|
+
:param image_min_size: Minimum height and width of image to extract
|
|
156
|
+
:param retries: Override the default retry configuration for this method
|
|
157
|
+
:param server_url: Override the default server URL for this method
|
|
158
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
159
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
160
|
+
"""
|
|
161
|
+
base_url = None
|
|
162
|
+
url_variables = None
|
|
163
|
+
if timeout_ms is None:
|
|
164
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
165
|
+
|
|
166
|
+
if server_url is not None:
|
|
167
|
+
base_url = server_url
|
|
168
|
+
else:
|
|
169
|
+
base_url = self._get_url(base_url, url_variables)
|
|
170
|
+
|
|
171
|
+
request = models.OCRRequest(
|
|
172
|
+
model=model,
|
|
173
|
+
id=id,
|
|
174
|
+
document=utils.get_pydantic_model(document, models.Document),
|
|
175
|
+
pages=pages,
|
|
176
|
+
include_image_base64=include_image_base64,
|
|
177
|
+
image_limit=image_limit,
|
|
178
|
+
image_min_size=image_min_size,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
req = self._build_request_async(
|
|
182
|
+
method="POST",
|
|
183
|
+
path="/v1/ocr",
|
|
184
|
+
base_url=base_url,
|
|
185
|
+
url_variables=url_variables,
|
|
186
|
+
request=request,
|
|
187
|
+
request_body_required=True,
|
|
188
|
+
request_has_path_params=False,
|
|
189
|
+
request_has_query_params=True,
|
|
190
|
+
user_agent_header="user-agent",
|
|
191
|
+
accept_header_value="application/json",
|
|
192
|
+
http_headers=http_headers,
|
|
193
|
+
security=self.sdk_configuration.security,
|
|
194
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
195
|
+
request, False, False, "json", models.OCRRequest
|
|
196
|
+
),
|
|
197
|
+
timeout_ms=timeout_ms,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
if retries == UNSET:
|
|
201
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
202
|
+
retries = self.sdk_configuration.retry_config
|
|
203
|
+
|
|
204
|
+
retry_config = None
|
|
205
|
+
if isinstance(retries, utils.RetryConfig):
|
|
206
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
207
|
+
|
|
208
|
+
http_res = await self.do_request_async(
|
|
209
|
+
hook_ctx=HookContext(
|
|
210
|
+
base_url=base_url or "",
|
|
211
|
+
operation_id="ocr_v1_ocr_post",
|
|
212
|
+
oauth2_scopes=[],
|
|
213
|
+
security_source=get_security_from_env(
|
|
214
|
+
self.sdk_configuration.security, models.Security
|
|
215
|
+
),
|
|
216
|
+
),
|
|
217
|
+
request=req,
|
|
218
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
219
|
+
retry_config=retry_config,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
response_data: Any = None
|
|
223
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
224
|
+
return utils.unmarshal_json(http_res.text, models.OCRResponse)
|
|
225
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
226
|
+
response_data = utils.unmarshal_json(
|
|
227
|
+
http_res.text, models.HTTPValidationErrorData
|
|
228
|
+
)
|
|
229
|
+
raise models.HTTPValidationError(data=response_data)
|
|
230
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
231
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
232
|
+
raise models.SDKError(
|
|
233
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
234
|
+
)
|
|
235
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
236
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
237
|
+
raise models.SDKError(
|
|
238
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
content_type = http_res.headers.get("Content-Type")
|
|
242
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
243
|
+
raise models.SDKError(
|
|
244
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
245
|
+
http_res.status_code,
|
|
246
|
+
http_res_text,
|
|
247
|
+
http_res,
|
|
248
|
+
)
|