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