mistralai 1.0.3__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_hooks/sdkhooks.py +23 -4
  3. mistralai/_hooks/types.py +27 -9
  4. mistralai/_version.py +12 -0
  5. mistralai/agents.py +334 -164
  6. mistralai/basesdk.py +90 -5
  7. mistralai/batch.py +17 -0
  8. mistralai/chat.py +316 -166
  9. mistralai/classifiers.py +396 -0
  10. mistralai/embeddings.py +79 -55
  11. mistralai/files.py +487 -194
  12. mistralai/fim.py +206 -132
  13. mistralai/fine_tuning.py +3 -2
  14. mistralai/jobs.py +392 -263
  15. mistralai/mistral_jobs.py +733 -0
  16. mistralai/models/__init__.py +593 -50
  17. mistralai/models/agentscompletionrequest.py +70 -17
  18. mistralai/models/agentscompletionstreamrequest.py +72 -17
  19. mistralai/models/apiendpoint.py +9 -0
  20. mistralai/models/archiveftmodelout.py +15 -5
  21. mistralai/models/assistantmessage.py +22 -10
  22. mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
  23. mistralai/models/batcherror.py +17 -0
  24. mistralai/models/batchjobin.py +58 -0
  25. mistralai/models/batchjobout.py +117 -0
  26. mistralai/models/batchjobsout.py +30 -0
  27. mistralai/models/batchjobstatus.py +15 -0
  28. mistralai/models/chatclassificationrequest.py +104 -0
  29. mistralai/models/chatcompletionchoice.py +13 -6
  30. mistralai/models/chatcompletionrequest.py +86 -21
  31. mistralai/models/chatcompletionresponse.py +8 -4
  32. mistralai/models/chatcompletionstreamrequest.py +88 -21
  33. mistralai/models/checkpointout.py +4 -3
  34. mistralai/models/classificationobject.py +21 -0
  35. mistralai/models/classificationrequest.py +59 -0
  36. mistralai/models/classificationresponse.py +21 -0
  37. mistralai/models/completionchunk.py +12 -5
  38. mistralai/models/completionevent.py +2 -3
  39. mistralai/models/completionresponsestreamchoice.py +22 -8
  40. mistralai/models/contentchunk.py +13 -10
  41. mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
  42. mistralai/models/deletefileout.py +4 -3
  43. mistralai/models/deletemodelout.py +5 -4
  44. mistralai/models/deltamessage.py +23 -11
  45. mistralai/models/detailedjobout.py +70 -12
  46. mistralai/models/embeddingrequest.py +14 -9
  47. mistralai/models/embeddingresponse.py +7 -3
  48. mistralai/models/embeddingresponsedata.py +5 -4
  49. mistralai/models/eventout.py +11 -6
  50. mistralai/models/filepurpose.py +8 -0
  51. mistralai/models/files_api_routes_delete_fileop.py +5 -5
  52. mistralai/models/files_api_routes_download_fileop.py +16 -0
  53. mistralai/models/files_api_routes_list_filesop.py +96 -0
  54. mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
  55. mistralai/models/files_api_routes_upload_fileop.py +33 -14
  56. mistralai/models/fileschema.py +22 -15
  57. mistralai/models/fimcompletionrequest.py +44 -16
  58. mistralai/models/fimcompletionresponse.py +8 -4
  59. mistralai/models/fimcompletionstreamrequest.py +44 -16
  60. mistralai/models/finetuneablemodel.py +7 -1
  61. mistralai/models/ftmodelcapabilitiesout.py +6 -4
  62. mistralai/models/ftmodelcard.py +121 -0
  63. mistralai/models/ftmodelout.py +39 -9
  64. mistralai/models/function.py +5 -4
  65. mistralai/models/functioncall.py +4 -3
  66. mistralai/models/functionname.py +17 -0
  67. mistralai/models/githubrepositoryin.py +24 -7
  68. mistralai/models/githubrepositoryout.py +24 -7
  69. mistralai/models/httpvalidationerror.py +1 -3
  70. mistralai/models/imageurl.py +47 -0
  71. mistralai/models/imageurlchunk.py +38 -0
  72. mistralai/models/jobin.py +24 -7
  73. mistralai/models/jobmetadataout.py +32 -8
  74. mistralai/models/jobout.py +65 -12
  75. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  76. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  77. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  78. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
  79. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
  80. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
  81. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
  82. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
  83. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
  84. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
  85. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
  86. mistralai/models/jobsout.py +13 -5
  87. mistralai/models/legacyjobmetadataout.py +55 -9
  88. mistralai/models/listfilesout.py +7 -3
  89. mistralai/models/metricout.py +12 -8
  90. mistralai/models/modelcapabilities.py +9 -4
  91. mistralai/models/modellist.py +21 -7
  92. mistralai/models/responseformat.py +7 -8
  93. mistralai/models/responseformats.py +8 -0
  94. mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
  95. mistralai/models/retrievefileout.py +25 -15
  96. mistralai/models/sampletype.py +6 -2
  97. mistralai/models/security.py +14 -5
  98. mistralai/models/source.py +3 -2
  99. mistralai/models/systemmessage.py +10 -9
  100. mistralai/models/textchunk.py +14 -5
  101. mistralai/models/tool.py +10 -9
  102. mistralai/models/toolcall.py +10 -8
  103. mistralai/models/toolchoice.py +29 -0
  104. mistralai/models/toolchoiceenum.py +7 -0
  105. mistralai/models/toolmessage.py +13 -6
  106. mistralai/models/tooltypes.py +8 -0
  107. mistralai/models/trainingfile.py +4 -4
  108. mistralai/models/trainingparameters.py +34 -8
  109. mistralai/models/trainingparametersin.py +36 -10
  110. mistralai/models/unarchiveftmodelout.py +15 -5
  111. mistralai/models/updateftmodelin.py +9 -6
  112. mistralai/models/uploadfileout.py +22 -15
  113. mistralai/models/usageinfo.py +4 -3
  114. mistralai/models/usermessage.py +42 -10
  115. mistralai/models/validationerror.py +5 -3
  116. mistralai/models/wandbintegration.py +23 -7
  117. mistralai/models/wandbintegrationout.py +23 -8
  118. mistralai/models_.py +416 -294
  119. mistralai/sdk.py +31 -19
  120. mistralai/sdkconfiguration.py +9 -11
  121. mistralai/utils/__init__.py +14 -1
  122. mistralai/utils/annotations.py +13 -2
  123. mistralai/utils/logger.py +4 -1
  124. mistralai/utils/retries.py +2 -1
  125. mistralai/utils/security.py +13 -6
  126. mistralai/utils/serializers.py +25 -0
  127. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
  128. mistralai-1.2.0.dist-info/RECORD +276 -0
  129. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
  130. mistralai_azure/__init__.py +4 -0
  131. mistralai_azure/_hooks/sdkhooks.py +23 -4
  132. mistralai_azure/_hooks/types.py +27 -9
  133. mistralai_azure/_version.py +12 -0
  134. mistralai_azure/basesdk.py +91 -6
  135. mistralai_azure/chat.py +308 -166
  136. mistralai_azure/models/__init__.py +164 -16
  137. mistralai_azure/models/assistantmessage.py +29 -11
  138. mistralai_azure/models/chatcompletionchoice.py +15 -6
  139. mistralai_azure/models/chatcompletionrequest.py +94 -22
  140. mistralai_azure/models/chatcompletionresponse.py +8 -4
  141. mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
  142. mistralai_azure/models/completionchunk.py +12 -5
  143. mistralai_azure/models/completionevent.py +2 -3
  144. mistralai_azure/models/completionresponsestreamchoice.py +19 -8
  145. mistralai_azure/models/contentchunk.py +4 -11
  146. mistralai_azure/models/deltamessage.py +30 -12
  147. mistralai_azure/models/function.py +5 -4
  148. mistralai_azure/models/functioncall.py +4 -3
  149. mistralai_azure/models/functionname.py +17 -0
  150. mistralai_azure/models/httpvalidationerror.py +1 -3
  151. mistralai_azure/models/responseformat.py +7 -8
  152. mistralai_azure/models/responseformats.py +8 -0
  153. mistralai_azure/models/security.py +13 -5
  154. mistralai_azure/models/systemmessage.py +10 -9
  155. mistralai_azure/models/textchunk.py +14 -5
  156. mistralai_azure/models/tool.py +10 -9
  157. mistralai_azure/models/toolcall.py +10 -8
  158. mistralai_azure/models/toolchoice.py +29 -0
  159. mistralai_azure/models/toolchoiceenum.py +7 -0
  160. mistralai_azure/models/toolmessage.py +20 -7
  161. mistralai_azure/models/tooltypes.py +8 -0
  162. mistralai_azure/models/usageinfo.py +4 -3
  163. mistralai_azure/models/usermessage.py +42 -10
  164. mistralai_azure/models/validationerror.py +5 -3
  165. mistralai_azure/sdkconfiguration.py +9 -11
  166. mistralai_azure/utils/__init__.py +16 -3
  167. mistralai_azure/utils/annotations.py +13 -2
  168. mistralai_azure/utils/forms.py +10 -9
  169. mistralai_azure/utils/headers.py +8 -8
  170. mistralai_azure/utils/logger.py +6 -0
  171. mistralai_azure/utils/queryparams.py +16 -14
  172. mistralai_azure/utils/retries.py +2 -1
  173. mistralai_azure/utils/security.py +12 -6
  174. mistralai_azure/utils/serializers.py +42 -8
  175. mistralai_azure/utils/url.py +13 -8
  176. mistralai_azure/utils/values.py +6 -0
  177. mistralai_gcp/__init__.py +4 -0
  178. mistralai_gcp/_hooks/sdkhooks.py +23 -4
  179. mistralai_gcp/_hooks/types.py +27 -9
  180. mistralai_gcp/_version.py +12 -0
  181. mistralai_gcp/basesdk.py +91 -6
  182. mistralai_gcp/chat.py +308 -166
  183. mistralai_gcp/fim.py +198 -132
  184. mistralai_gcp/models/__init__.py +186 -18
  185. mistralai_gcp/models/assistantmessage.py +29 -11
  186. mistralai_gcp/models/chatcompletionchoice.py +15 -6
  187. mistralai_gcp/models/chatcompletionrequest.py +91 -22
  188. mistralai_gcp/models/chatcompletionresponse.py +8 -4
  189. mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
  190. mistralai_gcp/models/completionchunk.py +12 -5
  191. mistralai_gcp/models/completionevent.py +2 -3
  192. mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
  193. mistralai_gcp/models/contentchunk.py +4 -11
  194. mistralai_gcp/models/deltamessage.py +30 -12
  195. mistralai_gcp/models/fimcompletionrequest.py +51 -17
  196. mistralai_gcp/models/fimcompletionresponse.py +8 -4
  197. mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
  198. mistralai_gcp/models/function.py +5 -4
  199. mistralai_gcp/models/functioncall.py +4 -3
  200. mistralai_gcp/models/functionname.py +17 -0
  201. mistralai_gcp/models/httpvalidationerror.py +1 -3
  202. mistralai_gcp/models/responseformat.py +7 -8
  203. mistralai_gcp/models/responseformats.py +8 -0
  204. mistralai_gcp/models/security.py +13 -5
  205. mistralai_gcp/models/systemmessage.py +10 -9
  206. mistralai_gcp/models/textchunk.py +14 -5
  207. mistralai_gcp/models/tool.py +10 -9
  208. mistralai_gcp/models/toolcall.py +10 -8
  209. mistralai_gcp/models/toolchoice.py +29 -0
  210. mistralai_gcp/models/toolchoiceenum.py +7 -0
  211. mistralai_gcp/models/toolmessage.py +20 -7
  212. mistralai_gcp/models/tooltypes.py +8 -0
  213. mistralai_gcp/models/usageinfo.py +4 -3
  214. mistralai_gcp/models/usermessage.py +42 -10
  215. mistralai_gcp/models/validationerror.py +5 -3
  216. mistralai_gcp/sdk.py +6 -7
  217. mistralai_gcp/sdkconfiguration.py +9 -11
  218. mistralai_gcp/utils/__init__.py +16 -3
  219. mistralai_gcp/utils/annotations.py +13 -2
  220. mistralai_gcp/utils/forms.py +10 -9
  221. mistralai_gcp/utils/headers.py +8 -8
  222. mistralai_gcp/utils/logger.py +6 -0
  223. mistralai_gcp/utils/queryparams.py +16 -14
  224. mistralai_gcp/utils/retries.py +2 -1
  225. mistralai_gcp/utils/security.py +12 -6
  226. mistralai_gcp/utils/serializers.py +42 -8
  227. mistralai_gcp/utils/url.py +13 -8
  228. mistralai_gcp/utils/values.py +6 -0
  229. mistralai-1.0.3.dist-info/RECORD +0 -236
  230. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
