mistralai 1.0.3__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistralai/__init__.py +4 -0
- mistralai/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/_version.py +12 -0
- mistralai/agents.py +334 -164
- mistralai/basesdk.py +90 -5
- mistralai/batch.py +17 -0
- mistralai/chat.py +316 -166
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +79 -55
- mistralai/files.py +487 -194
- mistralai/fim.py +206 -132
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +392 -263
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +593 -50
- mistralai/models/agentscompletionrequest.py +70 -17
- mistralai/models/agentscompletionstreamrequest.py +72 -17
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +15 -5
- mistralai/models/assistantmessage.py +22 -10
- mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
- 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 +13 -6
- mistralai/models/chatcompletionrequest.py +86 -21
- mistralai/models/chatcompletionresponse.py +8 -4
- mistralai/models/chatcompletionstreamrequest.py +88 -21
- mistralai/models/checkpointout.py +4 -3
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +12 -5
- mistralai/models/completionevent.py +2 -3
- mistralai/models/completionresponsestreamchoice.py +22 -8
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
- mistralai/models/deletefileout.py +4 -3
- mistralai/models/deletemodelout.py +5 -4
- mistralai/models/deltamessage.py +23 -11
- mistralai/models/detailedjobout.py +70 -12
- mistralai/models/embeddingrequest.py +14 -9
- mistralai/models/embeddingresponse.py +7 -3
- mistralai/models/embeddingresponsedata.py +5 -4
- mistralai/models/eventout.py +11 -6
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +5 -5
- 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 +5 -5
- mistralai/models/files_api_routes_upload_fileop.py +33 -14
- mistralai/models/fileschema.py +22 -15
- mistralai/models/fimcompletionrequest.py +44 -16
- mistralai/models/fimcompletionresponse.py +8 -4
- mistralai/models/fimcompletionstreamrequest.py +44 -16
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +6 -4
- mistralai/models/ftmodelcard.py +121 -0
- mistralai/models/ftmodelout.py +39 -9
- mistralai/models/function.py +5 -4
- mistralai/models/functioncall.py +4 -3
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +24 -7
- mistralai/models/githubrepositoryout.py +24 -7
- mistralai/models/httpvalidationerror.py +1 -3
- mistralai/models/imageurl.py +47 -0
- mistralai/models/imageurlchunk.py +38 -0
- mistralai/models/jobin.py +24 -7
- mistralai/models/jobmetadataout.py +32 -8
- mistralai/models/jobout.py +65 -12
- 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 +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
- 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 +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
- mistralai/models/jobsout.py +13 -5
- mistralai/models/legacyjobmetadataout.py +55 -9
- mistralai/models/listfilesout.py +7 -3
- mistralai/models/metricout.py +12 -8
- mistralai/models/modelcapabilities.py +9 -4
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +7 -8
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
- mistralai/models/retrievefileout.py +25 -15
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +14 -5
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +10 -9
- mistralai/models/textchunk.py +14 -5
- mistralai/models/tool.py +10 -9
- mistralai/models/toolcall.py +10 -8
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +13 -6
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +4 -4
- mistralai/models/trainingparameters.py +34 -8
- mistralai/models/trainingparametersin.py +36 -10
- mistralai/models/unarchiveftmodelout.py +15 -5
- mistralai/models/updateftmodelin.py +9 -6
- mistralai/models/uploadfileout.py +22 -15
- mistralai/models/usageinfo.py +4 -3
- mistralai/models/usermessage.py +42 -10
- mistralai/models/validationerror.py +5 -3
- mistralai/models/wandbintegration.py +23 -7
- mistralai/models/wandbintegrationout.py +23 -8
- mistralai/models_.py +416 -294
- mistralai/sdk.py +31 -19
- mistralai/sdkconfiguration.py +9 -11
- mistralai/utils/__init__.py +14 -1
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
- mistralai-1.2.0.dist-info/RECORD +276 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/_version.py +12 -0
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +308 -166
- mistralai_azure/models/__init__.py +164 -16
- mistralai_azure/models/assistantmessage.py +29 -11
- mistralai_azure/models/chatcompletionchoice.py +15 -6
- mistralai_azure/models/chatcompletionrequest.py +94 -22
- mistralai_azure/models/chatcompletionresponse.py +8 -4
- mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
- mistralai_azure/models/completionchunk.py +12 -5
- mistralai_azure/models/completionevent.py +2 -3
- mistralai_azure/models/completionresponsestreamchoice.py +19 -8
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +30 -12
- mistralai_azure/models/function.py +5 -4
- mistralai_azure/models/functioncall.py +4 -3
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +1 -3
- mistralai_azure/models/responseformat.py +7 -8
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +13 -5
- mistralai_azure/models/systemmessage.py +10 -9
- mistralai_azure/models/textchunk.py +14 -5
- mistralai_azure/models/tool.py +10 -9
- mistralai_azure/models/toolcall.py +10 -8
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +20 -7
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +4 -3
- mistralai_azure/models/usermessage.py +42 -10
- mistralai_azure/models/validationerror.py +5 -3
- mistralai_azure/sdkconfiguration.py +9 -11
- mistralai_azure/utils/__init__.py +16 -3
- mistralai_azure/utils/annotations.py +13 -2
- 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 +42 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +308 -166
- mistralai_gcp/fim.py +198 -132
- mistralai_gcp/models/__init__.py +186 -18
- mistralai_gcp/models/assistantmessage.py +29 -11
- mistralai_gcp/models/chatcompletionchoice.py +15 -6
- mistralai_gcp/models/chatcompletionrequest.py +91 -22
- mistralai_gcp/models/chatcompletionresponse.py +8 -4
- mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
- mistralai_gcp/models/completionchunk.py +12 -5
- mistralai_gcp/models/completionevent.py +2 -3
- mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +30 -12
- mistralai_gcp/models/fimcompletionrequest.py +51 -17
- mistralai_gcp/models/fimcompletionresponse.py +8 -4
- mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
- mistralai_gcp/models/function.py +5 -4
- mistralai_gcp/models/functioncall.py +4 -3
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +1 -3
- mistralai_gcp/models/responseformat.py +7 -8
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +13 -5
- mistralai_gcp/models/systemmessage.py +10 -9
- mistralai_gcp/models/textchunk.py +14 -5
- mistralai_gcp/models/tool.py +10 -9
- mistralai_gcp/models/toolcall.py +10 -8
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +20 -7
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +4 -3
- mistralai_gcp/models/usermessage.py +42 -10
- mistralai_gcp/models/validationerror.py +5 -3
- mistralai_gcp/sdk.py +6 -7
- mistralai_gcp/sdkconfiguration.py +9 -11
- mistralai_gcp/utils/__init__.py +16 -3
- mistralai_gcp/utils/annotations.py +13 -2
- 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 +42 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.3.dist-info/RECORD +0 -236
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
mistralai/jobs.py
CHANGED
|
@@ -8,11 +8,11 @@ from mistralai.types import OptionalNullable, UNSET
|
|
|
8
8
|
from mistralai.utils import get_security_from_env
|
|
9
9
|
from typing import List, Optional, Union
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
class Jobs(BaseSDK):
|
|
12
|
-
|
|
13
|
-
|
|
14
13
|
def list(
|
|
15
|
-
self,
|
|
14
|
+
self,
|
|
15
|
+
*,
|
|
16
16
|
page: Optional[int] = 0,
|
|
17
17
|
page_size: Optional[int] = 100,
|
|
18
18
|
model: OptionalNullable[str] = UNSET,
|
|
@@ -47,10 +47,10 @@ class Jobs(BaseSDK):
|
|
|
47
47
|
url_variables = None
|
|
48
48
|
if timeout_ms is None:
|
|
49
49
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
if server_url is not None:
|
|
52
52
|
base_url = server_url
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
request = models.JobsAPIRoutesFineTuningGetFineTuningJobsRequest(
|
|
55
55
|
page=page,
|
|
56
56
|
page_size=page_size,
|
|
@@ -62,7 +62,7 @@ class Jobs(BaseSDK):
|
|
|
62
62
|
wandb_name=wandb_name,
|
|
63
63
|
suffix=suffix,
|
|
64
64
|
)
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
req = self.build_request(
|
|
67
67
|
method="GET",
|
|
68
68
|
path="/v1/fine_tuning/jobs",
|
|
@@ -77,40 +77,48 @@ class Jobs(BaseSDK):
|
|
|
77
77
|
security=self.sdk_configuration.security,
|
|
78
78
|
timeout_ms=timeout_ms,
|
|
79
79
|
)
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
if retries == UNSET:
|
|
82
82
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
83
83
|
retries = self.sdk_configuration.retry_config
|
|
84
84
|
|
|
85
85
|
retry_config = None
|
|
86
86
|
if isinstance(retries, utils.RetryConfig):
|
|
87
|
-
retry_config = (retries, [
|
|
88
|
-
|
|
89
|
-
"500",
|
|
90
|
-
"502",
|
|
91
|
-
"503",
|
|
92
|
-
"504"
|
|
93
|
-
])
|
|
94
|
-
|
|
87
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
88
|
+
|
|
95
89
|
http_res = self.do_request(
|
|
96
|
-
hook_ctx=HookContext(
|
|
90
|
+
hook_ctx=HookContext(
|
|
91
|
+
operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_jobs",
|
|
92
|
+
oauth2_scopes=[],
|
|
93
|
+
security_source=get_security_from_env(
|
|
94
|
+
self.sdk_configuration.security, models.Security
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
97
|
request=req,
|
|
98
|
-
error_status_codes=["4XX","5XX"],
|
|
99
|
-
retry_config=retry_config
|
|
98
|
+
error_status_codes=["4XX", "5XX"],
|
|
99
|
+
retry_config=retry_config,
|
|
100
100
|
)
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
if utils.match_response(http_res, "200", "application/json"):
|
|
103
103
|
return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
|
|
104
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
105
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
106
|
+
raise models.SDKError(
|
|
107
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
108
|
+
)
|
|
109
|
+
|
|
107
110
|
content_type = http_res.headers.get("Content-Type")
|
|
108
|
-
|
|
111
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
112
|
+
raise models.SDKError(
|
|
113
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
114
|
+
http_res.status_code,
|
|
115
|
+
http_res_text,
|
|
116
|
+
http_res,
|
|
117
|
+
)
|
|
109
118
|
|
|
110
|
-
|
|
111
|
-
|
|
112
119
|
async def list_async(
|
|
113
|
-
self,
|
|
120
|
+
self,
|
|
121
|
+
*,
|
|
114
122
|
page: Optional[int] = 0,
|
|
115
123
|
page_size: Optional[int] = 100,
|
|
116
124
|
model: OptionalNullable[str] = UNSET,
|
|
@@ -145,10 +153,10 @@ class Jobs(BaseSDK):
|
|
|
145
153
|
url_variables = None
|
|
146
154
|
if timeout_ms is None:
|
|
147
155
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
148
|
-
|
|
156
|
+
|
|
149
157
|
if server_url is not None:
|
|
150
158
|
base_url = server_url
|
|
151
|
-
|
|
159
|
+
|
|
152
160
|
request = models.JobsAPIRoutesFineTuningGetFineTuningJobsRequest(
|
|
153
161
|
page=page,
|
|
154
162
|
page_size=page_size,
|
|
@@ -160,8 +168,8 @@ class Jobs(BaseSDK):
|
|
|
160
168
|
wandb_name=wandb_name,
|
|
161
169
|
suffix=suffix,
|
|
162
170
|
)
|
|
163
|
-
|
|
164
|
-
req = self.
|
|
171
|
+
|
|
172
|
+
req = self.build_request_async(
|
|
165
173
|
method="GET",
|
|
166
174
|
path="/v1/fine_tuning/jobs",
|
|
167
175
|
base_url=base_url,
|
|
@@ -175,47 +183,67 @@ class Jobs(BaseSDK):
|
|
|
175
183
|
security=self.sdk_configuration.security,
|
|
176
184
|
timeout_ms=timeout_ms,
|
|
177
185
|
)
|
|
178
|
-
|
|
186
|
+
|
|
179
187
|
if retries == UNSET:
|
|
180
188
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
181
189
|
retries = self.sdk_configuration.retry_config
|
|
182
190
|
|
|
183
191
|
retry_config = None
|
|
184
192
|
if isinstance(retries, utils.RetryConfig):
|
|
185
|
-
retry_config = (retries, [
|
|
186
|
-
|
|
187
|
-
"500",
|
|
188
|
-
"502",
|
|
189
|
-
"503",
|
|
190
|
-
"504"
|
|
191
|
-
])
|
|
192
|
-
|
|
193
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
194
|
+
|
|
193
195
|
http_res = await self.do_request_async(
|
|
194
|
-
hook_ctx=HookContext(
|
|
196
|
+
hook_ctx=HookContext(
|
|
197
|
+
operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_jobs",
|
|
198
|
+
oauth2_scopes=[],
|
|
199
|
+
security_source=get_security_from_env(
|
|
200
|
+
self.sdk_configuration.security, models.Security
|
|
201
|
+
),
|
|
202
|
+
),
|
|
195
203
|
request=req,
|
|
196
|
-
error_status_codes=["4XX","5XX"],
|
|
197
|
-
retry_config=retry_config
|
|
204
|
+
error_status_codes=["4XX", "5XX"],
|
|
205
|
+
retry_config=retry_config,
|
|
198
206
|
)
|
|
199
|
-
|
|
207
|
+
|
|
200
208
|
if utils.match_response(http_res, "200", "application/json"):
|
|
201
209
|
return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
|
|
202
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
203
|
-
|
|
204
|
-
|
|
210
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
211
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
212
|
+
raise models.SDKError(
|
|
213
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
214
|
+
)
|
|
215
|
+
|
|
205
216
|
content_type = http_res.headers.get("Content-Type")
|
|
206
|
-
|
|
217
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
218
|
+
raise models.SDKError(
|
|
219
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
220
|
+
http_res.status_code,
|
|
221
|
+
http_res_text,
|
|
222
|
+
http_res,
|
|
223
|
+
)
|
|
207
224
|
|
|
208
|
-
|
|
209
|
-
|
|
210
225
|
def create(
|
|
211
|
-
self,
|
|
226
|
+
self,
|
|
227
|
+
*,
|
|
212
228
|
model: models.FineTuneableModel,
|
|
213
|
-
hyperparameters: Union[
|
|
214
|
-
|
|
229
|
+
hyperparameters: Union[
|
|
230
|
+
models.TrainingParametersIn, models.TrainingParametersInTypedDict
|
|
231
|
+
],
|
|
232
|
+
training_files: Optional[
|
|
233
|
+
Union[List[models.TrainingFile], List[models.TrainingFileTypedDict]]
|
|
234
|
+
] = None,
|
|
215
235
|
validation_files: OptionalNullable[List[str]] = UNSET,
|
|
216
236
|
suffix: OptionalNullable[str] = UNSET,
|
|
217
|
-
integrations: OptionalNullable[
|
|
218
|
-
|
|
237
|
+
integrations: OptionalNullable[
|
|
238
|
+
Union[
|
|
239
|
+
List[models.JobInIntegrations], List[models.JobInIntegrationsTypedDict]
|
|
240
|
+
]
|
|
241
|
+
] = UNSET,
|
|
242
|
+
repositories: Optional[
|
|
243
|
+
Union[
|
|
244
|
+
List[models.JobInRepositories], List[models.JobInRepositoriesTypedDict]
|
|
245
|
+
]
|
|
246
|
+
] = None,
|
|
219
247
|
auto_start: Optional[bool] = None,
|
|
220
248
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
221
249
|
server_url: Optional[str] = None,
|
|
@@ -227,11 +255,11 @@ class Jobs(BaseSDK):
|
|
|
227
255
|
|
|
228
256
|
:param model: The name of the model to fine-tune.
|
|
229
257
|
:param hyperparameters: The fine-tuning hyperparameter settings used in a fine-tune job.
|
|
230
|
-
:param training_files:
|
|
258
|
+
:param training_files:
|
|
231
259
|
:param validation_files: A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in `checkpoints` when getting the status of a running fine-tuning job. The same data should not be present in both train and validation files.
|
|
232
260
|
:param suffix: A string that will be added to your fine-tuning model name. For example, a suffix of \"my-great-model\" would produce a model name like `ft:open-mistral-7b:my-great-model:xxx...`
|
|
233
261
|
:param integrations: A list of integrations to enable for your fine-tuning job.
|
|
234
|
-
:param repositories:
|
|
262
|
+
:param repositories:
|
|
235
263
|
:param auto_start: This field will be required in a future release.
|
|
236
264
|
:param retries: Override the default retry configuration for this method
|
|
237
265
|
:param server_url: Override the default server URL for this method
|
|
@@ -241,21 +269,29 @@ class Jobs(BaseSDK):
|
|
|
241
269
|
url_variables = None
|
|
242
270
|
if timeout_ms is None:
|
|
243
271
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
244
|
-
|
|
272
|
+
|
|
245
273
|
if server_url is not None:
|
|
246
274
|
base_url = server_url
|
|
247
|
-
|
|
275
|
+
|
|
248
276
|
request = models.JobIn(
|
|
249
277
|
model=model,
|
|
250
|
-
training_files=utils.get_pydantic_model(
|
|
278
|
+
training_files=utils.get_pydantic_model(
|
|
279
|
+
training_files, Optional[List[models.TrainingFile]]
|
|
280
|
+
),
|
|
251
281
|
validation_files=validation_files,
|
|
252
|
-
hyperparameters=utils.get_pydantic_model(
|
|
282
|
+
hyperparameters=utils.get_pydantic_model(
|
|
283
|
+
hyperparameters, models.TrainingParametersIn
|
|
284
|
+
),
|
|
253
285
|
suffix=suffix,
|
|
254
|
-
integrations=utils.get_pydantic_model(
|
|
255
|
-
|
|
286
|
+
integrations=utils.get_pydantic_model(
|
|
287
|
+
integrations, OptionalNullable[List[models.JobInIntegrations]]
|
|
288
|
+
),
|
|
289
|
+
repositories=utils.get_pydantic_model(
|
|
290
|
+
repositories, Optional[List[models.JobInRepositories]]
|
|
291
|
+
),
|
|
256
292
|
auto_start=auto_start,
|
|
257
293
|
)
|
|
258
|
-
|
|
294
|
+
|
|
259
295
|
req = self.build_request(
|
|
260
296
|
method="POST",
|
|
261
297
|
path="/v1/fine_tuning/jobs",
|
|
@@ -268,50 +304,75 @@ class Jobs(BaseSDK):
|
|
|
268
304
|
user_agent_header="user-agent",
|
|
269
305
|
accept_header_value="application/json",
|
|
270
306
|
security=self.sdk_configuration.security,
|
|
271
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
307
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
308
|
+
request, False, False, "json", models.JobIn
|
|
309
|
+
),
|
|
272
310
|
timeout_ms=timeout_ms,
|
|
273
311
|
)
|
|
274
|
-
|
|
312
|
+
|
|
275
313
|
if retries == UNSET:
|
|
276
314
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
277
315
|
retries = self.sdk_configuration.retry_config
|
|
278
316
|
|
|
279
317
|
retry_config = None
|
|
280
318
|
if isinstance(retries, utils.RetryConfig):
|
|
281
|
-
retry_config = (retries, [
|
|
282
|
-
|
|
283
|
-
"500",
|
|
284
|
-
"502",
|
|
285
|
-
"503",
|
|
286
|
-
"504"
|
|
287
|
-
])
|
|
288
|
-
|
|
319
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
320
|
+
|
|
289
321
|
http_res = self.do_request(
|
|
290
|
-
hook_ctx=HookContext(
|
|
322
|
+
hook_ctx=HookContext(
|
|
323
|
+
operation_id="jobs_api_routes_fine_tuning_create_fine_tuning_job",
|
|
324
|
+
oauth2_scopes=[],
|
|
325
|
+
security_source=get_security_from_env(
|
|
326
|
+
self.sdk_configuration.security, models.Security
|
|
327
|
+
),
|
|
328
|
+
),
|
|
291
329
|
request=req,
|
|
292
|
-
error_status_codes=["4XX","5XX"],
|
|
293
|
-
retry_config=retry_config
|
|
330
|
+
error_status_codes=["4XX", "5XX"],
|
|
331
|
+
retry_config=retry_config,
|
|
294
332
|
)
|
|
295
|
-
|
|
333
|
+
|
|
296
334
|
if utils.match_response(http_res, "200", "application/json"):
|
|
297
|
-
return utils.unmarshal_json(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
335
|
+
return utils.unmarshal_json(
|
|
336
|
+
http_res.text,
|
|
337
|
+
Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
|
|
338
|
+
)
|
|
339
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
340
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
341
|
+
raise models.SDKError(
|
|
342
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
343
|
+
)
|
|
344
|
+
|
|
301
345
|
content_type = http_res.headers.get("Content-Type")
|
|
302
|
-
|
|
346
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
347
|
+
raise models.SDKError(
|
|
348
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
349
|
+
http_res.status_code,
|
|
350
|
+
http_res_text,
|
|
351
|
+
http_res,
|
|
352
|
+
)
|
|
303
353
|
|
|
304
|
-
|
|
305
|
-
|
|
306
354
|
async def create_async(
|
|
307
|
-
self,
|
|
355
|
+
self,
|
|
356
|
+
*,
|
|
308
357
|
model: models.FineTuneableModel,
|
|
309
|
-
hyperparameters: Union[
|
|
310
|
-
|
|
358
|
+
hyperparameters: Union[
|
|
359
|
+
models.TrainingParametersIn, models.TrainingParametersInTypedDict
|
|
360
|
+
],
|
|
361
|
+
training_files: Optional[
|
|
362
|
+
Union[List[models.TrainingFile], List[models.TrainingFileTypedDict]]
|
|
363
|
+
] = None,
|
|
311
364
|
validation_files: OptionalNullable[List[str]] = UNSET,
|
|
312
365
|
suffix: OptionalNullable[str] = UNSET,
|
|
313
|
-
integrations: OptionalNullable[
|
|
314
|
-
|
|
366
|
+
integrations: OptionalNullable[
|
|
367
|
+
Union[
|
|
368
|
+
List[models.JobInIntegrations], List[models.JobInIntegrationsTypedDict]
|
|
369
|
+
]
|
|
370
|
+
] = UNSET,
|
|
371
|
+
repositories: Optional[
|
|
372
|
+
Union[
|
|
373
|
+
List[models.JobInRepositories], List[models.JobInRepositoriesTypedDict]
|
|
374
|
+
]
|
|
375
|
+
] = None,
|
|
315
376
|
auto_start: Optional[bool] = None,
|
|
316
377
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
317
378
|
server_url: Optional[str] = None,
|
|
@@ -323,11 +384,11 @@ class Jobs(BaseSDK):
|
|
|
323
384
|
|
|
324
385
|
:param model: The name of the model to fine-tune.
|
|
325
386
|
:param hyperparameters: The fine-tuning hyperparameter settings used in a fine-tune job.
|
|
326
|
-
:param training_files:
|
|
387
|
+
:param training_files:
|
|
327
388
|
:param validation_files: A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in `checkpoints` when getting the status of a running fine-tuning job. The same data should not be present in both train and validation files.
|
|
328
389
|
:param suffix: A string that will be added to your fine-tuning model name. For example, a suffix of \"my-great-model\" would produce a model name like `ft:open-mistral-7b:my-great-model:xxx...`
|
|
329
390
|
:param integrations: A list of integrations to enable for your fine-tuning job.
|
|
330
|
-
:param repositories:
|
|
391
|
+
:param repositories:
|
|
331
392
|
:param auto_start: This field will be required in a future release.
|
|
332
393
|
:param retries: Override the default retry configuration for this method
|
|
333
394
|
:param server_url: Override the default server URL for this method
|
|
@@ -337,22 +398,30 @@ class Jobs(BaseSDK):
|
|
|
337
398
|
url_variables = None
|
|
338
399
|
if timeout_ms is None:
|
|
339
400
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
340
|
-
|
|
401
|
+
|
|
341
402
|
if server_url is not None:
|
|
342
403
|
base_url = server_url
|
|
343
|
-
|
|
404
|
+
|
|
344
405
|
request = models.JobIn(
|
|
345
406
|
model=model,
|
|
346
|
-
training_files=utils.get_pydantic_model(
|
|
407
|
+
training_files=utils.get_pydantic_model(
|
|
408
|
+
training_files, Optional[List[models.TrainingFile]]
|
|
409
|
+
),
|
|
347
410
|
validation_files=validation_files,
|
|
348
|
-
hyperparameters=utils.get_pydantic_model(
|
|
411
|
+
hyperparameters=utils.get_pydantic_model(
|
|
412
|
+
hyperparameters, models.TrainingParametersIn
|
|
413
|
+
),
|
|
349
414
|
suffix=suffix,
|
|
350
|
-
integrations=utils.get_pydantic_model(
|
|
351
|
-
|
|
415
|
+
integrations=utils.get_pydantic_model(
|
|
416
|
+
integrations, OptionalNullable[List[models.JobInIntegrations]]
|
|
417
|
+
),
|
|
418
|
+
repositories=utils.get_pydantic_model(
|
|
419
|
+
repositories, Optional[List[models.JobInRepositories]]
|
|
420
|
+
),
|
|
352
421
|
auto_start=auto_start,
|
|
353
422
|
)
|
|
354
|
-
|
|
355
|
-
req = self.
|
|
423
|
+
|
|
424
|
+
req = self.build_request_async(
|
|
356
425
|
method="POST",
|
|
357
426
|
path="/v1/fine_tuning/jobs",
|
|
358
427
|
base_url=base_url,
|
|
@@ -364,43 +433,56 @@ class Jobs(BaseSDK):
|
|
|
364
433
|
user_agent_header="user-agent",
|
|
365
434
|
accept_header_value="application/json",
|
|
366
435
|
security=self.sdk_configuration.security,
|
|
367
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
436
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
437
|
+
request, False, False, "json", models.JobIn
|
|
438
|
+
),
|
|
368
439
|
timeout_ms=timeout_ms,
|
|
369
440
|
)
|
|
370
|
-
|
|
441
|
+
|
|
371
442
|
if retries == UNSET:
|
|
372
443
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
373
444
|
retries = self.sdk_configuration.retry_config
|
|
374
445
|
|
|
375
446
|
retry_config = None
|
|
376
447
|
if isinstance(retries, utils.RetryConfig):
|
|
377
|
-
retry_config = (retries, [
|
|
378
|
-
|
|
379
|
-
"500",
|
|
380
|
-
"502",
|
|
381
|
-
"503",
|
|
382
|
-
"504"
|
|
383
|
-
])
|
|
384
|
-
|
|
448
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
449
|
+
|
|
385
450
|
http_res = await self.do_request_async(
|
|
386
|
-
hook_ctx=HookContext(
|
|
451
|
+
hook_ctx=HookContext(
|
|
452
|
+
operation_id="jobs_api_routes_fine_tuning_create_fine_tuning_job",
|
|
453
|
+
oauth2_scopes=[],
|
|
454
|
+
security_source=get_security_from_env(
|
|
455
|
+
self.sdk_configuration.security, models.Security
|
|
456
|
+
),
|
|
457
|
+
),
|
|
387
458
|
request=req,
|
|
388
|
-
error_status_codes=["4XX","5XX"],
|
|
389
|
-
retry_config=retry_config
|
|
459
|
+
error_status_codes=["4XX", "5XX"],
|
|
460
|
+
retry_config=retry_config,
|
|
390
461
|
)
|
|
391
|
-
|
|
462
|
+
|
|
392
463
|
if utils.match_response(http_res, "200", "application/json"):
|
|
393
|
-
return utils.unmarshal_json(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
464
|
+
return utils.unmarshal_json(
|
|
465
|
+
http_res.text,
|
|
466
|
+
Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
|
|
467
|
+
)
|
|
468
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
469
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
470
|
+
raise models.SDKError(
|
|
471
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
472
|
+
)
|
|
473
|
+
|
|
397
474
|
content_type = http_res.headers.get("Content-Type")
|
|
398
|
-
|
|
475
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
476
|
+
raise models.SDKError(
|
|
477
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
478
|
+
http_res.status_code,
|
|
479
|
+
http_res_text,
|
|
480
|
+
http_res,
|
|
481
|
+
)
|
|
399
482
|
|
|
400
|
-
|
|
401
|
-
|
|
402
483
|
def get(
|
|
403
|
-
self,
|
|
484
|
+
self,
|
|
485
|
+
*,
|
|
404
486
|
job_id: str,
|
|
405
487
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
406
488
|
server_url: Optional[str] = None,
|
|
@@ -419,14 +501,14 @@ class Jobs(BaseSDK):
|
|
|
419
501
|
url_variables = None
|
|
420
502
|
if timeout_ms is None:
|
|
421
503
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
422
|
-
|
|
504
|
+
|
|
423
505
|
if server_url is not None:
|
|
424
506
|
base_url = server_url
|
|
425
|
-
|
|
507
|
+
|
|
426
508
|
request = models.JobsAPIRoutesFineTuningGetFineTuningJobRequest(
|
|
427
509
|
job_id=job_id,
|
|
428
510
|
)
|
|
429
|
-
|
|
511
|
+
|
|
430
512
|
req = self.build_request(
|
|
431
513
|
method="GET",
|
|
432
514
|
path="/v1/fine_tuning/jobs/{job_id}",
|
|
@@ -441,40 +523,48 @@ class Jobs(BaseSDK):
|
|
|
441
523
|
security=self.sdk_configuration.security,
|
|
442
524
|
timeout_ms=timeout_ms,
|
|
443
525
|
)
|
|
444
|
-
|
|
526
|
+
|
|
445
527
|
if retries == UNSET:
|
|
446
528
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
447
529
|
retries = self.sdk_configuration.retry_config
|
|
448
530
|
|
|
449
531
|
retry_config = None
|
|
450
532
|
if isinstance(retries, utils.RetryConfig):
|
|
451
|
-
retry_config = (retries, [
|
|
452
|
-
|
|
453
|
-
"500",
|
|
454
|
-
"502",
|
|
455
|
-
"503",
|
|
456
|
-
"504"
|
|
457
|
-
])
|
|
458
|
-
|
|
533
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
534
|
+
|
|
459
535
|
http_res = self.do_request(
|
|
460
|
-
hook_ctx=HookContext(
|
|
536
|
+
hook_ctx=HookContext(
|
|
537
|
+
operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_job",
|
|
538
|
+
oauth2_scopes=[],
|
|
539
|
+
security_source=get_security_from_env(
|
|
540
|
+
self.sdk_configuration.security, models.Security
|
|
541
|
+
),
|
|
542
|
+
),
|
|
461
543
|
request=req,
|
|
462
|
-
error_status_codes=["4XX","5XX"],
|
|
463
|
-
retry_config=retry_config
|
|
544
|
+
error_status_codes=["4XX", "5XX"],
|
|
545
|
+
retry_config=retry_config,
|
|
464
546
|
)
|
|
465
|
-
|
|
547
|
+
|
|
466
548
|
if utils.match_response(http_res, "200", "application/json"):
|
|
467
549
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
468
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
469
|
-
|
|
470
|
-
|
|
550
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
551
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
552
|
+
raise models.SDKError(
|
|
553
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
554
|
+
)
|
|
555
|
+
|
|
471
556
|
content_type = http_res.headers.get("Content-Type")
|
|
472
|
-
|
|
557
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
558
|
+
raise models.SDKError(
|
|
559
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
560
|
+
http_res.status_code,
|
|
561
|
+
http_res_text,
|
|
562
|
+
http_res,
|
|
563
|
+
)
|
|
473
564
|
|
|
474
|
-
|
|
475
|
-
|
|
476
565
|
async def get_async(
|
|
477
|
-
self,
|
|
566
|
+
self,
|
|
567
|
+
*,
|
|
478
568
|
job_id: str,
|
|
479
569
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
480
570
|
server_url: Optional[str] = None,
|
|
@@ -493,15 +583,15 @@ class Jobs(BaseSDK):
|
|
|
493
583
|
url_variables = None
|
|
494
584
|
if timeout_ms is None:
|
|
495
585
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
496
|
-
|
|
586
|
+
|
|
497
587
|
if server_url is not None:
|
|
498
588
|
base_url = server_url
|
|
499
|
-
|
|
589
|
+
|
|
500
590
|
request = models.JobsAPIRoutesFineTuningGetFineTuningJobRequest(
|
|
501
591
|
job_id=job_id,
|
|
502
592
|
)
|
|
503
|
-
|
|
504
|
-
req = self.
|
|
593
|
+
|
|
594
|
+
req = self.build_request_async(
|
|
505
595
|
method="GET",
|
|
506
596
|
path="/v1/fine_tuning/jobs/{job_id}",
|
|
507
597
|
base_url=base_url,
|
|
@@ -515,40 +605,48 @@ class Jobs(BaseSDK):
|
|
|
515
605
|
security=self.sdk_configuration.security,
|
|
516
606
|
timeout_ms=timeout_ms,
|
|
517
607
|
)
|
|
518
|
-
|
|
608
|
+
|
|
519
609
|
if retries == UNSET:
|
|
520
610
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
521
611
|
retries = self.sdk_configuration.retry_config
|
|
522
612
|
|
|
523
613
|
retry_config = None
|
|
524
614
|
if isinstance(retries, utils.RetryConfig):
|
|
525
|
-
retry_config = (retries, [
|
|
526
|
-
|
|
527
|
-
"500",
|
|
528
|
-
"502",
|
|
529
|
-
"503",
|
|
530
|
-
"504"
|
|
531
|
-
])
|
|
532
|
-
|
|
615
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
616
|
+
|
|
533
617
|
http_res = await self.do_request_async(
|
|
534
|
-
hook_ctx=HookContext(
|
|
618
|
+
hook_ctx=HookContext(
|
|
619
|
+
operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_job",
|
|
620
|
+
oauth2_scopes=[],
|
|
621
|
+
security_source=get_security_from_env(
|
|
622
|
+
self.sdk_configuration.security, models.Security
|
|
623
|
+
),
|
|
624
|
+
),
|
|
535
625
|
request=req,
|
|
536
|
-
error_status_codes=["4XX","5XX"],
|
|
537
|
-
retry_config=retry_config
|
|
626
|
+
error_status_codes=["4XX", "5XX"],
|
|
627
|
+
retry_config=retry_config,
|
|
538
628
|
)
|
|
539
|
-
|
|
629
|
+
|
|
540
630
|
if utils.match_response(http_res, "200", "application/json"):
|
|
541
631
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
542
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
543
|
-
|
|
544
|
-
|
|
632
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
633
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
634
|
+
raise models.SDKError(
|
|
635
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
636
|
+
)
|
|
637
|
+
|
|
545
638
|
content_type = http_res.headers.get("Content-Type")
|
|
546
|
-
|
|
639
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
640
|
+
raise models.SDKError(
|
|
641
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
642
|
+
http_res.status_code,
|
|
643
|
+
http_res_text,
|
|
644
|
+
http_res,
|
|
645
|
+
)
|
|
547
646
|
|
|
548
|
-
|
|
549
|
-
|
|
550
647
|
def cancel(
|
|
551
|
-
self,
|
|
648
|
+
self,
|
|
649
|
+
*,
|
|
552
650
|
job_id: str,
|
|
553
651
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
554
652
|
server_url: Optional[str] = None,
|
|
@@ -567,14 +665,14 @@ class Jobs(BaseSDK):
|
|
|
567
665
|
url_variables = None
|
|
568
666
|
if timeout_ms is None:
|
|
569
667
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
570
|
-
|
|
668
|
+
|
|
571
669
|
if server_url is not None:
|
|
572
670
|
base_url = server_url
|
|
573
|
-
|
|
671
|
+
|
|
574
672
|
request = models.JobsAPIRoutesFineTuningCancelFineTuningJobRequest(
|
|
575
673
|
job_id=job_id,
|
|
576
674
|
)
|
|
577
|
-
|
|
675
|
+
|
|
578
676
|
req = self.build_request(
|
|
579
677
|
method="POST",
|
|
580
678
|
path="/v1/fine_tuning/jobs/{job_id}/cancel",
|
|
@@ -589,40 +687,48 @@ class Jobs(BaseSDK):
|
|
|
589
687
|
security=self.sdk_configuration.security,
|
|
590
688
|
timeout_ms=timeout_ms,
|
|
591
689
|
)
|
|
592
|
-
|
|
690
|
+
|
|
593
691
|
if retries == UNSET:
|
|
594
692
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
595
693
|
retries = self.sdk_configuration.retry_config
|
|
596
694
|
|
|
597
695
|
retry_config = None
|
|
598
696
|
if isinstance(retries, utils.RetryConfig):
|
|
599
|
-
retry_config = (retries, [
|
|
600
|
-
|
|
601
|
-
"500",
|
|
602
|
-
"502",
|
|
603
|
-
"503",
|
|
604
|
-
"504"
|
|
605
|
-
])
|
|
606
|
-
|
|
697
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
698
|
+
|
|
607
699
|
http_res = self.do_request(
|
|
608
|
-
hook_ctx=HookContext(
|
|
700
|
+
hook_ctx=HookContext(
|
|
701
|
+
operation_id="jobs_api_routes_fine_tuning_cancel_fine_tuning_job",
|
|
702
|
+
oauth2_scopes=[],
|
|
703
|
+
security_source=get_security_from_env(
|
|
704
|
+
self.sdk_configuration.security, models.Security
|
|
705
|
+
),
|
|
706
|
+
),
|
|
609
707
|
request=req,
|
|
610
|
-
error_status_codes=["4XX","5XX"],
|
|
611
|
-
retry_config=retry_config
|
|
708
|
+
error_status_codes=["4XX", "5XX"],
|
|
709
|
+
retry_config=retry_config,
|
|
612
710
|
)
|
|
613
|
-
|
|
711
|
+
|
|
614
712
|
if utils.match_response(http_res, "200", "application/json"):
|
|
615
713
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
616
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
617
|
-
|
|
618
|
-
|
|
714
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
715
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
716
|
+
raise models.SDKError(
|
|
717
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
718
|
+
)
|
|
719
|
+
|
|
619
720
|
content_type = http_res.headers.get("Content-Type")
|
|
620
|
-
|
|
721
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
722
|
+
raise models.SDKError(
|
|
723
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
724
|
+
http_res.status_code,
|
|
725
|
+
http_res_text,
|
|
726
|
+
http_res,
|
|
727
|
+
)
|
|
621
728
|
|
|
622
|
-
|
|
623
|
-
|
|
624
729
|
async def cancel_async(
|
|
625
|
-
self,
|
|
730
|
+
self,
|
|
731
|
+
*,
|
|
626
732
|
job_id: str,
|
|
627
733
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
628
734
|
server_url: Optional[str] = None,
|
|
@@ -641,15 +747,15 @@ class Jobs(BaseSDK):
|
|
|
641
747
|
url_variables = None
|
|
642
748
|
if timeout_ms is None:
|
|
643
749
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
644
|
-
|
|
750
|
+
|
|
645
751
|
if server_url is not None:
|
|
646
752
|
base_url = server_url
|
|
647
|
-
|
|
753
|
+
|
|
648
754
|
request = models.JobsAPIRoutesFineTuningCancelFineTuningJobRequest(
|
|
649
755
|
job_id=job_id,
|
|
650
756
|
)
|
|
651
|
-
|
|
652
|
-
req = self.
|
|
757
|
+
|
|
758
|
+
req = self.build_request_async(
|
|
653
759
|
method="POST",
|
|
654
760
|
path="/v1/fine_tuning/jobs/{job_id}/cancel",
|
|
655
761
|
base_url=base_url,
|
|
@@ -663,40 +769,48 @@ class Jobs(BaseSDK):
|
|
|
663
769
|
security=self.sdk_configuration.security,
|
|
664
770
|
timeout_ms=timeout_ms,
|
|
665
771
|
)
|
|
666
|
-
|
|
772
|
+
|
|
667
773
|
if retries == UNSET:
|
|
668
774
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
669
775
|
retries = self.sdk_configuration.retry_config
|
|
670
776
|
|
|
671
777
|
retry_config = None
|
|
672
778
|
if isinstance(retries, utils.RetryConfig):
|
|
673
|
-
retry_config = (retries, [
|
|
674
|
-
|
|
675
|
-
"500",
|
|
676
|
-
"502",
|
|
677
|
-
"503",
|
|
678
|
-
"504"
|
|
679
|
-
])
|
|
680
|
-
|
|
779
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
780
|
+
|
|
681
781
|
http_res = await self.do_request_async(
|
|
682
|
-
hook_ctx=HookContext(
|
|
782
|
+
hook_ctx=HookContext(
|
|
783
|
+
operation_id="jobs_api_routes_fine_tuning_cancel_fine_tuning_job",
|
|
784
|
+
oauth2_scopes=[],
|
|
785
|
+
security_source=get_security_from_env(
|
|
786
|
+
self.sdk_configuration.security, models.Security
|
|
787
|
+
),
|
|
788
|
+
),
|
|
683
789
|
request=req,
|
|
684
|
-
error_status_codes=["4XX","5XX"],
|
|
685
|
-
retry_config=retry_config
|
|
790
|
+
error_status_codes=["4XX", "5XX"],
|
|
791
|
+
retry_config=retry_config,
|
|
686
792
|
)
|
|
687
|
-
|
|
793
|
+
|
|
688
794
|
if utils.match_response(http_res, "200", "application/json"):
|
|
689
795
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
690
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
691
|
-
|
|
692
|
-
|
|
796
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
797
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
798
|
+
raise models.SDKError(
|
|
799
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
800
|
+
)
|
|
801
|
+
|
|
693
802
|
content_type = http_res.headers.get("Content-Type")
|
|
694
|
-
|
|
803
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
804
|
+
raise models.SDKError(
|
|
805
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
806
|
+
http_res.status_code,
|
|
807
|
+
http_res_text,
|
|
808
|
+
http_res,
|
|
809
|
+
)
|
|
695
810
|
|
|
696
|
-
|
|
697
|
-
|
|
698
811
|
def start(
|
|
699
|
-
self,
|
|
812
|
+
self,
|
|
813
|
+
*,
|
|
700
814
|
job_id: str,
|
|
701
815
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
702
816
|
server_url: Optional[str] = None,
|
|
@@ -706,7 +820,7 @@ class Jobs(BaseSDK):
|
|
|
706
820
|
|
|
707
821
|
Request the start of a validated fine tuning job.
|
|
708
822
|
|
|
709
|
-
:param job_id:
|
|
823
|
+
:param job_id:
|
|
710
824
|
:param retries: Override the default retry configuration for this method
|
|
711
825
|
:param server_url: Override the default server URL for this method
|
|
712
826
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -715,14 +829,14 @@ class Jobs(BaseSDK):
|
|
|
715
829
|
url_variables = None
|
|
716
830
|
if timeout_ms is None:
|
|
717
831
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
718
|
-
|
|
832
|
+
|
|
719
833
|
if server_url is not None:
|
|
720
834
|
base_url = server_url
|
|
721
|
-
|
|
835
|
+
|
|
722
836
|
request = models.JobsAPIRoutesFineTuningStartFineTuningJobRequest(
|
|
723
837
|
job_id=job_id,
|
|
724
838
|
)
|
|
725
|
-
|
|
839
|
+
|
|
726
840
|
req = self.build_request(
|
|
727
841
|
method="POST",
|
|
728
842
|
path="/v1/fine_tuning/jobs/{job_id}/start",
|
|
@@ -737,40 +851,48 @@ class Jobs(BaseSDK):
|
|
|
737
851
|
security=self.sdk_configuration.security,
|
|
738
852
|
timeout_ms=timeout_ms,
|
|
739
853
|
)
|
|
740
|
-
|
|
854
|
+
|
|
741
855
|
if retries == UNSET:
|
|
742
856
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
743
857
|
retries = self.sdk_configuration.retry_config
|
|
744
858
|
|
|
745
859
|
retry_config = None
|
|
746
860
|
if isinstance(retries, utils.RetryConfig):
|
|
747
|
-
retry_config = (retries, [
|
|
748
|
-
|
|
749
|
-
"500",
|
|
750
|
-
"502",
|
|
751
|
-
"503",
|
|
752
|
-
"504"
|
|
753
|
-
])
|
|
754
|
-
|
|
861
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
862
|
+
|
|
755
863
|
http_res = self.do_request(
|
|
756
|
-
hook_ctx=HookContext(
|
|
864
|
+
hook_ctx=HookContext(
|
|
865
|
+
operation_id="jobs_api_routes_fine_tuning_start_fine_tuning_job",
|
|
866
|
+
oauth2_scopes=[],
|
|
867
|
+
security_source=get_security_from_env(
|
|
868
|
+
self.sdk_configuration.security, models.Security
|
|
869
|
+
),
|
|
870
|
+
),
|
|
757
871
|
request=req,
|
|
758
|
-
error_status_codes=["4XX","5XX"],
|
|
759
|
-
retry_config=retry_config
|
|
872
|
+
error_status_codes=["4XX", "5XX"],
|
|
873
|
+
retry_config=retry_config,
|
|
760
874
|
)
|
|
761
|
-
|
|
875
|
+
|
|
762
876
|
if utils.match_response(http_res, "200", "application/json"):
|
|
763
877
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
764
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
765
|
-
|
|
766
|
-
|
|
878
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
879
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
880
|
+
raise models.SDKError(
|
|
881
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
882
|
+
)
|
|
883
|
+
|
|
767
884
|
content_type = http_res.headers.get("Content-Type")
|
|
768
|
-
|
|
885
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
886
|
+
raise models.SDKError(
|
|
887
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
888
|
+
http_res.status_code,
|
|
889
|
+
http_res_text,
|
|
890
|
+
http_res,
|
|
891
|
+
)
|
|
769
892
|
|
|
770
|
-
|
|
771
|
-
|
|
772
893
|
async def start_async(
|
|
773
|
-
self,
|
|
894
|
+
self,
|
|
895
|
+
*,
|
|
774
896
|
job_id: str,
|
|
775
897
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
776
898
|
server_url: Optional[str] = None,
|
|
@@ -780,7 +902,7 @@ class Jobs(BaseSDK):
|
|
|
780
902
|
|
|
781
903
|
Request the start of a validated fine tuning job.
|
|
782
904
|
|
|
783
|
-
:param job_id:
|
|
905
|
+
:param job_id:
|
|
784
906
|
:param retries: Override the default retry configuration for this method
|
|
785
907
|
:param server_url: Override the default server URL for this method
|
|
786
908
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -789,15 +911,15 @@ class Jobs(BaseSDK):
|
|
|
789
911
|
url_variables = None
|
|
790
912
|
if timeout_ms is None:
|
|
791
913
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
792
|
-
|
|
914
|
+
|
|
793
915
|
if server_url is not None:
|
|
794
916
|
base_url = server_url
|
|
795
|
-
|
|
917
|
+
|
|
796
918
|
request = models.JobsAPIRoutesFineTuningStartFineTuningJobRequest(
|
|
797
919
|
job_id=job_id,
|
|
798
920
|
)
|
|
799
|
-
|
|
800
|
-
req = self.
|
|
921
|
+
|
|
922
|
+
req = self.build_request_async(
|
|
801
923
|
method="POST",
|
|
802
924
|
path="/v1/fine_tuning/jobs/{job_id}/start",
|
|
803
925
|
base_url=base_url,
|
|
@@ -811,34 +933,41 @@ class Jobs(BaseSDK):
|
|
|
811
933
|
security=self.sdk_configuration.security,
|
|
812
934
|
timeout_ms=timeout_ms,
|
|
813
935
|
)
|
|
814
|
-
|
|
936
|
+
|
|
815
937
|
if retries == UNSET:
|
|
816
938
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
817
939
|
retries = self.sdk_configuration.retry_config
|
|
818
940
|
|
|
819
941
|
retry_config = None
|
|
820
942
|
if isinstance(retries, utils.RetryConfig):
|
|
821
|
-
retry_config = (retries, [
|
|
822
|
-
|
|
823
|
-
"500",
|
|
824
|
-
"502",
|
|
825
|
-
"503",
|
|
826
|
-
"504"
|
|
827
|
-
])
|
|
828
|
-
|
|
943
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
944
|
+
|
|
829
945
|
http_res = await self.do_request_async(
|
|
830
|
-
hook_ctx=HookContext(
|
|
946
|
+
hook_ctx=HookContext(
|
|
947
|
+
operation_id="jobs_api_routes_fine_tuning_start_fine_tuning_job",
|
|
948
|
+
oauth2_scopes=[],
|
|
949
|
+
security_source=get_security_from_env(
|
|
950
|
+
self.sdk_configuration.security, models.Security
|
|
951
|
+
),
|
|
952
|
+
),
|
|
831
953
|
request=req,
|
|
832
|
-
error_status_codes=["4XX","5XX"],
|
|
833
|
-
retry_config=retry_config
|
|
954
|
+
error_status_codes=["4XX", "5XX"],
|
|
955
|
+
retry_config=retry_config,
|
|
834
956
|
)
|
|
835
|
-
|
|
957
|
+
|
|
836
958
|
if utils.match_response(http_res, "200", "application/json"):
|
|
837
959
|
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
838
|
-
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
960
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
961
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
962
|
+
raise models.SDKError(
|
|
963
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
964
|
+
)
|
|
843
965
|
|
|
844
|
-
|
|
966
|
+
content_type = http_res.headers.get("Content-Type")
|
|
967
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
968
|
+
raise models.SDKError(
|
|
969
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
970
|
+
http_res.status_code,
|
|
971
|
+
http_res_text,
|
|
972
|
+
http_res,
|
|
973
|
+
)
|