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.
Files changed (187) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_version.py +12 -0
  3. mistralai/agents.py +56 -22
  4. mistralai/batch.py +17 -0
  5. mistralai/chat.py +64 -30
  6. mistralai/classifiers.py +396 -0
  7. mistralai/embeddings.py +10 -6
  8. mistralai/files.py +252 -19
  9. mistralai/fim.py +40 -30
  10. mistralai/jobs.py +40 -20
  11. mistralai/mistral_jobs.py +733 -0
  12. mistralai/models/__init__.py +108 -18
  13. mistralai/models/agentscompletionrequest.py +27 -10
  14. mistralai/models/agentscompletionstreamrequest.py +27 -10
  15. mistralai/models/apiendpoint.py +9 -0
  16. mistralai/models/archiveftmodelout.py +11 -5
  17. mistralai/models/assistantmessage.py +11 -6
  18. mistralai/models/basemodelcard.py +22 -6
  19. mistralai/models/batcherror.py +17 -0
  20. mistralai/models/batchjobin.py +58 -0
  21. mistralai/models/batchjobout.py +117 -0
  22. mistralai/models/batchjobsout.py +30 -0
  23. mistralai/models/batchjobstatus.py +15 -0
  24. mistralai/models/chatclassificationrequest.py +104 -0
  25. mistralai/models/chatcompletionchoice.py +9 -4
  26. mistralai/models/chatcompletionrequest.py +32 -13
  27. mistralai/models/chatcompletionresponse.py +2 -2
  28. mistralai/models/chatcompletionstreamrequest.py +32 -13
  29. mistralai/models/checkpointout.py +1 -1
  30. mistralai/models/classificationobject.py +21 -0
  31. mistralai/models/classificationrequest.py +59 -0
  32. mistralai/models/classificationresponse.py +21 -0
  33. mistralai/models/completionchunk.py +2 -2
  34. mistralai/models/completionevent.py +1 -1
  35. mistralai/models/completionresponsestreamchoice.py +11 -5
  36. mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
  37. mistralai/models/deletefileout.py +1 -1
  38. mistralai/models/deletemodelout.py +2 -2
  39. mistralai/models/deltamessage.py +14 -7
  40. mistralai/models/detailedjobout.py +11 -5
  41. mistralai/models/embeddingrequest.py +5 -5
  42. mistralai/models/embeddingresponse.py +2 -1
  43. mistralai/models/embeddingresponsedata.py +2 -2
  44. mistralai/models/eventout.py +2 -2
  45. mistralai/models/filepurpose.py +8 -0
  46. mistralai/models/files_api_routes_delete_fileop.py +1 -2
  47. mistralai/models/files_api_routes_download_fileop.py +16 -0
  48. mistralai/models/files_api_routes_list_filesop.py +96 -0
  49. mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
  50. mistralai/models/files_api_routes_upload_fileop.py +9 -9
  51. mistralai/models/fileschema.py +7 -21
  52. mistralai/models/fimcompletionrequest.py +20 -13
  53. mistralai/models/fimcompletionresponse.py +2 -2
  54. mistralai/models/fimcompletionstreamrequest.py +20 -13
  55. mistralai/models/ftmodelcapabilitiesout.py +2 -2
  56. mistralai/models/ftmodelcard.py +24 -6
  57. mistralai/models/ftmodelout.py +9 -5
  58. mistralai/models/function.py +2 -2
  59. mistralai/models/functioncall.py +2 -1
  60. mistralai/models/functionname.py +1 -1
  61. mistralai/models/githubrepositoryin.py +11 -5
  62. mistralai/models/githubrepositoryout.py +11 -5
  63. mistralai/models/httpvalidationerror.py +0 -2
  64. mistralai/models/imageurl.py +1 -2
  65. mistralai/models/imageurlchunk.py +11 -5
  66. mistralai/models/jobin.py +2 -2
  67. mistralai/models/jobmetadataout.py +1 -2
  68. mistralai/models/jobout.py +10 -5
  69. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  70. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  71. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  72. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
  73. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
  74. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
  75. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
  76. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
  77. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
  78. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
  79. mistralai/models/jobsout.py +9 -5
  80. mistralai/models/legacyjobmetadataout.py +12 -5
  81. mistralai/models/listfilesout.py +5 -1
  82. mistralai/models/metricout.py +1 -2
  83. mistralai/models/modelcapabilities.py +2 -2
  84. mistralai/models/modellist.py +2 -2
  85. mistralai/models/responseformat.py +2 -2
  86. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
  87. mistralai/models/retrievefileout.py +10 -21
  88. mistralai/models/sampletype.py +6 -2
  89. mistralai/models/security.py +2 -2
  90. mistralai/models/source.py +3 -2
  91. mistralai/models/systemmessage.py +6 -6
  92. mistralai/models/textchunk.py +9 -5
  93. mistralai/models/tool.py +2 -2
  94. mistralai/models/toolcall.py +2 -2
  95. mistralai/models/toolchoice.py +2 -2
  96. mistralai/models/toolmessage.py +2 -2
  97. mistralai/models/trainingfile.py +2 -2
  98. mistralai/models/trainingparameters.py +7 -2
  99. mistralai/models/trainingparametersin.py +7 -2
  100. mistralai/models/unarchiveftmodelout.py +11 -5
  101. mistralai/models/updateftmodelin.py +1 -2
  102. mistralai/models/uploadfileout.py +7 -21
  103. mistralai/models/usageinfo.py +1 -1
  104. mistralai/models/usermessage.py +36 -5
  105. mistralai/models/validationerror.py +2 -1
  106. mistralai/models/wandbintegration.py +11 -5
  107. mistralai/models/wandbintegrationout.py +12 -6
  108. mistralai/models_.py +48 -24
  109. mistralai/sdk.py +7 -0
  110. mistralai/sdkconfiguration.py +7 -7
  111. mistralai/utils/__init__.py +8 -0
  112. mistralai/utils/annotations.py +13 -2
  113. mistralai/utils/serializers.py +25 -0
  114. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
  115. mistralai-1.2.1.dist-info/RECORD +276 -0
  116. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
  117. mistralai_azure/__init__.py +4 -0
  118. mistralai_azure/_version.py +12 -0
  119. mistralai_azure/chat.py +64 -30
  120. mistralai_azure/models/__init__.py +9 -3
  121. mistralai_azure/models/assistantmessage.py +11 -6
  122. mistralai_azure/models/chatcompletionchoice.py +10 -5
  123. mistralai_azure/models/chatcompletionrequest.py +32 -13
  124. mistralai_azure/models/chatcompletionresponse.py +2 -2
  125. mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
  126. mistralai_azure/models/completionchunk.py +2 -2
  127. mistralai_azure/models/completionevent.py +1 -1
  128. mistralai_azure/models/completionresponsestreamchoice.py +9 -4
  129. mistralai_azure/models/deltamessage.py +14 -7
  130. mistralai_azure/models/function.py +2 -2
  131. mistralai_azure/models/functioncall.py +2 -1
  132. mistralai_azure/models/functionname.py +1 -1
  133. mistralai_azure/models/httpvalidationerror.py +0 -2
  134. mistralai_azure/models/responseformat.py +2 -2
  135. mistralai_azure/models/security.py +1 -2
  136. mistralai_azure/models/systemmessage.py +6 -6
  137. mistralai_azure/models/textchunk.py +9 -5
  138. mistralai_azure/models/tool.py +2 -2
  139. mistralai_azure/models/toolcall.py +2 -2
  140. mistralai_azure/models/toolchoice.py +2 -2
  141. mistralai_azure/models/toolmessage.py +2 -2
  142. mistralai_azure/models/usageinfo.py +1 -1
  143. mistralai_azure/models/usermessage.py +36 -5
  144. mistralai_azure/models/validationerror.py +2 -1
  145. mistralai_azure/sdkconfiguration.py +7 -7
  146. mistralai_azure/utils/__init__.py +8 -0
  147. mistralai_azure/utils/annotations.py +13 -2
  148. mistralai_azure/utils/serializers.py +25 -0
  149. mistralai_gcp/__init__.py +4 -0
  150. mistralai_gcp/_version.py +12 -0
  151. mistralai_gcp/chat.py +64 -30
  152. mistralai_gcp/fim.py +40 -30
  153. mistralai_gcp/models/__init__.py +9 -3
  154. mistralai_gcp/models/assistantmessage.py +11 -6
  155. mistralai_gcp/models/chatcompletionchoice.py +10 -5
  156. mistralai_gcp/models/chatcompletionrequest.py +32 -13
  157. mistralai_gcp/models/chatcompletionresponse.py +2 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
  159. mistralai_gcp/models/completionchunk.py +2 -2
  160. mistralai_gcp/models/completionevent.py +1 -1
  161. mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
  162. mistralai_gcp/models/deltamessage.py +14 -7
  163. mistralai_gcp/models/fimcompletionrequest.py +20 -13
  164. mistralai_gcp/models/fimcompletionresponse.py +2 -2
  165. mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
  166. mistralai_gcp/models/function.py +2 -2
  167. mistralai_gcp/models/functioncall.py +2 -1
  168. mistralai_gcp/models/functionname.py +1 -1
  169. mistralai_gcp/models/httpvalidationerror.py +0 -2
  170. mistralai_gcp/models/responseformat.py +2 -2
  171. mistralai_gcp/models/security.py +1 -2
  172. mistralai_gcp/models/systemmessage.py +6 -6
  173. mistralai_gcp/models/textchunk.py +9 -5
  174. mistralai_gcp/models/tool.py +2 -2
  175. mistralai_gcp/models/toolcall.py +2 -2
  176. mistralai_gcp/models/toolchoice.py +2 -2
  177. mistralai_gcp/models/toolmessage.py +2 -2
  178. mistralai_gcp/models/usageinfo.py +1 -1
  179. mistralai_gcp/models/usermessage.py +36 -5
  180. mistralai_gcp/models/validationerror.py +2 -1
  181. mistralai_gcp/sdk.py +20 -11
  182. mistralai_gcp/sdkconfiguration.py +7 -7
  183. mistralai_gcp/utils/__init__.py +8 -0
  184. mistralai_gcp/utils/annotations.py +13 -2
  185. mistralai_gcp/utils/serializers.py +25 -0
  186. mistralai-1.1.0.dist-info/RECORD +0 -254
  187. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
