mistralai 0.5.5a50__py3-none-any.whl → 1.0.0rc2__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/agents.py +434 -0
- mistralai/basesdk.py +43 -6
- mistralai/chat.py +29 -34
- mistralai/embeddings.py +4 -4
- mistralai/files.py +10 -10
- mistralai/fim.py +17 -18
- mistralai/fine_tuning.py +10 -849
- mistralai/jobs.py +854 -0
- mistralai/models/__init__.py +4 -2
- mistralai/models/agentscompletionrequest.py +96 -0
- mistralai/models/agentscompletionstreamrequest.py +92 -0
- mistralai/models/assistantmessage.py +4 -9
- mistralai/models/chatcompletionchoice.py +4 -15
- mistralai/models/chatcompletionrequest.py +11 -16
- mistralai/models/chatcompletionstreamrequest.py +11 -16
- mistralai/models/completionresponsestreamchoice.py +4 -9
- mistralai/models/deltamessage.py +4 -9
- mistralai/models/detailedjobout.py +4 -9
- mistralai/models/embeddingrequest.py +4 -9
- mistralai/models/eventout.py +4 -9
- mistralai/models/fileschema.py +4 -9
- mistralai/models/fimcompletionrequest.py +11 -16
- mistralai/models/fimcompletionstreamrequest.py +11 -16
- mistralai/models/ftmodelout.py +4 -9
- mistralai/models/githubrepositoryin.py +4 -9
- mistralai/models/githubrepositoryout.py +4 -9
- mistralai/models/httpvalidationerror.py +1 -1
- mistralai/models/jobin.py +4 -9
- mistralai/models/jobmetadataout.py +4 -9
- mistralai/models/jobout.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
- mistralai/models/legacyjobmetadataout.py +4 -9
- mistralai/models/metricout.py +4 -9
- mistralai/models/modelcard.py +4 -9
- mistralai/models/retrievefileout.py +4 -9
- mistralai/models/security.py +4 -4
- mistralai/models/toolmessage.py +4 -9
- mistralai/models/trainingparameters.py +4 -9
- mistralai/models/trainingparametersin.py +4 -9
- mistralai/models/updateftmodelin.py +4 -9
- mistralai/models/uploadfileout.py +4 -9
- mistralai/models/wandbintegration.py +4 -9
- mistralai/models/wandbintegrationout.py +4 -9
- mistralai/models_.py +14 -14
- mistralai/sdk.py +14 -6
- mistralai/sdkconfiguration.py +5 -4
- mistralai/types/basemodel.py +10 -6
- mistralai/utils/__init__.py +4 -0
- mistralai/utils/eventstreaming.py +8 -9
- mistralai/utils/logger.py +16 -0
- mistralai/utils/retries.py +2 -2
- mistralai/utils/security.py +5 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/METADATA +113 -53
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/RECORD +96 -89
- mistralai_azure/basesdk.py +42 -4
- mistralai_azure/chat.py +15 -20
- mistralai_azure/models/__init__.py +2 -2
- mistralai_azure/models/assistantmessage.py +4 -9
- mistralai_azure/models/chatcompletionchoice.py +4 -15
- mistralai_azure/models/chatcompletionrequest.py +7 -12
- mistralai_azure/models/chatcompletionstreamrequest.py +7 -12
- mistralai_azure/models/completionresponsestreamchoice.py +4 -9
- mistralai_azure/models/deltamessage.py +4 -9
- mistralai_azure/models/httpvalidationerror.py +1 -1
- mistralai_azure/models/toolmessage.py +4 -9
- mistralai_azure/sdk.py +7 -2
- mistralai_azure/sdkconfiguration.py +5 -4
- mistralai_azure/types/basemodel.py +10 -6
- mistralai_azure/utils/__init__.py +4 -0
- mistralai_azure/utils/eventstreaming.py +8 -9
- mistralai_azure/utils/logger.py +16 -0
- mistralai_azure/utils/retries.py +2 -2
- mistralai_gcp/basesdk.py +42 -4
- mistralai_gcp/chat.py +12 -17
- mistralai_gcp/fim.py +12 -13
- mistralai_gcp/models/__init__.py +2 -2
- mistralai_gcp/models/assistantmessage.py +4 -9
- mistralai_gcp/models/chatcompletionchoice.py +4 -15
- mistralai_gcp/models/chatcompletionrequest.py +9 -14
- mistralai_gcp/models/chatcompletionstreamrequest.py +9 -14
- mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
- mistralai_gcp/models/deltamessage.py +4 -9
- mistralai_gcp/models/fimcompletionrequest.py +11 -16
- mistralai_gcp/models/fimcompletionstreamrequest.py +11 -16
- mistralai_gcp/models/httpvalidationerror.py +1 -1
- mistralai_gcp/models/toolmessage.py +4 -9
- mistralai_gcp/sdk.py +9 -0
- mistralai_gcp/sdkconfiguration.py +5 -4
- mistralai_gcp/types/basemodel.py +10 -6
- mistralai_gcp/utils/__init__.py +4 -0
- mistralai_gcp/utils/eventstreaming.py +8 -9
- mistralai_gcp/utils/logger.py +16 -0
- mistralai_gcp/utils/retries.py +2 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/LICENSE +0 -0
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/WHEEL +0 -0
mistralai/jobs.py
ADDED
|
@@ -0,0 +1,854 @@
|
|
|
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 List, Optional, Union
|
|
10
|
+
|
|
11
|
+
class Jobs(BaseSDK):
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def list(
|
|
15
|
+
self, *,
|
|
16
|
+
page: Optional[int] = 0,
|
|
17
|
+
page_size: Optional[int] = 100,
|
|
18
|
+
model: OptionalNullable[str] = UNSET,
|
|
19
|
+
created_after: OptionalNullable[datetime] = UNSET,
|
|
20
|
+
created_by_me: Optional[bool] = False,
|
|
21
|
+
status: OptionalNullable[models.QueryParamStatus] = UNSET,
|
|
22
|
+
wandb_project: OptionalNullable[str] = UNSET,
|
|
23
|
+
wandb_name: OptionalNullable[str] = UNSET,
|
|
24
|
+
suffix: OptionalNullable[str] = UNSET,
|
|
25
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
26
|
+
server_url: Optional[str] = None,
|
|
27
|
+
timeout_ms: Optional[int] = None,
|
|
28
|
+
) -> Optional[models.JobsOut]:
|
|
29
|
+
r"""Get Fine Tuning Jobs
|
|
30
|
+
|
|
31
|
+
Get a list of fine-tuning jobs for your organization and user.
|
|
32
|
+
|
|
33
|
+
:param page: The page number of the results to be returned.
|
|
34
|
+
:param page_size: The number of items to return per page.
|
|
35
|
+
:param model: The model name used for fine-tuning to filter on. When set, the other results are not displayed.
|
|
36
|
+
:param created_after: The date/time to filter on. When set, the results for previous creation times are not displayed.
|
|
37
|
+
:param created_by_me: When set, only return results for jobs created by the API caller. Other results are not displayed.
|
|
38
|
+
:param status: The current job state to filter on. When set, the other results are not displayed.
|
|
39
|
+
:param wandb_project: The Weights and Biases project to filter on. When set, the other results are not displayed.
|
|
40
|
+
:param wandb_name: The Weight and Biases run name to filter on. When set, the other results are not displayed.
|
|
41
|
+
:param suffix: The model suffix to filter on. When set, the other results are not displayed.
|
|
42
|
+
:param retries: Override the default retry configuration for this method
|
|
43
|
+
:param server_url: Override the default server URL for this method
|
|
44
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
45
|
+
"""
|
|
46
|
+
base_url = None
|
|
47
|
+
url_variables = None
|
|
48
|
+
if timeout_ms is None:
|
|
49
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
50
|
+
|
|
51
|
+
if server_url is not None:
|
|
52
|
+
base_url = server_url
|
|
53
|
+
|
|
54
|
+
request = models.JobsAPIRoutesFineTuningGetFineTuningJobsRequest(
|
|
55
|
+
page=page,
|
|
56
|
+
page_size=page_size,
|
|
57
|
+
model=model,
|
|
58
|
+
created_after=created_after,
|
|
59
|
+
created_by_me=created_by_me,
|
|
60
|
+
status=status,
|
|
61
|
+
wandb_project=wandb_project,
|
|
62
|
+
wandb_name=wandb_name,
|
|
63
|
+
suffix=suffix,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
req = self.build_request(
|
|
67
|
+
method="GET",
|
|
68
|
+
path="/v1/fine_tuning/jobs",
|
|
69
|
+
base_url=base_url,
|
|
70
|
+
url_variables=url_variables,
|
|
71
|
+
request=request,
|
|
72
|
+
request_body_required=False,
|
|
73
|
+
request_has_path_params=False,
|
|
74
|
+
request_has_query_params=True,
|
|
75
|
+
user_agent_header="user-agent",
|
|
76
|
+
accept_header_value="application/json",
|
|
77
|
+
security=self.sdk_configuration.security,
|
|
78
|
+
timeout_ms=timeout_ms,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if retries == UNSET:
|
|
82
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
83
|
+
retries = self.sdk_configuration.retry_config
|
|
84
|
+
|
|
85
|
+
retry_config = None
|
|
86
|
+
if isinstance(retries, utils.RetryConfig):
|
|
87
|
+
retry_config = (retries, [
|
|
88
|
+
"429",
|
|
89
|
+
"500",
|
|
90
|
+
"502",
|
|
91
|
+
"503",
|
|
92
|
+
"504"
|
|
93
|
+
])
|
|
94
|
+
|
|
95
|
+
http_res = self.do_request(
|
|
96
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_jobs", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
97
|
+
request=req,
|
|
98
|
+
error_status_codes=["4XX","5XX"],
|
|
99
|
+
retry_config=retry_config
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
103
|
+
return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
|
|
104
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
105
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
106
|
+
|
|
107
|
+
content_type = http_res.headers.get("Content-Type")
|
|
108
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def list_async(
|
|
113
|
+
self, *,
|
|
114
|
+
page: Optional[int] = 0,
|
|
115
|
+
page_size: Optional[int] = 100,
|
|
116
|
+
model: OptionalNullable[str] = UNSET,
|
|
117
|
+
created_after: OptionalNullable[datetime] = UNSET,
|
|
118
|
+
created_by_me: Optional[bool] = False,
|
|
119
|
+
status: OptionalNullable[models.QueryParamStatus] = UNSET,
|
|
120
|
+
wandb_project: OptionalNullable[str] = UNSET,
|
|
121
|
+
wandb_name: OptionalNullable[str] = UNSET,
|
|
122
|
+
suffix: OptionalNullable[str] = UNSET,
|
|
123
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
124
|
+
server_url: Optional[str] = None,
|
|
125
|
+
timeout_ms: Optional[int] = None,
|
|
126
|
+
) -> Optional[models.JobsOut]:
|
|
127
|
+
r"""Get Fine Tuning Jobs
|
|
128
|
+
|
|
129
|
+
Get a list of fine-tuning jobs for your organization and user.
|
|
130
|
+
|
|
131
|
+
:param page: The page number of the results to be returned.
|
|
132
|
+
:param page_size: The number of items to return per page.
|
|
133
|
+
:param model: The model name used for fine-tuning to filter on. When set, the other results are not displayed.
|
|
134
|
+
:param created_after: The date/time to filter on. When set, the results for previous creation times are not displayed.
|
|
135
|
+
:param created_by_me: When set, only return results for jobs created by the API caller. Other results are not displayed.
|
|
136
|
+
:param status: The current job state to filter on. When set, the other results are not displayed.
|
|
137
|
+
:param wandb_project: The Weights and Biases project to filter on. When set, the other results are not displayed.
|
|
138
|
+
:param wandb_name: The Weight and Biases run name to filter on. When set, the other results are not displayed.
|
|
139
|
+
:param suffix: The model suffix to filter on. When set, the other results are not displayed.
|
|
140
|
+
:param retries: Override the default retry configuration for this method
|
|
141
|
+
:param server_url: Override the default server URL for this method
|
|
142
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
143
|
+
"""
|
|
144
|
+
base_url = None
|
|
145
|
+
url_variables = None
|
|
146
|
+
if timeout_ms is None:
|
|
147
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
148
|
+
|
|
149
|
+
if server_url is not None:
|
|
150
|
+
base_url = server_url
|
|
151
|
+
|
|
152
|
+
request = models.JobsAPIRoutesFineTuningGetFineTuningJobsRequest(
|
|
153
|
+
page=page,
|
|
154
|
+
page_size=page_size,
|
|
155
|
+
model=model,
|
|
156
|
+
created_after=created_after,
|
|
157
|
+
created_by_me=created_by_me,
|
|
158
|
+
status=status,
|
|
159
|
+
wandb_project=wandb_project,
|
|
160
|
+
wandb_name=wandb_name,
|
|
161
|
+
suffix=suffix,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
req = self.build_request(
|
|
165
|
+
method="GET",
|
|
166
|
+
path="/v1/fine_tuning/jobs",
|
|
167
|
+
base_url=base_url,
|
|
168
|
+
url_variables=url_variables,
|
|
169
|
+
request=request,
|
|
170
|
+
request_body_required=False,
|
|
171
|
+
request_has_path_params=False,
|
|
172
|
+
request_has_query_params=True,
|
|
173
|
+
user_agent_header="user-agent",
|
|
174
|
+
accept_header_value="application/json",
|
|
175
|
+
security=self.sdk_configuration.security,
|
|
176
|
+
timeout_ms=timeout_ms,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
if retries == UNSET:
|
|
180
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
181
|
+
retries = self.sdk_configuration.retry_config
|
|
182
|
+
|
|
183
|
+
retry_config = None
|
|
184
|
+
if isinstance(retries, utils.RetryConfig):
|
|
185
|
+
retry_config = (retries, [
|
|
186
|
+
"429",
|
|
187
|
+
"500",
|
|
188
|
+
"502",
|
|
189
|
+
"503",
|
|
190
|
+
"504"
|
|
191
|
+
])
|
|
192
|
+
|
|
193
|
+
http_res = await self.do_request_async(
|
|
194
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_jobs", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
195
|
+
request=req,
|
|
196
|
+
error_status_codes=["4XX","5XX"],
|
|
197
|
+
retry_config=retry_config
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
201
|
+
return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
|
|
202
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
203
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
204
|
+
|
|
205
|
+
content_type = http_res.headers.get("Content-Type")
|
|
206
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def create(
|
|
211
|
+
self, *,
|
|
212
|
+
model: models.FineTuneableModel,
|
|
213
|
+
hyperparameters: Union[models.TrainingParametersIn, models.TrainingParametersInTypedDict],
|
|
214
|
+
dry_run: OptionalNullable[bool] = UNSET,
|
|
215
|
+
training_files: Optional[Union[List[models.TrainingFile], List[models.TrainingFileTypedDict]]] = None,
|
|
216
|
+
validation_files: OptionalNullable[List[str]] = UNSET,
|
|
217
|
+
suffix: OptionalNullable[str] = UNSET,
|
|
218
|
+
integrations: OptionalNullable[Union[List[models.WandbIntegration], List[models.WandbIntegrationTypedDict]]] = UNSET,
|
|
219
|
+
repositories: Optional[Union[List[models.GithubRepositoryIn], List[models.GithubRepositoryInTypedDict]]] = None,
|
|
220
|
+
auto_start: Optional[bool] = None,
|
|
221
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
222
|
+
server_url: Optional[str] = None,
|
|
223
|
+
timeout_ms: Optional[int] = None,
|
|
224
|
+
) -> Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse]:
|
|
225
|
+
r"""Create Fine Tuning Job
|
|
226
|
+
|
|
227
|
+
Create a new fine-tuning job, it will be queued for processing.
|
|
228
|
+
|
|
229
|
+
:param model: The name of the model to fine-tune.
|
|
230
|
+
:param hyperparameters: The fine-tuning hyperparameter settings used in a fine-tune job.
|
|
231
|
+
:param dry_run: * If `true` the job is not spawned, instead the query returns a handful of useful metadata for the user to perform sanity checks (see `LegacyJobMetadataOut` response). * Otherwise, the job is started and the query returns the job ID along with some of the input parameters (see `JobOut` response).
|
|
232
|
+
:param training_files:
|
|
233
|
+
: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.
|
|
234
|
+
: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...`
|
|
235
|
+
:param integrations: A list of integrations to enable for your fine-tuning job.
|
|
236
|
+
:param repositories:
|
|
237
|
+
:param auto_start: This field will be required in a future release.
|
|
238
|
+
:param retries: Override the default retry configuration for this method
|
|
239
|
+
:param server_url: Override the default server URL for this method
|
|
240
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
241
|
+
"""
|
|
242
|
+
base_url = None
|
|
243
|
+
url_variables = None
|
|
244
|
+
if timeout_ms is None:
|
|
245
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
246
|
+
|
|
247
|
+
if server_url is not None:
|
|
248
|
+
base_url = server_url
|
|
249
|
+
|
|
250
|
+
request = models.JobsAPIRoutesFineTuningCreateFineTuningJobRequest(
|
|
251
|
+
dry_run=dry_run,
|
|
252
|
+
job_in=models.JobIn(
|
|
253
|
+
model=model,
|
|
254
|
+
training_files=utils.get_pydantic_model(training_files, Optional[List[models.TrainingFile]]),
|
|
255
|
+
validation_files=validation_files,
|
|
256
|
+
hyperparameters=utils.get_pydantic_model(hyperparameters, models.TrainingParametersIn),
|
|
257
|
+
suffix=suffix,
|
|
258
|
+
integrations=utils.get_pydantic_model(integrations, OptionalNullable[List[models.WandbIntegration]]),
|
|
259
|
+
repositories=utils.get_pydantic_model(repositories, Optional[List[models.GithubRepositoryIn]]),
|
|
260
|
+
auto_start=auto_start,
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
req = self.build_request(
|
|
265
|
+
method="POST",
|
|
266
|
+
path="/v1/fine_tuning/jobs",
|
|
267
|
+
base_url=base_url,
|
|
268
|
+
url_variables=url_variables,
|
|
269
|
+
request=request,
|
|
270
|
+
request_body_required=True,
|
|
271
|
+
request_has_path_params=False,
|
|
272
|
+
request_has_query_params=True,
|
|
273
|
+
user_agent_header="user-agent",
|
|
274
|
+
accept_header_value="application/json",
|
|
275
|
+
security=self.sdk_configuration.security,
|
|
276
|
+
get_serialized_body=lambda: utils.serialize_request_body(request.job_in, False, False, "json", models.JobIn),
|
|
277
|
+
timeout_ms=timeout_ms,
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
if retries == UNSET:
|
|
281
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
282
|
+
retries = self.sdk_configuration.retry_config
|
|
283
|
+
|
|
284
|
+
retry_config = None
|
|
285
|
+
if isinstance(retries, utils.RetryConfig):
|
|
286
|
+
retry_config = (retries, [
|
|
287
|
+
"429",
|
|
288
|
+
"500",
|
|
289
|
+
"502",
|
|
290
|
+
"503",
|
|
291
|
+
"504"
|
|
292
|
+
])
|
|
293
|
+
|
|
294
|
+
http_res = self.do_request(
|
|
295
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_create_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
296
|
+
request=req,
|
|
297
|
+
error_status_codes=["4XX","5XX"],
|
|
298
|
+
retry_config=retry_config
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
302
|
+
return utils.unmarshal_json(http_res.text, Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse])
|
|
303
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
304
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
305
|
+
|
|
306
|
+
content_type = http_res.headers.get("Content-Type")
|
|
307
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
async def create_async(
|
|
312
|
+
self, *,
|
|
313
|
+
model: models.FineTuneableModel,
|
|
314
|
+
hyperparameters: Union[models.TrainingParametersIn, models.TrainingParametersInTypedDict],
|
|
315
|
+
dry_run: OptionalNullable[bool] = UNSET,
|
|
316
|
+
training_files: Optional[Union[List[models.TrainingFile], List[models.TrainingFileTypedDict]]] = None,
|
|
317
|
+
validation_files: OptionalNullable[List[str]] = UNSET,
|
|
318
|
+
suffix: OptionalNullable[str] = UNSET,
|
|
319
|
+
integrations: OptionalNullable[Union[List[models.WandbIntegration], List[models.WandbIntegrationTypedDict]]] = UNSET,
|
|
320
|
+
repositories: Optional[Union[List[models.GithubRepositoryIn], List[models.GithubRepositoryInTypedDict]]] = None,
|
|
321
|
+
auto_start: Optional[bool] = None,
|
|
322
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
323
|
+
server_url: Optional[str] = None,
|
|
324
|
+
timeout_ms: Optional[int] = None,
|
|
325
|
+
) -> Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse]:
|
|
326
|
+
r"""Create Fine Tuning Job
|
|
327
|
+
|
|
328
|
+
Create a new fine-tuning job, it will be queued for processing.
|
|
329
|
+
|
|
330
|
+
:param model: The name of the model to fine-tune.
|
|
331
|
+
:param hyperparameters: The fine-tuning hyperparameter settings used in a fine-tune job.
|
|
332
|
+
:param dry_run: * If `true` the job is not spawned, instead the query returns a handful of useful metadata for the user to perform sanity checks (see `LegacyJobMetadataOut` response). * Otherwise, the job is started and the query returns the job ID along with some of the input parameters (see `JobOut` response).
|
|
333
|
+
:param training_files:
|
|
334
|
+
: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.
|
|
335
|
+
: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...`
|
|
336
|
+
:param integrations: A list of integrations to enable for your fine-tuning job.
|
|
337
|
+
:param repositories:
|
|
338
|
+
:param auto_start: This field will be required in a future release.
|
|
339
|
+
:param retries: Override the default retry configuration for this method
|
|
340
|
+
:param server_url: Override the default server URL for this method
|
|
341
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
342
|
+
"""
|
|
343
|
+
base_url = None
|
|
344
|
+
url_variables = None
|
|
345
|
+
if timeout_ms is None:
|
|
346
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
347
|
+
|
|
348
|
+
if server_url is not None:
|
|
349
|
+
base_url = server_url
|
|
350
|
+
|
|
351
|
+
request = models.JobsAPIRoutesFineTuningCreateFineTuningJobRequest(
|
|
352
|
+
dry_run=dry_run,
|
|
353
|
+
job_in=models.JobIn(
|
|
354
|
+
model=model,
|
|
355
|
+
training_files=utils.get_pydantic_model(training_files, Optional[List[models.TrainingFile]]),
|
|
356
|
+
validation_files=validation_files,
|
|
357
|
+
hyperparameters=utils.get_pydantic_model(hyperparameters, models.TrainingParametersIn),
|
|
358
|
+
suffix=suffix,
|
|
359
|
+
integrations=utils.get_pydantic_model(integrations, OptionalNullable[List[models.WandbIntegration]]),
|
|
360
|
+
repositories=utils.get_pydantic_model(repositories, Optional[List[models.GithubRepositoryIn]]),
|
|
361
|
+
auto_start=auto_start,
|
|
362
|
+
),
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
req = self.build_request(
|
|
366
|
+
method="POST",
|
|
367
|
+
path="/v1/fine_tuning/jobs",
|
|
368
|
+
base_url=base_url,
|
|
369
|
+
url_variables=url_variables,
|
|
370
|
+
request=request,
|
|
371
|
+
request_body_required=True,
|
|
372
|
+
request_has_path_params=False,
|
|
373
|
+
request_has_query_params=True,
|
|
374
|
+
user_agent_header="user-agent",
|
|
375
|
+
accept_header_value="application/json",
|
|
376
|
+
security=self.sdk_configuration.security,
|
|
377
|
+
get_serialized_body=lambda: utils.serialize_request_body(request.job_in, False, False, "json", models.JobIn),
|
|
378
|
+
timeout_ms=timeout_ms,
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
if retries == UNSET:
|
|
382
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
383
|
+
retries = self.sdk_configuration.retry_config
|
|
384
|
+
|
|
385
|
+
retry_config = None
|
|
386
|
+
if isinstance(retries, utils.RetryConfig):
|
|
387
|
+
retry_config = (retries, [
|
|
388
|
+
"429",
|
|
389
|
+
"500",
|
|
390
|
+
"502",
|
|
391
|
+
"503",
|
|
392
|
+
"504"
|
|
393
|
+
])
|
|
394
|
+
|
|
395
|
+
http_res = await self.do_request_async(
|
|
396
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_create_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
397
|
+
request=req,
|
|
398
|
+
error_status_codes=["4XX","5XX"],
|
|
399
|
+
retry_config=retry_config
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
403
|
+
return utils.unmarshal_json(http_res.text, Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse])
|
|
404
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
405
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
406
|
+
|
|
407
|
+
content_type = http_res.headers.get("Content-Type")
|
|
408
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def get(
|
|
413
|
+
self, *,
|
|
414
|
+
job_id: str,
|
|
415
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
416
|
+
server_url: Optional[str] = None,
|
|
417
|
+
timeout_ms: Optional[int] = None,
|
|
418
|
+
) -> Optional[models.DetailedJobOut]:
|
|
419
|
+
r"""Get Fine Tuning Job
|
|
420
|
+
|
|
421
|
+
Get a fine-tuned job details by its UUID.
|
|
422
|
+
|
|
423
|
+
:param job_id: The ID of the job to analyse.
|
|
424
|
+
:param retries: Override the default retry configuration for this method
|
|
425
|
+
:param server_url: Override the default server URL for this method
|
|
426
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
427
|
+
"""
|
|
428
|
+
base_url = None
|
|
429
|
+
url_variables = None
|
|
430
|
+
if timeout_ms is None:
|
|
431
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
432
|
+
|
|
433
|
+
if server_url is not None:
|
|
434
|
+
base_url = server_url
|
|
435
|
+
|
|
436
|
+
request = models.JobsAPIRoutesFineTuningGetFineTuningJobRequest(
|
|
437
|
+
job_id=job_id,
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
req = self.build_request(
|
|
441
|
+
method="GET",
|
|
442
|
+
path="/v1/fine_tuning/jobs/{job_id}",
|
|
443
|
+
base_url=base_url,
|
|
444
|
+
url_variables=url_variables,
|
|
445
|
+
request=request,
|
|
446
|
+
request_body_required=False,
|
|
447
|
+
request_has_path_params=True,
|
|
448
|
+
request_has_query_params=True,
|
|
449
|
+
user_agent_header="user-agent",
|
|
450
|
+
accept_header_value="application/json",
|
|
451
|
+
security=self.sdk_configuration.security,
|
|
452
|
+
timeout_ms=timeout_ms,
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
if retries == UNSET:
|
|
456
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
457
|
+
retries = self.sdk_configuration.retry_config
|
|
458
|
+
|
|
459
|
+
retry_config = None
|
|
460
|
+
if isinstance(retries, utils.RetryConfig):
|
|
461
|
+
retry_config = (retries, [
|
|
462
|
+
"429",
|
|
463
|
+
"500",
|
|
464
|
+
"502",
|
|
465
|
+
"503",
|
|
466
|
+
"504"
|
|
467
|
+
])
|
|
468
|
+
|
|
469
|
+
http_res = self.do_request(
|
|
470
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
471
|
+
request=req,
|
|
472
|
+
error_status_codes=["4XX","5XX"],
|
|
473
|
+
retry_config=retry_config
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
477
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
478
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
479
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
480
|
+
|
|
481
|
+
content_type = http_res.headers.get("Content-Type")
|
|
482
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
async def get_async(
|
|
487
|
+
self, *,
|
|
488
|
+
job_id: str,
|
|
489
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
490
|
+
server_url: Optional[str] = None,
|
|
491
|
+
timeout_ms: Optional[int] = None,
|
|
492
|
+
) -> Optional[models.DetailedJobOut]:
|
|
493
|
+
r"""Get Fine Tuning Job
|
|
494
|
+
|
|
495
|
+
Get a fine-tuned job details by its UUID.
|
|
496
|
+
|
|
497
|
+
:param job_id: The ID of the job to analyse.
|
|
498
|
+
:param retries: Override the default retry configuration for this method
|
|
499
|
+
:param server_url: Override the default server URL for this method
|
|
500
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
501
|
+
"""
|
|
502
|
+
base_url = None
|
|
503
|
+
url_variables = None
|
|
504
|
+
if timeout_ms is None:
|
|
505
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
506
|
+
|
|
507
|
+
if server_url is not None:
|
|
508
|
+
base_url = server_url
|
|
509
|
+
|
|
510
|
+
request = models.JobsAPIRoutesFineTuningGetFineTuningJobRequest(
|
|
511
|
+
job_id=job_id,
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
req = self.build_request(
|
|
515
|
+
method="GET",
|
|
516
|
+
path="/v1/fine_tuning/jobs/{job_id}",
|
|
517
|
+
base_url=base_url,
|
|
518
|
+
url_variables=url_variables,
|
|
519
|
+
request=request,
|
|
520
|
+
request_body_required=False,
|
|
521
|
+
request_has_path_params=True,
|
|
522
|
+
request_has_query_params=True,
|
|
523
|
+
user_agent_header="user-agent",
|
|
524
|
+
accept_header_value="application/json",
|
|
525
|
+
security=self.sdk_configuration.security,
|
|
526
|
+
timeout_ms=timeout_ms,
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
if retries == UNSET:
|
|
530
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
531
|
+
retries = self.sdk_configuration.retry_config
|
|
532
|
+
|
|
533
|
+
retry_config = None
|
|
534
|
+
if isinstance(retries, utils.RetryConfig):
|
|
535
|
+
retry_config = (retries, [
|
|
536
|
+
"429",
|
|
537
|
+
"500",
|
|
538
|
+
"502",
|
|
539
|
+
"503",
|
|
540
|
+
"504"
|
|
541
|
+
])
|
|
542
|
+
|
|
543
|
+
http_res = await self.do_request_async(
|
|
544
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_get_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
545
|
+
request=req,
|
|
546
|
+
error_status_codes=["4XX","5XX"],
|
|
547
|
+
retry_config=retry_config
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
551
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
552
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
553
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
554
|
+
|
|
555
|
+
content_type = http_res.headers.get("Content-Type")
|
|
556
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def cancel(
|
|
561
|
+
self, *,
|
|
562
|
+
job_id: str,
|
|
563
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
564
|
+
server_url: Optional[str] = None,
|
|
565
|
+
timeout_ms: Optional[int] = None,
|
|
566
|
+
) -> Optional[models.DetailedJobOut]:
|
|
567
|
+
r"""Cancel Fine Tuning Job
|
|
568
|
+
|
|
569
|
+
Request the cancellation of a fine tuning job.
|
|
570
|
+
|
|
571
|
+
:param job_id: The ID of the job to cancel.
|
|
572
|
+
:param retries: Override the default retry configuration for this method
|
|
573
|
+
:param server_url: Override the default server URL for this method
|
|
574
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
575
|
+
"""
|
|
576
|
+
base_url = None
|
|
577
|
+
url_variables = None
|
|
578
|
+
if timeout_ms is None:
|
|
579
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
580
|
+
|
|
581
|
+
if server_url is not None:
|
|
582
|
+
base_url = server_url
|
|
583
|
+
|
|
584
|
+
request = models.JobsAPIRoutesFineTuningCancelFineTuningJobRequest(
|
|
585
|
+
job_id=job_id,
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
req = self.build_request(
|
|
589
|
+
method="POST",
|
|
590
|
+
path="/v1/fine_tuning/jobs/{job_id}/cancel",
|
|
591
|
+
base_url=base_url,
|
|
592
|
+
url_variables=url_variables,
|
|
593
|
+
request=request,
|
|
594
|
+
request_body_required=False,
|
|
595
|
+
request_has_path_params=True,
|
|
596
|
+
request_has_query_params=True,
|
|
597
|
+
user_agent_header="user-agent",
|
|
598
|
+
accept_header_value="application/json",
|
|
599
|
+
security=self.sdk_configuration.security,
|
|
600
|
+
timeout_ms=timeout_ms,
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
if retries == UNSET:
|
|
604
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
605
|
+
retries = self.sdk_configuration.retry_config
|
|
606
|
+
|
|
607
|
+
retry_config = None
|
|
608
|
+
if isinstance(retries, utils.RetryConfig):
|
|
609
|
+
retry_config = (retries, [
|
|
610
|
+
"429",
|
|
611
|
+
"500",
|
|
612
|
+
"502",
|
|
613
|
+
"503",
|
|
614
|
+
"504"
|
|
615
|
+
])
|
|
616
|
+
|
|
617
|
+
http_res = self.do_request(
|
|
618
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_cancel_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
619
|
+
request=req,
|
|
620
|
+
error_status_codes=["4XX","5XX"],
|
|
621
|
+
retry_config=retry_config
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
625
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
626
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
627
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
628
|
+
|
|
629
|
+
content_type = http_res.headers.get("Content-Type")
|
|
630
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
async def cancel_async(
|
|
635
|
+
self, *,
|
|
636
|
+
job_id: str,
|
|
637
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
638
|
+
server_url: Optional[str] = None,
|
|
639
|
+
timeout_ms: Optional[int] = None,
|
|
640
|
+
) -> Optional[models.DetailedJobOut]:
|
|
641
|
+
r"""Cancel Fine Tuning Job
|
|
642
|
+
|
|
643
|
+
Request the cancellation of a fine tuning job.
|
|
644
|
+
|
|
645
|
+
:param job_id: The ID of the job to cancel.
|
|
646
|
+
:param retries: Override the default retry configuration for this method
|
|
647
|
+
:param server_url: Override the default server URL for this method
|
|
648
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
649
|
+
"""
|
|
650
|
+
base_url = None
|
|
651
|
+
url_variables = None
|
|
652
|
+
if timeout_ms is None:
|
|
653
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
654
|
+
|
|
655
|
+
if server_url is not None:
|
|
656
|
+
base_url = server_url
|
|
657
|
+
|
|
658
|
+
request = models.JobsAPIRoutesFineTuningCancelFineTuningJobRequest(
|
|
659
|
+
job_id=job_id,
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
req = self.build_request(
|
|
663
|
+
method="POST",
|
|
664
|
+
path="/v1/fine_tuning/jobs/{job_id}/cancel",
|
|
665
|
+
base_url=base_url,
|
|
666
|
+
url_variables=url_variables,
|
|
667
|
+
request=request,
|
|
668
|
+
request_body_required=False,
|
|
669
|
+
request_has_path_params=True,
|
|
670
|
+
request_has_query_params=True,
|
|
671
|
+
user_agent_header="user-agent",
|
|
672
|
+
accept_header_value="application/json",
|
|
673
|
+
security=self.sdk_configuration.security,
|
|
674
|
+
timeout_ms=timeout_ms,
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
if retries == UNSET:
|
|
678
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
679
|
+
retries = self.sdk_configuration.retry_config
|
|
680
|
+
|
|
681
|
+
retry_config = None
|
|
682
|
+
if isinstance(retries, utils.RetryConfig):
|
|
683
|
+
retry_config = (retries, [
|
|
684
|
+
"429",
|
|
685
|
+
"500",
|
|
686
|
+
"502",
|
|
687
|
+
"503",
|
|
688
|
+
"504"
|
|
689
|
+
])
|
|
690
|
+
|
|
691
|
+
http_res = await self.do_request_async(
|
|
692
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_cancel_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
693
|
+
request=req,
|
|
694
|
+
error_status_codes=["4XX","5XX"],
|
|
695
|
+
retry_config=retry_config
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
699
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
700
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
701
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
702
|
+
|
|
703
|
+
content_type = http_res.headers.get("Content-Type")
|
|
704
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def start(
|
|
709
|
+
self, *,
|
|
710
|
+
job_id: str,
|
|
711
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
712
|
+
server_url: Optional[str] = None,
|
|
713
|
+
timeout_ms: Optional[int] = None,
|
|
714
|
+
) -> Optional[models.DetailedJobOut]:
|
|
715
|
+
r"""Start Fine Tuning Job
|
|
716
|
+
|
|
717
|
+
Request the start of a validated fine tuning job.
|
|
718
|
+
|
|
719
|
+
:param job_id:
|
|
720
|
+
:param retries: Override the default retry configuration for this method
|
|
721
|
+
:param server_url: Override the default server URL for this method
|
|
722
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
723
|
+
"""
|
|
724
|
+
base_url = None
|
|
725
|
+
url_variables = None
|
|
726
|
+
if timeout_ms is None:
|
|
727
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
728
|
+
|
|
729
|
+
if server_url is not None:
|
|
730
|
+
base_url = server_url
|
|
731
|
+
|
|
732
|
+
request = models.JobsAPIRoutesFineTuningStartFineTuningJobRequest(
|
|
733
|
+
job_id=job_id,
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
req = self.build_request(
|
|
737
|
+
method="POST",
|
|
738
|
+
path="/v1/fine_tuning/jobs/{job_id}/start",
|
|
739
|
+
base_url=base_url,
|
|
740
|
+
url_variables=url_variables,
|
|
741
|
+
request=request,
|
|
742
|
+
request_body_required=False,
|
|
743
|
+
request_has_path_params=True,
|
|
744
|
+
request_has_query_params=True,
|
|
745
|
+
user_agent_header="user-agent",
|
|
746
|
+
accept_header_value="application/json",
|
|
747
|
+
security=self.sdk_configuration.security,
|
|
748
|
+
timeout_ms=timeout_ms,
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
if retries == UNSET:
|
|
752
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
753
|
+
retries = self.sdk_configuration.retry_config
|
|
754
|
+
|
|
755
|
+
retry_config = None
|
|
756
|
+
if isinstance(retries, utils.RetryConfig):
|
|
757
|
+
retry_config = (retries, [
|
|
758
|
+
"429",
|
|
759
|
+
"500",
|
|
760
|
+
"502",
|
|
761
|
+
"503",
|
|
762
|
+
"504"
|
|
763
|
+
])
|
|
764
|
+
|
|
765
|
+
http_res = self.do_request(
|
|
766
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_start_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
767
|
+
request=req,
|
|
768
|
+
error_status_codes=["4XX","5XX"],
|
|
769
|
+
retry_config=retry_config
|
|
770
|
+
)
|
|
771
|
+
|
|
772
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
773
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
774
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
775
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
776
|
+
|
|
777
|
+
content_type = http_res.headers.get("Content-Type")
|
|
778
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
async def start_async(
|
|
783
|
+
self, *,
|
|
784
|
+
job_id: str,
|
|
785
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
786
|
+
server_url: Optional[str] = None,
|
|
787
|
+
timeout_ms: Optional[int] = None,
|
|
788
|
+
) -> Optional[models.DetailedJobOut]:
|
|
789
|
+
r"""Start Fine Tuning Job
|
|
790
|
+
|
|
791
|
+
Request the start of a validated fine tuning job.
|
|
792
|
+
|
|
793
|
+
:param job_id:
|
|
794
|
+
:param retries: Override the default retry configuration for this method
|
|
795
|
+
:param server_url: Override the default server URL for this method
|
|
796
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
797
|
+
"""
|
|
798
|
+
base_url = None
|
|
799
|
+
url_variables = None
|
|
800
|
+
if timeout_ms is None:
|
|
801
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
802
|
+
|
|
803
|
+
if server_url is not None:
|
|
804
|
+
base_url = server_url
|
|
805
|
+
|
|
806
|
+
request = models.JobsAPIRoutesFineTuningStartFineTuningJobRequest(
|
|
807
|
+
job_id=job_id,
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
req = self.build_request(
|
|
811
|
+
method="POST",
|
|
812
|
+
path="/v1/fine_tuning/jobs/{job_id}/start",
|
|
813
|
+
base_url=base_url,
|
|
814
|
+
url_variables=url_variables,
|
|
815
|
+
request=request,
|
|
816
|
+
request_body_required=False,
|
|
817
|
+
request_has_path_params=True,
|
|
818
|
+
request_has_query_params=True,
|
|
819
|
+
user_agent_header="user-agent",
|
|
820
|
+
accept_header_value="application/json",
|
|
821
|
+
security=self.sdk_configuration.security,
|
|
822
|
+
timeout_ms=timeout_ms,
|
|
823
|
+
)
|
|
824
|
+
|
|
825
|
+
if retries == UNSET:
|
|
826
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
827
|
+
retries = self.sdk_configuration.retry_config
|
|
828
|
+
|
|
829
|
+
retry_config = None
|
|
830
|
+
if isinstance(retries, utils.RetryConfig):
|
|
831
|
+
retry_config = (retries, [
|
|
832
|
+
"429",
|
|
833
|
+
"500",
|
|
834
|
+
"502",
|
|
835
|
+
"503",
|
|
836
|
+
"504"
|
|
837
|
+
])
|
|
838
|
+
|
|
839
|
+
http_res = await self.do_request_async(
|
|
840
|
+
hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_start_fine_tuning_job", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
|
|
841
|
+
request=req,
|
|
842
|
+
error_status_codes=["4XX","5XX"],
|
|
843
|
+
retry_config=retry_config
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
847
|
+
return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
|
|
848
|
+
if utils.match_response(http_res, ["4XX","5XX"], "*"):
|
|
849
|
+
raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
|
|
850
|
+
|
|
851
|
+
content_type = http_res.headers.get("Content-Type")
|
|
852
|
+
raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
|
|
853
|
+
|
|
854
|
+
|