mistralai 1.7.1__py3-none-any.whl → 1.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. mistralai/_version.py +2 -2
  2. mistralai/beta.py +22 -0
  3. mistralai/conversations.py +2660 -0
  4. mistralai/embeddings.py +12 -0
  5. mistralai/extra/__init__.py +10 -2
  6. mistralai/extra/exceptions.py +14 -0
  7. mistralai/extra/mcp/__init__.py +0 -0
  8. mistralai/extra/mcp/auth.py +166 -0
  9. mistralai/extra/mcp/base.py +155 -0
  10. mistralai/extra/mcp/sse.py +165 -0
  11. mistralai/extra/mcp/stdio.py +22 -0
  12. mistralai/extra/run/__init__.py +0 -0
  13. mistralai/extra/run/context.py +295 -0
  14. mistralai/extra/run/result.py +212 -0
  15. mistralai/extra/run/tools.py +225 -0
  16. mistralai/extra/run/utils.py +36 -0
  17. mistralai/extra/tests/test_struct_chat.py +1 -1
  18. mistralai/mistral_agents.py +1160 -0
  19. mistralai/models/__init__.py +472 -1
  20. mistralai/models/agent.py +129 -0
  21. mistralai/models/agentconversation.py +71 -0
  22. mistralai/models/agentcreationrequest.py +109 -0
  23. mistralai/models/agenthandoffdoneevent.py +33 -0
  24. mistralai/models/agenthandoffentry.py +75 -0
  25. mistralai/models/agenthandoffstartedevent.py +33 -0
  26. mistralai/models/agents_api_v1_agents_getop.py +16 -0
  27. mistralai/models/agents_api_v1_agents_listop.py +24 -0
  28. mistralai/models/agents_api_v1_agents_update_versionop.py +21 -0
  29. mistralai/models/agents_api_v1_agents_updateop.py +23 -0
  30. mistralai/models/agents_api_v1_conversations_append_streamop.py +28 -0
  31. mistralai/models/agents_api_v1_conversations_appendop.py +28 -0
  32. mistralai/models/agents_api_v1_conversations_getop.py +33 -0
  33. mistralai/models/agents_api_v1_conversations_historyop.py +16 -0
  34. mistralai/models/agents_api_v1_conversations_listop.py +37 -0
  35. mistralai/models/agents_api_v1_conversations_messagesop.py +16 -0
  36. mistralai/models/agents_api_v1_conversations_restart_streamop.py +26 -0
  37. mistralai/models/agents_api_v1_conversations_restartop.py +26 -0
  38. mistralai/models/agentupdaterequest.py +111 -0
  39. mistralai/models/builtinconnectors.py +13 -0
  40. mistralai/models/chatcompletionresponse.py +6 -6
  41. mistralai/models/codeinterpretertool.py +17 -0
  42. mistralai/models/completionargs.py +100 -0
  43. mistralai/models/completionargsstop.py +13 -0
  44. mistralai/models/completionjobout.py +3 -3
  45. mistralai/models/conversationappendrequest.py +35 -0
  46. mistralai/models/conversationappendstreamrequest.py +37 -0
  47. mistralai/models/conversationevents.py +72 -0
  48. mistralai/models/conversationhistory.py +58 -0
  49. mistralai/models/conversationinputs.py +14 -0
  50. mistralai/models/conversationmessages.py +28 -0
  51. mistralai/models/conversationrequest.py +133 -0
  52. mistralai/models/conversationresponse.py +51 -0
  53. mistralai/models/conversationrestartrequest.py +42 -0
  54. mistralai/models/conversationrestartstreamrequest.py +44 -0
  55. mistralai/models/conversationstreamrequest.py +135 -0
  56. mistralai/models/conversationusageinfo.py +63 -0
  57. mistralai/models/documentlibrarytool.py +22 -0
  58. mistralai/models/embeddingdtype.py +7 -0
  59. mistralai/models/embeddingrequest.py +43 -3
  60. mistralai/models/fimcompletionresponse.py +6 -6
  61. mistralai/models/functioncallentry.py +76 -0
  62. mistralai/models/functioncallentryarguments.py +15 -0
  63. mistralai/models/functioncallevent.py +36 -0
  64. mistralai/models/functionresultentry.py +69 -0
  65. mistralai/models/functiontool.py +21 -0
  66. mistralai/models/imagegenerationtool.py +17 -0
  67. mistralai/models/inputentries.py +18 -0
  68. mistralai/models/messageentries.py +18 -0
  69. mistralai/models/messageinputcontentchunks.py +26 -0
  70. mistralai/models/messageinputentry.py +89 -0
  71. mistralai/models/messageoutputcontentchunks.py +30 -0
  72. mistralai/models/messageoutputentry.py +100 -0
  73. mistralai/models/messageoutputevent.py +93 -0
  74. mistralai/models/modelconversation.py +127 -0
  75. mistralai/models/outputcontentchunks.py +30 -0
  76. mistralai/models/responsedoneevent.py +25 -0
  77. mistralai/models/responseerrorevent.py +27 -0
  78. mistralai/models/responsestartedevent.py +24 -0
  79. mistralai/models/ssetypes.py +18 -0
  80. mistralai/models/toolexecutiondoneevent.py +34 -0
  81. mistralai/models/toolexecutionentry.py +70 -0
  82. mistralai/models/toolexecutionstartedevent.py +31 -0
  83. mistralai/models/toolfilechunk.py +61 -0
  84. mistralai/models/toolreferencechunk.py +61 -0
  85. mistralai/models/websearchpremiumtool.py +17 -0
  86. mistralai/models/websearchtool.py +17 -0
  87. mistralai/sdk.py +3 -0
  88. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/METADATA +42 -7
  89. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/RECORD +91 -14
  90. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/LICENSE +0 -0
  91. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1160 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from mistralai import models, utils
