mistralai 0.4.2__py3-none-any.whl → 0.5.5a50__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 +5 -0
- mistralai/_hooks/__init__.py +5 -0
- mistralai/_hooks/custom_user_agent.py +16 -0
- mistralai/_hooks/deprecation_warning.py +26 -0
- mistralai/_hooks/registration.py +17 -0
- mistralai/_hooks/sdkhooks.py +57 -0
- mistralai/_hooks/types.py +76 -0
- mistralai/async_client.py +5 -413
- mistralai/basesdk.py +216 -0
- mistralai/chat.py +475 -0
- mistralai/client.py +5 -414
- mistralai/embeddings.py +182 -0
- mistralai/files.py +600 -84
- mistralai/fim.py +439 -0
- mistralai/fine_tuning.py +855 -0
- mistralai/httpclient.py +78 -0
- mistralai/models/__init__.py +80 -0
- mistralai/models/archiveftmodelout.py +19 -0
- mistralai/models/assistantmessage.py +58 -0
- mistralai/models/chatcompletionchoice.py +33 -0
- mistralai/models/chatcompletionrequest.py +114 -0
- mistralai/models/chatcompletionresponse.py +27 -0
- mistralai/models/chatcompletionstreamrequest.py +112 -0
- mistralai/models/checkpointout.py +25 -0
- mistralai/models/completionchunk.py +27 -0
- mistralai/models/completionevent.py +15 -0
- mistralai/models/completionresponsestreamchoice.py +53 -0
- mistralai/models/contentchunk.py +17 -0
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +16 -0
- mistralai/models/deletefileout.py +24 -0
- mistralai/models/deletemodelout.py +25 -0
- mistralai/models/deltamessage.py +52 -0
- mistralai/models/detailedjobout.py +96 -0
- mistralai/models/embeddingrequest.py +66 -0
- mistralai/models/embeddingresponse.py +24 -0
- mistralai/models/embeddingresponsedata.py +19 -0
- mistralai/models/eventout.py +55 -0
- mistralai/models/files_api_routes_delete_fileop.py +16 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +16 -0
- mistralai/models/files_api_routes_upload_fileop.py +51 -0
- mistralai/models/fileschema.py +76 -0
- mistralai/models/fimcompletionrequest.py +99 -0
- mistralai/models/fimcompletionresponse.py +27 -0
- mistralai/models/fimcompletionstreamrequest.py +97 -0
- mistralai/models/finetuneablemodel.py +8 -0
- mistralai/models/ftmodelcapabilitiesout.py +21 -0
- mistralai/models/ftmodelout.py +70 -0
- mistralai/models/function.py +19 -0
- mistralai/models/functioncall.py +16 -0
- mistralai/models/githubrepositoryin.py +57 -0
- mistralai/models/githubrepositoryout.py +57 -0
- mistralai/models/httpvalidationerror.py +23 -0
- mistralai/models/jobin.py +78 -0
- mistralai/models/jobmetadataout.py +59 -0
- mistralai/models/jobout.py +112 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +16 -0
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +18 -0
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +73 -0
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +18 -0
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +86 -0
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +16 -0
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +16 -0
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +19 -0
- mistralai/models/jobsout.py +20 -0
- mistralai/models/legacyjobmetadataout.py +85 -0
- mistralai/models/listfilesout.py +17 -0
- mistralai/models/metricout.py +55 -0
- mistralai/models/modelcapabilities.py +21 -0
- mistralai/models/modelcard.py +71 -0
- mistralai/models/modellist.py +18 -0
- mistralai/models/responseformat.py +18 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +16 -0
- mistralai/models/retrievefileout.py +76 -0
- mistralai/models/sampletype.py +7 -0
- mistralai/models/sdkerror.py +22 -0
- mistralai/models/security.py +16 -0
- mistralai/models/source.py +7 -0
- mistralai/models/systemmessage.py +26 -0
- mistralai/models/textchunk.py +17 -0
- mistralai/models/tool.py +18 -0
- mistralai/models/toolcall.py +20 -0
- mistralai/models/toolmessage.py +55 -0
- mistralai/models/trainingfile.py +17 -0
- mistralai/models/trainingparameters.py +53 -0
- mistralai/models/trainingparametersin.py +61 -0
- mistralai/models/unarchiveftmodelout.py +19 -0
- mistralai/models/updateftmodelin.py +49 -0
- mistralai/models/uploadfileout.py +76 -0
- mistralai/models/usageinfo.py +18 -0
- mistralai/models/usermessage.py +26 -0
- mistralai/models/validationerror.py +24 -0
- mistralai/models/wandbintegration.py +61 -0
- mistralai/models/wandbintegrationout.py +57 -0
- mistralai/models_.py +928 -0
- mistralai/py.typed +1 -0
- mistralai/sdk.py +111 -0
- mistralai/sdkconfiguration.py +53 -0
- mistralai/types/__init__.py +21 -0
- mistralai/types/basemodel.py +35 -0
- mistralai/utils/__init__.py +82 -0
- mistralai/utils/annotations.py +19 -0
- mistralai/utils/enums.py +34 -0
- mistralai/utils/eventstreaming.py +179 -0
- mistralai/utils/forms.py +207 -0
- mistralai/utils/headers.py +136 -0
- mistralai/utils/metadata.py +118 -0
- mistralai/utils/queryparams.py +203 -0
- mistralai/utils/requestbodies.py +66 -0
- mistralai/utils/retries.py +216 -0
- mistralai/utils/security.py +182 -0
- mistralai/utils/serializers.py +181 -0
- mistralai/utils/url.py +150 -0
- mistralai/utils/values.py +128 -0
- {mistralai-0.4.2.dist-info → mistralai-0.5.5a50.dist-info}/LICENSE +1 -1
- mistralai-0.5.5a50.dist-info/METADATA +626 -0
- mistralai-0.5.5a50.dist-info/RECORD +228 -0
- mistralai_azure/__init__.py +5 -0
- mistralai_azure/_hooks/__init__.py +5 -0
- mistralai_azure/_hooks/custom_user_agent.py +16 -0
- mistralai_azure/_hooks/registration.py +15 -0
- mistralai_azure/_hooks/sdkhooks.py +57 -0
- mistralai_azure/_hooks/types.py +76 -0
- mistralai_azure/basesdk.py +215 -0
- mistralai_azure/chat.py +475 -0
- mistralai_azure/httpclient.py +78 -0
- mistralai_azure/models/__init__.py +28 -0
- mistralai_azure/models/assistantmessage.py +58 -0
- mistralai_azure/models/chatcompletionchoice.py +33 -0
- mistralai_azure/models/chatcompletionrequest.py +114 -0
- mistralai_azure/models/chatcompletionresponse.py +27 -0
- mistralai_azure/models/chatcompletionstreamrequest.py +112 -0
- mistralai_azure/models/completionchunk.py +27 -0
- mistralai_azure/models/completionevent.py +15 -0
- mistralai_azure/models/completionresponsestreamchoice.py +53 -0
- mistralai_azure/models/contentchunk.py +17 -0
- mistralai_azure/models/deltamessage.py +52 -0
- mistralai_azure/models/function.py +19 -0
- mistralai_azure/models/functioncall.py +16 -0
- mistralai_azure/models/httpvalidationerror.py +23 -0
- mistralai_azure/models/responseformat.py +18 -0
- mistralai_azure/models/sdkerror.py +22 -0
- mistralai_azure/models/security.py +16 -0
- mistralai_azure/models/systemmessage.py +26 -0
- mistralai_azure/models/textchunk.py +17 -0
- mistralai_azure/models/tool.py +18 -0
- mistralai_azure/models/toolcall.py +20 -0
- mistralai_azure/models/toolmessage.py +55 -0
- mistralai_azure/models/usageinfo.py +18 -0
- mistralai_azure/models/usermessage.py +26 -0
- mistralai_azure/models/validationerror.py +24 -0
- mistralai_azure/py.typed +1 -0
- mistralai_azure/sdk.py +102 -0
- mistralai_azure/sdkconfiguration.py +53 -0
- mistralai_azure/types/__init__.py +21 -0
- mistralai_azure/types/basemodel.py +35 -0
- mistralai_azure/utils/__init__.py +80 -0
- mistralai_azure/utils/annotations.py +19 -0
- mistralai_azure/utils/enums.py +34 -0
- mistralai_azure/utils/eventstreaming.py +179 -0
- mistralai_azure/utils/forms.py +207 -0
- mistralai_azure/utils/headers.py +136 -0
- mistralai_azure/utils/metadata.py +118 -0
- mistralai_azure/utils/queryparams.py +203 -0
- mistralai_azure/utils/requestbodies.py +66 -0
- mistralai_azure/utils/retries.py +216 -0
- mistralai_azure/utils/security.py +168 -0
- mistralai_azure/utils/serializers.py +181 -0
- mistralai_azure/utils/url.py +150 -0
- mistralai_azure/utils/values.py +128 -0
- mistralai_gcp/__init__.py +5 -0
- mistralai_gcp/_hooks/__init__.py +5 -0
- mistralai_gcp/_hooks/custom_user_agent.py +16 -0
- mistralai_gcp/_hooks/registration.py +15 -0
- mistralai_gcp/_hooks/sdkhooks.py +57 -0
- mistralai_gcp/_hooks/types.py +76 -0
- mistralai_gcp/basesdk.py +215 -0
- mistralai_gcp/chat.py +463 -0
- mistralai_gcp/fim.py +439 -0
- mistralai_gcp/httpclient.py +78 -0
- mistralai_gcp/models/__init__.py +31 -0
- mistralai_gcp/models/assistantmessage.py +58 -0
- mistralai_gcp/models/chatcompletionchoice.py +33 -0
- mistralai_gcp/models/chatcompletionrequest.py +110 -0
- mistralai_gcp/models/chatcompletionresponse.py +27 -0
- mistralai_gcp/models/chatcompletionstreamrequest.py +108 -0
- mistralai_gcp/models/completionchunk.py +27 -0
- mistralai_gcp/models/completionevent.py +15 -0
- mistralai_gcp/models/completionresponsestreamchoice.py +53 -0
- mistralai_gcp/models/contentchunk.py +17 -0
- mistralai_gcp/models/deltamessage.py +52 -0
- mistralai_gcp/models/fimcompletionrequest.py +99 -0
- mistralai_gcp/models/fimcompletionresponse.py +27 -0
- mistralai_gcp/models/fimcompletionstreamrequest.py +97 -0
- mistralai_gcp/models/function.py +19 -0
- mistralai_gcp/models/functioncall.py +16 -0
- mistralai_gcp/models/httpvalidationerror.py +23 -0
- mistralai_gcp/models/responseformat.py +18 -0
- mistralai_gcp/models/sdkerror.py +22 -0
- mistralai_gcp/models/security.py +16 -0
- mistralai_gcp/models/systemmessage.py +26 -0
- mistralai_gcp/models/textchunk.py +17 -0
- mistralai_gcp/models/tool.py +18 -0
- mistralai_gcp/models/toolcall.py +20 -0
- mistralai_gcp/models/toolmessage.py +55 -0
- mistralai_gcp/models/usageinfo.py +18 -0
- mistralai_gcp/models/usermessage.py +26 -0
- mistralai_gcp/models/validationerror.py +24 -0
- mistralai_gcp/py.typed +1 -0
- mistralai_gcp/sdk.py +165 -0
- mistralai_gcp/sdkconfiguration.py +53 -0
- mistralai_gcp/types/__init__.py +21 -0
- mistralai_gcp/types/basemodel.py +35 -0
- mistralai_gcp/utils/__init__.py +80 -0
- mistralai_gcp/utils/annotations.py +19 -0
- mistralai_gcp/utils/enums.py +34 -0
- mistralai_gcp/utils/eventstreaming.py +179 -0
- mistralai_gcp/utils/forms.py +207 -0
- mistralai_gcp/utils/headers.py +136 -0
- mistralai_gcp/utils/metadata.py +118 -0
- mistralai_gcp/utils/queryparams.py +203 -0
- mistralai_gcp/utils/requestbodies.py +66 -0
- mistralai_gcp/utils/retries.py +216 -0
- mistralai_gcp/utils/security.py +168 -0
- mistralai_gcp/utils/serializers.py +181 -0
- mistralai_gcp/utils/url.py +150 -0
- mistralai_gcp/utils/values.py +128 -0
- py.typed +1 -0
- mistralai/client_base.py +0 -211
- mistralai/constants.py +0 -5
- mistralai/exceptions.py +0 -54
- mistralai/jobs.py +0 -172
- mistralai/models/chat_completion.py +0 -93
- mistralai/models/common.py +0 -9
- mistralai/models/embeddings.py +0 -19
- mistralai/models/files.py +0 -23
- mistralai/models/jobs.py +0 -100
- mistralai/models/models.py +0 -39
- mistralai-0.4.2.dist-info/METADATA +0 -82
- mistralai-0.4.2.dist-info/RECORD +0 -20
- {mistralai-0.4.2.dist-info → mistralai-0.5.5a50.dist-info}/WHEEL +0 -0
mistralai/basesdk.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .sdkconfiguration import SDKConfiguration
|
|
4
|
+
import httpx
|
|
5
|
+
from mistralai import models
|
|
6
|
+
from mistralai._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext
|
|
7
|
+
import mistralai.utils as utils
|
|
8
|
+
from mistralai.utils import RetryConfig, SerializedRequestBody
|
|
9
|
+
from typing import Callable, List, Optional, Tuple
|
|
10
|
+
|
|
11
|
+
class BaseSDK:
|
|
12
|
+
sdk_configuration: SDKConfiguration
|
|
13
|
+
|
|
14
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
15
|
+
self.sdk_configuration = sdk_config
|
|
16
|
+
|
|
17
|
+
def get_url(self, base_url, url_variables):
|
|
18
|
+
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
|
19
|
+
|
|
20
|
+
if base_url is None:
|
|
21
|
+
base_url = sdk_url
|
|
22
|
+
|
|
23
|
+
if url_variables is None:
|
|
24
|
+
url_variables = sdk_variables
|
|
25
|
+
|
|
26
|
+
return utils.template_url(base_url, url_variables)
|
|
27
|
+
|
|
28
|
+
def build_request(
|
|
29
|
+
self,
|
|
30
|
+
method,
|
|
31
|
+
path,
|
|
32
|
+
base_url,
|
|
33
|
+
url_variables,
|
|
34
|
+
request,
|
|
35
|
+
request_body_required,
|
|
36
|
+
request_has_path_params,
|
|
37
|
+
request_has_query_params,
|
|
38
|
+
user_agent_header,
|
|
39
|
+
accept_header_value,
|
|
40
|
+
_globals=None,
|
|
41
|
+
security=None,
|
|
42
|
+
timeout_ms: Optional[int] = None,
|
|
43
|
+
get_serialized_body: Optional[
|
|
44
|
+
Callable[[], Optional[SerializedRequestBody]]
|
|
45
|
+
] = None,
|
|
46
|
+
url_override: Optional[str] = None,
|
|
47
|
+
) -> httpx.Request:
|
|
48
|
+
client = self.sdk_configuration.client
|
|
49
|
+
|
|
50
|
+
query_params = {}
|
|
51
|
+
|
|
52
|
+
url = url_override
|
|
53
|
+
if url is None:
|
|
54
|
+
url = utils.generate_url(
|
|
55
|
+
self.get_url(base_url, url_variables),
|
|
56
|
+
path,
|
|
57
|
+
request if request_has_path_params else None,
|
|
58
|
+
_globals if request_has_path_params else None,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
query_params = utils.get_query_params(
|
|
62
|
+
request if request_has_query_params else None,
|
|
63
|
+
_globals if request_has_query_params else None,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
headers = utils.get_headers(request, _globals)
|
|
67
|
+
headers["Accept"] = accept_header_value
|
|
68
|
+
headers[user_agent_header] = self.sdk_configuration.user_agent
|
|
69
|
+
|
|
70
|
+
if security is not None:
|
|
71
|
+
if callable(security):
|
|
72
|
+
security = security()
|
|
73
|
+
else:
|
|
74
|
+
security = utils.get_security_from_env(models.Security)
|
|
75
|
+
if security is not None:
|
|
76
|
+
security_headers, security_query_params = utils.get_security(security)
|
|
77
|
+
headers = {**headers, **security_headers}
|
|
78
|
+
query_params = {**query_params, **security_query_params}
|
|
79
|
+
|
|
80
|
+
serialized_request_body = SerializedRequestBody("application/octet-stream")
|
|
81
|
+
if get_serialized_body is not None:
|
|
82
|
+
rb = get_serialized_body()
|
|
83
|
+
if request_body_required and rb is None:
|
|
84
|
+
raise ValueError("request body is required")
|
|
85
|
+
|
|
86
|
+
if rb is not None:
|
|
87
|
+
serialized_request_body = rb
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
serialized_request_body.media_type is not None
|
|
91
|
+
and serialized_request_body.media_type
|
|
92
|
+
not in (
|
|
93
|
+
"multipart/form-data",
|
|
94
|
+
"multipart/mixed",
|
|
95
|
+
)
|
|
96
|
+
):
|
|
97
|
+
headers["content-type"] = serialized_request_body.media_type
|
|
98
|
+
|
|
99
|
+
timeout = timeout_ms / 1000 if timeout_ms is not None else None
|
|
100
|
+
|
|
101
|
+
return client.build_request(
|
|
102
|
+
method,
|
|
103
|
+
url,
|
|
104
|
+
params=query_params,
|
|
105
|
+
content=serialized_request_body.content,
|
|
106
|
+
data=serialized_request_body.data,
|
|
107
|
+
files=serialized_request_body.files,
|
|
108
|
+
headers=headers,
|
|
109
|
+
timeout=timeout,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def do_request(
|
|
113
|
+
self,
|
|
114
|
+
hook_ctx,
|
|
115
|
+
request,
|
|
116
|
+
error_status_codes,
|
|
117
|
+
stream=False,
|
|
118
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
119
|
+
) -> httpx.Response:
|
|
120
|
+
client = self.sdk_configuration.client
|
|
121
|
+
|
|
122
|
+
def do():
|
|
123
|
+
http_res = None
|
|
124
|
+
try:
|
|
125
|
+
req = self.sdk_configuration.get_hooks().before_request(
|
|
126
|
+
BeforeRequestContext(hook_ctx), request
|
|
127
|
+
)
|
|
128
|
+
http_res = client.send(req, stream=stream)
|
|
129
|
+
except Exception as e:
|
|
130
|
+
_, e = self.sdk_configuration.get_hooks().after_error(
|
|
131
|
+
AfterErrorContext(hook_ctx), None, e
|
|
132
|
+
)
|
|
133
|
+
if e is not None:
|
|
134
|
+
raise e
|
|
135
|
+
|
|
136
|
+
if http_res is None:
|
|
137
|
+
raise models.SDKError("No response received")
|
|
138
|
+
|
|
139
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
140
|
+
result, err = self.sdk_configuration.get_hooks().after_error(
|
|
141
|
+
AfterErrorContext(hook_ctx), http_res, None
|
|
142
|
+
)
|
|
143
|
+
if err is not None:
|
|
144
|
+
raise err
|
|
145
|
+
if result is not None:
|
|
146
|
+
http_res = result
|
|
147
|
+
else:
|
|
148
|
+
raise models.SDKError("Unexpected error occurred")
|
|
149
|
+
|
|
150
|
+
return http_res
|
|
151
|
+
|
|
152
|
+
if retry_config is not None:
|
|
153
|
+
http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
|
|
154
|
+
else:
|
|
155
|
+
http_res = do()
|
|
156
|
+
|
|
157
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
158
|
+
http_res = self.sdk_configuration.get_hooks().after_success(
|
|
159
|
+
AfterSuccessContext(hook_ctx), http_res
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return http_res
|
|
163
|
+
|
|
164
|
+
async def do_request_async(
|
|
165
|
+
self,
|
|
166
|
+
hook_ctx,
|
|
167
|
+
request,
|
|
168
|
+
error_status_codes,
|
|
169
|
+
stream=False,
|
|
170
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
171
|
+
) -> httpx.Response:
|
|
172
|
+
client = self.sdk_configuration.async_client
|
|
173
|
+
|
|
174
|
+
async def do():
|
|
175
|
+
http_res = None
|
|
176
|
+
try:
|
|
177
|
+
req = self.sdk_configuration.get_hooks().before_request(
|
|
178
|
+
BeforeRequestContext(hook_ctx), request
|
|
179
|
+
)
|
|
180
|
+
http_res = await client.send(req, stream=stream)
|
|
181
|
+
except Exception as e:
|
|
182
|
+
_, e = self.sdk_configuration.get_hooks().after_error(
|
|
183
|
+
AfterErrorContext(hook_ctx), None, e
|
|
184
|
+
)
|
|
185
|
+
if e is not None:
|
|
186
|
+
raise e
|
|
187
|
+
|
|
188
|
+
if http_res is None:
|
|
189
|
+
raise models.SDKError("No response received")
|
|
190
|
+
|
|
191
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
192
|
+
result, err = self.sdk_configuration.get_hooks().after_error(
|
|
193
|
+
AfterErrorContext(hook_ctx), http_res, None
|
|
194
|
+
)
|
|
195
|
+
if err is not None:
|
|
196
|
+
raise err
|
|
197
|
+
if result is not None:
|
|
198
|
+
http_res = result
|
|
199
|
+
else:
|
|
200
|
+
raise models.SDKError("Unexpected error occurred")
|
|
201
|
+
|
|
202
|
+
return http_res
|
|
203
|
+
|
|
204
|
+
if retry_config is not None:
|
|
205
|
+
http_res = await utils.retry_async(
|
|
206
|
+
do, utils.Retries(retry_config[0], retry_config[1])
|
|
207
|
+
)
|
|
208
|
+
else:
|
|
209
|
+
http_res = await do()
|
|
210
|
+
|
|
211
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
212
|
+
http_res = self.sdk_configuration.get_hooks().after_success(
|
|
213
|
+
AfterSuccessContext(hook_ctx), http_res
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return http_res
|