mistralai 1.1.0__py3-none-any.whl → 1.2.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/__init__.py +4 -0
- mistralai/_version.py +12 -0
- mistralai/agents.py +56 -22
- mistralai/batch.py +17 -0
- mistralai/chat.py +64 -30
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +10 -6
- mistralai/files.py +252 -19
- mistralai/fim.py +40 -30
- mistralai/jobs.py +40 -20
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +108 -18
- mistralai/models/agentscompletionrequest.py +27 -10
- mistralai/models/agentscompletionstreamrequest.py +27 -10
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +11 -5
- mistralai/models/assistantmessage.py +11 -6
- mistralai/models/basemodelcard.py +22 -6
- mistralai/models/batcherror.py +17 -0
- mistralai/models/batchjobin.py +58 -0
- mistralai/models/batchjobout.py +117 -0
- mistralai/models/batchjobsout.py +30 -0
- mistralai/models/batchjobstatus.py +15 -0
- mistralai/models/chatclassificationrequest.py +104 -0
- mistralai/models/chatcompletionchoice.py +9 -4
- mistralai/models/chatcompletionrequest.py +32 -13
- mistralai/models/chatcompletionresponse.py +2 -2
- mistralai/models/chatcompletionstreamrequest.py +32 -13
- mistralai/models/checkpointout.py +1 -1
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +2 -2
- mistralai/models/completionevent.py +1 -1
- mistralai/models/completionresponsestreamchoice.py +11 -5
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
- mistralai/models/deletefileout.py +1 -1
- mistralai/models/deletemodelout.py +2 -2
- mistralai/models/deltamessage.py +14 -7
- mistralai/models/detailedjobout.py +11 -5
- mistralai/models/embeddingrequest.py +5 -5
- mistralai/models/embeddingresponse.py +2 -1
- mistralai/models/embeddingresponsedata.py +2 -2
- mistralai/models/eventout.py +2 -2
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +1 -2
- mistralai/models/files_api_routes_download_fileop.py +16 -0
- mistralai/models/files_api_routes_list_filesop.py +96 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
- mistralai/models/files_api_routes_upload_fileop.py +9 -9
- mistralai/models/fileschema.py +7 -21
- mistralai/models/fimcompletionrequest.py +20 -13
- mistralai/models/fimcompletionresponse.py +2 -2
- mistralai/models/fimcompletionstreamrequest.py +20 -13
- mistralai/models/ftmodelcapabilitiesout.py +2 -2
- mistralai/models/ftmodelcard.py +24 -6
- mistralai/models/ftmodelout.py +9 -5
- mistralai/models/function.py +2 -2
- mistralai/models/functioncall.py +2 -1
- mistralai/models/functionname.py +1 -1
- mistralai/models/githubrepositoryin.py +11 -5
- mistralai/models/githubrepositoryout.py +11 -5
- mistralai/models/httpvalidationerror.py +0 -2
- mistralai/models/imageurl.py +1 -2
- mistralai/models/imageurlchunk.py +11 -5
- mistralai/models/jobin.py +2 -2
- mistralai/models/jobmetadataout.py +1 -2
- mistralai/models/jobout.py +10 -5
- mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
- mistralai/models/jobsout.py +9 -5
- mistralai/models/legacyjobmetadataout.py +12 -5
- mistralai/models/listfilesout.py +5 -1
- mistralai/models/metricout.py +1 -2
- mistralai/models/modelcapabilities.py +2 -2
- mistralai/models/modellist.py +2 -2
- mistralai/models/responseformat.py +2 -2
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
- mistralai/models/retrievefileout.py +10 -21
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +2 -2
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +6 -6
- mistralai/models/textchunk.py +9 -5
- mistralai/models/tool.py +2 -2
- mistralai/models/toolcall.py +2 -2
- mistralai/models/toolchoice.py +2 -2
- mistralai/models/toolmessage.py +2 -2
- mistralai/models/trainingfile.py +2 -2
- mistralai/models/trainingparameters.py +7 -2
- mistralai/models/trainingparametersin.py +7 -2
- mistralai/models/unarchiveftmodelout.py +11 -5
- mistralai/models/updateftmodelin.py +1 -2
- mistralai/models/uploadfileout.py +7 -21
- mistralai/models/usageinfo.py +1 -1
- mistralai/models/usermessage.py +36 -5
- mistralai/models/validationerror.py +2 -1
- mistralai/models/wandbintegration.py +11 -5
- mistralai/models/wandbintegrationout.py +12 -6
- mistralai/models_.py +48 -24
- mistralai/sdk.py +7 -0
- mistralai/sdkconfiguration.py +7 -7
- mistralai/utils/__init__.py +8 -0
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
- mistralai-1.2.1.dist-info/RECORD +276 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_version.py +12 -0
- mistralai_azure/chat.py +64 -30
- mistralai_azure/models/__init__.py +9 -3
- mistralai_azure/models/assistantmessage.py +11 -6
- mistralai_azure/models/chatcompletionchoice.py +10 -5
- mistralai_azure/models/chatcompletionrequest.py +32 -13
- mistralai_azure/models/chatcompletionresponse.py +2 -2
- mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
- mistralai_azure/models/completionchunk.py +2 -2
- mistralai_azure/models/completionevent.py +1 -1
- mistralai_azure/models/completionresponsestreamchoice.py +9 -4
- mistralai_azure/models/deltamessage.py +14 -7
- mistralai_azure/models/function.py +2 -2
- mistralai_azure/models/functioncall.py +2 -1
- mistralai_azure/models/functionname.py +1 -1
- mistralai_azure/models/httpvalidationerror.py +0 -2
- mistralai_azure/models/responseformat.py +2 -2
- mistralai_azure/models/security.py +1 -2
- mistralai_azure/models/systemmessage.py +6 -6
- mistralai_azure/models/textchunk.py +9 -5
- mistralai_azure/models/tool.py +2 -2
- mistralai_azure/models/toolcall.py +2 -2
- mistralai_azure/models/toolchoice.py +2 -2
- mistralai_azure/models/toolmessage.py +2 -2
- mistralai_azure/models/usageinfo.py +1 -1
- mistralai_azure/models/usermessage.py +36 -5
- mistralai_azure/models/validationerror.py +2 -1
- mistralai_azure/sdkconfiguration.py +7 -7
- mistralai_azure/utils/__init__.py +8 -0
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/serializers.py +25 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/chat.py +64 -30
- mistralai_gcp/fim.py +40 -30
- mistralai_gcp/models/__init__.py +9 -3
- mistralai_gcp/models/assistantmessage.py +11 -6
- mistralai_gcp/models/chatcompletionchoice.py +10 -5
- mistralai_gcp/models/chatcompletionrequest.py +32 -13
- mistralai_gcp/models/chatcompletionresponse.py +2 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
- mistralai_gcp/models/completionchunk.py +2 -2
- mistralai_gcp/models/completionevent.py +1 -1
- mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
- mistralai_gcp/models/deltamessage.py +14 -7
- mistralai_gcp/models/fimcompletionrequest.py +20 -13
- mistralai_gcp/models/fimcompletionresponse.py +2 -2
- mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
- mistralai_gcp/models/function.py +2 -2
- mistralai_gcp/models/functioncall.py +2 -1
- mistralai_gcp/models/functionname.py +1 -1
- mistralai_gcp/models/httpvalidationerror.py +0 -2
- mistralai_gcp/models/responseformat.py +2 -2
- mistralai_gcp/models/security.py +1 -2
- mistralai_gcp/models/systemmessage.py +6 -6
- mistralai_gcp/models/textchunk.py +9 -5
- mistralai_gcp/models/tool.py +2 -2
- mistralai_gcp/models/toolcall.py +2 -2
- mistralai_gcp/models/toolchoice.py +2 -2
- mistralai_gcp/models/toolmessage.py +2 -2
- mistralai_gcp/models/usageinfo.py +1 -1
- mistralai_gcp/models/usermessage.py +36 -5
- mistralai_gcp/models/validationerror.py +2 -1
- mistralai_gcp/sdk.py +20 -11
- mistralai_gcp/sdkconfiguration.py +7 -7
- mistralai_gcp/utils/__init__.py +8 -0
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/serializers.py +25 -0
- mistralai-1.1.0.dist-info/RECORD +0 -254
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
mistralai/classifiers.py
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
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, Optional, Union
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Classifiers(BaseSDK):
|
|
12
|
+
r"""Classifiers API."""
|
|
13
|
+
|
|
14
|
+
def moderate(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
inputs: Union[
|
|
18
|
+
models.ClassificationRequestInputs,
|
|
19
|
+
models.ClassificationRequestInputsTypedDict,
|
|
20
|
+
],
|
|
21
|
+
model: OptionalNullable[str] = UNSET,
|
|
22
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
23
|
+
server_url: Optional[str] = None,
|
|
24
|
+
timeout_ms: Optional[int] = None,
|
|
25
|
+
) -> Optional[models.ClassificationResponse]:
|
|
26
|
+
r"""Moderations
|
|
27
|
+
|
|
28
|
+
:param inputs: Text to classify.
|
|
29
|
+
:param model:
|
|
30
|
+
:param retries: Override the default retry configuration for this method
|
|
31
|
+
:param server_url: Override the default server URL for this method
|
|
32
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
33
|
+
"""
|
|
34
|
+
base_url = None
|
|
35
|
+
url_variables = None
|
|
36
|
+
if timeout_ms is None:
|
|
37
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
38
|
+
|
|
39
|
+
if server_url is not None:
|
|
40
|
+
base_url = server_url
|
|
41
|
+
|
|
42
|
+
request = models.ClassificationRequest(
|
|
43
|
+
inputs=inputs,
|
|
44
|
+
model=model,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
req = self.build_request(
|
|
48
|
+
method="POST",
|
|
49
|
+
path="/v1/moderations",
|
|
50
|
+
base_url=base_url,
|
|
51
|
+
url_variables=url_variables,
|
|
52
|
+
request=request,
|
|
53
|
+
request_body_required=True,
|
|
54
|
+
request_has_path_params=False,
|
|
55
|
+
request_has_query_params=True,
|
|
56
|
+
user_agent_header="user-agent",
|
|
57
|
+
accept_header_value="application/json",
|
|
58
|
+
security=self.sdk_configuration.security,
|
|
59
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
60
|
+
request, False, False, "json", models.ClassificationRequest
|
|
61
|
+
),
|
|
62
|
+
timeout_ms=timeout_ms,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if retries == UNSET:
|
|
66
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
67
|
+
retries = self.sdk_configuration.retry_config
|
|
68
|
+
|
|
69
|
+
retry_config = None
|
|
70
|
+
if isinstance(retries, utils.RetryConfig):
|
|
71
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
72
|
+
|
|
73
|
+
http_res = self.do_request(
|
|
74
|
+
hook_ctx=HookContext(
|
|
75
|
+
operation_id="moderations_v1_moderations_post",
|
|
76
|
+
oauth2_scopes=[],
|
|
77
|
+
security_source=get_security_from_env(
|
|
78
|
+
self.sdk_configuration.security, models.Security
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
request=req,
|
|
82
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
83
|
+
retry_config=retry_config,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
data: Any = None
|
|
87
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
88
|
+
return utils.unmarshal_json(
|
|
89
|
+
http_res.text, Optional[models.ClassificationResponse]
|
|
90
|
+
)
|
|
91
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
92
|
+
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
93
|
+
raise models.HTTPValidationError(data=data)
|
|
94
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
95
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
96
|
+
raise models.SDKError(
|
|
97
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
content_type = http_res.headers.get("Content-Type")
|
|
101
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
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
|
+
)
|
|
108
|
+
|
|
109
|
+
async def moderate_async(
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
inputs: Union[
|
|
113
|
+
models.ClassificationRequestInputs,
|
|
114
|
+
models.ClassificationRequestInputsTypedDict,
|
|
115
|
+
],
|
|
116
|
+
model: OptionalNullable[str] = UNSET,
|
|
117
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
118
|
+
server_url: Optional[str] = None,
|
|
119
|
+
timeout_ms: Optional[int] = None,
|
|
120
|
+
) -> Optional[models.ClassificationResponse]:
|
|
121
|
+
r"""Moderations
|
|
122
|
+
|
|
123
|
+
:param inputs: Text to classify.
|
|
124
|
+
:param model:
|
|
125
|
+
:param retries: Override the default retry configuration for this method
|
|
126
|
+
:param server_url: Override the default server URL for this method
|
|
127
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
128
|
+
"""
|
|
129
|
+
base_url = None
|
|
130
|
+
url_variables = None
|
|
131
|
+
if timeout_ms is None:
|
|
132
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
133
|
+
|
|
134
|
+
if server_url is not None:
|
|
135
|
+
base_url = server_url
|
|
136
|
+
|
|
137
|
+
request = models.ClassificationRequest(
|
|
138
|
+
inputs=inputs,
|
|
139
|
+
model=model,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
req = self.build_request_async(
|
|
143
|
+
method="POST",
|
|
144
|
+
path="/v1/moderations",
|
|
145
|
+
base_url=base_url,
|
|
146
|
+
url_variables=url_variables,
|
|
147
|
+
request=request,
|
|
148
|
+
request_body_required=True,
|
|
149
|
+
request_has_path_params=False,
|
|
150
|
+
request_has_query_params=True,
|
|
151
|
+
user_agent_header="user-agent",
|
|
152
|
+
accept_header_value="application/json",
|
|
153
|
+
security=self.sdk_configuration.security,
|
|
154
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
155
|
+
request, False, False, "json", models.ClassificationRequest
|
|
156
|
+
),
|
|
157
|
+
timeout_ms=timeout_ms,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
if retries == UNSET:
|
|
161
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
162
|
+
retries = self.sdk_configuration.retry_config
|
|
163
|
+
|
|
164
|
+
retry_config = None
|
|
165
|
+
if isinstance(retries, utils.RetryConfig):
|
|
166
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
167
|
+
|
|
168
|
+
http_res = await self.do_request_async(
|
|
169
|
+
hook_ctx=HookContext(
|
|
170
|
+
operation_id="moderations_v1_moderations_post",
|
|
171
|
+
oauth2_scopes=[],
|
|
172
|
+
security_source=get_security_from_env(
|
|
173
|
+
self.sdk_configuration.security, models.Security
|
|
174
|
+
),
|
|
175
|
+
),
|
|
176
|
+
request=req,
|
|
177
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
178
|
+
retry_config=retry_config,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
data: Any = None
|
|
182
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
183
|
+
return utils.unmarshal_json(
|
|
184
|
+
http_res.text, Optional[models.ClassificationResponse]
|
|
185
|
+
)
|
|
186
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
187
|
+
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
188
|
+
raise models.HTTPValidationError(data=data)
|
|
189
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
190
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
191
|
+
raise models.SDKError(
|
|
192
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
content_type = http_res.headers.get("Content-Type")
|
|
196
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
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
|
+
)
|
|
203
|
+
|
|
204
|
+
def moderate_chat(
|
|
205
|
+
self,
|
|
206
|
+
*,
|
|
207
|
+
inputs: Union[
|
|
208
|
+
models.ChatClassificationRequestInputs,
|
|
209
|
+
models.ChatClassificationRequestInputsTypedDict,
|
|
210
|
+
],
|
|
211
|
+
model: Nullable[str],
|
|
212
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
213
|
+
server_url: Optional[str] = None,
|
|
214
|
+
timeout_ms: Optional[int] = None,
|
|
215
|
+
) -> Optional[models.ClassificationResponse]:
|
|
216
|
+
r"""Moderations Chat
|
|
217
|
+
|
|
218
|
+
:param inputs: Chat to classify
|
|
219
|
+
:param model:
|
|
220
|
+
:param retries: Override the default retry configuration for this method
|
|
221
|
+
:param server_url: Override the default server URL for this method
|
|
222
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
223
|
+
"""
|
|
224
|
+
base_url = None
|
|
225
|
+
url_variables = None
|
|
226
|
+
if timeout_ms is None:
|
|
227
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
228
|
+
|
|
229
|
+
if server_url is not None:
|
|
230
|
+
base_url = server_url
|
|
231
|
+
|
|
232
|
+
request = models.ChatClassificationRequest(
|
|
233
|
+
inputs=utils.get_pydantic_model(
|
|
234
|
+
inputs, models.ChatClassificationRequestInputs
|
|
235
|
+
),
|
|
236
|
+
model=model,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
req = self.build_request(
|
|
240
|
+
method="POST",
|
|
241
|
+
path="/v1/chat/moderations",
|
|
242
|
+
base_url=base_url,
|
|
243
|
+
url_variables=url_variables,
|
|
244
|
+
request=request,
|
|
245
|
+
request_body_required=True,
|
|
246
|
+
request_has_path_params=False,
|
|
247
|
+
request_has_query_params=True,
|
|
248
|
+
user_agent_header="user-agent",
|
|
249
|
+
accept_header_value="application/json",
|
|
250
|
+
security=self.sdk_configuration.security,
|
|
251
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
252
|
+
request, False, False, "json", models.ChatClassificationRequest
|
|
253
|
+
),
|
|
254
|
+
timeout_ms=timeout_ms,
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
if retries == UNSET:
|
|
258
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
259
|
+
retries = self.sdk_configuration.retry_config
|
|
260
|
+
|
|
261
|
+
retry_config = None
|
|
262
|
+
if isinstance(retries, utils.RetryConfig):
|
|
263
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
264
|
+
|
|
265
|
+
http_res = self.do_request(
|
|
266
|
+
hook_ctx=HookContext(
|
|
267
|
+
operation_id="moderations_chat_v1_chat_moderations_post",
|
|
268
|
+
oauth2_scopes=[],
|
|
269
|
+
security_source=get_security_from_env(
|
|
270
|
+
self.sdk_configuration.security, models.Security
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
request=req,
|
|
274
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
275
|
+
retry_config=retry_config,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
data: Any = None
|
|
279
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
280
|
+
return utils.unmarshal_json(
|
|
281
|
+
http_res.text, Optional[models.ClassificationResponse]
|
|
282
|
+
)
|
|
283
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
284
|
+
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
285
|
+
raise models.HTTPValidationError(data=data)
|
|
286
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
287
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
288
|
+
raise models.SDKError(
|
|
289
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
content_type = http_res.headers.get("Content-Type")
|
|
293
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
294
|
+
raise models.SDKError(
|
|
295
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
296
|
+
http_res.status_code,
|
|
297
|
+
http_res_text,
|
|
298
|
+
http_res,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
async def moderate_chat_async(
|
|
302
|
+
self,
|
|
303
|
+
*,
|
|
304
|
+
inputs: Union[
|
|
305
|
+
models.ChatClassificationRequestInputs,
|
|
306
|
+
models.ChatClassificationRequestInputsTypedDict,
|
|
307
|
+
],
|
|
308
|
+
model: Nullable[str],
|
|
309
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
310
|
+
server_url: Optional[str] = None,
|
|
311
|
+
timeout_ms: Optional[int] = None,
|
|
312
|
+
) -> Optional[models.ClassificationResponse]:
|
|
313
|
+
r"""Moderations Chat
|
|
314
|
+
|
|
315
|
+
:param inputs: Chat to classify
|
|
316
|
+
:param model:
|
|
317
|
+
:param retries: Override the default retry configuration for this method
|
|
318
|
+
:param server_url: Override the default server URL for this method
|
|
319
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
320
|
+
"""
|
|
321
|
+
base_url = None
|
|
322
|
+
url_variables = None
|
|
323
|
+
if timeout_ms is None:
|
|
324
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
325
|
+
|
|
326
|
+
if server_url is not None:
|
|
327
|
+
base_url = server_url
|
|
328
|
+
|
|
329
|
+
request = models.ChatClassificationRequest(
|
|
330
|
+
inputs=utils.get_pydantic_model(
|
|
331
|
+
inputs, models.ChatClassificationRequestInputs
|
|
332
|
+
),
|
|
333
|
+
model=model,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
req = self.build_request_async(
|
|
337
|
+
method="POST",
|
|
338
|
+
path="/v1/chat/moderations",
|
|
339
|
+
base_url=base_url,
|
|
340
|
+
url_variables=url_variables,
|
|
341
|
+
request=request,
|
|
342
|
+
request_body_required=True,
|
|
343
|
+
request_has_path_params=False,
|
|
344
|
+
request_has_query_params=True,
|
|
345
|
+
user_agent_header="user-agent",
|
|
346
|
+
accept_header_value="application/json",
|
|
347
|
+
security=self.sdk_configuration.security,
|
|
348
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
349
|
+
request, False, False, "json", models.ChatClassificationRequest
|
|
350
|
+
),
|
|
351
|
+
timeout_ms=timeout_ms,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
if retries == UNSET:
|
|
355
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
356
|
+
retries = self.sdk_configuration.retry_config
|
|
357
|
+
|
|
358
|
+
retry_config = None
|
|
359
|
+
if isinstance(retries, utils.RetryConfig):
|
|
360
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
361
|
+
|
|
362
|
+
http_res = await self.do_request_async(
|
|
363
|
+
hook_ctx=HookContext(
|
|
364
|
+
operation_id="moderations_chat_v1_chat_moderations_post",
|
|
365
|
+
oauth2_scopes=[],
|
|
366
|
+
security_source=get_security_from_env(
|
|
367
|
+
self.sdk_configuration.security, models.Security
|
|
368
|
+
),
|
|
369
|
+
),
|
|
370
|
+
request=req,
|
|
371
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
372
|
+
retry_config=retry_config,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
data: Any = None
|
|
376
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
377
|
+
return utils.unmarshal_json(
|
|
378
|
+
http_res.text, Optional[models.ClassificationResponse]
|
|
379
|
+
)
|
|
380
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
381
|
+
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
382
|
+
raise models.HTTPValidationError(data=data)
|
|
383
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
384
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
385
|
+
raise models.SDKError(
|
|
386
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
content_type = http_res.headers.get("Content-Type")
|
|
390
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
391
|
+
raise models.SDKError(
|
|
392
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
393
|
+
http_res.status_code,
|
|
394
|
+
http_res_text,
|
|
395
|
+
http_res,
|
|
396
|
+
)
|
mistralai/embeddings.py
CHANGED
|
@@ -15,7 +15,7 @@ class Embeddings(BaseSDK):
|
|
|
15
15
|
self,
|
|
16
16
|
*,
|
|
17
17
|
inputs: Union[models.Inputs, models.InputsTypedDict],
|
|
18
|
-
model: str,
|
|
18
|
+
model: Optional[str] = "mistral-embed",
|
|
19
19
|
encoding_format: OptionalNullable[str] = UNSET,
|
|
20
20
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
21
21
|
server_url: Optional[str] = None,
|
|
@@ -94,15 +94,17 @@ class Embeddings(BaseSDK):
|
|
|
94
94
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
95
95
|
raise models.HTTPValidationError(data=data)
|
|
96
96
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
97
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
97
98
|
raise models.SDKError(
|
|
98
|
-
"API error occurred", http_res.status_code,
|
|
99
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
99
100
|
)
|
|
100
101
|
|
|
101
102
|
content_type = http_res.headers.get("Content-Type")
|
|
103
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
102
104
|
raise models.SDKError(
|
|
103
105
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
104
106
|
http_res.status_code,
|
|
105
|
-
|
|
107
|
+
http_res_text,
|
|
106
108
|
http_res,
|
|
107
109
|
)
|
|
108
110
|
|
|
@@ -110,7 +112,7 @@ class Embeddings(BaseSDK):
|
|
|
110
112
|
self,
|
|
111
113
|
*,
|
|
112
114
|
inputs: Union[models.Inputs, models.InputsTypedDict],
|
|
113
|
-
model: str,
|
|
115
|
+
model: Optional[str] = "mistral-embed",
|
|
114
116
|
encoding_format: OptionalNullable[str] = UNSET,
|
|
115
117
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
116
118
|
server_url: Optional[str] = None,
|
|
@@ -189,14 +191,16 @@ class Embeddings(BaseSDK):
|
|
|
189
191
|
data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
|
|
190
192
|
raise models.HTTPValidationError(data=data)
|
|
191
193
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
194
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
192
195
|
raise models.SDKError(
|
|
193
|
-
"API error occurred", http_res.status_code,
|
|
196
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
194
197
|
)
|
|
195
198
|
|
|
196
199
|
content_type = http_res.headers.get("Content-Type")
|
|
200
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
197
201
|
raise models.SDKError(
|
|
198
202
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
199
203
|
http_res.status_code,
|
|
200
|
-
|
|
204
|
+
http_res_text,
|
|
201
205
|
http_res,
|
|
202
206
|
)
|