5
+ from mistralai._hooks import HookContext
6
+ from mistralai.types import OptionalNullable, UNSET
7
+ from mistralai.utils import get_security_from_env
8
+ from typing import Any, List, Mapping, Optional, Union
9
+
10
+
11
+ class MistralAgents(BaseSDK):
12
+ r"""(beta) Agents API"""
13
+
14
+ def create(
15
+ self,
16
+ *,
17
+ model: str,
18
+ name: str,
19
+ instructions: OptionalNullable[str] = UNSET,
20
+ tools: Optional[
21
+ Union[
22
+ List[models.AgentCreationRequestTools],
23
+ List[models.AgentCreationRequestToolsTypedDict],
24
+ ]
25
+ ] = None,
26
+ completion_args: Optional[
27
+ Union[models.CompletionArgs, models.CompletionArgsTypedDict]
28
+ ] = None,
29
+ description: OptionalNullable[str] = UNSET,
30
+ handoffs: OptionalNullable[List[str]] = UNSET,
31
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
32
+ server_url: Optional[str] = None,
33
+ timeout_ms: Optional[int] = None,
34
+ http_headers: Optional[Mapping[str, str]] = None,
35
+ ) -> models.Agent:
36
+ r"""Create a agent that can be used within a conversation.
37
+
38
+ Create a new agent giving it instructions, tools, description. The agent is then available to be used as a regular assistant in a conversation or as part of an agent pool from which it can be used.
39
+
40
+ :param model:
41
+ :param name:
42
+ :param instructions: Instruction prompt the model will follow during the conversation.
43
+ :param tools: List of tools which are available to the model during the conversation.
44
+ :param completion_args: White-listed arguments from the completion API
45
+ :param description:
46
+ :param handoffs:
47
+ :param retries: Override the default retry configuration for this method
48
+ :param server_url: Override the default server URL for this method
49
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
50
+ :param http_headers: Additional headers to set or replace on requests.
51
+ """
52
+ base_url = None
53
+ url_variables = None
54
+ if timeout_ms is None:
55
+ timeout_ms = self.sdk_configuration.timeout_ms
56
+
57
+ if server_url is not None:
58
+ base_url = server_url
59
+ else:
60
+ base_url = self._get_url(base_url, url_variables)
61
+
62
+ request = models.AgentCreationRequest(
63
+ instructions=instructions,
64
+ tools=utils.get_pydantic_model(
65
+ tools, Optional[List[models.AgentCreationRequestTools]]
66
+ ),
67
+ completion_args=utils.get_pydantic_model(
68
+ completion_args, Optional[models.CompletionArgs]
69
+ ),
70
+ model=model,
71
+ name=name,
72
+ description=description,
73
+ handoffs=handoffs,
74
+ )
75
+
76
+ req = self._build_request(
77
+ method="POST",
78
+ path="/v1/agents",
79
+ base_url=base_url,
80
+ url_variables=url_variables,
81
+ request=request,
82
+ request_body_required=True,
83
+ request_has_path_params=False,
84
+ request_has_query_params=True,
85
+ user_agent_header="user-agent",
86
+ accept_header_value="application/json",
87
+ http_headers=http_headers,
88
+ security=self.sdk_configuration.security,
89
+ get_serialized_body=lambda: utils.serialize_request_body(
90
+ request, False, False, "json", models.AgentCreationRequest
91
+ ),
92
+ timeout_ms=timeout_ms,
93
+ )
94
+
95
+ if retries == UNSET:
96
+ if self.sdk_configuration.retry_config is not UNSET:
97
+ retries = self.sdk_configuration.retry_config
98
+
99
+ retry_config = None
100
+ if isinstance(retries, utils.RetryConfig):
101
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
102
+
103
+ http_res = self.do_request(
104
+ hook_ctx=HookContext(
105
+ base_url=base_url or "",
106
+ operation_id="agents_api_v1_agents_create",
107
+ oauth2_scopes=[],
108
+ security_source=get_security_from_env(
109
+ self.sdk_configuration.security, models.Security
110
+ ),
111
+ ),
112
+ request=req,
113
+ error_status_codes=["422", "4XX", "5XX"],
114
+ retry_config=retry_config,
115
+ )
116
+
117
+ response_data: Any = None
118
+ if utils.match_response(http_res, "200", "application/json"):
119
+ return utils.unmarshal_json(http_res.text, models.Agent)
120
+ if utils.match_response(http_res, "422", "application/json"):
121
+ response_data = utils.unmarshal_json(
122
+ http_res.text, models.HTTPValidationErrorData
123
+ )
124
+ raise models.HTTPValidationError(data=response_data)
125
+ if utils.match_response(http_res, "4XX", "*"):
126
+ http_res_text = utils.stream_to_text(http_res)
127
+ raise models.SDKError(
128
+ "API error occurred", http_res.status_code, http_res_text, http_res
129
+ )
130
+ if utils.match_response(http_res, "5XX", "*"):
131
+ http_res_text = utils.stream_to_text(http_res)
132
+ raise models.SDKError(
133
+ "API error occurred", http_res.status_code, http_res_text, http_res
134
+ )
135
+
136
+ content_type = http_res.headers.get("Content-Type")
137
+ http_res_text = utils.stream_to_text(http_res)
138
+ raise models.SDKError(
139
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
140
+ http_res.status_code,
141
+ http_res_text,
142
+ http_res,
143
+ )
144
+
145
+ async def create_async(
146
+ self,
147
+ *,
148
+ model: str,
149
+ name: str,
150
+ instructions: OptionalNullable[str] = UNSET,
151
+ tools: Optional[
152
+ Union[
153
+ List[models.AgentCreationRequestTools],
154
+ List[models.AgentCreationRequestToolsTypedDict],
155
+ ]
156
+ ] = None,
157
+ completion_args: Optional[
158
+ Union[models.CompletionArgs, models.CompletionArgsTypedDict]
159
+ ] = None,
160
+ description: OptionalNullable[str] = UNSET,
161
+ handoffs: OptionalNullable[List[str]] = UNSET,
162
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
163
+ server_url: Optional[str] = None,
164
+ timeout_ms: Optional[int] = None,
165
+ http_headers: Optional[Mapping[str, str]] = None,
166
+ ) -> models.Agent:
167
+ r"""Create a agent that can be used within a conversation.
168
+
169
+ Create a new agent giving it instructions, tools, description. The agent is then available to be used as a regular assistant in a conversation or as part of an agent pool from which it can be used.
170
+
171
+ :param model:
172
+ :param name:
173
+ :param instructions: Instruction prompt the model will follow during the conversation.
174
+ :param tools: List of tools which are available to the model during the conversation.
175
+ :param completion_args: White-listed arguments from the completion API
176
+ :param description:
177
+ :param handoffs:
178
+ :param retries: Override the default retry configuration for this method
179
+ :param server_url: Override the default server URL for this method
180
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
181
+ :param http_headers: Additional headers to set or replace on requests.
182
+ """
183
+ base_url = None
184
+ url_variables = None
185
+ if timeout_ms is None:
186
+ timeout_ms = self.sdk_configuration.timeout_ms
187
+
188
+ if server_url is not None:
189
+ base_url = server_url
190
+ else:
191
+ base_url = self._get_url(base_url, url_variables)
192
+
193
+ request = models.AgentCreationRequest(
194
+ instructions=instructions,
195
+ tools=utils.get_pydantic_model(
196
+ tools, Optional[List[models.AgentCreationRequestTools]]
197
+ ),
198
+ completion_args=utils.get_pydantic_model(
199
+ completion_args, Optional[models.CompletionArgs]
200
+ ),
201
+ model=model,
202
+ name=name,
203
+ description=description,
204
+ handoffs=handoffs,
205
+ )
206
+
207
+ req = self._build_request_async(
208
+ method="POST",
209
+ path="/v1/agents",
210
+ base_url=base_url,
211
+ url_variables=url_variables,
212
+ request=request,
213
+ request_body_required=True,
214
+ request_has_path_params=False,
215
+ request_has_query_params=True,
216
+ user_agent_header="user-agent",
217
+ accept_header_value="application/json",
218
+ http_headers=http_headers,
219
+ security=self.sdk_configuration.security,
220
+ get_serialized_body=lambda: utils.serialize_request_body(
221
+ request, False, False, "json", models.AgentCreationRequest
222
+ ),
223
+ timeout_ms=timeout_ms,
224
+ )
225
+
226
+ if retries == UNSET:
227
+ if self.sdk_configuration.retry_config is not UNSET:
228
+ retries = self.sdk_configuration.retry_config
229
+
230
+ retry_config = None
231
+ if isinstance(retries, utils.RetryConfig):
232
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
233
+
234
+ http_res = await self.do_request_async(
235
+ hook_ctx=HookContext(
236
+ base_url=base_url or "",
237
+ operation_id="agents_api_v1_agents_create",
238
+ oauth2_scopes=[],
239
+ security_source=get_security_from_env(
240
+ self.sdk_configuration.security, models.Security
241
+ ),
242
+ ),
243
+ request=req,
244
+ error_status_codes=["422", "4XX", "5XX"],
245
+ retry_config=retry_config,
246
+ )
247
+
248
+ response_data: Any = None
249
+ if utils.match_response(http_res, "200", "application/json"):
250
+ return utils.unmarshal_json(http_res.text, models.Agent)
251
+ if utils.match_response(http_res, "422", "application/json"):
252
+ response_data = utils.unmarshal_json(
253
+ http_res.text, models.HTTPValidationErrorData
254
+ )
255
+ raise models.HTTPValidationError(data=response_data)
256
+ if utils.match_response(http_res, "4XX", "*"):
257
+ http_res_text = await utils.stream_to_text_async(http_res)
258
+ raise models.SDKError(
259
+ "API error occurred", http_res.status_code, http_res_text, http_res
260
+ )
261
+ if utils.match_response(http_res, "5XX", "*"):
262
+ http_res_text = await utils.stream_to_text_async(http_res)
263
+ raise models.SDKError(
264
+ "API error occurred", http_res.status_code, http_res_text, http_res
265
+ )
266
+
267
+ content_type = http_res.headers.get("Content-Type")
268
+ http_res_text = await utils.stream_to_text_async(http_res)
269
+ raise models.SDKError(
270
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
271
+ http_res.status_code,
272
+ http_res_text,
273
+ http_res,
274
+ )
275
+
276
+ def list(
277
+ self,
278
+ *,
279
+ page: Optional[int] = 0,
280
+ page_size: Optional[int] = 20,
281
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
282
+ server_url: Optional[str] = None,
283
+ timeout_ms: Optional[int] = None,
284
+ http_headers: Optional[Mapping[str, str]] = None,
285
+ ) -> List[models.Agent]:
286
+ r"""List agent entities.
287
+
288
+ Retrieve a list of agent entities sorted by creation time.
289
+
290
+ :param page:
291
+ :param page_size:
292
+ :param retries: Override the default retry configuration for this method
293
+ :param server_url: Override the default server URL for this method
294
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
295
+ :param http_headers: Additional headers to set or replace on requests.
296
+ """
297
+ base_url = None
298
+ url_variables = None
299
+ if timeout_ms is None:
300
+ timeout_ms = self.sdk_configuration.timeout_ms
301
+
302
+ if server_url is not None:
303
+ base_url = server_url
304
+ else:
305
+ base_url = self._get_url(base_url, url_variables)
306
+
307
+ request = models.AgentsAPIV1AgentsListRequest(
308
+ page=page,
309
+ page_size=page_size,
310
+ )
311
+
312
+ req = self._build_request(
313
+ method="GET",
314
+ path="/v1/agents",
315
+ base_url=base_url,
316
+ url_variables=url_variables,
317
+ request=request,
318
+ request_body_required=False,
319
+ request_has_path_params=False,
320
+ request_has_query_params=True,
321
+ user_agent_header="user-agent",
322
+ accept_header_value="application/json",
323
+ http_headers=http_headers,
324
+ security=self.sdk_configuration.security,
325
+ timeout_ms=timeout_ms,
326
+ )
327
+
328
+ if retries == UNSET:
329
+ if self.sdk_configuration.retry_config is not UNSET:
330
+ retries = self.sdk_configuration.retry_config
331
+
332
+ retry_config = None
333
+ if isinstance(retries, utils.RetryConfig):
334
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
335
+
336
+ http_res = self.do_request(
337
+ hook_ctx=HookContext(
338
+ base_url=base_url or "",
339
+ operation_id="agents_api_v1_agents_list",
340
+ oauth2_scopes=[],
341
+ security_source=get_security_from_env(
342
+ self.sdk_configuration.security, models.Security
343
+ ),
344
+ ),
345
+ request=req,
346
+ error_status_codes=["422", "4XX", "5XX"],
347
+ retry_config=retry_config,
348
+ )
349
+
350
+ response_data: Any = None
351
+ if utils.match_response(http_res, "200", "application/json"):
352
+ return utils.unmarshal_json(http_res.text, List[models.Agent])
353
+ if utils.match_response(http_res, "422", "application/json"):
354
+ response_data = utils.unmarshal_json(
355
+ http_res.text, models.HTTPValidationErrorData
356
+ )
357
+ raise models.HTTPValidationError(data=response_data)
358
+ if utils.match_response(http_res, "4XX", "*"):
359
+ http_res_text = utils.stream_to_text(http_res)
360
+ raise models.SDKError(
361
+ "API error occurred", http_res.status_code, http_res_text, http_res
362
+ )
363
+ if utils.match_response(http_res, "5XX", "*"):
364
+ http_res_text = utils.stream_to_text(http_res)
365
+ raise models.SDKError(
366
+ "API error occurred", http_res.status_code, http_res_text, http_res
367
+ )
368
+
369
+ content_type = http_res.headers.get("Content-Type")
370
+ http_res_text = utils.stream_to_text(http_res)
371
+ raise models.SDKError(
372
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
373
+ http_res.status_code,
374
+ http_res_text,
375
+ http_res,
376
+ )
377
+
378
+ async def list_async(
379
+ self,
380
+ *,
381
+ page: Optional[int] = 0,
382
+ page_size: Optional[int] = 20,
383
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
384
+ server_url: Optional[str] = None,
385
+ timeout_ms: Optional[int] = None,
386
+ http_headers: Optional[Mapping[str, str]] = None,
387
+ ) -> List[models.Agent]:
388
+ r"""List agent entities.
389
+
390
+ Retrieve a list of agent entities sorted by creation time.
391
+
392
+ :param page:
393
+ :param page_size:
394
+ :param retries: Override the default retry configuration for this method
395
+ :param server_url: Override the default server URL for this method
396
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
397
+ :param http_headers: Additional headers to set or replace on requests.
398
+ """
399
+ base_url = None
400
+ url_variables = None
401
+ if timeout_ms is None:
402
+ timeout_ms = self.sdk_configuration.timeout_ms
403
+
404
+ if server_url is not None:
405
+ base_url = server_url
406
+ else:
407
+ base_url = self._get_url(base_url, url_variables)
408
+
409
+ request = models.AgentsAPIV1AgentsListRequest(
410
+ page=page,
411
+ page_size=page_size,
412
+ )
413
+
414
+ req = self._build_request_async(
415
+ method="GET",
416
+ path="/v1/agents",
417
+ base_url=base_url,
418
+ url_variables=url_variables,
419
+ request=request,
420
+ request_body_required=False,
421
+ request_has_path_params=False,
422
+ request_has_query_params=True,
423
+ user_agent_header="user-agent",
424
+ accept_header_value="application/json",
425
+ http_headers=http_headers,
426
+ security=self.sdk_configuration.security,
427
+ timeout_ms=timeout_ms,
428
+ )
429
+
430
+ if retries == UNSET:
431
+ if self.sdk_configuration.retry_config is not UNSET:
432
+ retries = self.sdk_configuration.retry_config
433
+
434
+ retry_config = None
435
+ if isinstance(retries, utils.RetryConfig):
436
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
437
+
438
+ http_res = await self.do_request_async(
439
+ hook_ctx=HookContext(
440
+ base_url=base_url or "",
441
+ operation_id="agents_api_v1_agents_list",
442
+ oauth2_scopes=[],
443
+ security_source=get_security_from_env(
444
+ self.sdk_configuration.security, models.Security
445
+ ),
446
+ ),
447
+ request=req,
448
+ error_status_codes=["422", "4XX", "5XX"],
449
+ retry_config=retry_config,
450
+ )
451
+
452
+ response_data: Any = None
453
+ if utils.match_response(http_res, "200", "application/json"):
454
+ return utils.unmarshal_json(http_res.text, List[models.Agent])
455
+ if utils.match_response(http_res, "422", "application/json"):
456
+ response_data = utils.unmarshal_json(
457
+ http_res.text, models.HTTPValidationErrorData
458
+ )
459
+ raise models.HTTPValidationError(data=response_data)
460
+ if utils.match_response(http_res, "4XX", "*"):
461
+ http_res_text = await utils.stream_to_text_async(http_res)
462
+ raise models.SDKError(
463
+ "API error occurred", http_res.status_code, http_res_text, http_res
464
+ )
465
+ if utils.match_response(http_res, "5XX", "*"):
466
+ http_res_text = await utils.stream_to_text_async(http_res)
467
+ raise models.SDKError(
468
+ "API error occurred", http_res.status_code, http_res_text, http_res
469
+ )
470
+
471
+ content_type = http_res.headers.get("Content-Type")
472
+ http_res_text = await utils.stream_to_text_async(http_res)
473
+ raise models.SDKError(
474
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
475
+ http_res.status_code,
476
+ http_res_text,
477
+ http_res,
478
+ )
479
+
480
+ def get(
481
+ self,
482
+ *,
483
+ agent_id: str,
484
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
485
+ server_url: Optional[str] = None,
486
+ timeout_ms: Optional[int] = None,
487
+ http_headers: Optional[Mapping[str, str]] = None,
488
+ ) -> models.Agent:
489
+ r"""Retrieve an agent entity.
490
+
491
+ Given an agent retrieve an agent entity with its attributes.
492
+
493
+ :param agent_id:
494
+ :param retries: Override the default retry configuration for this method
495
+ :param server_url: Override the default server URL for this method
496
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
497
+ :param http_headers: Additional headers to set or replace on requests.
498
+ """
499
+ base_url = None
500
+ url_variables = None
501
+ if timeout_ms is None:
502
+ timeout_ms = self.sdk_configuration.timeout_ms
503
+
504
+ if server_url is not None:
505
+ base_url = server_url
506
+ else:
507
+ base_url = self._get_url(base_url, url_variables)
508
+
509
+ request = models.AgentsAPIV1AgentsGetRequest(
510
+ agent_id=agent_id,
511
+ )
512
+
513
+ req = self._build_request(
514
+ method="GET",
515
+ path="/v1/agents/{agent_id}",
516
+ base_url=base_url,
517
+ url_variables=url_variables,
518
+ request=request,
519
+ request_body_required=False,
520
+ request_has_path_params=True,
521
+ request_has_query_params=True,
522
+ user_agent_header="user-agent",
523
+ accept_header_value="application/json",
524
+ http_headers=http_headers,
525
+ security=self.sdk_configuration.security,
526
+ timeout_ms=timeout_ms,
527
+ )
528
+
529
+ if retries == UNSET:
530
+ if self.sdk_configuration.retry_config is not UNSET:
531
+ retries = self.sdk_configuration.retry_config
532
+
533
+ retry_config = None
534
+ if isinstance(retries, utils.RetryConfig):
535
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
536
+
537
+ http_res = self.do_request(
538
+ hook_ctx=HookContext(
539
+ base_url=base_url or "",
540
+ operation_id="agents_api_v1_agents_get",
541
+ oauth2_scopes=[],
542
+ security_source=get_security_from_env(
543
+ self.sdk_configuration.security, models.Security
544
+ ),
545
+ ),
546
+ request=req,
547
+ error_status_codes=["422", "4XX", "5XX"],
548
+ retry_config=retry_config,
549
+ )
550
+
551
+ response_data: Any = None
552
+ if utils.match_response(http_res, "200", "application/json"):
553
+ return utils.unmarshal_json(http_res.text, models.Agent)
554
+ if utils.match_response(http_res, "422", "application/json"):
555
+ response_data = utils.unmarshal_json(
556
+ http_res.text, models.HTTPValidationErrorData
557
+ )
558
+ raise models.HTTPValidationError(data=response_data)
559
+ if utils.match_response(http_res, "4XX", "*"):
560
+ http_res_text = utils.stream_to_text(http_res)
561
+ raise models.SDKError(
562
+ "API error occurred", http_res.status_code, http_res_text, http_res
563
+ )
564
+ if utils.match_response(http_res, "5XX", "*"):
565
+ http_res_text = utils.stream_to_text(http_res)
566
+ raise models.SDKError(
567
+ "API error occurred", http_res.status_code, http_res_text, http_res
568
+ )
569
+
570
+ content_type = http_res.headers.get("Content-Type")
571
+ http_res_text = utils.stream_to_text(http_res)
572
+ raise models.SDKError(
573
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
574
+ http_res.status_code,
575
+ http_res_text,
576
+ http_res,
577
+ )
578
+
579
+ async def get_async(
580
+ self,
581
+ *,
582
+ agent_id: str,
583
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
584
+ server_url: Optional[str] = None,
585
+ timeout_ms: Optional[int] = None,
586
+ http_headers: Optional[Mapping[str, str]] = None,
587
+ ) -> models.Agent:
588
+ r"""Retrieve an agent entity.
589
+
590
+ Given an agent retrieve an agent entity with its attributes.
591
+
592
+ :param agent_id:
593
+ :param retries: Override the default retry configuration for this method
594
+ :param server_url: Override the default server URL for this method
595
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
596
+ :param http_headers: Additional headers to set or replace on requests.
597
+ """
598
+ base_url = None
599
+ url_variables = None
600
+ if timeout_ms is None:
601
+ timeout_ms = self.sdk_configuration.timeout_ms
602
+
603
+ if server_url is not None:
604
+ base_url = server_url
605
+ else:
606
+ base_url = self._get_url(base_url, url_variables)
607
+
608
+ request = models.AgentsAPIV1AgentsGetRequest(
609
+ agent_id=agent_id,
610
+ )
611
+
612
+ req = self._build_request_async(
613
+ method="GET",
614
+ path="/v1/agents/{agent_id}",
615
+ base_url=base_url,
616
+ url_variables=url_variables,
617
+ request=request,
618
+ request_body_required=False,
619
+ request_has_path_params=True,
620
+ request_has_query_params=True,
621
+ user_agent_header="user-agent",
622
+ accept_header_value="application/json",
623
+ http_headers=http_headers,
624
+ security=self.sdk_configuration.security,
625
+ timeout_ms=timeout_ms,
626
+ )
627
+
628
+ if retries == UNSET:
629
+ if self.sdk_configuration.retry_config is not UNSET:
630
+ retries = self.sdk_configuration.retry_config
631
+
632
+ retry_config = None
633
+ if isinstance(retries, utils.RetryConfig):
634
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
635
+
636
+ http_res = await self.do_request_async(
637
+ hook_ctx=HookContext(
638
+ base_url=base_url or "",
639
+ operation_id="agents_api_v1_agents_get",
640
+ oauth2_scopes=[],
641
+ security_source=get_security_from_env(
642
+ self.sdk_configuration.security, models.Security
643
+ ),
644
+ ),
645
+ request=req,
646
+ error_status_codes=["422", "4XX", "5XX"],
647
+ retry_config=retry_config,
648
+ )
649
+
650
+ response_data: Any = None
651
+ if utils.match_response(http_res, "200", "application/json"):
652
+ return utils.unmarshal_json(http_res.text, models.Agent)
653
+ if utils.match_response(http_res, "422", "application/json"):
654
+ response_data = utils.unmarshal_json(
655
+ http_res.text, models.HTTPValidationErrorData
656
+ )
657
+ raise models.HTTPValidationError(data=response_data)
658
+ if utils.match_response(http_res, "4XX", "*"):
659
+ http_res_text = await utils.stream_to_text_async(http_res)
660
+ raise models.SDKError(
661
+ "API error occurred", http_res.status_code, http_res_text, http_res
662
+ )
663
+ if utils.match_response(http_res, "5XX", "*"):
664
+ http_res_text = await utils.stream_to_text_async(http_res)
665
+ raise models.SDKError(
666
+ "API error occurred", http_res.status_code, http_res_text, http_res
667
+ )
668
+
669
+ content_type = http_res.headers.get("Content-Type")
670
+ http_res_text = await utils.stream_to_text_async(http_res)
671
+ raise models.SDKError(
672
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
673
+ http_res.status_code,
674
+ http_res_text,
675
+ http_res,
676
+ )
677
+
678
+ def update(
679
+ self,
680
+ *,
681
+ agent_id: str,
682
+ instructions: OptionalNullable[str] = UNSET,
683
+ tools: Optional[
684
+ Union[
685
+ List[models.AgentUpdateRequestTools],
686
+ List[models.AgentUpdateRequestToolsTypedDict],
687
+ ]
688
+ ] = None,
689
+ completion_args: Optional[
690
+ Union[models.CompletionArgs, models.CompletionArgsTypedDict]
691
+ ] = None,
692
+ model: OptionalNullable[str] = UNSET,
693
+ name: OptionalNullable[str] = UNSET,
694
+ description: OptionalNullable[str] = UNSET,
695
+ handoffs: OptionalNullable[List[str]] = UNSET,
696
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
697
+ server_url: Optional[str] = None,
698
+ timeout_ms: Optional[int] = None,
699
+ http_headers: Optional[Mapping[str, str]] = None,
700
+ ) -> models.Agent:
701
+ r"""Update an agent entity.
702
+
703
+ Update an agent attributes and create a new version.
704
+
705
+ :param agent_id:
706
+ :param instructions: Instruction prompt the model will follow during the conversation.
707
+ :param tools: List of tools which are available to the model during the conversation.
708
+ :param completion_args: White-listed arguments from the completion API
709
+ :param model:
710
+ :param name:
711
+ :param description:
712
+ :param handoffs:
713
+ :param retries: Override the default retry configuration for this method
714
+ :param server_url: Override the default server URL for this method
715
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
716
+ :param http_headers: Additional headers to set or replace on requests.
717
+ """
718
+ base_url = None
719
+ url_variables = None
720
+ if timeout_ms is None:
721
+ timeout_ms = self.sdk_configuration.timeout_ms
722
+
723
+ if server_url is not None:
724
+ base_url = server_url
725
+ else:
726
+ base_url = self._get_url(base_url, url_variables)
727
+
728
+ request = models.AgentsAPIV1AgentsUpdateRequest(
729
+ agent_id=agent_id,
730
+ agent_update_request=models.AgentUpdateRequest(
731
+ instructions=instructions,
732
+ tools=utils.get_pydantic_model(
733
+ tools, Optional[List[models.AgentUpdateRequestTools]]
734
+ ),
735
+ completion_args=utils.get_pydantic_model(
736
+ completion_args, Optional[models.CompletionArgs]
737
+ ),
738
+ model=model,
739
+ name=name,
740
+ description=description,
741
+ handoffs=handoffs,
742
+ ),
743
+ )
744
+
745
+ req = self._build_request(
746
+ method="PATCH",
747
+ path="/v1/agents/{agent_id}",
748
+ base_url=base_url,
749
+ url_variables=url_variables,
750
+ request=request,
751
+ request_body_required=True,
752
+ request_has_path_params=True,
753
+ request_has_query_params=True,
754
+ user_agent_header="user-agent",
755
+ accept_header_value="application/json",
756
+ http_headers=http_headers,
757
+ security=self.sdk_configuration.security,
758
+ get_serialized_body=lambda: utils.serialize_request_body(
759
+ request.agent_update_request,
760
+ False,
761
+ False,
762
+ "json",
763
+ models.AgentUpdateRequest,
764
+ ),
765
+ timeout_ms=timeout_ms,
766
+ )
767
+
768
+ if retries == UNSET:
769
+ if self.sdk_configuration.retry_config is not UNSET:
770
+ retries = self.sdk_configuration.retry_config
771
+
772
+ retry_config = None
773
+ if isinstance(retries, utils.RetryConfig):
774
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
775
+
776
+ http_res = self.do_request(
777
+ hook_ctx=HookContext(
778
+ base_url=base_url or "",
779
+ operation_id="agents_api_v1_agents_update",
780
+ oauth2_scopes=[],
781
+ security_source=get_security_from_env(
782
+ self.sdk_configuration.security, models.Security
783
+ ),
784
+ ),
785
+ request=req,
786
+ error_status_codes=["422", "4XX", "5XX"],
787
+ retry_config=retry_config,
788
+ )
789
+
790
+ response_data: Any = None
791
+ if utils.match_response(http_res, "200", "application/json"):
792
+ return utils.unmarshal_json(http_res.text, models.Agent)
793
+ if utils.match_response(http_res, "422", "application/json"):
794
+ response_data = utils.unmarshal_json(
795
+ http_res.text, models.HTTPValidationErrorData
796
+ )
797
+ raise models.HTTPValidationError(data=response_data)
798
+ if utils.match_response(http_res, "4XX", "*"):
799
+ http_res_text = utils.stream_to_text(http_res)
800
+ raise models.SDKError(
801
+ "API error occurred", http_res.status_code, http_res_text, http_res
802
+ )
803
+ if utils.match_response(http_res, "5XX", "*"):
804
+ http_res_text = utils.stream_to_text(http_res)
805
+ raise models.SDKError(
806
+ "API error occurred", http_res.status_code, http_res_text, http_res
807
+ )
808
+
809
+ content_type = http_res.headers.get("Content-Type")
810
+ http_res_text = utils.stream_to_text(http_res)
811
+ raise models.SDKError(
812
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
813
+ http_res.status_code,
814
+ http_res_text,
815
+ http_res,
816
+ )
817
+
818
+ async def update_async(
819
+ self,
820
+ *,
821
+ agent_id: str,
822
+ instructions: OptionalNullable[str] = UNSET,
823
+ tools: Optional[
824
+ Union[
825
+ List[models.AgentUpdateRequestTools],
826
+ List[models.AgentUpdateRequestToolsTypedDict],
827
+ ]
828
+ ] = None,
829
+ completion_args: Optional[
830
+ Union[models.CompletionArgs, models.CompletionArgsTypedDict]
831
+ ] = None,
832
+ model: OptionalNullable[str] = UNSET,
833
+ name: OptionalNullable[str] = UNSET,
834
+ description: OptionalNullable[str] = UNSET,
835
+ handoffs: OptionalNullable[List[str]] = UNSET,
836
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
837
+ server_url: Optional[str] = None,
838
+ timeout_ms: Optional[int] = None,
839
+ http_headers: Optional[Mapping[str, str]] = None,
840
+ ) -> models.Agent:
841
+ r"""Update an agent entity.
842
+
843
+ Update an agent attributes and create a new version.
844
+
845
+ :param agent_id:
846
+ :param instructions: Instruction prompt the model will follow during the conversation.
847
+ :param tools: List of tools which are available to the model during the conversation.
848
+ :param completion_args: White-listed arguments from the completion API
849
+ :param model:
850
+ :param name:
851
+ :param description:
852
+ :param handoffs:
853
+ :param retries: Override the default retry configuration for this method
854
+ :param server_url: Override the default server URL for this method
855
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
856
+ :param http_headers: Additional headers to set or replace on requests.
857
+ """
858
+ base_url = None
859
+ url_variables = None
860
+ if timeout_ms is None:
861
+ timeout_ms = self.sdk_configuration.timeout_ms
862
+
863
+ if server_url is not None:
864
+ base_url = server_url
865
+ else:
866
+ base_url = self._get_url(base_url, url_variables)
867
+
868
+ request = models.AgentsAPIV1AgentsUpdateRequest(
869
+ agent_id=agent_id,
870
+ agent_update_request=models.AgentUpdateRequest(
871
+ instructions=instructions,
872
+ tools=utils.get_pydantic_model(
873
+ tools, Optional[List[models.AgentUpdateRequestTools]]
874
+ ),
875
+ completion_args=utils.get_pydantic_model(
876
+ completion_args, Optional[models.CompletionArgs]
877
+ ),
878
+ model=model,
879
+ name=name,
880
+ description=description,
881
+ handoffs=handoffs,
882
+ ),
883
+ )
884
+
885
+ req = self._build_request_async(
886
+ method="PATCH",
887
+ path="/v1/agents/{agent_id}",
888
+ base_url=base_url,
889
+ url_variables=url_variables,
890
+ request=request,
891
+ request_body_required=True,
892
+ request_has_path_params=True,
893
+ request_has_query_params=True,
894
+ user_agent_header="user-agent",
895
+ accept_header_value="application/json",
896
+ http_headers=http_headers,
897
+ security=self.sdk_configuration.security,
898
+ get_serialized_body=lambda: utils.serialize_request_body(
899
+ request.agent_update_request,
900
+ False,
901
+ False,
902
+ "json",
903
+ models.AgentUpdateRequest,
904
+ ),
905
+ timeout_ms=timeout_ms,
906
+ )
907
+
908
+ if retries == UNSET:
909
+ if self.sdk_configuration.retry_config is not UNSET:
910
+ retries = self.sdk_configuration.retry_config
911
+
912
+ retry_config = None
913
+ if isinstance(retries, utils.RetryConfig):
914
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
915
+
916
+ http_res = await self.do_request_async(
917
+ hook_ctx=HookContext(
918
+ base_url=base_url or "",
919
+ operation_id="agents_api_v1_agents_update",
920
+ oauth2_scopes=[],
921
+ security_source=get_security_from_env(
922
+ self.sdk_configuration.security, models.Security
923
+ ),
924
+ ),
925
+ request=req,
926
+ error_status_codes=["422", "4XX", "5XX"],
927
+ retry_config=retry_config,
928
+ )
929
+
930
+ response_data: Any = None
931
+ if utils.match_response(http_res, "200", "application/json"):
932
+ return utils.unmarshal_json(http_res.text, models.Agent)
933
+ if utils.match_response(http_res, "422", "application/json"):
934
+ response_data = utils.unmarshal_json(
935
+ http_res.text, models.HTTPValidationErrorData
936
+ )
937
+ raise models.HTTPValidationError(data=response_data)
938
+ if utils.match_response(http_res, "4XX", "*"):
939
+ http_res_text = await utils.stream_to_text_async(http_res)
940
+ raise models.SDKError(
941
+ "API error occurred", http_res.status_code, http_res_text, http_res
942
+ )
943
+ if utils.match_response(http_res, "5XX", "*"):
944
+ http_res_text = await utils.stream_to_text_async(http_res)
945
+ raise models.SDKError(
946
+ "API error occurred", http_res.status_code, http_res_text, http_res
947
+ )
948
+
949
+ content_type = http_res.headers.get("Content-Type")
950
+ http_res_text = await utils.stream_to_text_async(http_res)
951
+ raise models.SDKError(
952
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
953
+ http_res.status_code,
954
+ http_res_text,
955
+ http_res,
956
+ )
957
+
958
+ def update_version(
959
+ self,
960
+ *,
961
+ agent_id: str,
962
+ version: int,
963
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
964
+ server_url: Optional[str] = None,
965
+ timeout_ms: Optional[int] = None,
966
+ http_headers: Optional[Mapping[str, str]] = None,
967
+ ) -> models.Agent:
968
+ r"""Update an agent version.
969
+
970
+ Switch the version of an agent.
971
+
972
+ :param agent_id:
973
+ :param version:
974
+ :param retries: Override the default retry configuration for this method
975
+ :param server_url: Override the default server URL for this method
976
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
977
+ :param http_headers: Additional headers to set or replace on requests.
978
+ """
979
+ base_url = None
980
+ url_variables = None
981
+ if timeout_ms is None:
982
+ timeout_ms = self.sdk_configuration.timeout_ms
983
+
984
+ if server_url is not None:
985
+ base_url = server_url
986
+ else:
987
+ base_url = self._get_url(base_url, url_variables)
988
+
989
+ request = models.AgentsAPIV1AgentsUpdateVersionRequest(
990
+ agent_id=agent_id,
991
+ version=version,
992
+ )
993
+
994
+ req = self._build_request(
995
+ method="PATCH",
996
+ path="/v1/agents/{agent_id}/version",
997
+ base_url=base_url,
998
+ url_variables=url_variables,
999
+ request=request,
1000
+ request_body_required=False,
1001
+ request_has_path_params=True,
1002
+ request_has_query_params=True,
1003
+ user_agent_header="user-agent",
1004
+ accept_header_value="application/json",
1005
+ http_headers=http_headers,
1006
+ security=self.sdk_configuration.security,
1007
+ timeout_ms=timeout_ms,
1008
+ )
1009
+
1010
+ if retries == UNSET:
1011
+ if self.sdk_configuration.retry_config is not UNSET:
1012
+ retries = self.sdk_configuration.retry_config
1013
+
1014
+ retry_config = None
1015
+ if isinstance(retries, utils.RetryConfig):
1016
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1017
+
1018
+ http_res = self.do_request(
1019
+ hook_ctx=HookContext(
1020
+ base_url=base_url or "",
1021
+ operation_id="agents_api_v1_agents_update_version",
1022
+ oauth2_scopes=[],
1023
+ security_source=get_security_from_env(
1024
+ self.sdk_configuration.security, models.Security
1025
+ ),
1026
+ ),
1027
+ request=req,
1028
+ error_status_codes=["422", "4XX", "5XX"],
1029
+ retry_config=retry_config,
1030
+ )
1031
+
1032
+ response_data: Any = None
1033
+ if utils.match_response(http_res, "200", "application/json"):
1034
+ return utils.unmarshal_json(http_res.text, models.Agent)
1035
+ if utils.match_response(http_res, "422", "application/json"):
1036
+ response_data = utils.unmarshal_json(
1037
+ http_res.text, models.HTTPValidationErrorData
1038
+ )
1039
+ raise models.HTTPValidationError(data=response_data)
1040
+ if utils.match_response(http_res, "4XX", "*"):
1041
+ http_res_text = utils.stream_to_text(http_res)
1042
+ raise models.SDKError(
1043
+ "API error occurred", http_res.status_code, http_res_text, http_res
1044
+ )
1045
+ if utils.match_response(http_res, "5XX", "*"):
1046
+ http_res_text = utils.stream_to_text(http_res)
1047
+ raise models.SDKError(
1048
+ "API error occurred", http_res.status_code, http_res_text, http_res
1049
+ )
1050
+
1051
+ content_type = http_res.headers.get("Content-Type")
1052
+ http_res_text = utils.stream_to_text(http_res)
1053
+ raise models.SDKError(
1054
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1055
+ http_res.status_code,
1056
+ http_res_text,
1057
+ http_res,
1058
+ )
1059
+
1060
+ async def update_version_async(
1061
+ self,
1062
+ *,
1063
+ agent_id: str,
1064
+ version: int,
1065
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1066
+ server_url: Optional[str] = None,
1067
+ timeout_ms: Optional[int] = None,
1068
+ http_headers: Optional[Mapping[str, str]] = None,
1069
+ ) -> models.Agent:
1070
+ r"""Update an agent version.
1071
+
1072
+ Switch the version of an agent.
1073
+
1074
+ :param agent_id:
1075
+ :param version:
1076
+ :param retries: Override the default retry configuration for this method
1077
+ :param server_url: Override the default server URL for this method
1078
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1079
+ :param http_headers: Additional headers to set or replace on requests.
1080
+ """
1081
+ base_url = None
1082
+ url_variables = None
1083
+ if timeout_ms is None:
1084
+ timeout_ms = self.sdk_configuration.timeout_ms
1085
+
1086
+ if server_url is not None:
1087
+ base_url = server_url
1088
+ else:
1089
+ base_url = self._get_url(base_url, url_variables)
1090
+
1091
+ request = models.AgentsAPIV1AgentsUpdateVersionRequest(
1092
+ agent_id=agent_id,
1093
+ version=version,
1094
+ )
1095
+
1096
+ req = self._build_request_async(
1097
+ method="PATCH",
1098
+ path="/v1/agents/{agent_id}/version",
1099
+ base_url=base_url,
1100
+ url_variables=url_variables,
1101
+ request=request,
1102
+ request_body_required=False,
1103
+ request_has_path_params=True,
1104
+ request_has_query_params=True,
1105
+ user_agent_header="user-agent",
1106
+ accept_header_value="application/json",
1107
+ http_headers=http_headers,
1108
+ security=self.sdk_configuration.security,
1109
+ timeout_ms=timeout_ms,
1110
+ )
1111
+
1112
+ if retries == UNSET:
1113
+ if self.sdk_configuration.retry_config is not UNSET:
1114
+ retries = self.sdk_configuration.retry_config
1115
+
1116
+ retry_config = None
1117
+ if isinstance(retries, utils.RetryConfig):
1118
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1119
+
1120
+ http_res = await self.do_request_async(
1121
+ hook_ctx=HookContext(
1122
+ base_url=base_url or "",
1123
+ operation_id="agents_api_v1_agents_update_version",
1124
+ oauth2_scopes=[],
1125
+ security_source=get_security_from_env(
1126
+ self.sdk_configuration.security, models.Security
1127
+ ),
1128
+ ),
1129
+ request=req,
1130
+ error_status_codes=["422", "4XX", "5XX"],
1131
+ retry_config=retry_config,
1132
+ )
1133
+
1134
+ response_data: Any = None
1135
+ if utils.match_response(http_res, "200", "application/json"):
1136
+ return utils.unmarshal_json(http_res.text, models.Agent)
1137
+ if utils.match_response(http_res, "422", "application/json"):
1138
+ response_data = utils.unmarshal_json(
1139
+ http_res.text, models.HTTPValidationErrorData
1140
+ )
1141
+ raise models.HTTPValidationError(data=response_data)
1142
+ if utils.match_response(http_res, "4XX", "*"):
1143
+ http_res_text = await utils.stream_to_text_async(http_res)
1144
+ raise models.SDKError(
1145
+ "API error occurred", http_res.status_code, http_res_text, http_res
1146
+ )
1147
+ if utils.match_response(http_res, "5XX", "*"):
1148
+ http_res_text = await utils.stream_to_text_async(http_res)
1149
+ raise models.SDKError(
1150
+ "API error occurred", http_res.status_code, http_res_text, http_res
1151
+ )
1152
+
1153
+ content_type = http_res.headers.get("Content-Type")
1154
+ http_res_text = await utils.stream_to_text_async(http_res)
1155
+ raise models.SDKError(
1156
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1157
+ http_res.status_code,
1158
+ http_res_text,
1159
+ http_res,
1160
+ )