@@ -0,0 +1,733 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from datetime import datetime
5
+ from mistralai import models, utils
6
+ from mistralai._hooks import HookContext
7
+ from mistralai.types import OptionalNullable, UNSET
8
+ from mistralai.utils import get_security_from_env
9
+ from typing import Any, Dict, List, Optional
10
+
11
+
12
+ class MistralJobs(BaseSDK):
13
+ def list(
14
+ self,
15
+ *,
16
+ page: Optional[int] = 0,
17
+ page_size: Optional[int] = 100,
18
+ model: OptionalNullable[str] = UNSET,
19
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
20
+ created_after: OptionalNullable[datetime] = UNSET,
21
+ created_by_me: Optional[bool] = False,
22
+ status: OptionalNullable[models.BatchJobStatus] = UNSET,
23
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
24
+ server_url: Optional[str] = None,
25
+ timeout_ms: Optional[int] = None,
26
+ ) -> Optional[models.BatchJobsOut]:
27
+ r"""Get Batch Jobs
28
+
29
+ Get a list of batch jobs for your organization and user.
30
+
31
+ :param page:
32
+ :param page_size:
33
+ :param model:
34
+ :param metadata:
35
+ :param created_after:
36
+ :param created_by_me:
37
+ :param status:
38
+ :param retries: Override the default retry configuration for this method
39
+ :param server_url: Override the default server URL for this method
40
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
41
+ """
42
+ base_url = None
43
+ url_variables = None
44
+ if timeout_ms is None:
45
+ timeout_ms = self.sdk_configuration.timeout_ms
46
+
47
+ if server_url is not None:
48
+ base_url = server_url
49
+
50
+ request = models.JobsAPIRoutesBatchGetBatchJobsRequest(
51
+ page=page,
52
+ page_size=page_size,
53
+ model=model,
54
+ metadata=metadata,
55
+ created_after=created_after,
56
+ created_by_me=created_by_me,
57
+ status=status,
58
+ )
59
+
60
+ req = self.build_request(
61
+ method="GET",
62
+ path="/v1/batch/jobs",
63
+ base_url=base_url,
64
+ url_variables=url_variables,
65
+ request=request,
66
+ request_body_required=False,
67
+ request_has_path_params=False,
68
+ request_has_query_params=True,
69
+ user_agent_header="user-agent",
70
+ accept_header_value="application/json",
71
+ security=self.sdk_configuration.security,
72
+ timeout_ms=timeout_ms,
73
+ )
74
+
75
+ if retries == UNSET:
76
+ if self.sdk_configuration.retry_config is not UNSET:
77
+ retries = self.sdk_configuration.retry_config
78
+
79
+ retry_config = None
80
+ if isinstance(retries, utils.RetryConfig):
81
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
82
+
83
+ http_res = self.do_request(
84
+ hook_ctx=HookContext(
85
+ operation_id="jobs_api_routes_batch_get_batch_jobs",
86
+ oauth2_scopes=[],
87
+ security_source=get_security_from_env(
88
+ self.sdk_configuration.security, models.Security
89
+ ),
90
+ ),
91
+ request=req,
92
+ error_status_codes=["4XX", "5XX"],
93
+ retry_config=retry_config,
94
+ )
95
+
96
+ if utils.match_response(http_res, "200", "application/json"):
97
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobsOut])
98
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
99
+ http_res_text = utils.stream_to_text(http_res)
100
+ raise models.SDKError(
101
+ "API error occurred", http_res.status_code, http_res_text, http_res
102
+ )
103
+
104
+ content_type = http_res.headers.get("Content-Type")
105
+ http_res_text = utils.stream_to_text(http_res)
106
+ raise models.SDKError(
107
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
108
+ http_res.status_code,
109
+ http_res_text,
110
+ http_res,
111
+ )
112
+
113
+ async def list_async(
114
+ self,
115
+ *,
116
+ page: Optional[int] = 0,
117
+ page_size: Optional[int] = 100,
118
+ model: OptionalNullable[str] = UNSET,
119
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
120
+ created_after: OptionalNullable[datetime] = UNSET,
121
+ created_by_me: Optional[bool] = False,
122
+ status: OptionalNullable[models.BatchJobStatus] = UNSET,
123
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
124
+ server_url: Optional[str] = None,
125
+ timeout_ms: Optional[int] = None,
126
+ ) -> Optional[models.BatchJobsOut]:
127
+ r"""Get Batch Jobs
128
+
129
+ Get a list of batch jobs for your organization and user.
130
+
131
+ :param page:
132
+ :param page_size:
133
+ :param model:
134
+ :param metadata:
135
+ :param created_after:
136
+ :param created_by_me:
137
+ :param status:
138
+ :param retries: Override the default retry configuration for this method
139
+ :param server_url: Override the default server URL for this method
140
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
141
+ """
142
+ base_url = None
143
+ url_variables = None
144
+ if timeout_ms is None:
145
+ timeout_ms = self.sdk_configuration.timeout_ms
146
+
147
+ if server_url is not None:
148
+ base_url = server_url
149
+
150
+ request = models.JobsAPIRoutesBatchGetBatchJobsRequest(
151
+ page=page,
152
+ page_size=page_size,
153
+ model=model,
154
+ metadata=metadata,
155
+ created_after=created_after,
156
+ created_by_me=created_by_me,
157
+ status=status,
158
+ )
159
+
160
+ req = self.build_request_async(
161
+ method="GET",
162
+ path="/v1/batch/jobs",
163
+ base_url=base_url,
164
+ url_variables=url_variables,
165
+ request=request,
166
+ request_body_required=False,
167
+ request_has_path_params=False,
168
+ request_has_query_params=True,
169
+ user_agent_header="user-agent",
170
+ accept_header_value="application/json",
171
+ security=self.sdk_configuration.security,
172
+ timeout_ms=timeout_ms,
173
+ )
174
+
175
+ if retries == UNSET:
176
+ if self.sdk_configuration.retry_config is not UNSET:
177
+ retries = self.sdk_configuration.retry_config
178
+
179
+ retry_config = None
180
+ if isinstance(retries, utils.RetryConfig):
181
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
182
+
183
+ http_res = await self.do_request_async(
184
+ hook_ctx=HookContext(
185
+ operation_id="jobs_api_routes_batch_get_batch_jobs",
186
+ oauth2_scopes=[],
187
+ security_source=get_security_from_env(
188
+ self.sdk_configuration.security, models.Security
189
+ ),
190
+ ),
191
+ request=req,
192
+ error_status_codes=["4XX", "5XX"],
193
+ retry_config=retry_config,
194
+ )
195
+
196
+ if utils.match_response(http_res, "200", "application/json"):
197
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobsOut])
198
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
199
+ http_res_text = await utils.stream_to_text_async(http_res)
200
+ raise models.SDKError(
201
+ "API error occurred", http_res.status_code, http_res_text, http_res
202
+ )
203
+
204
+ content_type = http_res.headers.get("Content-Type")
205
+ http_res_text = await utils.stream_to_text_async(http_res)
206
+ raise models.SDKError(
207
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
208
+ http_res.status_code,
209
+ http_res_text,
210
+ http_res,
211
+ )
212
+
213
+ def create(
214
+ self,
215
+ *,
216
+ input_files: List[str],
217
+ endpoint: models.APIEndpoint,
218
+ model: str,
219
+ metadata: OptionalNullable[Dict[str, str]] = UNSET,
220
+ timeout_hours: Optional[int] = 24,
221
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
222
+ server_url: Optional[str] = None,
223
+ timeout_ms: Optional[int] = None,
224
+ ) -> Optional[models.BatchJobOut]:
225
+ r"""Create Batch Job
226
+
227
+ Create a new batch job, it will be queued for processing.
228
+
229
+ :param input_files:
230
+ :param endpoint:
231
+ :param model:
232
+ :param metadata:
233
+ :param timeout_hours:
234
+ :param retries: Override the default retry configuration for this method
235
+ :param server_url: Override the default server URL for this method
236
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
237
+ """
238
+ base_url = None
239
+ url_variables = None
240
+ if timeout_ms is None:
241
+ timeout_ms = self.sdk_configuration.timeout_ms
242
+
243
+ if server_url is not None:
244
+ base_url = server_url
245
+
246
+ request = models.BatchJobIn(
247
+ input_files=input_files,
248
+ endpoint=endpoint,
249
+ model=model,
250
+ metadata=metadata,
251
+ timeout_hours=timeout_hours,
252
+ )
253
+
254
+ req = self.build_request(
255
+ method="POST",
256
+ path="/v1/batch/jobs",
257
+ base_url=base_url,
258
+ url_variables=url_variables,
259
+ request=request,
260
+ request_body_required=True,
261
+ request_has_path_params=False,
262
+ request_has_query_params=True,
263
+ user_agent_header="user-agent",
264
+ accept_header_value="application/json",
265
+ security=self.sdk_configuration.security,
266
+ get_serialized_body=lambda: utils.serialize_request_body(
267
+ request, False, False, "json", models.BatchJobIn
268
+ ),
269
+ timeout_ms=timeout_ms,
270
+ )
271
+
272
+ if retries == UNSET:
273
+ if self.sdk_configuration.retry_config is not UNSET:
274
+ retries = self.sdk_configuration.retry_config
275
+
276
+ retry_config = None
277
+ if isinstance(retries, utils.RetryConfig):
278
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
279
+
280
+ http_res = self.do_request(
281
+ hook_ctx=HookContext(
282
+ operation_id="jobs_api_routes_batch_create_batch_job",
283
+ oauth2_scopes=[],
284
+ security_source=get_security_from_env(
285
+ self.sdk_configuration.security, models.Security
286
+ ),
287
+ ),
288
+ request=req,
289
+ error_status_codes=["4XX", "5XX"],
290
+ retry_config=retry_config,
291
+ )
292
+
293
+ if utils.match_response(http_res, "200", "application/json"):
294
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
295
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
296
+ http_res_text = utils.stream_to_text(http_res)
297
+ raise models.SDKError(
298
+ "API error occurred", http_res.status_code, http_res_text, http_res
299
+ )
300
+
301
+ content_type = http_res.headers.get("Content-Type")
302
+ http_res_text = utils.stream_to_text(http_res)
303
+ raise models.SDKError(
304
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
305
+ http_res.status_code,
306
+ http_res_text,
307
+ http_res,
308
+ )
309
+
310
+ async def create_async(
311
+ self,
312
+ *,
313
+ input_files: List[str],
314
+ endpoint: models.APIEndpoint,
315
+ model: str,
316
+ metadata: OptionalNullable[Dict[str, str]] = UNSET,
317
+ timeout_hours: Optional[int] = 24,
318
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
319
+ server_url: Optional[str] = None,
320
+ timeout_ms: Optional[int] = None,
321
+ ) -> Optional[models.BatchJobOut]:
322
+ r"""Create Batch Job
323
+
324
+ Create a new batch job, it will be queued for processing.
325
+
326
+ :param input_files:
327
+ :param endpoint:
328
+ :param model:
329
+ :param metadata:
330
+ :param timeout_hours:
331
+ :param retries: Override the default retry configuration for this method
332
+ :param server_url: Override the default server URL for this method
333
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
334
+ """
335
+ base_url = None
336
+ url_variables = None
337
+ if timeout_ms is None:
338
+ timeout_ms = self.sdk_configuration.timeout_ms
339
+
340
+ if server_url is not None:
341
+ base_url = server_url
342
+
343
+ request = models.BatchJobIn(
344
+ input_files=input_files,
345
+ endpoint=endpoint,
346
+ model=model,
347
+ metadata=metadata,
348
+ timeout_hours=timeout_hours,
349
+ )
350
+
351
+ req = self.build_request_async(
352
+ method="POST",
353
+ path="/v1/batch/jobs",
354
+ base_url=base_url,
355
+ url_variables=url_variables,
356
+ request=request,
357
+ request_body_required=True,
358
+ request_has_path_params=False,
359
+ request_has_query_params=True,
360
+ user_agent_header="user-agent",
361
+ accept_header_value="application/json",
362
+ security=self.sdk_configuration.security,
363
+ get_serialized_body=lambda: utils.serialize_request_body(
364
+ request, False, False, "json", models.BatchJobIn
365
+ ),
366
+ timeout_ms=timeout_ms,
367
+ )
368
+
369
+ if retries == UNSET:
370
+ if self.sdk_configuration.retry_config is not UNSET:
371
+ retries = self.sdk_configuration.retry_config
372
+
373
+ retry_config = None
374
+ if isinstance(retries, utils.RetryConfig):
375
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
376
+
377
+ http_res = await self.do_request_async(
378
+ hook_ctx=HookContext(
379
+ operation_id="jobs_api_routes_batch_create_batch_job",
380
+ oauth2_scopes=[],
381
+ security_source=get_security_from_env(
382
+ self.sdk_configuration.security, models.Security
383
+ ),
384
+ ),
385
+ request=req,
386
+ error_status_codes=["4XX", "5XX"],
387
+ retry_config=retry_config,
388
+ )
389
+
390
+ if utils.match_response(http_res, "200", "application/json"):
391
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
392
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
393
+ http_res_text = await utils.stream_to_text_async(http_res)
394
+ raise models.SDKError(
395
+ "API error occurred", http_res.status_code, http_res_text, http_res
396
+ )
397
+
398
+ content_type = http_res.headers.get("Content-Type")
399
+ http_res_text = await utils.stream_to_text_async(http_res)
400
+ raise models.SDKError(
401
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
402
+ http_res.status_code,
403
+ http_res_text,
404
+ http_res,
405
+ )
406
+
407
+ def get(
408
+ self,
409
+ *,
410
+ job_id: str,
411
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
412
+ server_url: Optional[str] = None,
413
+ timeout_ms: Optional[int] = None,
414
+ ) -> Optional[models.BatchJobOut]:
415
+ r"""Get Batch Job
416
+
417
+ Get a batch job details by its UUID.
418
+
419
+ :param job_id:
420
+ :param retries: Override the default retry configuration for this method
421
+ :param server_url: Override the default server URL for this method
422
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
423
+ """
424
+ base_url = None
425
+ url_variables = None
426
+ if timeout_ms is None:
427
+ timeout_ms = self.sdk_configuration.timeout_ms
428
+
429
+ if server_url is not None:
430
+ base_url = server_url
431
+
432
+ request = models.JobsAPIRoutesBatchGetBatchJobRequest(
433
+ job_id=job_id,
434
+ )
435
+
436
+ req = self.build_request(
437
+ method="GET",
438
+ path="/v1/batch/jobs/{job_id}",
439
+ base_url=base_url,
440
+ url_variables=url_variables,
441
+ request=request,
442
+ request_body_required=False,
443
+ request_has_path_params=True,
444
+ request_has_query_params=True,
445
+ user_agent_header="user-agent",
446
+ accept_header_value="application/json",
447
+ security=self.sdk_configuration.security,
448
+ timeout_ms=timeout_ms,
449
+ )
450
+
451
+ if retries == UNSET:
452
+ if self.sdk_configuration.retry_config is not UNSET:
453
+ retries = self.sdk_configuration.retry_config
454
+
455
+ retry_config = None
456
+ if isinstance(retries, utils.RetryConfig):
457
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
458
+
459
+ http_res = self.do_request(
460
+ hook_ctx=HookContext(
461
+ operation_id="jobs_api_routes_batch_get_batch_job",
462
+ oauth2_scopes=[],
463
+ security_source=get_security_from_env(
464
+ self.sdk_configuration.security, models.Security
465
+ ),
466
+ ),
467
+ request=req,
468
+ error_status_codes=["4XX", "5XX"],
469
+ retry_config=retry_config,
470
+ )
471
+
472
+ if utils.match_response(http_res, "200", "application/json"):
473
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
474
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
475
+ http_res_text = utils.stream_to_text(http_res)
476
+ raise models.SDKError(
477
+ "API error occurred", http_res.status_code, http_res_text, http_res
478
+ )
479
+
480
+ content_type = http_res.headers.get("Content-Type")
481
+ http_res_text = utils.stream_to_text(http_res)
482
+ raise models.SDKError(
483
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
484
+ http_res.status_code,
485
+ http_res_text,
486
+ http_res,
487
+ )
488
+
489
+ async def get_async(
490
+ self,
491
+ *,
492
+ job_id: str,
493
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
494
+ server_url: Optional[str] = None,
495
+ timeout_ms: Optional[int] = None,
496
+ ) -> Optional[models.BatchJobOut]:
497
+ r"""Get Batch Job
498
+
499
+ Get a batch job details by its UUID.
500
+
501
+ :param job_id:
502
+ :param retries: Override the default retry configuration for this method
503
+ :param server_url: Override the default server URL for this method
504
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
505
+ """
506
+ base_url = None
507
+ url_variables = None
508
+ if timeout_ms is None:
509
+ timeout_ms = self.sdk_configuration.timeout_ms
510
+
511
+ if server_url is not None:
512
+ base_url = server_url
513
+
514
+ request = models.JobsAPIRoutesBatchGetBatchJobRequest(
515
+ job_id=job_id,
516
+ )
517
+
518
+ req = self.build_request_async(
519
+ method="GET",
520
+ path="/v1/batch/jobs/{job_id}",
521
+ base_url=base_url,
522
+ url_variables=url_variables,
523
+ request=request,
524
+ request_body_required=False,
525
+ request_has_path_params=True,
526
+ request_has_query_params=True,
527
+ user_agent_header="user-agent",
528
+ accept_header_value="application/json",
529
+ security=self.sdk_configuration.security,
530
+ timeout_ms=timeout_ms,
531
+ )
532
+
533
+ if retries == UNSET:
534
+ if self.sdk_configuration.retry_config is not UNSET:
535
+ retries = self.sdk_configuration.retry_config
536
+
537
+ retry_config = None
538
+ if isinstance(retries, utils.RetryConfig):
539
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
540
+
541
+ http_res = await self.do_request_async(
542
+ hook_ctx=HookContext(
543
+ operation_id="jobs_api_routes_batch_get_batch_job",
544
+ oauth2_scopes=[],
545
+ security_source=get_security_from_env(
546
+ self.sdk_configuration.security, models.Security
547
+ ),
548
+ ),
549
+ request=req,
550
+ error_status_codes=["4XX", "5XX"],
551
+ retry_config=retry_config,
552
+ )
553
+
554
+ if utils.match_response(http_res, "200", "application/json"):
555
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
556
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
557
+ http_res_text = await utils.stream_to_text_async(http_res)
558
+ raise models.SDKError(
559
+ "API error occurred", http_res.status_code, http_res_text, http_res
560
+ )
561
+
562
+ content_type = http_res.headers.get("Content-Type")
563
+ http_res_text = await utils.stream_to_text_async(http_res)
564
+ raise models.SDKError(
565
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
566
+ http_res.status_code,
567
+ http_res_text,
568
+ http_res,
569
+ )
570
+
571
+ def cancel(
572
+ self,
573
+ *,
574
+ job_id: str,
575
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
576
+ server_url: Optional[str] = None,
577
+ timeout_ms: Optional[int] = None,
578
+ ) -> Optional[models.BatchJobOut]:
579
+ r"""Cancel Batch Job
580
+
581
+ Request the cancellation of a batch job.
582
+
583
+ :param job_id:
584
+ :param retries: Override the default retry configuration for this method
585
+ :param server_url: Override the default server URL for this method
586
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
587
+ """
588
+ base_url = None
589
+ url_variables = None
590
+ if timeout_ms is None:
591
+ timeout_ms = self.sdk_configuration.timeout_ms
592
+
593
+ if server_url is not None:
594
+ base_url = server_url
595
+
596
+ request = models.JobsAPIRoutesBatchCancelBatchJobRequest(
597
+ job_id=job_id,
598
+ )
599
+
600
+ req = self.build_request(
601
+ method="POST",
602
+ path="/v1/batch/jobs/{job_id}/cancel",
603
+ base_url=base_url,
604
+ url_variables=url_variables,
605
+ request=request,
606
+ request_body_required=False,
607
+ request_has_path_params=True,
608
+ request_has_query_params=True,
609
+ user_agent_header="user-agent",
610
+ accept_header_value="application/json",
611
+ security=self.sdk_configuration.security,
612
+ timeout_ms=timeout_ms,
613
+ )
614
+
615
+ if retries == UNSET:
616
+ if self.sdk_configuration.retry_config is not UNSET:
617
+ retries = self.sdk_configuration.retry_config
618
+
619
+ retry_config = None
620
+ if isinstance(retries, utils.RetryConfig):
621
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
622
+
623
+ http_res = self.do_request(
624
+ hook_ctx=HookContext(
625
+ operation_id="jobs_api_routes_batch_cancel_batch_job",
626
+ oauth2_scopes=[],
627
+ security_source=get_security_from_env(
628
+ self.sdk_configuration.security, models.Security
629
+ ),
630
+ ),
631
+ request=req,
632
+ error_status_codes=["4XX", "5XX"],
633
+ retry_config=retry_config,
634
+ )
635
+
636
+ if utils.match_response(http_res, "200", "application/json"):
637
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
638
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
639
+ http_res_text = utils.stream_to_text(http_res)
640
+ raise models.SDKError(
641
+ "API error occurred", http_res.status_code, http_res_text, http_res
642
+ )
643
+
644
+ content_type = http_res.headers.get("Content-Type")
645
+ http_res_text = utils.stream_to_text(http_res)
646
+ raise models.SDKError(
647
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
648
+ http_res.status_code,
649
+ http_res_text,
650
+ http_res,
651
+ )
652
+
653
+ async def cancel_async(
654
+ self,
655
+ *,
656
+ job_id: str,
657
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
658
+ server_url: Optional[str] = None,
659
+ timeout_ms: Optional[int] = None,
660
+ ) -> Optional[models.BatchJobOut]:
661
+ r"""Cancel Batch Job
662
+
663
+ Request the cancellation of a batch job.
664
+
665
+ :param job_id:
666
+ :param retries: Override the default retry configuration for this method
667
+ :param server_url: Override the default server URL for this method
668
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
669
+ """
670
+ base_url = None
671
+ url_variables = None
672
+ if timeout_ms is None:
673
+ timeout_ms = self.sdk_configuration.timeout_ms
674
+
675
+ if server_url is not None:
676
+ base_url = server_url
677
+
678
+ request = models.JobsAPIRoutesBatchCancelBatchJobRequest(
679
+ job_id=job_id,
680
+ )
681
+
682
+ req = self.build_request_async(
683
+ method="POST",
684
+ path="/v1/batch/jobs/{job_id}/cancel",
685
+ base_url=base_url,
686
+ url_variables=url_variables,
687
+ request=request,
688
+ request_body_required=False,
689
+ request_has_path_params=True,
690
+ request_has_query_params=True,
691
+ user_agent_header="user-agent",
692
+ accept_header_value="application/json",
693
+ security=self.sdk_configuration.security,
694
+ timeout_ms=timeout_ms,
695
+ )
696
+
697
+ if retries == UNSET:
698
+ if self.sdk_configuration.retry_config is not UNSET:
699
+ retries = self.sdk_configuration.retry_config
700
+
701
+ retry_config = None
702
+ if isinstance(retries, utils.RetryConfig):
703
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
704
+
705
+ http_res = await self.do_request_async(
706
+ hook_ctx=HookContext(
707
+ operation_id="jobs_api_routes_batch_cancel_batch_job",
708
+ oauth2_scopes=[],
709
+ security_source=get_security_from_env(
710
+ self.sdk_configuration.security, models.Security
711
+ ),
712
+ ),
713
+ request=req,
714
+ error_status_codes=["4XX", "5XX"],
715
+ retry_config=retry_config,
716
+ )
717
+
718
+ if utils.match_response(http_res, "200", "application/json"):
719
+ return utils.unmarshal_json(http_res.text, Optional[models.BatchJobOut])
720
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
721
+ http_res_text = await utils.stream_to_text_async(http_res)
722
+ raise models.SDKError(
723
+ "API error occurred", http_res.status_code, http_res_text, http_res
724
+ )
725
+
726
+ content_type = http_res.headers.get("Content-Type")
727
+ http_res_text = await utils.stream_to_text_async(http_res)
728
+ raise models.SDKError(
729
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
730
+ http_res.status_code,
731
+ http_res_text,
732
+ http_res,
733
+ )