mistralai/models_.py CHANGED
@@ -7,12 +7,13 @@ from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import get_security_from_env
8
8
  from typing import Any, Optional
9
9
 
10
+
10
11
  class Models(BaseSDK):
11
12
  r"""Model Management API"""
12
-
13
-
13
+
14
14
  def list(
15
- self, *,
15
+ self,
16
+ *,
16
17
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
17
18
  server_url: Optional[str] = None,
18
19
  timeout_ms: Optional[int] = None,
@@ -29,7 +30,7 @@ class Models(BaseSDK):
29
30
  url_variables = None
30
31
  if timeout_ms is None:
31
32
  timeout_ms = self.sdk_configuration.timeout_ms
32
-
33
+
33
34
  if server_url is not None:
34
35
  base_url = server_url
35
36
  req = self.build_request(
@@ -46,44 +47,52 @@ class Models(BaseSDK):
46
47
  security=self.sdk_configuration.security,
47
48
  timeout_ms=timeout_ms,
48
49
  )
49
-
50
+
50
51
  if retries == UNSET:
51
52
  if self.sdk_configuration.retry_config is not UNSET:
52
53
  retries = self.sdk_configuration.retry_config
53
54
 
54
55
  retry_config = None
55
56
  if isinstance(retries, utils.RetryConfig):
56
- retry_config = (retries, [
57
- "429",
58
- "500",
59
- "502",
60
- "503",
61
- "504"
62
- ])
63
-
57
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
58
+
64
59
  http_res = self.do_request(
65
- hook_ctx=HookContext(operation_id="list_models_v1_models_get", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
60
+ hook_ctx=HookContext(
61
+ operation_id="list_models_v1_models_get",
62
+ oauth2_scopes=[],
63
+ security_source=get_security_from_env(
64
+ self.sdk_configuration.security, models.Security
65
+ ),
66
+ ),
66
67
  request=req,
67
- error_status_codes=["422","4XX","5XX"],
68
- retry_config=retry_config
68
+ error_status_codes=["422", "4XX", "5XX"],
69
+ retry_config=retry_config,
69
70
  )
70
-
71
+
71
72
  data: Any = None
72
73
  if utils.match_response(http_res, "200", "application/json"):
73
74
  return utils.unmarshal_json(http_res.text, Optional[models.ModelList])
74
75
  if utils.match_response(http_res, "422", "application/json"):
75
76
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
76
77
  raise models.HTTPValidationError(data=data)
77
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
78
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
79
-
78
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
79
+ http_res_text = utils.stream_to_text(http_res)
80
+ raise models.SDKError(
81
+ "API error occurred", http_res.status_code, http_res_text, http_res
82
+ )
83
+
80
84
  content_type = http_res.headers.get("Content-Type")
81
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
85
+ http_res_text = utils.stream_to_text(http_res)
86
+ raise models.SDKError(
87
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
88
+ http_res.status_code,
89
+ http_res_text,
90
+ http_res,
91
+ )
82
92
 
83
-
84
-
85
93
  async def list_async(
86
- self, *,
94
+ self,
95
+ *,
87
96
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
88
97
  server_url: Optional[str] = None,
89
98
  timeout_ms: Optional[int] = None,
@@ -100,10 +109,10 @@ class Models(BaseSDK):
100
109
  url_variables = None
101
110
  if timeout_ms is None:
102
111
  timeout_ms = self.sdk_configuration.timeout_ms
103
-
112
+
104
113
  if server_url is not None:
105
114
  base_url = server_url
106
- req = self.build_request(
115
+ req = self.build_request_async(
107
116
  method="GET",
108
117
  path="/v1/models",
109
118
  base_url=base_url,
@@ -117,49 +126,59 @@ class Models(BaseSDK):
117
126
  security=self.sdk_configuration.security,
118
127
  timeout_ms=timeout_ms,
119
128
  )
120
-
129
+
121
130
  if retries == UNSET:
122
131
  if self.sdk_configuration.retry_config is not UNSET:
123
132
  retries = self.sdk_configuration.retry_config
124
133
 
125
134
  retry_config = None
126
135
  if isinstance(retries, utils.RetryConfig):
127
- retry_config = (retries, [
128
- "429",
129
- "500",
130
- "502",
131
- "503",
132
- "504"
133
- ])
134
-
136
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
137
+
135
138
  http_res = await self.do_request_async(
136
- hook_ctx=HookContext(operation_id="list_models_v1_models_get", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
139
+ hook_ctx=HookContext(
140
+ operation_id="list_models_v1_models_get",
141
+ oauth2_scopes=[],
142
+ security_source=get_security_from_env(
143
+ self.sdk_configuration.security, models.Security
144
+ ),
145
+ ),
137
146
  request=req,
138
- error_status_codes=["422","4XX","5XX"],
139
- retry_config=retry_config
147
+ error_status_codes=["422", "4XX", "5XX"],
148
+ retry_config=retry_config,
140
149
  )
141
-
150
+
142
151
  data: Any = None
143
152
  if utils.match_response(http_res, "200", "application/json"):
144
153
  return utils.unmarshal_json(http_res.text, Optional[models.ModelList])
145
154
  if utils.match_response(http_res, "422", "application/json"):
146
155
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
147
156
  raise models.HTTPValidationError(data=data)
148
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
149
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
150
-
157
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
158
+ http_res_text = await utils.stream_to_text_async(http_res)
159
+ raise models.SDKError(
160
+ "API error occurred", http_res.status_code, http_res_text, http_res
161
+ )
162
+
151
163
  content_type = http_res.headers.get("Content-Type")
152
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
164
+ http_res_text = await utils.stream_to_text_async(http_res)
165
+ raise models.SDKError(
166
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
167
+ http_res.status_code,
168
+ http_res_text,
169
+ http_res,
170
+ )
153
171
 
154
-
155
-
156
172
  def retrieve(
157
- self, *,
173
+ self,
174
+ *,
158
175
  model_id: str,
159
176
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
160
177
  server_url: Optional[str] = None,
161
178
  timeout_ms: Optional[int] = None,
162
- ) -> Optional[models.ModelCard]:
179
+ ) -> Optional[
180
+ models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
181
+ ]:
163
182
  r"""Retrieve Model
164
183
 
165
184
  Retrieve a model information.
@@ -173,14 +192,14 @@ class Models(BaseSDK):
173
192
  url_variables = None
174
193
  if timeout_ms is None:
175
194
  timeout_ms = self.sdk_configuration.timeout_ms
176
-
195
+
177
196
  if server_url is not None:
178
197
  base_url = server_url
179
-
198
+
180
199
  request = models.RetrieveModelV1ModelsModelIDGetRequest(
181
200
  model_id=model_id,
182
201
  )
183
-
202
+
184
203
  req = self.build_request(
185
204
  method="GET",
186
205
  path="/v1/models/{model_id}",
@@ -195,49 +214,64 @@ class Models(BaseSDK):
195
214
  security=self.sdk_configuration.security,
196
215
  timeout_ms=timeout_ms,
197
216
  )
198
-
217
+
199
218
  if retries == UNSET:
200
219
  if self.sdk_configuration.retry_config is not UNSET:
201
220
  retries = self.sdk_configuration.retry_config
202
221
 
203
222
  retry_config = None
204
223
  if isinstance(retries, utils.RetryConfig):
205
- retry_config = (retries, [
206
- "429",
207
- "500",
208
- "502",
209
- "503",
210
- "504"
211
- ])
212
-
224
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
225
+
213
226
  http_res = self.do_request(
214
- hook_ctx=HookContext(operation_id="retrieve_model_v1_models__model_id__get", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
227
+ hook_ctx=HookContext(
228
+ operation_id="retrieve_model_v1_models__model_id__get",
229
+ oauth2_scopes=[],
230
+ security_source=get_security_from_env(
231
+ self.sdk_configuration.security, models.Security
232
+ ),
233
+ ),
215
234
  request=req,
216
- error_status_codes=["422","4XX","5XX"],
217
- retry_config=retry_config
235
+ error_status_codes=["422", "4XX", "5XX"],
236
+ retry_config=retry_config,
218
237
  )
219
-
238
+
220
239
  data: Any = None
221
240
  if utils.match_response(http_res, "200", "application/json"):
222
- return utils.unmarshal_json(http_res.text, Optional[models.ModelCard])
241
+ return utils.unmarshal_json(
242
+ http_res.text,
243
+ Optional[
244
+ models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
245
+ ],
246
+ )
223
247
  if utils.match_response(http_res, "422", "application/json"):
224
248
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
225
249
  raise models.HTTPValidationError(data=data)
226
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
227
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
228
-
250
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
251
+ http_res_text = utils.stream_to_text(http_res)
252
+ raise models.SDKError(
253
+ "API error occurred", http_res.status_code, http_res_text, http_res
254
+ )
255
+
229
256
  content_type = http_res.headers.get("Content-Type")
230
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
257
+ http_res_text = utils.stream_to_text(http_res)
258
+ raise models.SDKError(
259
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
260
+ http_res.status_code,
261
+ http_res_text,
262
+ http_res,
263
+ )
231
264
 
232
-
233
-
234
265
  async def retrieve_async(
235
- self, *,
266
+ self,
267
+ *,
236
268
  model_id: str,
237
269
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
238
270
  server_url: Optional[str] = None,
239
271
  timeout_ms: Optional[int] = None,
240
- ) -> Optional[models.ModelCard]:
272
+ ) -> Optional[
273
+ models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
274
+ ]:
241
275
  r"""Retrieve Model
242
276
 
243
277
  Retrieve a model information.
@@ -251,15 +285,15 @@ class Models(BaseSDK):
251
285
  url_variables = None
252
286
  if timeout_ms is None:
253
287
  timeout_ms = self.sdk_configuration.timeout_ms
254
-
288
+
255
289
  if server_url is not None:
256
290
  base_url = server_url
257
-
291
+
258
292
  request = models.RetrieveModelV1ModelsModelIDGetRequest(
259
293
  model_id=model_id,
260
294
  )
261
-
262
- req = self.build_request(
295
+
296
+ req = self.build_request_async(
263
297
  method="GET",
264
298
  path="/v1/models/{model_id}",
265
299
  base_url=base_url,
@@ -273,44 +307,57 @@ class Models(BaseSDK):
273
307
  security=self.sdk_configuration.security,
274
308
  timeout_ms=timeout_ms,
275
309
  )
276
-
310
+
277
311
  if retries == UNSET:
278
312
  if self.sdk_configuration.retry_config is not UNSET:
279
313
  retries = self.sdk_configuration.retry_config
280
314
 
281
315
  retry_config = None
282
316
  if isinstance(retries, utils.RetryConfig):
283
- retry_config = (retries, [
284
- "429",
285
- "500",
286
- "502",
287
- "503",
288
- "504"
289
- ])
290
-
317
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
318
+
291
319
  http_res = await self.do_request_async(
292
- hook_ctx=HookContext(operation_id="retrieve_model_v1_models__model_id__get", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
320
+ hook_ctx=HookContext(
321
+ operation_id="retrieve_model_v1_models__model_id__get",
322
+ oauth2_scopes=[],
323
+ security_source=get_security_from_env(
324
+ self.sdk_configuration.security, models.Security
325
+ ),
326
+ ),
293
327
  request=req,
294
- error_status_codes=["422","4XX","5XX"],
295
- retry_config=retry_config
328
+ error_status_codes=["422", "4XX", "5XX"],
329
+ retry_config=retry_config,
296
330
  )
297
-
331
+
298
332
  data: Any = None
299
333
  if utils.match_response(http_res, "200", "application/json"):
300
- return utils.unmarshal_json(http_res.text, Optional[models.ModelCard])
334
+ return utils.unmarshal_json(
335
+ http_res.text,
336
+ Optional[
337
+ models.RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet
338
+ ],
339
+ )
301
340
  if utils.match_response(http_res, "422", "application/json"):
302
341
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
303
342
  raise models.HTTPValidationError(data=data)
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
-
343
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
344
+ http_res_text = await utils.stream_to_text_async(http_res)
345
+ raise models.SDKError(
346
+ "API error occurred", http_res.status_code, http_res_text, http_res
347
+ )
348
+
307
349
  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)
350
+ http_res_text = await utils.stream_to_text_async(http_res)
351
+ raise models.SDKError(
352
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
353
+ http_res.status_code,
354
+ http_res_text,
355
+ http_res,
356
+ )
309
357
 
310
-
311
-
312
358
  def delete(
313
- self, *,
359
+ self,
360
+ *,
314
361
  model_id: str,
315
362
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
316
363
  server_url: Optional[str] = None,
@@ -329,14 +376,14 @@ class Models(BaseSDK):
329
376
  url_variables = None
330
377
  if timeout_ms is None:
331
378
  timeout_ms = self.sdk_configuration.timeout_ms
332
-
379
+
333
380
  if server_url is not None:
334
381
  base_url = server_url
335
-
382
+
336
383
  request = models.DeleteModelV1ModelsModelIDDeleteRequest(
337
384
  model_id=model_id,
338
385
  )
339
-
386
+
340
387
  req = self.build_request(
341
388
  method="DELETE",
342
389
  path="/v1/models/{model_id}",
@@ -351,44 +398,52 @@ class Models(BaseSDK):
351
398
  security=self.sdk_configuration.security,
352
399
  timeout_ms=timeout_ms,
353
400
  )
354
-
401
+
355
402
  if retries == UNSET:
356
403
  if self.sdk_configuration.retry_config is not UNSET:
357
404
  retries = self.sdk_configuration.retry_config
358
405
 
359
406
  retry_config = None
360
407
  if isinstance(retries, utils.RetryConfig):
361
- retry_config = (retries, [
362
- "429",
363
- "500",
364
- "502",
365
- "503",
366
- "504"
367
- ])
368
-
408
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
409
+
369
410
  http_res = self.do_request(
370
- hook_ctx=HookContext(operation_id="delete_model_v1_models__model_id__delete", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
411
+ hook_ctx=HookContext(
412
+ operation_id="delete_model_v1_models__model_id__delete",
413
+ oauth2_scopes=[],
414
+ security_source=get_security_from_env(
415
+ self.sdk_configuration.security, models.Security
416
+ ),
417
+ ),
371
418
  request=req,
372
- error_status_codes=["422","4XX","5XX"],
373
- retry_config=retry_config
419
+ error_status_codes=["422", "4XX", "5XX"],
420
+ retry_config=retry_config,
374
421
  )
375
-
422
+
376
423
  data: Any = None
377
424
  if utils.match_response(http_res, "200", "application/json"):
378
425
  return utils.unmarshal_json(http_res.text, Optional[models.DeleteModelOut])
379
426
  if utils.match_response(http_res, "422", "application/json"):
380
427
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
381
428
  raise models.HTTPValidationError(data=data)
382
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
383
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
384
-
429
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
430
+ http_res_text = utils.stream_to_text(http_res)
431
+ raise models.SDKError(
432
+ "API error occurred", http_res.status_code, http_res_text, http_res
433
+ )
434
+
385
435
  content_type = http_res.headers.get("Content-Type")
386
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
436
+ http_res_text = utils.stream_to_text(http_res)
437
+ raise models.SDKError(
438
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
439
+ http_res.status_code,
440
+ http_res_text,
441
+ http_res,
442
+ )
387
443
 
388
-
389
-
390
444
  async def delete_async(
391
- self, *,
445
+ self,
446
+ *,
392
447
  model_id: str,
393
448
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
394
449
  server_url: Optional[str] = None,
@@ -407,15 +462,15 @@ class Models(BaseSDK):
407
462
  url_variables = None
408
463
  if timeout_ms is None:
409
464
  timeout_ms = self.sdk_configuration.timeout_ms
410
-
465
+
411
466
  if server_url is not None:
412
467
  base_url = server_url
413
-
468
+
414
469
  request = models.DeleteModelV1ModelsModelIDDeleteRequest(
415
470
  model_id=model_id,
416
471
  )
417
-
418
- req = self.build_request(
472
+
473
+ req = self.build_request_async(
419
474
  method="DELETE",
420
475
  path="/v1/models/{model_id}",
421
476
  base_url=base_url,
@@ -429,44 +484,52 @@ class Models(BaseSDK):
429
484
  security=self.sdk_configuration.security,
430
485
  timeout_ms=timeout_ms,
431
486
  )
432
-
487
+
433
488
  if retries == UNSET:
434
489
  if self.sdk_configuration.retry_config is not UNSET:
435
490
  retries = self.sdk_configuration.retry_config
436
491
 
437
492
  retry_config = None
438
493
  if isinstance(retries, utils.RetryConfig):
439
- retry_config = (retries, [
440
- "429",
441
- "500",
442
- "502",
443
- "503",
444
- "504"
445
- ])
446
-
494
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
495
+
447
496
  http_res = await self.do_request_async(
448
- hook_ctx=HookContext(operation_id="delete_model_v1_models__model_id__delete", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
497
+ hook_ctx=HookContext(
498
+ operation_id="delete_model_v1_models__model_id__delete",
499
+ oauth2_scopes=[],
500
+ security_source=get_security_from_env(
501
+ self.sdk_configuration.security, models.Security
502
+ ),
503
+ ),
449
504
  request=req,
450
- error_status_codes=["422","4XX","5XX"],
451
- retry_config=retry_config
505
+ error_status_codes=["422", "4XX", "5XX"],
506
+ retry_config=retry_config,
452
507
  )
453
-
508
+
454
509
  data: Any = None
455
510
  if utils.match_response(http_res, "200", "application/json"):
456
511
  return utils.unmarshal_json(http_res.text, Optional[models.DeleteModelOut])
457
512
  if utils.match_response(http_res, "422", "application/json"):
458
513
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
459
514
  raise models.HTTPValidationError(data=data)
460
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
461
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
462
-
515
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
516
+ http_res_text = await utils.stream_to_text_async(http_res)
517
+ raise models.SDKError(
518
+ "API error occurred", http_res.status_code, http_res_text, http_res
519
+ )
520
+
463
521
  content_type = http_res.headers.get("Content-Type")
464
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
522
+ http_res_text = await utils.stream_to_text_async(http_res)
523
+ raise models.SDKError(
524
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
525
+ http_res.status_code,
526
+ http_res_text,
527
+ http_res,
528
+ )
465
529
 
466
-
467
-
468
530
  def update(
469
- self, *,
531
+ self,
532
+ *,
470
533
  model_id: str,
471
534
  name: OptionalNullable[str] = UNSET,
472
535
  description: OptionalNullable[str] = UNSET,
@@ -479,8 +542,8 @@ class Models(BaseSDK):
479
542
  Update a model name or description.
480
543
 
481
544
  :param model_id: The ID of the model to update.
482
- :param name:
483
- :param description:
545
+ :param name:
546
+ :param description:
484
547
  :param retries: Override the default retry configuration for this method
485
548
  :param server_url: Override the default server URL for this method
486
549
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -489,10 +552,10 @@ class Models(BaseSDK):
489
552
  url_variables = None
490
553
  if timeout_ms is None:
491
554
  timeout_ms = self.sdk_configuration.timeout_ms
492
-
555
+
493
556
  if server_url is not None:
494
557
  base_url = server_url
495
-
558
+
496
559
  request = models.JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(
497
560
  model_id=model_id,
498
561
  update_ft_model_in=models.UpdateFTModelIn(
@@ -500,7 +563,7 @@ class Models(BaseSDK):
500
563
  description=description,
501
564
  ),
502
565
  )
503
-
566
+
504
567
  req = self.build_request(
505
568
  method="PATCH",
506
569
  path="/v1/fine_tuning/models/{model_id}",
@@ -513,43 +576,53 @@ class Models(BaseSDK):
513
576
  user_agent_header="user-agent",
514
577
  accept_header_value="application/json",
515
578
  security=self.sdk_configuration.security,
516
- get_serialized_body=lambda: utils.serialize_request_body(request.update_ft_model_in, False, False, "json", models.UpdateFTModelIn),
579
+ get_serialized_body=lambda: utils.serialize_request_body(
580
+ request.update_ft_model_in, False, False, "json", models.UpdateFTModelIn
581
+ ),
517
582
  timeout_ms=timeout_ms,
518
583
  )
519
-
584
+
520
585
  if retries == UNSET:
521
586
  if self.sdk_configuration.retry_config is not UNSET:
522
587
  retries = self.sdk_configuration.retry_config
523
588
 
524
589
  retry_config = None
525
590
  if isinstance(retries, utils.RetryConfig):
526
- retry_config = (retries, [
527
- "429",
528
- "500",
529
- "502",
530
- "503",
531
- "504"
532
- ])
533
-
591
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
592
+
534
593
  http_res = self.do_request(
535
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
594
+ hook_ctx=HookContext(
595
+ operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model",
596
+ oauth2_scopes=[],
597
+ security_source=get_security_from_env(
598
+ self.sdk_configuration.security, models.Security
599
+ ),
600
+ ),
536
601
  request=req,
537
- error_status_codes=["4XX","5XX"],
538
- retry_config=retry_config
602
+ error_status_codes=["4XX", "5XX"],
603
+ retry_config=retry_config,
539
604
  )
540
-
605
+
541
606
  if utils.match_response(http_res, "200", "application/json"):
542
607
  return utils.unmarshal_json(http_res.text, Optional[models.FTModelOut])
543
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
544
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
545
-
608
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
609
+ http_res_text = utils.stream_to_text(http_res)
610
+ raise models.SDKError(
611
+ "API error occurred", http_res.status_code, http_res_text, http_res
612
+ )
613
+
546
614
  content_type = http_res.headers.get("Content-Type")
547
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
615
+ http_res_text = utils.stream_to_text(http_res)
616
+ raise models.SDKError(
617
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
618
+ http_res.status_code,
619
+ http_res_text,
620
+ http_res,
621
+ )
548
622
 
549
-
550
-
551
623
  async def update_async(
552
- self, *,
624
+ self,
625
+ *,
553
626
  model_id: str,
554
627
  name: OptionalNullable[str] = UNSET,
555
628
  description: OptionalNullable[str] = UNSET,
@@ -562,8 +635,8 @@ class Models(BaseSDK):
562
635
  Update a model name or description.
563
636
 
564
637
  :param model_id: The ID of the model to update.
565
- :param name:
566
- :param description:
638
+ :param name:
639
+ :param description:
567
640
  :param retries: Override the default retry configuration for this method
568
641
  :param server_url: Override the default server URL for this method
569
642
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -572,10 +645,10 @@ class Models(BaseSDK):
572
645
  url_variables = None
573
646
  if timeout_ms is None:
574
647
  timeout_ms = self.sdk_configuration.timeout_ms
575
-
648
+
576
649
  if server_url is not None:
577
650
  base_url = server_url
578
-
651
+
579
652
  request = models.JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(
580
653
  model_id=model_id,
581
654
  update_ft_model_in=models.UpdateFTModelIn(
@@ -583,8 +656,8 @@ class Models(BaseSDK):
583
656
  description=description,
584
657
  ),
585
658
  )
586
-
587
- req = self.build_request(
659
+
660
+ req = self.build_request_async(
588
661
  method="PATCH",
589
662
  path="/v1/fine_tuning/models/{model_id}",
590
663
  base_url=base_url,
@@ -596,43 +669,53 @@ class Models(BaseSDK):
596
669
  user_agent_header="user-agent",
597
670
  accept_header_value="application/json",
598
671
  security=self.sdk_configuration.security,
599
- get_serialized_body=lambda: utils.serialize_request_body(request.update_ft_model_in, False, False, "json", models.UpdateFTModelIn),
672
+ get_serialized_body=lambda: utils.serialize_request_body(
673
+ request.update_ft_model_in, False, False, "json", models.UpdateFTModelIn
674
+ ),
600
675
  timeout_ms=timeout_ms,
601
676
  )
602
-
677
+
603
678
  if retries == UNSET:
604
679
  if self.sdk_configuration.retry_config is not UNSET:
605
680
  retries = self.sdk_configuration.retry_config
606
681
 
607
682
  retry_config = None
608
683
  if isinstance(retries, utils.RetryConfig):
609
- retry_config = (retries, [
610
- "429",
611
- "500",
612
- "502",
613
- "503",
614
- "504"
615
- ])
616
-
684
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
685
+
617
686
  http_res = await self.do_request_async(
618
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
687
+ hook_ctx=HookContext(
688
+ operation_id="jobs_api_routes_fine_tuning_update_fine_tuned_model",
689
+ oauth2_scopes=[],
690
+ security_source=get_security_from_env(
691
+ self.sdk_configuration.security, models.Security
692
+ ),
693
+ ),
619
694
  request=req,
620
- error_status_codes=["4XX","5XX"],
621
- retry_config=retry_config
695
+ error_status_codes=["4XX", "5XX"],
696
+ retry_config=retry_config,
622
697
  )
623
-
698
+
624
699
  if utils.match_response(http_res, "200", "application/json"):
625
700
  return utils.unmarshal_json(http_res.text, Optional[models.FTModelOut])
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
-
701
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
702
+ http_res_text = await utils.stream_to_text_async(http_res)
703
+ raise models.SDKError(
704
+ "API error occurred", http_res.status_code, http_res_text, http_res
705
+ )
706
+
629
707
  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)
708
+ http_res_text = await utils.stream_to_text_async(http_res)
709
+ raise models.SDKError(
710
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
711
+ http_res.status_code,
712
+ http_res_text,
713
+ http_res,
714
+ )
631
715
 
632
-
633
-
634
716
  def archive(
635
- self, *,
717
+ self,
718
+ *,
636
719
  model_id: str,
637
720
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
638
721
  server_url: Optional[str] = None,
@@ -651,14 +734,14 @@ class Models(BaseSDK):
651
734
  url_variables = None
652
735
  if timeout_ms is None:
653
736
  timeout_ms = self.sdk_configuration.timeout_ms
654
-
737
+
655
738
  if server_url is not None:
656
739
  base_url = server_url
657
-
740
+
658
741
  request = models.JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(
659
742
  model_id=model_id,
660
743
  )
661
-
744
+
662
745
  req = self.build_request(
663
746
  method="POST",
664
747
  path="/v1/fine_tuning/models/{model_id}/archive",
@@ -673,40 +756,50 @@ class Models(BaseSDK):
673
756
  security=self.sdk_configuration.security,
674
757
  timeout_ms=timeout_ms,
675
758
  )
676
-
759
+
677
760
  if retries == UNSET:
678
761
  if self.sdk_configuration.retry_config is not UNSET:
679
762
  retries = self.sdk_configuration.retry_config
680
763
 
681
764
  retry_config = None
682
765
  if isinstance(retries, utils.RetryConfig):
683
- retry_config = (retries, [
684
- "429",
685
- "500",
686
- "502",
687
- "503",
688
- "504"
689
- ])
690
-
766
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
767
+
691
768
  http_res = self.do_request(
692
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
769
+ hook_ctx=HookContext(
770
+ operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model",
771
+ oauth2_scopes=[],
772
+ security_source=get_security_from_env(
773
+ self.sdk_configuration.security, models.Security
774
+ ),
775
+ ),
693
776
  request=req,
694
- error_status_codes=["4XX","5XX"],
695
- retry_config=retry_config
777
+ error_status_codes=["4XX", "5XX"],
778
+ retry_config=retry_config,
696
779
  )
697
-
780
+
698
781
  if utils.match_response(http_res, "200", "application/json"):
699
- return utils.unmarshal_json(http_res.text, Optional[models.ArchiveFTModelOut])
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
-
782
+ return utils.unmarshal_json(
783
+ http_res.text, Optional[models.ArchiveFTModelOut]
784
+ )
785
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
786
+ http_res_text = utils.stream_to_text(http_res)
787
+ raise models.SDKError(
788
+ "API error occurred", http_res.status_code, http_res_text, http_res
789
+ )
790
+
703
791
  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)
792
+ http_res_text = utils.stream_to_text(http_res)
793
+ raise models.SDKError(
794
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
795
+ http_res.status_code,
796
+ http_res_text,
797
+ http_res,
798
+ )
705
799
 
706
-
707
-
708
800
  async def archive_async(
709
- self, *,
801
+ self,
802
+ *,
710
803
  model_id: str,
711
804
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
712
805
  server_url: Optional[str] = None,
@@ -725,15 +818,15 @@ class Models(BaseSDK):
725
818
  url_variables = None
726
819
  if timeout_ms is None:
727
820
  timeout_ms = self.sdk_configuration.timeout_ms
728
-
821
+
729
822
  if server_url is not None:
730
823
  base_url = server_url
731
-
824
+
732
825
  request = models.JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(
733
826
  model_id=model_id,
734
827
  )
735
-
736
- req = self.build_request(
828
+
829
+ req = self.build_request_async(
737
830
  method="POST",
738
831
  path="/v1/fine_tuning/models/{model_id}/archive",
739
832
  base_url=base_url,
@@ -747,40 +840,50 @@ class Models(BaseSDK):
747
840
  security=self.sdk_configuration.security,
748
841
  timeout_ms=timeout_ms,
749
842
  )
750
-
843
+
751
844
  if retries == UNSET:
752
845
  if self.sdk_configuration.retry_config is not UNSET:
753
846
  retries = self.sdk_configuration.retry_config
754
847
 
755
848
  retry_config = None
756
849
  if isinstance(retries, utils.RetryConfig):
757
- retry_config = (retries, [
758
- "429",
759
- "500",
760
- "502",
761
- "503",
762
- "504"
763
- ])
764
-
850
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
851
+
765
852
  http_res = await self.do_request_async(
766
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
853
+ hook_ctx=HookContext(
854
+ operation_id="jobs_api_routes_fine_tuning_archive_fine_tuned_model",
855
+ oauth2_scopes=[],
856
+ security_source=get_security_from_env(
857
+ self.sdk_configuration.security, models.Security
858
+ ),
859
+ ),
767
860
  request=req,
768
- error_status_codes=["4XX","5XX"],
769
- retry_config=retry_config
861
+ error_status_codes=["4XX", "5XX"],
862
+ retry_config=retry_config,
770
863
  )
771
-
864
+
772
865
  if utils.match_response(http_res, "200", "application/json"):
773
- return utils.unmarshal_json(http_res.text, Optional[models.ArchiveFTModelOut])
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
-
866
+ return utils.unmarshal_json(
867
+ http_res.text, Optional[models.ArchiveFTModelOut]
868
+ )
869
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
870
+ http_res_text = await utils.stream_to_text_async(http_res)
871
+ raise models.SDKError(
872
+ "API error occurred", http_res.status_code, http_res_text, http_res
873
+ )
874
+
777
875
  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)
876
+ http_res_text = await utils.stream_to_text_async(http_res)
877
+ raise models.SDKError(
878
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
879
+ http_res.status_code,
880
+ http_res_text,
881
+ http_res,
882
+ )
779
883
 
780
-
781
-
782
884
  def unarchive(
783
- self, *,
885
+ self,
886
+ *,
784
887
  model_id: str,
785
888
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
786
889
  server_url: Optional[str] = None,
@@ -799,14 +902,14 @@ class Models(BaseSDK):
799
902
  url_variables = None
800
903
  if timeout_ms is None:
801
904
  timeout_ms = self.sdk_configuration.timeout_ms
802
-
905
+
803
906
  if server_url is not None:
804
907
  base_url = server_url
805
-
908
+
806
909
  request = models.JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(
807
910
  model_id=model_id,
808
911
  )
809
-
912
+
810
913
  req = self.build_request(
811
914
  method="DELETE",
812
915
  path="/v1/fine_tuning/models/{model_id}/archive",
@@ -821,40 +924,50 @@ class Models(BaseSDK):
821
924
  security=self.sdk_configuration.security,
822
925
  timeout_ms=timeout_ms,
823
926
  )
824
-
927
+
825
928
  if retries == UNSET:
826
929
  if self.sdk_configuration.retry_config is not UNSET:
827
930
  retries = self.sdk_configuration.retry_config
828
931
 
829
932
  retry_config = None
830
933
  if isinstance(retries, utils.RetryConfig):
831
- retry_config = (retries, [
832
- "429",
833
- "500",
834
- "502",
835
- "503",
836
- "504"
837
- ])
838
-
934
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
935
+
839
936
  http_res = self.do_request(
840
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
937
+ hook_ctx=HookContext(
938
+ operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model",
939
+ oauth2_scopes=[],
940
+ security_source=get_security_from_env(
941
+ self.sdk_configuration.security, models.Security
942
+ ),
943
+ ),
841
944
  request=req,
842
- error_status_codes=["4XX","5XX"],
843
- retry_config=retry_config
945
+ error_status_codes=["4XX", "5XX"],
946
+ retry_config=retry_config,
844
947
  )
845
-
948
+
846
949
  if utils.match_response(http_res, "200", "application/json"):
847
- return utils.unmarshal_json(http_res.text, Optional[models.UnarchiveFTModelOut])
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
-
950
+ return utils.unmarshal_json(
951
+ http_res.text, Optional[models.UnarchiveFTModelOut]
952
+ )
953
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
954
+ http_res_text = utils.stream_to_text(http_res)
955
+ raise models.SDKError(
956
+ "API error occurred", http_res.status_code, http_res_text, http_res
957
+ )
958
+
851
959
  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)
960
+ http_res_text = utils.stream_to_text(http_res)
961
+ raise models.SDKError(
962
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
963
+ http_res.status_code,
964
+ http_res_text,
965
+ http_res,
966
+ )
853
967
 
854
-
855
-
856
968
  async def unarchive_async(
857
- self, *,
969
+ self,
970
+ *,
858
971
  model_id: str,
859
972
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
860
973
  server_url: Optional[str] = None,
@@ -873,15 +986,15 @@ class Models(BaseSDK):
873
986
  url_variables = None
874
987
  if timeout_ms is None:
875
988
  timeout_ms = self.sdk_configuration.timeout_ms
876
-
989
+
877
990
  if server_url is not None:
878
991
  base_url = server_url
879
-
992
+
880
993
  request = models.JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(
881
994
  model_id=model_id,
882
995
  )
883
-
884
- req = self.build_request(
996
+
997
+ req = self.build_request_async(
885
998
  method="DELETE",
886
999
  path="/v1/fine_tuning/models/{model_id}/archive",
887
1000
  base_url=base_url,
@@ -895,34 +1008,43 @@ class Models(BaseSDK):
895
1008
  security=self.sdk_configuration.security,
896
1009
  timeout_ms=timeout_ms,
897
1010
  )
898
-
1011
+
899
1012
  if retries == UNSET:
900
1013
  if self.sdk_configuration.retry_config is not UNSET:
901
1014
  retries = self.sdk_configuration.retry_config
902
1015
 
903
1016
  retry_config = None
904
1017
  if isinstance(retries, utils.RetryConfig):
905
- retry_config = (retries, [
906
- "429",
907
- "500",
908
- "502",
909
- "503",
910
- "504"
911
- ])
912
-
1018
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1019
+
913
1020
  http_res = await self.do_request_async(
914
- hook_ctx=HookContext(operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
1021
+ hook_ctx=HookContext(
1022
+ operation_id="jobs_api_routes_fine_tuning_unarchive_fine_tuned_model",
1023
+ oauth2_scopes=[],
1024
+ security_source=get_security_from_env(
1025
+ self.sdk_configuration.security, models.Security
1026
+ ),
1027
+ ),
915
1028
  request=req,
916
- error_status_codes=["4XX","5XX"],
917
- retry_config=retry_config
1029
+ error_status_codes=["4XX", "5XX"],
1030
+ retry_config=retry_config,
918
1031
  )
919
-
1032
+
920
1033
  if utils.match_response(http_res, "200", "application/json"):
921
- return utils.unmarshal_json(http_res.text, Optional[models.UnarchiveFTModelOut])
922
- if utils.match_response(http_res, ["4XX","5XX"], "*"):
923
- raise models.SDKError("API error occurred", http_res.status_code, http_res.text, http_res)
924
-
925
- content_type = http_res.headers.get("Content-Type")
926
- raise models.SDKError(f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, http_res.text, http_res)
1034
+ return utils.unmarshal_json(
1035
+ http_res.text, Optional[models.UnarchiveFTModelOut]
1036
+ )
1037
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1038
+ http_res_text = await utils.stream_to_text_async(http_res)
1039
+ raise models.SDKError(
1040
+ "API error occurred", http_res.status_code, http_res_text, http_res
1041
+ )
927
1042
 
928
-
1043
+ content_type = http_res.headers.get("Content-Type")
1044
+ http_res_text = await utils.stream_to_text_async(http_res)
1045
+ raise models.SDKError(
1046
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1047
+ http_res.status_code,
1048
+ http_res_text,
1049
+ http_res,
1050
+ )