mistralai 1.3.1__py3-none-any.whl → 1.5.0__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/__init__.py +10 -1
- mistralai/_version.py +4 -1
- mistralai/agents.py +58 -14
- mistralai/chat.py +140 -14
- mistralai/classifiers.py +32 -20
- mistralai/embeddings.py +16 -10
- mistralai/extra/README.md +56 -0
- mistralai/extra/__init__.py +5 -0
- mistralai/extra/struct_chat.py +41 -0
- mistralai/extra/tests/__init__.py +0 -0
- mistralai/extra/tests/test_struct_chat.py +103 -0
- mistralai/extra/tests/test_utils.py +162 -0
- mistralai/extra/utils/__init__.py +3 -0
- mistralai/extra/utils/_pydantic_helper.py +20 -0
- mistralai/extra/utils/response_format.py +24 -0
- mistralai/files.py +94 -34
- mistralai/fim.py +30 -14
- mistralai/httpclient.py +50 -0
- mistralai/jobs.py +80 -32
- mistralai/mistral_jobs.py +64 -24
- mistralai/models/__init__.py +8 -0
- mistralai/models/agentscompletionrequest.py +5 -0
- mistralai/models/agentscompletionstreamrequest.py +5 -0
- mistralai/models/chatcompletionrequest.py +5 -0
- mistralai/models/chatcompletionstreamrequest.py +5 -0
- mistralai/models/fileschema.py +3 -2
- mistralai/models/function.py +3 -0
- mistralai/models/jsonschema.py +55 -0
- mistralai/models/prediction.py +26 -0
- mistralai/models/responseformat.py +36 -1
- mistralai/models/responseformats.py +1 -1
- mistralai/models/retrievefileout.py +3 -2
- mistralai/models/toolcall.py +3 -0
- mistralai/models/uploadfileout.py +3 -2
- mistralai/models_.py +92 -48
- mistralai/sdk.py +13 -3
- mistralai/sdkconfiguration.py +10 -4
- {mistralai-1.3.1.dist-info → mistralai-1.5.0.dist-info}/METADATA +41 -42
- {mistralai-1.3.1.dist-info → mistralai-1.5.0.dist-info}/RECORD +43 -33
- {mistralai-1.3.1.dist-info → mistralai-1.5.0.dist-info}/WHEEL +1 -1
- mistralai_azure/_hooks/custom_user_agent.py +1 -1
- mistralai_gcp/sdk.py +1 -2
- py.typed +0 -1
- {mistralai-1.3.1.dist-info → mistralai-1.5.0.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import pydantic
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import Any, Dict, Optional
|
|
8
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class JSONSchemaTypedDict(TypedDict):
|
|
12
|
+
name: str
|
|
13
|
+
schema_definition: Dict[str, Any]
|
|
14
|
+
description: NotRequired[Nullable[str]]
|
|
15
|
+
strict: NotRequired[bool]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSONSchema(BaseModel):
|
|
19
|
+
name: str
|
|
20
|
+
|
|
21
|
+
schema_definition: Annotated[Dict[str, Any], pydantic.Field(alias="schema")]
|
|
22
|
+
|
|
23
|
+
description: OptionalNullable[str] = UNSET
|
|
24
|
+
|
|
25
|
+
strict: Optional[bool] = False
|
|
26
|
+
|
|
27
|
+
@model_serializer(mode="wrap")
|
|
28
|
+
def serialize_model(self, handler):
|
|
29
|
+
optional_fields = ["description", "strict"]
|
|
30
|
+
nullable_fields = ["description"]
|
|
31
|
+
null_default_fields = []
|
|
32
|
+
|
|
33
|
+
serialized = handler(self)
|
|
34
|
+
|
|
35
|
+
m = {}
|
|
36
|
+
|
|
37
|
+
for n, f in self.model_fields.items():
|
|
38
|
+
k = f.alias or n
|
|
39
|
+
val = serialized.get(k)
|
|
40
|
+
serialized.pop(k, None)
|
|
41
|
+
|
|
42
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
43
|
+
is_set = (
|
|
44
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
45
|
+
or k in null_default_fields
|
|
46
|
+
) # pylint: disable=no-member
|
|
47
|
+
|
|
48
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
49
|
+
m[k] = val
|
|
50
|
+
elif val != UNSET_SENTINEL and (
|
|
51
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
52
|
+
):
|
|
53
|
+
m[k] = val
|
|
54
|
+
|
|
55
|
+
return m
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import BaseModel
|
|
5
|
+
from mistralai.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, NotRequired, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
PredictionType = Literal["content"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PredictionTypedDict(TypedDict):
|
|
16
|
+
type: PredictionType
|
|
17
|
+
content: NotRequired[str]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Prediction(BaseModel):
|
|
21
|
+
TYPE: Annotated[
|
|
22
|
+
Annotated[Optional[PredictionType], AfterValidator(validate_const("content"))],
|
|
23
|
+
pydantic.Field(alias="type"),
|
|
24
|
+
] = "content"
|
|
25
|
+
|
|
26
|
+
content: Optional[str] = ""
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
+
from .jsonschema import JSONSchema, JSONSchemaTypedDict
|
|
4
5
|
from .responseformats import ResponseFormats
|
|
5
|
-
from mistralai.types import BaseModel
|
|
6
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
|
+
from pydantic import model_serializer
|
|
6
8
|
from typing import Optional
|
|
7
9
|
from typing_extensions import NotRequired, TypedDict
|
|
8
10
|
|
|
@@ -10,8 +12,41 @@ from typing_extensions import NotRequired, TypedDict
|
|
|
10
12
|
class ResponseFormatTypedDict(TypedDict):
|
|
11
13
|
type: NotRequired[ResponseFormats]
|
|
12
14
|
r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
|
|
15
|
+
json_schema: NotRequired[Nullable[JSONSchemaTypedDict]]
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
class ResponseFormat(BaseModel):
|
|
16
19
|
type: Optional[ResponseFormats] = None
|
|
17
20
|
r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
|
|
21
|
+
|
|
22
|
+
json_schema: OptionalNullable[JSONSchema] = UNSET
|
|
23
|
+
|
|
24
|
+
@model_serializer(mode="wrap")
|
|
25
|
+
def serialize_model(self, handler):
|
|
26
|
+
optional_fields = ["type", "json_schema"]
|
|
27
|
+
nullable_fields = ["json_schema"]
|
|
28
|
+
null_default_fields = []
|
|
29
|
+
|
|
30
|
+
serialized = handler(self)
|
|
31
|
+
|
|
32
|
+
m = {}
|
|
33
|
+
|
|
34
|
+
for n, f in self.model_fields.items():
|
|
35
|
+
k = f.alias or n
|
|
36
|
+
val = serialized.get(k)
|
|
37
|
+
serialized.pop(k, None)
|
|
38
|
+
|
|
39
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
40
|
+
is_set = (
|
|
41
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
42
|
+
or k in null_default_fields
|
|
43
|
+
) # pylint: disable=no-member
|
|
44
|
+
|
|
45
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
46
|
+
m[k] = val
|
|
47
|
+
elif val != UNSET_SENTINEL and (
|
|
48
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
49
|
+
):
|
|
50
|
+
m[k] = val
|
|
51
|
+
|
|
52
|
+
return m
|
|
@@ -4,5 +4,5 @@ from __future__ import annotations
|
|
|
4
4
|
from typing import Literal
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
ResponseFormats = Literal["text", "json_object"]
|
|
7
|
+
ResponseFormats = Literal["text", "json_object", "json_schema"]
|
|
8
8
|
r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
|
|
@@ -6,6 +6,7 @@ from .sampletype import SampleType
|
|
|
6
6
|
from .source import Source
|
|
7
7
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
8
8
|
from mistralai.utils import validate_open_enum
|
|
9
|
+
import pydantic
|
|
9
10
|
from pydantic import model_serializer
|
|
10
11
|
from pydantic.functional_validators import PlainValidator
|
|
11
12
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
@@ -16,7 +17,7 @@ class RetrieveFileOutTypedDict(TypedDict):
|
|
|
16
17
|
r"""The unique identifier of the file."""
|
|
17
18
|
object: str
|
|
18
19
|
r"""The object type, which is always \"file\"."""
|
|
19
|
-
|
|
20
|
+
size_bytes: int
|
|
20
21
|
r"""The size of the file, in bytes."""
|
|
21
22
|
created_at: int
|
|
22
23
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
@@ -36,7 +37,7 @@ class RetrieveFileOut(BaseModel):
|
|
|
36
37
|
object: str
|
|
37
38
|
r"""The object type, which is always \"file\"."""
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
size_bytes: Annotated[int, pydantic.Field(alias="bytes")]
|
|
40
41
|
r"""The size of the file, in bytes."""
|
|
41
42
|
|
|
42
43
|
created_at: int
|
mistralai/models/toolcall.py
CHANGED
|
@@ -14,6 +14,7 @@ class ToolCallTypedDict(TypedDict):
|
|
|
14
14
|
function: FunctionCallTypedDict
|
|
15
15
|
id: NotRequired[str]
|
|
16
16
|
type: NotRequired[ToolTypes]
|
|
17
|
+
index: NotRequired[int]
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class ToolCall(BaseModel):
|
|
@@ -24,3 +25,5 @@ class ToolCall(BaseModel):
|
|
|
24
25
|
type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
|
|
25
26
|
None
|
|
26
27
|
)
|
|
28
|
+
|
|
29
|
+
index: Optional[int] = 0
|
|
@@ -6,6 +6,7 @@ from .sampletype import SampleType
|
|
|
6
6
|
from .source import Source
|
|
7
7
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
8
8
|
from mistralai.utils import validate_open_enum
|
|
9
|
+
import pydantic
|
|
9
10
|
from pydantic import model_serializer
|
|
10
11
|
from pydantic.functional_validators import PlainValidator
|
|
11
12
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
@@ -16,7 +17,7 @@ class UploadFileOutTypedDict(TypedDict):
|
|
|
16
17
|
r"""The unique identifier of the file."""
|
|
17
18
|
object: str
|
|
18
19
|
r"""The object type, which is always \"file\"."""
|
|
19
|
-
|
|
20
|
+
size_bytes: int
|
|
20
21
|
r"""The size of the file, in bytes."""
|
|
21
22
|
created_at: int
|
|
22
23
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
@@ -35,7 +36,7 @@ class UploadFileOut(BaseModel):
|
|
|
35
36
|
object: str
|
|
36
37
|
r"""The object type, which is always \"file\"."""
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
size_bytes: Annotated[int, pydantic.Field(alias="bytes")]
|
|
39
40
|
r"""The size of the file, in bytes."""
|
|
40
41
|
|
|
41
42
|
created_at: int
|
mistralai/models_.py
CHANGED
|
@@ -18,7 +18,7 @@ class Models(BaseSDK):
|
|
|
18
18
|
server_url: Optional[str] = None,
|
|
19
19
|
timeout_ms: Optional[int] = None,
|
|
20
20
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
21
|
-
) ->
|
|
21
|
+
) -> models.ModelList:
|
|
22
22
|
r"""List Models
|
|
23
23
|
|
|
24
24
|
List all models available to the user.
|
|
@@ -74,11 +74,16 @@ class Models(BaseSDK):
|
|
|
74
74
|
|
|
75
75
|
data: Any = None
|
|
76
76
|
if utils.match_response(http_res, "200", "application/json"):
|
|
77
|
-
return utils.unmarshal_json(http_res.text,
|
|
77
|
+
return utils.unmarshal_json(http_res.text, models.ModelList)
|
|
78
78
|
if utils.match_response(http_res, "422", "application/json"):
|
|
79
79
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
80
80
|
raise models.HTTPValidationError(data=data)
|
|
81
|
-
if utils.match_response(http_res,
|
|
81
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
82
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
83
|
+
raise models.SDKError(
|
|
84
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
85
|
+
)
|
|
86
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
82
87
|
http_res_text = utils.stream_to_text(http_res)
|
|
83
88
|
raise models.SDKError(
|
|
84
89
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -100,7 +105,7 @@ class Models(BaseSDK):
|
|
|
100
105
|
server_url: Optional[str] = None,
|
|
101
106
|
timeout_ms: Optional[int] = None,
|
|
102
107
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
103
|
-
) ->
|
|
108
|
+
) -> models.ModelList:
|
|
104
109
|
r"""List Models
|
|
105
110
|
|
|
106
111
|
List all models available to the user.
|
|
@@ -156,11 +161,16 @@ class Models(BaseSDK):
|
|
|
156
161
|
|
|
157
162
|
data: Any = None
|
|
158
163
|
if utils.match_response(http_res, "200", "application/json"):
|
|
159
|
-
return utils.unmarshal_json(http_res.text,
|
|
164
|
+
return utils.unmarshal_json(http_res.text, models.ModelList)
|
|
160
165
|
if utils.match_response(http_res, "422", "application/json"):
|
|
161
166
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
162
167
|
raise models.HTTPValidationError(data=data)
|
|
163
|
-
if utils.match_response(http_res,
|
|
168
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
169
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
170
|
+
raise models.SDKError(
|
|
171
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
172
|
+
)
|
|
173
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
164
174
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
165
175
|
raise models.SDKError(
|
|
166
176
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -183,9 +193,7 @@ class Models(BaseSDK):
|
|
|
183
193
|
server_url: Optional[str] = None,
|
|
184
194
|
timeout_ms: Optional[int] = None,
|
|
185
195
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
186
|
-
) ->
|
|
187
|
-
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
|
|
188
|
-
]:
|
|
196
|
+
) -> models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet:
|
|
189
197
|
r"""Retrieve Model
|
|
190
198
|
|
|
191
199
|
Retrieve a model information.
|
|
@@ -249,14 +257,17 @@ class Models(BaseSDK):
|
|
|
249
257
|
if utils.match_response(http_res, "200", "application/json"):
|
|
250
258
|
return utils.unmarshal_json(
|
|
251
259
|
http_res.text,
|
|
252
|
-
|
|
253
|
-
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
|
|
254
|
-
],
|
|
260
|
+
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet,
|
|
255
261
|
)
|
|
256
262
|
if utils.match_response(http_res, "422", "application/json"):
|
|
257
263
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
258
264
|
raise models.HTTPValidationError(data=data)
|
|
259
|
-
if utils.match_response(http_res,
|
|
265
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
266
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
267
|
+
raise models.SDKError(
|
|
268
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
269
|
+
)
|
|
270
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
260
271
|
http_res_text = utils.stream_to_text(http_res)
|
|
261
272
|
raise models.SDKError(
|
|
262
273
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -279,9 +290,7 @@ class Models(BaseSDK):
|
|
|
279
290
|
server_url: Optional[str] = None,
|
|
280
291
|
timeout_ms: Optional[int] = None,
|
|
281
292
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
282
|
-
) ->
|
|
283
|
-
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
|
|
284
|
-
]:
|
|
293
|
+
) -> models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet:
|
|
285
294
|
r"""Retrieve Model
|
|
286
295
|
|
|
287
296
|
Retrieve a model information.
|
|
@@ -345,14 +354,17 @@ class Models(BaseSDK):
|
|
|
345
354
|
if utils.match_response(http_res, "200", "application/json"):
|
|
346
355
|
return utils.unmarshal_json(
|
|
347
356
|
http_res.text,
|
|
348
|
-
|
|
349
|
-
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
|
|
350
|
-
],
|
|
357
|
+
models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet,
|
|
351
358
|
)
|
|
352
359
|
if utils.match_response(http_res, "422", "application/json"):
|
|
353
360
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
354
361
|
raise models.HTTPValidationError(data=data)
|
|
355
|
-
if utils.match_response(http_res,
|
|
362
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
363
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
364
|
+
raise models.SDKError(
|
|
365
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
366
|
+
)
|
|
367
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
356
368
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
357
369
|
raise models.SDKError(
|
|
358
370
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -375,7 +387,7 @@ class Models(BaseSDK):
|
|
|
375
387
|
server_url: Optional[str] = None,
|
|
376
388
|
timeout_ms: Optional[int] = None,
|
|
377
389
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
378
|
-
) ->
|
|
390
|
+
) -> models.DeleteModelOut:
|
|
379
391
|
r"""Delete Model
|
|
380
392
|
|
|
381
393
|
Delete a fine-tuned model.
|
|
@@ -437,11 +449,16 @@ class Models(BaseSDK):
|
|
|
437
449
|
|
|
438
450
|
data: Any = None
|
|
439
451
|
if utils.match_response(http_res, "200", "application/json"):
|
|
440
|
-
return utils.unmarshal_json(http_res.text,
|
|
452
|
+
return utils.unmarshal_json(http_res.text, models.DeleteModelOut)
|
|
441
453
|
if utils.match_response(http_res, "422", "application/json"):
|
|
442
454
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
443
455
|
raise models.HTTPValidationError(data=data)
|
|
444
|
-
if utils.match_response(http_res,
|
|
456
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
457
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
458
|
+
raise models.SDKError(
|
|
459
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
460
|
+
)
|
|
461
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
445
462
|
http_res_text = utils.stream_to_text(http_res)
|
|
446
463
|
raise models.SDKError(
|
|
447
464
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -464,7 +481,7 @@ class Models(BaseSDK):
|
|
|
464
481
|
server_url: Optional[str] = None,
|
|
465
482
|
timeout_ms: Optional[int] = None,
|
|
466
483
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
467
|
-
) ->
|
|
484
|
+
) -> models.DeleteModelOut:
|
|
468
485
|
r"""Delete Model
|
|
469
486
|
|
|
470
487
|
Delete a fine-tuned model.
|
|
@@ -526,11 +543,16 @@ class Models(BaseSDK):
|
|
|
526
543
|
|
|
527
544
|
data: Any = None
|
|
528
545
|
if utils.match_response(http_res, "200", "application/json"):
|
|
529
|
-
return utils.unmarshal_json(http_res.text,
|
|
546
|
+
return utils.unmarshal_json(http_res.text, models.DeleteModelOut)
|
|
530
547
|
if utils.match_response(http_res, "422", "application/json"):
|
|
531
548
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
532
549
|
raise models.HTTPValidationError(data=data)
|
|
533
|
-
if utils.match_response(http_res,
|
|
550
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
551
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
552
|
+
raise models.SDKError(
|
|
553
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
554
|
+
)
|
|
555
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
534
556
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
535
557
|
raise models.SDKError(
|
|
536
558
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -555,7 +577,7 @@ class Models(BaseSDK):
|
|
|
555
577
|
server_url: Optional[str] = None,
|
|
556
578
|
timeout_ms: Optional[int] = None,
|
|
557
579
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
558
|
-
) ->
|
|
580
|
+
) -> models.FTModelOut:
|
|
559
581
|
r"""Update Fine Tuned Model
|
|
560
582
|
|
|
561
583
|
Update a model name or description.
|
|
@@ -625,8 +647,13 @@ class Models(BaseSDK):
|
|
|
625
647
|
)
|
|
626
648
|
|
|
627
649
|
if utils.match_response(http_res, "200", "application/json"):
|
|
628
|
-
return utils.unmarshal_json(http_res.text,
|
|
629
|
-
if utils.match_response(http_res,
|
|
650
|
+
return utils.unmarshal_json(http_res.text, models.FTModelOut)
|
|
651
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
652
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
653
|
+
raise models.SDKError(
|
|
654
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
655
|
+
)
|
|
656
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
630
657
|
http_res_text = utils.stream_to_text(http_res)
|
|
631
658
|
raise models.SDKError(
|
|
632
659
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -651,7 +678,7 @@ class Models(BaseSDK):
|
|
|
651
678
|
server_url: Optional[str] = None,
|
|
652
679
|
timeout_ms: Optional[int] = None,
|
|
653
680
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
654
|
-
) ->
|
|
681
|
+
) -> models.FTModelOut:
|
|
655
682
|
r"""Update Fine Tuned Model
|
|
656
683
|
|
|
657
684
|
Update a model name or description.
|
|
@@ -721,8 +748,13 @@ class Models(BaseSDK):
|
|
|
721
748
|
)
|
|
722
749
|
|
|
723
750
|
if utils.match_response(http_res, "200", "application/json"):
|
|
724
|
-
return utils.unmarshal_json(http_res.text,
|
|
725
|
-
if utils.match_response(http_res,
|
|
751
|
+
return utils.unmarshal_json(http_res.text, models.FTModelOut)
|
|
752
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
753
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
754
|
+
raise models.SDKError(
|
|
755
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
756
|
+
)
|
|
757
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
726
758
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
727
759
|
raise models.SDKError(
|
|
728
760
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -745,7 +777,7 @@ class Models(BaseSDK):
|
|
|
745
777
|
server_url: Optional[str] = None,
|
|
746
778
|
timeout_ms: Optional[int] = None,
|
|
747
779
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
748
|
-
) ->
|
|
780
|
+
) -> models.ArchiveFTModelOut:
|
|
749
781
|
r"""Archive Fine Tuned Model
|
|
750
782
|
|
|
751
783
|
Archive a fine-tuned model.
|
|
@@ -806,10 +838,13 @@ class Models(BaseSDK):
|
|
|
806
838
|
)
|
|
807
839
|
|
|
808
840
|
if utils.match_response(http_res, "200", "application/json"):
|
|
809
|
-
return utils.unmarshal_json(
|
|
810
|
-
|
|
841
|
+
return utils.unmarshal_json(http_res.text, models.ArchiveFTModelOut)
|
|
842
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
843
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
844
|
+
raise models.SDKError(
|
|
845
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
811
846
|
)
|
|
812
|
-
if utils.match_response(http_res,
|
|
847
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
813
848
|
http_res_text = utils.stream_to_text(http_res)
|
|
814
849
|
raise models.SDKError(
|
|
815
850
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -832,7 +867,7 @@ class Models(BaseSDK):
|
|
|
832
867
|
server_url: Optional[str] = None,
|
|
833
868
|
timeout_ms: Optional[int] = None,
|
|
834
869
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
835
|
-
) ->
|
|
870
|
+
) -> models.ArchiveFTModelOut:
|
|
836
871
|
r"""Archive Fine Tuned Model
|
|
837
872
|
|
|
838
873
|
Archive a fine-tuned model.
|
|
@@ -893,10 +928,13 @@ class Models(BaseSDK):
|
|
|
893
928
|
)
|
|
894
929
|
|
|
895
930
|
if utils.match_response(http_res, "200", "application/json"):
|
|
896
|
-
return utils.unmarshal_json(
|
|
897
|
-
|
|
931
|
+
return utils.unmarshal_json(http_res.text, models.ArchiveFTModelOut)
|
|
932
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
933
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
934
|
+
raise models.SDKError(
|
|
935
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
898
936
|
)
|
|
899
|
-
if utils.match_response(http_res,
|
|
937
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
900
938
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
901
939
|
raise models.SDKError(
|
|
902
940
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -919,7 +957,7 @@ class Models(BaseSDK):
|
|
|
919
957
|
server_url: Optional[str] = None,
|
|
920
958
|
timeout_ms: Optional[int] = None,
|
|
921
959
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
922
|
-
) ->
|
|
960
|
+
) -> models.UnarchiveFTModelOut:
|
|
923
961
|
r"""Unarchive Fine Tuned Model
|
|
924
962
|
|
|
925
963
|
Un-archive a fine-tuned model.
|
|
@@ -980,10 +1018,13 @@ class Models(BaseSDK):
|
|
|
980
1018
|
)
|
|
981
1019
|
|
|
982
1020
|
if utils.match_response(http_res, "200", "application/json"):
|
|
983
|
-
return utils.unmarshal_json(
|
|
984
|
-
|
|
1021
|
+
return utils.unmarshal_json(http_res.text, models.UnarchiveFTModelOut)
|
|
1022
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1023
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1024
|
+
raise models.SDKError(
|
|
1025
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
985
1026
|
)
|
|
986
|
-
if utils.match_response(http_res,
|
|
1027
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
987
1028
|
http_res_text = utils.stream_to_text(http_res)
|
|
988
1029
|
raise models.SDKError(
|
|
989
1030
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
@@ -1006,7 +1047,7 @@ class Models(BaseSDK):
|
|
|
1006
1047
|
server_url: Optional[str] = None,
|
|
1007
1048
|
timeout_ms: Optional[int] = None,
|
|
1008
1049
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
1009
|
-
) ->
|
|
1050
|
+
) -> models.UnarchiveFTModelOut:
|
|
1010
1051
|
r"""Unarchive Fine Tuned Model
|
|
1011
1052
|
|
|
1012
1053
|
Un-archive a fine-tuned model.
|
|
@@ -1067,10 +1108,13 @@ class Models(BaseSDK):
|
|
|
1067
1108
|
)
|
|
1068
1109
|
|
|
1069
1110
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1070
|
-
return utils.unmarshal_json(
|
|
1071
|
-
|
|
1111
|
+
return utils.unmarshal_json(http_res.text, models.UnarchiveFTModelOut)
|
|
1112
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1113
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1114
|
+
raise models.SDKError(
|
|
1115
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1072
1116
|
)
|
|
1073
|
-
if utils.match_response(http_res,
|
|
1117
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1074
1118
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1075
1119
|
raise models.SDKError(
|
|
1076
1120
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
mistralai/sdk.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
|
-
from .httpclient import AsyncHttpClient, HttpClient
|
|
4
|
+
from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
|
|
5
5
|
from .sdkconfiguration import SDKConfiguration
|
|
6
6
|
from .utils.logger import Logger, get_default_logger
|
|
7
7
|
from .utils.retries import RetryConfig
|
|
@@ -18,7 +18,8 @@ from mistralai.fim import Fim
|
|
|
18
18
|
from mistralai.fine_tuning import FineTuning
|
|
19
19
|
from mistralai.models_ import Models
|
|
20
20
|
from mistralai.types import OptionalNullable, UNSET
|
|
21
|
-
from typing import Any, Callable, Dict, Optional, Union
|
|
21
|
+
from typing import Any, Callable, Dict, Optional, Union, cast
|
|
22
|
+
import weakref
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
class Mistral(BaseSDK):
|
|
@@ -83,7 +84,8 @@ class Mistral(BaseSDK):
|
|
|
83
84
|
|
|
84
85
|
security: Any = None
|
|
85
86
|
if callable(api_key):
|
|
86
|
-
|
|
87
|
+
# pylint: disable=unnecessary-lambda-assignment
|
|
88
|
+
security = lambda: models.Security(api_key=api_key())
|
|
87
89
|
else:
|
|
88
90
|
security = models.Security(api_key=api_key)
|
|
89
91
|
|
|
@@ -117,6 +119,14 @@ class Mistral(BaseSDK):
|
|
|
117
119
|
# pylint: disable=protected-access
|
|
118
120
|
self.sdk_configuration.__dict__["_hooks"] = hooks
|
|
119
121
|
|
|
122
|
+
weakref.finalize(
|
|
123
|
+
self,
|
|
124
|
+
close_clients,
|
|
125
|
+
cast(ClientOwner, self.sdk_configuration),
|
|
126
|
+
self.sdk_configuration.client,
|
|
127
|
+
self.sdk_configuration.async_client,
|
|
128
|
+
)
|
|
129
|
+
|
|
120
130
|
self._init_sdks()
|
|
121
131
|
|
|
122
132
|
def _init_sdks(self):
|
mistralai/sdkconfiguration.py
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from ._hooks import SDKHooks
|
|
4
|
+
from ._version import (
|
|
5
|
+
__gen_version__,
|
|
6
|
+
__openapi_doc_version__,
|
|
7
|
+
__user_agent__,
|
|
8
|
+
__version__,
|
|
9
|
+
)
|
|
4
10
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
5
11
|
from .utils import Logger, RetryConfig, remove_suffix
|
|
6
12
|
from dataclasses import dataclass
|
|
@@ -27,10 +33,10 @@ class SDKConfiguration:
|
|
|
27
33
|
server_url: Optional[str] = ""
|
|
28
34
|
server: Optional[str] = ""
|
|
29
35
|
language: str = "python"
|
|
30
|
-
openapi_doc_version: str =
|
|
31
|
-
sdk_version: str =
|
|
32
|
-
gen_version: str =
|
|
33
|
-
user_agent: str =
|
|
36
|
+
openapi_doc_version: str = __openapi_doc_version__
|
|
37
|
+
sdk_version: str = __version__
|
|
38
|
+
gen_version: str = __gen_version__
|
|
39
|
+
user_agent: str = __user_agent__
|
|
34
40
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
35
41
|
timeout_ms: Optional[int] = None
|
|
36
42
|
|