mistralai 1.0.2__py3-none-any.whl → 1.1.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/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/agents.py +286 -150
- mistralai/basesdk.py +90 -5
- mistralai/chat.py +260 -144
- mistralai/embeddings.py +73 -53
- mistralai/files.py +252 -192
- mistralai/fim.py +174 -110
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +372 -263
- mistralai/models/__init__.py +499 -46
- mistralai/models/agentscompletionrequest.py +47 -11
- mistralai/models/agentscompletionstreamrequest.py +49 -11
- mistralai/models/archiveftmodelout.py +6 -2
- mistralai/models/assistantmessage.py +11 -4
- mistralai/models/{modelcard.py → basemodelcard.py} +37 -14
- mistralai/models/chatcompletionchoice.py +4 -2
- mistralai/models/chatcompletionrequest.py +57 -11
- mistralai/models/chatcompletionresponse.py +6 -2
- mistralai/models/chatcompletionstreamrequest.py +59 -11
- mistralai/models/checkpointout.py +3 -2
- mistralai/models/completionchunk.py +10 -3
- mistralai/models/completionevent.py +1 -2
- mistralai/models/completionresponsestreamchoice.py +13 -5
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +4 -3
- mistralai/models/deletefileout.py +3 -2
- mistralai/models/deletemodelout.py +3 -2
- mistralai/models/deltamessage.py +9 -4
- mistralai/models/detailedjobout.py +59 -7
- mistralai/models/embeddingrequest.py +9 -4
- mistralai/models/embeddingresponse.py +5 -2
- mistralai/models/embeddingresponsedata.py +3 -2
- mistralai/models/eventout.py +9 -4
- mistralai/models/files_api_routes_delete_fileop.py +4 -3
- mistralai/models/files_api_routes_retrieve_fileop.py +4 -3
- mistralai/models/files_api_routes_upload_fileop.py +27 -8
- mistralai/models/fileschema.py +26 -5
- mistralai/models/fimcompletionrequest.py +26 -5
- mistralai/models/fimcompletionresponse.py +6 -2
- mistralai/models/fimcompletionstreamrequest.py +26 -5
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +4 -2
- mistralai/models/ftmodelcard.py +103 -0
- mistralai/models/ftmodelout.py +32 -6
- mistralai/models/function.py +3 -2
- mistralai/models/functioncall.py +2 -2
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +15 -4
- mistralai/models/githubrepositoryout.py +15 -4
- mistralai/models/httpvalidationerror.py +2 -2
- mistralai/models/imageurl.py +48 -0
- mistralai/models/imageurlchunk.py +32 -0
- mistralai/models/jobin.py +22 -5
- mistralai/models/jobmetadataout.py +31 -6
- mistralai/models/jobout.py +55 -7
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +83 -16
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +4 -3
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +9 -4
- mistralai/models/jobsout.py +6 -2
- mistralai/models/legacyjobmetadataout.py +45 -6
- mistralai/models/listfilesout.py +2 -2
- mistralai/models/metricout.py +11 -6
- mistralai/models/modelcapabilities.py +7 -2
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +6 -7
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +24 -5
- mistralai/models/retrievefileout.py +26 -5
- mistralai/models/security.py +12 -3
- mistralai/models/systemmessage.py +6 -5
- mistralai/models/textchunk.py +9 -4
- mistralai/models/tool.py +9 -8
- mistralai/models/toolcall.py +9 -7
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +11 -4
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +2 -2
- mistralai/models/trainingparameters.py +27 -6
- mistralai/models/trainingparametersin.py +29 -8
- mistralai/models/unarchiveftmodelout.py +6 -2
- mistralai/models/updateftmodelin.py +8 -4
- mistralai/models/uploadfileout.py +26 -5
- mistralai/models/usageinfo.py +3 -2
- mistralai/models/usermessage.py +6 -5
- mistralai/models/validationerror.py +3 -2
- mistralai/models/wandbintegration.py +14 -4
- mistralai/models/wandbintegrationout.py +13 -4
- mistralai/models_.py +392 -294
- mistralai/sdk.py +24 -19
- mistralai/sdkconfiguration.py +6 -8
- mistralai/utils/__init__.py +6 -1
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/METADATA +103 -74
- mistralai-1.1.0.dist-info/RECORD +254 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +252 -144
- mistralai_azure/models/__init__.py +157 -15
- mistralai_azure/models/assistantmessage.py +18 -5
- mistralai_azure/models/chatcompletionchoice.py +7 -3
- mistralai_azure/models/chatcompletionrequest.py +65 -12
- mistralai_azure/models/chatcompletionresponse.py +6 -2
- mistralai_azure/models/chatcompletionstreamrequest.py +67 -12
- mistralai_azure/models/completionchunk.py +10 -3
- mistralai_azure/models/completionevent.py +1 -2
- mistralai_azure/models/completionresponsestreamchoice.py +10 -4
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +16 -5
- mistralai_azure/models/function.py +3 -2
- mistralai_azure/models/functioncall.py +2 -2
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +2 -2
- mistralai_azure/models/responseformat.py +6 -7
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +12 -3
- mistralai_azure/models/systemmessage.py +6 -5
- mistralai_azure/models/textchunk.py +9 -4
- mistralai_azure/models/tool.py +9 -8
- mistralai_azure/models/toolcall.py +9 -7
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +18 -5
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +3 -2
- mistralai_azure/models/usermessage.py +6 -5
- mistralai_azure/models/validationerror.py +3 -2
- mistralai_azure/sdkconfiguration.py +6 -8
- mistralai_azure/utils/__init__.py +8 -3
- mistralai_azure/utils/forms.py +10 -9
- mistralai_azure/utils/headers.py +8 -8
- mistralai_azure/utils/logger.py +6 -0
- mistralai_azure/utils/queryparams.py +16 -14
- mistralai_azure/utils/retries.py +2 -1
- mistralai_azure/utils/security.py +12 -6
- mistralai_azure/utils/serializers.py +17 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +252 -144
- mistralai_gcp/fim.py +166 -110
- mistralai_gcp/models/__init__.py +179 -17
- mistralai_gcp/models/assistantmessage.py +18 -5
- mistralai_gcp/models/chatcompletionchoice.py +7 -3
- mistralai_gcp/models/chatcompletionrequest.py +62 -12
- mistralai_gcp/models/chatcompletionresponse.py +6 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +64 -12
- mistralai_gcp/models/completionchunk.py +10 -3
- mistralai_gcp/models/completionevent.py +1 -2
- mistralai_gcp/models/completionresponsestreamchoice.py +10 -4
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +16 -5
- mistralai_gcp/models/fimcompletionrequest.py +33 -6
- mistralai_gcp/models/fimcompletionresponse.py +6 -2
- mistralai_gcp/models/fimcompletionstreamrequest.py +33 -6
- mistralai_gcp/models/function.py +3 -2
- mistralai_gcp/models/functioncall.py +2 -2
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +2 -2
- mistralai_gcp/models/responseformat.py +6 -7
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +12 -3
- mistralai_gcp/models/systemmessage.py +6 -5
- mistralai_gcp/models/textchunk.py +9 -4
- mistralai_gcp/models/tool.py +9 -8
- mistralai_gcp/models/toolcall.py +9 -7
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +18 -5
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +3 -2
- mistralai_gcp/models/usermessage.py +6 -5
- mistralai_gcp/models/validationerror.py +3 -2
- mistralai_gcp/sdk.py +14 -10
- mistralai_gcp/sdkconfiguration.py +6 -8
- mistralai_gcp/utils/__init__.py +8 -3
- mistralai_gcp/utils/forms.py +10 -9
- mistralai_gcp/utils/headers.py +8 -8
- mistralai_gcp/utils/logger.py +6 -0
- mistralai_gcp/utils/queryparams.py +16 -14
- mistralai_gcp/utils/retries.py +2 -1
- mistralai_gcp/utils/security.py +12 -6
- mistralai_gcp/utils/serializers.py +17 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.2.dist-info/RECORD +0 -236
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/LICENSE +0 -0
- {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/WHEEL +0 -0
mistralai/embeddings.py
CHANGED
|
@@ -7,12 +7,13 @@ from mistralai.types import OptionalNullable, UNSET
|
|
|
7
7
|
from mistralai.utils import get_security_from_env
|
|
8
8
|
from typing import Any, Optional, Union
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
class Embeddings(BaseSDK):
|
|
11
12
|
r"""Embeddings API."""
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def create(
|
|
15
|
-
self,
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
16
17
|
inputs: Union[models.Inputs, models.InputsTypedDict],
|
|
17
18
|
model: str,
|
|
18
19
|
encoding_format: OptionalNullable[str] = UNSET,
|
|
@@ -35,16 +36,16 @@ class Embeddings(BaseSDK):
|
|
|
35
36
|
url_variables = None
|
|
36
37
|
if timeout_ms is None:
|
|
37
38
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
38
|
-
|
|
39
|
+
|
|
39
40
|
if server_url is not None:
|
|
40
41
|
base_url = server_url
|
|
41
|
-
|
|
42
|
+
|
|
42
43
|
request = models.EmbeddingRequest(
|
|
43
44
|
inputs=inputs,
|
|
44
45
|
model=model,
|
|
45
46
|
encoding_format=encoding_format,
|
|
46
47
|
)
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
req = self.build_request(
|
|
49
50
|
method="POST",
|
|
50
51
|
path="/v1/embeddings",
|
|
@@ -57,47 +58,57 @@ class Embeddings(BaseSDK):
|
|
|
57
58
|
user_agent_header="user-agent",
|
|
58
59
|
accept_header_value="application/json",
|
|
59
60
|
security=self.sdk_configuration.security,
|
|
60
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
61
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
62
|
+
request, False, False, "json", models.EmbeddingRequest
|
|
63
|
+
),
|
|
61
64
|
timeout_ms=timeout_ms,
|
|
62
65
|
)
|
|
63
|
-
|
|
66
|
+
|
|
64
67
|
if retries == UNSET:
|
|
65
68
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
66
69
|
retries = self.sdk_configuration.retry_config
|
|
67
70
|
|
|
68
71
|
retry_config = None
|
|
69
72
|
if isinstance(retries, utils.RetryConfig):
|
|
70
|
-
retry_config = (retries, [
|
|
71
|
-
|
|
72
|
-
"500",
|
|
73
|
-
"502",
|
|
74
|
-
"503",
|
|
75
|
-
"504"
|
|
76
|
-
])
|
|
77
|
-
|
|
73
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
74
|
+
|
|
78
75
|
http_res = self.do_request(
|
|
79
|
-
hook_ctx=HookContext(
|
|
76
|
+
hook_ctx=HookContext(
|
|
77
|
+
operation_id="embeddings_v1_embeddings_post",
|
|
78
|
+
oauth2_scopes=[],
|
|
79
|
+
security_source=get_security_from_env(
|
|
80
|
+
self.sdk_configuration.security, models.Security
|
|
81
|
+
),
|
|
82
|
+
),
|
|
80
83
|
request=req,
|
|
81
|
-
error_status_codes=["422","4XX","5XX"],
|
|
82
|
-
retry_config=retry_config
|
|
84
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
85
|
+
retry_config=retry_config,
|
|
83
86
|
)
|
|
84
|
-
|
|
87
|
+
|
|
85
88
|
data: Any = None
|
|
86
89
|
if utils.match_response(http_res, "200", "application/json"):
|
|
87
|
-
return utils.unmarshal_json(
|
|
90
|
+
return utils.unmarshal_json(
|
|
91
|
+
http_res.text, Optional[models.EmbeddingResponse]
|
|
92
|
+
)
|
|
88
93
|
if utils.match_response(http_res, "422", "application/json"):
|
|
89
94
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
90
95
|
raise models.HTTPValidationError(data=data)
|
|
91
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
92
|
-
raise models.SDKError(
|
|
93
|
-
|
|
96
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
97
|
+
raise models.SDKError(
|
|
98
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
99
|
+
)
|
|
100
|
+
|
|
94
101
|
content_type = http_res.headers.get("Content-Type")
|
|
95
|
-
raise models.SDKError(
|
|
102
|
+
raise models.SDKError(
|
|
103
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
104
|
+
http_res.status_code,
|
|
105
|
+
http_res.text,
|
|
106
|
+
http_res,
|
|
107
|
+
)
|
|
96
108
|
|
|
97
|
-
|
|
98
|
-
|
|
99
109
|
async def create_async(
|
|
100
|
-
self,
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
101
112
|
inputs: Union[models.Inputs, models.InputsTypedDict],
|
|
102
113
|
model: str,
|
|
103
114
|
encoding_format: OptionalNullable[str] = UNSET,
|
|
@@ -120,17 +131,17 @@ class Embeddings(BaseSDK):
|
|
|
120
131
|
url_variables = None
|
|
121
132
|
if timeout_ms is None:
|
|
122
133
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
123
|
-
|
|
134
|
+
|
|
124
135
|
if server_url is not None:
|
|
125
136
|
base_url = server_url
|
|
126
|
-
|
|
137
|
+
|
|
127
138
|
request = models.EmbeddingRequest(
|
|
128
139
|
inputs=inputs,
|
|
129
140
|
model=model,
|
|
130
141
|
encoding_format=encoding_format,
|
|
131
142
|
)
|
|
132
|
-
|
|
133
|
-
req = self.
|
|
143
|
+
|
|
144
|
+
req = self.build_request_async(
|
|
134
145
|
method="POST",
|
|
135
146
|
path="/v1/embeddings",
|
|
136
147
|
base_url=base_url,
|
|
@@ -142,41 +153,50 @@ class Embeddings(BaseSDK):
|
|
|
142
153
|
user_agent_header="user-agent",
|
|
143
154
|
accept_header_value="application/json",
|
|
144
155
|
security=self.sdk_configuration.security,
|
|
145
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
156
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
157
|
+
request, False, False, "json", models.EmbeddingRequest
|
|
158
|
+
),
|
|
146
159
|
timeout_ms=timeout_ms,
|
|
147
160
|
)
|
|
148
|
-
|
|
161
|
+
|
|
149
162
|
if retries == UNSET:
|
|
150
163
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
151
164
|
retries = self.sdk_configuration.retry_config
|
|
152
165
|
|
|
153
166
|
retry_config = None
|
|
154
167
|
if isinstance(retries, utils.RetryConfig):
|
|
155
|
-
retry_config = (retries, [
|
|
156
|
-
|
|
157
|
-
"500",
|
|
158
|
-
"502",
|
|
159
|
-
"503",
|
|
160
|
-
"504"
|
|
161
|
-
])
|
|
162
|
-
|
|
168
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
169
|
+
|
|
163
170
|
http_res = await self.do_request_async(
|
|
164
|
-
hook_ctx=HookContext(
|
|
171
|
+
hook_ctx=HookContext(
|
|
172
|
+
operation_id="embeddings_v1_embeddings_post",
|
|
173
|
+
oauth2_scopes=[],
|
|
174
|
+
security_source=get_security_from_env(
|
|
175
|
+
self.sdk_configuration.security, models.Security
|
|
176
|
+
),
|
|
177
|
+
),
|
|
165
178
|
request=req,
|
|
166
|
-
error_status_codes=["422","4XX","5XX"],
|
|
167
|
-
retry_config=retry_config
|
|
179
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
180
|
+
retry_config=retry_config,
|
|
168
181
|
)
|
|
169
|
-
|
|
182
|
+
|
|
170
183
|
data: Any = None
|
|
171
184
|
if utils.match_response(http_res, "200", "application/json"):
|
|
172
|
-
return utils.unmarshal_json(
|
|
185
|
+
return utils.unmarshal_json(
|
|
186
|
+
http_res.text, Optional[models.EmbeddingResponse]
|
|
187
|
+
)
|
|
173
188
|
if utils.match_response(http_res, "422", "application/json"):
|
|
174
189
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
175
190
|
raise models.HTTPValidationError(data=data)
|
|
176
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
177
|
-
raise models.SDKError(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
191
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
192
|
+
raise models.SDKError(
|
|
193
|
+
"API error occurred", http_res.status_code, http_res.text, http_res
|
|
194
|
+
)
|
|
181
195
|
|
|
182
|
-
|
|
196
|
+
content_type = http_res.headers.get("Content-Type")
|
|
197
|
+
raise models.SDKError(
|
|
198
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
199
|
+
http_res.status_code,
|
|
200
|
+
http_res.text,
|
|
201
|
+
http_res,
|
|
202
|
+
)
|