mistralai 1.9.10__py3-none-any.whl → 1.10.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 (86) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -0
  3. mistralai/_version.py +3 -3
  4. mistralai/accesses.py +51 -116
  5. mistralai/agents.py +58 -85
  6. mistralai/audio.py +8 -3
  7. mistralai/basesdk.py +15 -5
  8. mistralai/batch.py +6 -3
  9. mistralai/beta.py +10 -5
  10. mistralai/chat.py +70 -97
  11. mistralai/classifiers.py +57 -144
  12. mistralai/conversations.py +435 -412
  13. mistralai/documents.py +156 -359
  14. mistralai/embeddings.py +21 -42
  15. mistralai/extra/observability/__init__.py +15 -0
  16. mistralai/extra/observability/otel.py +393 -0
  17. mistralai/extra/run/tools.py +28 -16
  18. mistralai/files.py +53 -176
  19. mistralai/fim.py +46 -73
  20. mistralai/fine_tuning.py +6 -3
  21. mistralai/jobs.py +49 -158
  22. mistralai/libraries.py +71 -178
  23. mistralai/mistral_agents.py +298 -179
  24. mistralai/mistral_jobs.py +51 -138
  25. mistralai/models/__init__.py +94 -5
  26. mistralai/models/agent.py +15 -2
  27. mistralai/models/agentconversation.py +11 -3
  28. mistralai/models/agentcreationrequest.py +6 -2
  29. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  30. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  31. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  32. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  33. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  34. mistralai/models/agentscompletionrequest.py +21 -6
  35. mistralai/models/agentscompletionstreamrequest.py +21 -6
  36. mistralai/models/agentupdaterequest.py +18 -2
  37. mistralai/models/audiotranscriptionrequest.py +2 -0
  38. mistralai/models/batchjobin.py +10 -0
  39. mistralai/models/chatcompletionrequest.py +22 -5
  40. mistralai/models/chatcompletionstreamrequest.py +22 -5
  41. mistralai/models/conversationrequest.py +15 -4
  42. mistralai/models/conversationrestartrequest.py +50 -2
  43. mistralai/models/conversationrestartstreamrequest.py +50 -2
  44. mistralai/models/conversationstreamrequest.py +15 -4
  45. mistralai/models/documentout.py +26 -10
  46. mistralai/models/documentupdatein.py +24 -3
  47. mistralai/models/embeddingrequest.py +8 -8
  48. mistralai/models/files_api_routes_list_filesop.py +7 -0
  49. mistralai/models/fimcompletionrequest.py +8 -9
  50. mistralai/models/fimcompletionstreamrequest.py +8 -9
  51. mistralai/models/httpvalidationerror.py +11 -6
  52. mistralai/models/libraries_documents_list_v1op.py +15 -2
  53. mistralai/models/libraryout.py +10 -7
  54. mistralai/models/listfilesout.py +35 -4
  55. mistralai/models/mistralerror.py +26 -0
  56. mistralai/models/modelcapabilities.py +13 -4
  57. mistralai/models/modelconversation.py +8 -2
  58. mistralai/models/no_response_error.py +13 -0
  59. mistralai/models/ocrpageobject.py +26 -5
  60. mistralai/models/ocrrequest.py +17 -1
  61. mistralai/models/ocrtableobject.py +31 -0
  62. mistralai/models/prediction.py +4 -0
  63. mistralai/models/requestsource.py +7 -0
  64. mistralai/models/responseformat.py +4 -2
  65. mistralai/models/responseformats.py +0 -1
  66. mistralai/models/responsevalidationerror.py +25 -0
  67. mistralai/models/sdkerror.py +30 -14
  68. mistralai/models/sharingdelete.py +36 -5
  69. mistralai/models/sharingin.py +36 -5
  70. mistralai/models/sharingout.py +3 -3
  71. mistralai/models/toolexecutiondeltaevent.py +13 -4
  72. mistralai/models/toolexecutiondoneevent.py +13 -4
  73. mistralai/models/toolexecutionentry.py +9 -4
  74. mistralai/models/toolexecutionstartedevent.py +13 -4
  75. mistralai/models_.py +67 -212
  76. mistralai/ocr.py +33 -36
  77. mistralai/sdk.py +15 -2
  78. mistralai/transcriptions.py +21 -60
  79. mistralai/utils/__init__.py +18 -5
  80. mistralai/utils/eventstreaming.py +10 -0
  81. mistralai/utils/serializers.py +3 -2
  82. mistralai/utils/unmarshal_json_response.py +24 -0
  83. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/METADATA +89 -40
  84. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/RECORD +86 -75
  85. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/WHEEL +1 -1
  86. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info/licenses}/LICENSE +0 -0
@@ -5,7 +5,8 @@ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
- from typing import Any, List, Mapping, Optional, Union
8
+ from mistralai.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import Any, Dict, List, Mapping, Optional, Union
9
10
 
10
11
  # region imports
11
12
  import typing
@@ -25,8 +26,10 @@ from mistralai.extra.run.result import (
25
26
  reconstitue_entries,
26
27
  )
27
28
  from mistralai.extra.run.utils import run_requirements
29
+ from mistralai.extra.observability.otel import GenAISpanEnum, get_or_create_otel_tracer
28
30
 
29
31
  logger = logging.getLogger(__name__)
32
+ tracing_enabled, tracer = get_or_create_otel_tracer()
30
33
 
31
34
  if typing.TYPE_CHECKING:
32
35
  from mistralai.extra.run.context import RunContext
@@ -66,50 +69,52 @@ class Conversations(BaseSDK):
66
69
  from mistralai.extra.run.context import _validate_run
67
70
  from mistralai.extra.run.tools import get_function_calls
68
71
 
69
- req, run_result, input_entries = await _validate_run(
70
- beta_client=Beta(self.sdk_configuration),
71
- run_ctx=run_ctx,
72
- inputs=inputs,
73
- instructions=instructions,
74
- tools=tools,
75
- completion_args=completion_args,
76
- )
72
+ with tracer.start_as_current_span(GenAISpanEnum.VALIDATE_RUN.value):
73
+ req, run_result, input_entries = await _validate_run(
74
+ beta_client=Beta(self.sdk_configuration),
75
+ run_ctx=run_ctx,
76
+ inputs=inputs,
77
+ instructions=instructions,
78
+ tools=tools,
79
+ completion_args=completion_args,
80
+ )
77
81
 
78
- while True:
79
- if run_ctx.conversation_id is None:
80
- res = await self.start_async(
81
- inputs=input_entries,
82
- http_headers=http_headers,
83
- name=name,
84
- description=description,
85
- retries=retries,
86
- server_url=server_url,
87
- timeout_ms=timeout_ms,
88
- **req, # type: ignore
89
- )
90
- run_result.conversation_id = res.conversation_id
91
- run_ctx.conversation_id = res.conversation_id
92
- logger.info(
93
- f"Started Run with conversation with id {res.conversation_id}"
94
- )
95
- else:
96
- res = await self.append_async(
97
- conversation_id=run_ctx.conversation_id,
98
- inputs=input_entries,
99
- retries=retries,
100
- server_url=server_url,
101
- timeout_ms=timeout_ms,
102
- )
103
- run_ctx.request_count += 1
104
- run_result.output_entries.extend(res.outputs)
105
- fcalls = get_function_calls(res.outputs)
106
- if not fcalls:
107
- logger.debug("No more function calls to execute")
108
- break
109
- else:
110
- fresults = await run_ctx.execute_function_calls(fcalls)
111
- run_result.output_entries.extend(fresults)
112
- input_entries = typing.cast(list[InputEntries], fresults)
82
+ with tracer.start_as_current_span(GenAISpanEnum.CONVERSATION.value):
83
+ while True:
84
+ if run_ctx.conversation_id is None:
85
+ res = await self.start_async(
86
+ inputs=input_entries,
87
+ http_headers=http_headers,
88
+ name=name,
89
+ description=description,
90
+ retries=retries,
91
+ server_url=server_url,
92
+ timeout_ms=timeout_ms,
93
+ **req, # type: ignore
94
+ )
95
+ run_result.conversation_id = res.conversation_id
96
+ run_ctx.conversation_id = res.conversation_id
97
+ logger.info(
98
+ f"Started Run with conversation with id {res.conversation_id}"
99
+ )
100
+ else:
101
+ res = await self.append_async(
102
+ conversation_id=run_ctx.conversation_id,
103
+ inputs=input_entries,
104
+ retries=retries,
105
+ server_url=server_url,
106
+ timeout_ms=timeout_ms,
107
+ )
108
+ run_ctx.request_count += 1
109
+ run_result.output_entries.extend(res.outputs)
110
+ fcalls = get_function_calls(res.outputs)
111
+ if not fcalls:
112
+ logger.debug("No more function calls to execute")
113
+ break
114
+ else:
115
+ fresults = await run_ctx.execute_function_calls(fcalls)
116
+ run_result.output_entries.extend(fresults)
117
+ input_entries = typing.cast(list[InputEntries], fresults)
113
118
  return run_result
114
119
 
115
120
  @run_requirements
@@ -223,15 +228,15 @@ class Conversations(BaseSDK):
223
228
  store: OptionalNullable[bool] = UNSET,
224
229
  handoff_execution: OptionalNullable[models.HandoffExecution] = UNSET,
225
230
  instructions: OptionalNullable[str] = UNSET,
226
- tools: OptionalNullable[
227
- Union[List[models.Tools], List[models.ToolsTypedDict]]
228
- ] = UNSET,
231
+ tools: Optional[Union[List[models.Tools], List[models.ToolsTypedDict]]] = None,
229
232
  completion_args: OptionalNullable[
230
233
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
231
234
  ] = UNSET,
232
235
  name: OptionalNullable[str] = UNSET,
233
236
  description: OptionalNullable[str] = UNSET,
237
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
234
238
  agent_id: OptionalNullable[str] = UNSET,
239
+ agent_version: OptionalNullable[int] = UNSET,
235
240
  model: OptionalNullable[str] = UNSET,
236
241
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
237
242
  server_url: Optional[str] = None,
@@ -247,11 +252,13 @@ class Conversations(BaseSDK):
247
252
  :param store:
248
253
  :param handoff_execution:
249
254
  :param instructions:
250
- :param tools:
255
+ :param tools: List of tools which are available to the model during the conversation.
251
256
  :param completion_args:
252
257
  :param name:
253
258
  :param description:
259
+ :param metadata:
254
260
  :param agent_id:
261
+ :param agent_version:
255
262
  :param model:
256
263
  :param retries: Override the default retry configuration for this method
257
264
  :param server_url: Override the default server URL for this method
@@ -274,13 +281,15 @@ class Conversations(BaseSDK):
274
281
  store=store,
275
282
  handoff_execution=handoff_execution,
276
283
  instructions=instructions,
277
- tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tools]]),
284
+ tools=utils.get_pydantic_model(tools, Optional[List[models.Tools]]),
278
285
  completion_args=utils.get_pydantic_model(
279
286
  completion_args, OptionalNullable[models.CompletionArgs]
280
287
  ),
281
288
  name=name,
282
289
  description=description,
290
+ metadata=metadata,
283
291
  agent_id=agent_id,
292
+ agent_version=agent_version,
284
293
  model=model,
285
294
  )
286
295
 
@@ -328,31 +337,20 @@ class Conversations(BaseSDK):
328
337
 
329
338
  response_data: Any = None
330
339
  if utils.match_response(http_res, "200", "application/json"):
331
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
340
+ return unmarshal_json_response(models.ConversationResponse, http_res)
332
341
  if utils.match_response(http_res, "422", "application/json"):
333
- response_data = utils.unmarshal_json(
334
- http_res.text, models.HTTPValidationErrorData
342
+ response_data = unmarshal_json_response(
343
+ models.HTTPValidationErrorData, http_res
335
344
  )
336
- raise models.HTTPValidationError(data=response_data)
345
+ raise models.HTTPValidationError(response_data, http_res)
337
346
  if utils.match_response(http_res, "4XX", "*"):
338
347
  http_res_text = utils.stream_to_text(http_res)
339
- raise models.SDKError(
340
- "API error occurred", http_res.status_code, http_res_text, http_res
341
- )
348
+ raise models.SDKError("API error occurred", http_res, http_res_text)
342
349
  if utils.match_response(http_res, "5XX", "*"):
343
350
  http_res_text = utils.stream_to_text(http_res)
344
- raise models.SDKError(
345
- "API error occurred", http_res.status_code, http_res_text, http_res
346
- )
351
+ raise models.SDKError("API error occurred", http_res, http_res_text)
347
352
 
348
- content_type = http_res.headers.get("Content-Type")
349
- http_res_text = utils.stream_to_text(http_res)
350
- raise models.SDKError(
351
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
352
- http_res.status_code,
353
- http_res_text,
354
- http_res,
355
- )
353
+ raise models.SDKError("Unexpected response received", http_res)
356
354
 
357
355
  async def start_async(
358
356
  self,
@@ -362,15 +360,15 @@ class Conversations(BaseSDK):
362
360
  store: OptionalNullable[bool] = UNSET,
363
361
  handoff_execution: OptionalNullable[models.HandoffExecution] = UNSET,
364
362
  instructions: OptionalNullable[str] = UNSET,
365
- tools: OptionalNullable[
366
- Union[List[models.Tools], List[models.ToolsTypedDict]]
367
- ] = UNSET,
363
+ tools: Optional[Union[List[models.Tools], List[models.ToolsTypedDict]]] = None,
368
364
  completion_args: OptionalNullable[
369
365
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
370
366
  ] = UNSET,
371
367
  name: OptionalNullable[str] = UNSET,
372
368
  description: OptionalNullable[str] = UNSET,
369
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
373
370
  agent_id: OptionalNullable[str] = UNSET,
371
+ agent_version: OptionalNullable[int] = UNSET,
374
372
  model: OptionalNullable[str] = UNSET,
375
373
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
376
374
  server_url: Optional[str] = None,
@@ -386,11 +384,13 @@ class Conversations(BaseSDK):
386
384
  :param store:
387
385
  :param handoff_execution:
388
386
  :param instructions:
389
- :param tools:
387
+ :param tools: List of tools which are available to the model during the conversation.
390
388
  :param completion_args:
391
389
  :param name:
392
390
  :param description:
391
+ :param metadata:
393
392
  :param agent_id:
393
+ :param agent_version:
394
394
  :param model:
395
395
  :param retries: Override the default retry configuration for this method
396
396
  :param server_url: Override the default server URL for this method
@@ -413,13 +413,15 @@ class Conversations(BaseSDK):
413
413
  store=store,
414
414
  handoff_execution=handoff_execution,
415
415
  instructions=instructions,
416
- tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tools]]),
416
+ tools=utils.get_pydantic_model(tools, Optional[List[models.Tools]]),
417
417
  completion_args=utils.get_pydantic_model(
418
418
  completion_args, OptionalNullable[models.CompletionArgs]
419
419
  ),
420
420
  name=name,
421
421
  description=description,
422
+ metadata=metadata,
422
423
  agent_id=agent_id,
424
+ agent_version=agent_version,
423
425
  model=model,
424
426
  )
425
427
 
@@ -467,37 +469,27 @@ class Conversations(BaseSDK):
467
469
 
468
470
  response_data: Any = None
469
471
  if utils.match_response(http_res, "200", "application/json"):
470
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
472
+ return unmarshal_json_response(models.ConversationResponse, http_res)
471
473
  if utils.match_response(http_res, "422", "application/json"):
472
- response_data = utils.unmarshal_json(
473
- http_res.text, models.HTTPValidationErrorData
474
+ response_data = unmarshal_json_response(
475
+ models.HTTPValidationErrorData, http_res
474
476
  )
475
- raise models.HTTPValidationError(data=response_data)
477
+ raise models.HTTPValidationError(response_data, http_res)
476
478
  if utils.match_response(http_res, "4XX", "*"):
477
479
  http_res_text = await utils.stream_to_text_async(http_res)
478
- raise models.SDKError(
479
- "API error occurred", http_res.status_code, http_res_text, http_res
480
- )
480
+ raise models.SDKError("API error occurred", http_res, http_res_text)
481
481
  if utils.match_response(http_res, "5XX", "*"):
482
482
  http_res_text = await utils.stream_to_text_async(http_res)
483
- raise models.SDKError(
484
- "API error occurred", http_res.status_code, http_res_text, http_res
485
- )
483
+ raise models.SDKError("API error occurred", http_res, http_res_text)
486
484
 
487
- content_type = http_res.headers.get("Content-Type")
488
- http_res_text = await utils.stream_to_text_async(http_res)
489
- raise models.SDKError(
490
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
491
- http_res.status_code,
492
- http_res_text,
493
- http_res,
494
- )
485
+ raise models.SDKError("Unexpected response received", http_res)
495
486
 
496
487
  def list(
497
488
  self,
498
489
  *,
499
490
  page: Optional[int] = 0,
500
491
  page_size: Optional[int] = 100,
492
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
501
493
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
502
494
  server_url: Optional[str] = None,
503
495
  timeout_ms: Optional[int] = None,
@@ -509,6 +501,7 @@ class Conversations(BaseSDK):
509
501
 
510
502
  :param page:
511
503
  :param page_size:
504
+ :param metadata:
512
505
  :param retries: Override the default retry configuration for this method
513
506
  :param server_url: Override the default server URL for this method
514
507
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -527,6 +520,7 @@ class Conversations(BaseSDK):
527
520
  request = models.AgentsAPIV1ConversationsListRequest(
528
521
  page=page,
529
522
  page_size=page_size,
523
+ metadata=metadata,
530
524
  )
531
525
 
532
526
  req = self._build_request(
@@ -570,37 +564,27 @@ class Conversations(BaseSDK):
570
564
 
571
565
  response_data: Any = None
572
566
  if utils.match_response(http_res, "200", "application/json"):
573
- return utils.unmarshal_json(http_res.text, List[models.ResponseBody])
567
+ return unmarshal_json_response(List[models.ResponseBody], http_res)
574
568
  if utils.match_response(http_res, "422", "application/json"):
575
- response_data = utils.unmarshal_json(
576
- http_res.text, models.HTTPValidationErrorData
569
+ response_data = unmarshal_json_response(
570
+ models.HTTPValidationErrorData, http_res
577
571
  )
578
- raise models.HTTPValidationError(data=response_data)
572
+ raise models.HTTPValidationError(response_data, http_res)
579
573
  if utils.match_response(http_res, "4XX", "*"):
580
574
  http_res_text = utils.stream_to_text(http_res)
581
- raise models.SDKError(
582
- "API error occurred", http_res.status_code, http_res_text, http_res
583
- )
575
+ raise models.SDKError("API error occurred", http_res, http_res_text)
584
576
  if utils.match_response(http_res, "5XX", "*"):
585
577
  http_res_text = utils.stream_to_text(http_res)
586
- raise models.SDKError(
587
- "API error occurred", http_res.status_code, http_res_text, http_res
588
- )
578
+ raise models.SDKError("API error occurred", http_res, http_res_text)
589
579
 
590
- content_type = http_res.headers.get("Content-Type")
591
- http_res_text = utils.stream_to_text(http_res)
592
- raise models.SDKError(
593
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
594
- http_res.status_code,
595
- http_res_text,
596
- http_res,
597
- )
580
+ raise models.SDKError("Unexpected response received", http_res)
598
581
 
599
582
  async def list_async(
600
583
  self,
601
584
  *,
602
585
  page: Optional[int] = 0,
603
586
  page_size: Optional[int] = 100,
587
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
604
588
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
605
589
  server_url: Optional[str] = None,
606
590
  timeout_ms: Optional[int] = None,
@@ -612,6 +596,7 @@ class Conversations(BaseSDK):
612
596
 
613
597
  :param page:
614
598
  :param page_size:
599
+ :param metadata:
615
600
  :param retries: Override the default retry configuration for this method
616
601
  :param server_url: Override the default server URL for this method
617
602
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -630,6 +615,7 @@ class Conversations(BaseSDK):
630
615
  request = models.AgentsAPIV1ConversationsListRequest(
631
616
  page=page,
632
617
  page_size=page_size,
618
+ metadata=metadata,
633
619
  )
634
620
 
635
621
  req = self._build_request_async(
@@ -673,31 +659,20 @@ class Conversations(BaseSDK):
673
659
 
674
660
  response_data: Any = None
675
661
  if utils.match_response(http_res, "200", "application/json"):
676
- return utils.unmarshal_json(http_res.text, List[models.ResponseBody])
662
+ return unmarshal_json_response(List[models.ResponseBody], http_res)
677
663
  if utils.match_response(http_res, "422", "application/json"):
678
- response_data = utils.unmarshal_json(
679
- http_res.text, models.HTTPValidationErrorData
664
+ response_data = unmarshal_json_response(
665
+ models.HTTPValidationErrorData, http_res
680
666
  )
681
- raise models.HTTPValidationError(data=response_data)
667
+ raise models.HTTPValidationError(response_data, http_res)
682
668
  if utils.match_response(http_res, "4XX", "*"):
683
669
  http_res_text = await utils.stream_to_text_async(http_res)
684
- raise models.SDKError(
685
- "API error occurred", http_res.status_code, http_res_text, http_res
686
- )
670
+ raise models.SDKError("API error occurred", http_res, http_res_text)
687
671
  if utils.match_response(http_res, "5XX", "*"):
688
672
  http_res_text = await utils.stream_to_text_async(http_res)
689
- raise models.SDKError(
690
- "API error occurred", http_res.status_code, http_res_text, http_res
691
- )
673
+ raise models.SDKError("API error occurred", http_res, http_res_text)
692
674
 
693
- content_type = http_res.headers.get("Content-Type")
694
- http_res_text = await utils.stream_to_text_async(http_res)
695
- raise models.SDKError(
696
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
697
- http_res.status_code,
698
- http_res_text,
699
- http_res,
700
- )
675
+ raise models.SDKError("Unexpected response received", http_res)
701
676
 
702
677
  def get(
703
678
  self,
@@ -773,34 +748,22 @@ class Conversations(BaseSDK):
773
748
 
774
749
  response_data: Any = None
775
750
  if utils.match_response(http_res, "200", "application/json"):
776
- return utils.unmarshal_json(
777
- http_res.text,
778
- models.AgentsAPIV1ConversationsGetResponseV1ConversationsGet,
751
+ return unmarshal_json_response(
752
+ models.AgentsAPIV1ConversationsGetResponseV1ConversationsGet, http_res
779
753
  )
780
754
  if utils.match_response(http_res, "422", "application/json"):
781
- response_data = utils.unmarshal_json(
782
- http_res.text, models.HTTPValidationErrorData
755
+ response_data = unmarshal_json_response(
756
+ models.HTTPValidationErrorData, http_res
783
757
  )
784
- raise models.HTTPValidationError(data=response_data)
758
+ raise models.HTTPValidationError(response_data, http_res)
785
759
  if utils.match_response(http_res, "4XX", "*"):
786
760
  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
- )
761
+ raise models.SDKError("API error occurred", http_res, http_res_text)
790
762
  if utils.match_response(http_res, "5XX", "*"):
791
763
  http_res_text = utils.stream_to_text(http_res)
792
- raise models.SDKError(
793
- "API error occurred", http_res.status_code, http_res_text, http_res
794
- )
764
+ raise models.SDKError("API error occurred", http_res, http_res_text)
795
765
 
796
- content_type = http_res.headers.get("Content-Type")
797
- http_res_text = utils.stream_to_text(http_res)
798
- raise models.SDKError(
799
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
800
- http_res.status_code,
801
- http_res_text,
802
- http_res,
803
- )
766
+ raise models.SDKError("Unexpected response received", http_res)
804
767
 
805
768
  async def get_async(
806
769
  self,
@@ -876,35 +839,201 @@ class Conversations(BaseSDK):
876
839
 
877
840
  response_data: Any = None
878
841
  if utils.match_response(http_res, "200", "application/json"):
879
- return utils.unmarshal_json(
880
- http_res.text,
881
- models.AgentsAPIV1ConversationsGetResponseV1ConversationsGet,
842
+ return unmarshal_json_response(
843
+ models.AgentsAPIV1ConversationsGetResponseV1ConversationsGet, http_res
882
844
  )
883
845
  if utils.match_response(http_res, "422", "application/json"):
884
- response_data = utils.unmarshal_json(
885
- http_res.text, models.HTTPValidationErrorData
846
+ response_data = unmarshal_json_response(
847
+ models.HTTPValidationErrorData, http_res
886
848
  )
887
- raise models.HTTPValidationError(data=response_data)
849
+ raise models.HTTPValidationError(response_data, http_res)
888
850
  if utils.match_response(http_res, "4XX", "*"):
889
851
  http_res_text = await utils.stream_to_text_async(http_res)
890
- raise models.SDKError(
891
- "API error occurred", http_res.status_code, http_res_text, http_res
892
- )
852
+ raise models.SDKError("API error occurred", http_res, http_res_text)
893
853
  if utils.match_response(http_res, "5XX", "*"):
894
854
  http_res_text = await utils.stream_to_text_async(http_res)
895
- raise models.SDKError(
896
- "API error occurred", http_res.status_code, http_res_text, http_res
855
+ raise models.SDKError("API error occurred", http_res, http_res_text)
856
+
857
+ raise models.SDKError("Unexpected response received", http_res)
858
+
859
+ def delete(
860
+ self,
861
+ *,
862
+ conversation_id: str,
863
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
864
+ server_url: Optional[str] = None,
865
+ timeout_ms: Optional[int] = None,
866
+ http_headers: Optional[Mapping[str, str]] = None,
867
+ ):
868
+ r"""Delete a conversation.
869
+
870
+ Delete a conversation given a conversation_id.
871
+
872
+ :param conversation_id: ID of the conversation from which we are fetching metadata.
873
+ :param retries: Override the default retry configuration for this method
874
+ :param server_url: Override the default server URL for this method
875
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
876
+ :param http_headers: Additional headers to set or replace on requests.
877
+ """
878
+ base_url = None
879
+ url_variables = None
880
+ if timeout_ms is None:
881
+ timeout_ms = self.sdk_configuration.timeout_ms
882
+
883
+ if server_url is not None:
884
+ base_url = server_url
885
+ else:
886
+ base_url = self._get_url(base_url, url_variables)
887
+
888
+ request = models.AgentsAPIV1ConversationsDeleteRequest(
889
+ conversation_id=conversation_id,
890
+ )
891
+
892
+ req = self._build_request(
893
+ method="DELETE",
894
+ path="/v1/conversations/{conversation_id}",
895
+ base_url=base_url,
896
+ url_variables=url_variables,
897
+ request=request,
898
+ request_body_required=False,
899
+ request_has_path_params=True,
900
+ request_has_query_params=True,
901
+ user_agent_header="user-agent",
902
+ accept_header_value="application/json",
903
+ http_headers=http_headers,
904
+ security=self.sdk_configuration.security,
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 = self.do_request(
917
+ hook_ctx=HookContext(
918
+ config=self.sdk_configuration,
919
+ base_url=base_url or "",
920
+ operation_id="agents_api_v1_conversations_delete",
921
+ oauth2_scopes=[],
922
+ security_source=get_security_from_env(
923
+ self.sdk_configuration.security, models.Security
924
+ ),
925
+ ),
926
+ request=req,
927
+ error_status_codes=["422", "4XX", "5XX"],
928
+ retry_config=retry_config,
929
+ )
930
+
931
+ response_data: Any = None
932
+ if utils.match_response(http_res, "204", "*"):
933
+ return
934
+ if utils.match_response(http_res, "422", "application/json"):
935
+ response_data = unmarshal_json_response(
936
+ models.HTTPValidationErrorData, http_res
897
937
  )
938
+ raise models.HTTPValidationError(response_data, http_res)
939
+ if utils.match_response(http_res, "4XX", "*"):
940
+ http_res_text = utils.stream_to_text(http_res)
941
+ raise models.SDKError("API error occurred", http_res, http_res_text)
942
+ if utils.match_response(http_res, "5XX", "*"):
943
+ http_res_text = utils.stream_to_text(http_res)
944
+ raise models.SDKError("API error occurred", http_res, http_res_text)
898
945
 
899
- content_type = http_res.headers.get("Content-Type")
900
- http_res_text = await utils.stream_to_text_async(http_res)
901
- raise models.SDKError(
902
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
903
- http_res.status_code,
904
- http_res_text,
905
- http_res,
946
+ raise models.SDKError("Unexpected response received", http_res)
947
+
948
+ async def delete_async(
949
+ self,
950
+ *,
951
+ conversation_id: str,
952
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
953
+ server_url: Optional[str] = None,
954
+ timeout_ms: Optional[int] = None,
955
+ http_headers: Optional[Mapping[str, str]] = None,
956
+ ):
957
+ r"""Delete a conversation.
958
+
959
+ Delete a conversation given a conversation_id.
960
+
961
+ :param conversation_id: ID of the conversation from which we are fetching metadata.
962
+ :param retries: Override the default retry configuration for this method
963
+ :param server_url: Override the default server URL for this method
964
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
965
+ :param http_headers: Additional headers to set or replace on requests.
966
+ """
967
+ base_url = None
968
+ url_variables = None
969
+ if timeout_ms is None:
970
+ timeout_ms = self.sdk_configuration.timeout_ms
971
+
972
+ if server_url is not None:
973
+ base_url = server_url
974
+ else:
975
+ base_url = self._get_url(base_url, url_variables)
976
+
977
+ request = models.AgentsAPIV1ConversationsDeleteRequest(
978
+ conversation_id=conversation_id,
979
+ )
980
+
981
+ req = self._build_request_async(
982
+ method="DELETE",
983
+ path="/v1/conversations/{conversation_id}",
984
+ base_url=base_url,
985
+ url_variables=url_variables,
986
+ request=request,
987
+ request_body_required=False,
988
+ request_has_path_params=True,
989
+ request_has_query_params=True,
990
+ user_agent_header="user-agent",
991
+ accept_header_value="application/json",
992
+ http_headers=http_headers,
993
+ security=self.sdk_configuration.security,
994
+ timeout_ms=timeout_ms,
995
+ )
996
+
997
+ if retries == UNSET:
998
+ if self.sdk_configuration.retry_config is not UNSET:
999
+ retries = self.sdk_configuration.retry_config
1000
+
1001
+ retry_config = None
1002
+ if isinstance(retries, utils.RetryConfig):
1003
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1004
+
1005
+ http_res = await self.do_request_async(
1006
+ hook_ctx=HookContext(
1007
+ config=self.sdk_configuration,
1008
+ base_url=base_url or "",
1009
+ operation_id="agents_api_v1_conversations_delete",
1010
+ oauth2_scopes=[],
1011
+ security_source=get_security_from_env(
1012
+ self.sdk_configuration.security, models.Security
1013
+ ),
1014
+ ),
1015
+ request=req,
1016
+ error_status_codes=["422", "4XX", "5XX"],
1017
+ retry_config=retry_config,
906
1018
  )
907
1019
 
1020
+ response_data: Any = None
1021
+ if utils.match_response(http_res, "204", "*"):
1022
+ return
1023
+ if utils.match_response(http_res, "422", "application/json"):
1024
+ response_data = unmarshal_json_response(
1025
+ models.HTTPValidationErrorData, http_res
1026
+ )
1027
+ raise models.HTTPValidationError(response_data, http_res)
1028
+ if utils.match_response(http_res, "4XX", "*"):
1029
+ http_res_text = await utils.stream_to_text_async(http_res)
1030
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1031
+ if utils.match_response(http_res, "5XX", "*"):
1032
+ http_res_text = await utils.stream_to_text_async(http_res)
1033
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1034
+
1035
+ raise models.SDKError("Unexpected response received", http_res)
1036
+
908
1037
  def append(
909
1038
  self,
910
1039
  *,
@@ -1009,31 +1138,20 @@ class Conversations(BaseSDK):
1009
1138
 
1010
1139
  response_data: Any = None
1011
1140
  if utils.match_response(http_res, "200", "application/json"):
1012
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
1141
+ return unmarshal_json_response(models.ConversationResponse, http_res)
1013
1142
  if utils.match_response(http_res, "422", "application/json"):
1014
- response_data = utils.unmarshal_json(
1015
- http_res.text, models.HTTPValidationErrorData
1143
+ response_data = unmarshal_json_response(
1144
+ models.HTTPValidationErrorData, http_res
1016
1145
  )
1017
- raise models.HTTPValidationError(data=response_data)
1146
+ raise models.HTTPValidationError(response_data, http_res)
1018
1147
  if utils.match_response(http_res, "4XX", "*"):
1019
1148
  http_res_text = utils.stream_to_text(http_res)
1020
- raise models.SDKError(
1021
- "API error occurred", http_res.status_code, http_res_text, http_res
1022
- )
1149
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1023
1150
  if utils.match_response(http_res, "5XX", "*"):
1024
1151
  http_res_text = utils.stream_to_text(http_res)
1025
- raise models.SDKError(
1026
- "API error occurred", http_res.status_code, http_res_text, http_res
1027
- )
1152
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1028
1153
 
1029
- content_type = http_res.headers.get("Content-Type")
1030
- http_res_text = utils.stream_to_text(http_res)
1031
- raise models.SDKError(
1032
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1033
- http_res.status_code,
1034
- http_res_text,
1035
- http_res,
1036
- )
1154
+ raise models.SDKError("Unexpected response received", http_res)
1037
1155
 
1038
1156
  async def append_async(
1039
1157
  self,
@@ -1139,31 +1257,20 @@ class Conversations(BaseSDK):
1139
1257
 
1140
1258
  response_data: Any = None
1141
1259
  if utils.match_response(http_res, "200", "application/json"):
1142
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
1260
+ return unmarshal_json_response(models.ConversationResponse, http_res)
1143
1261
  if utils.match_response(http_res, "422", "application/json"):
1144
- response_data = utils.unmarshal_json(
1145
- http_res.text, models.HTTPValidationErrorData
1262
+ response_data = unmarshal_json_response(
1263
+ models.HTTPValidationErrorData, http_res
1146
1264
  )
1147
- raise models.HTTPValidationError(data=response_data)
1265
+ raise models.HTTPValidationError(response_data, http_res)
1148
1266
  if utils.match_response(http_res, "4XX", "*"):
1149
1267
  http_res_text = await utils.stream_to_text_async(http_res)
1150
- raise models.SDKError(
1151
- "API error occurred", http_res.status_code, http_res_text, http_res
1152
- )
1268
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1153
1269
  if utils.match_response(http_res, "5XX", "*"):
1154
1270
  http_res_text = await utils.stream_to_text_async(http_res)
1155
- raise models.SDKError(
1156
- "API error occurred", http_res.status_code, http_res_text, http_res
1157
- )
1271
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1158
1272
 
1159
- content_type = http_res.headers.get("Content-Type")
1160
- http_res_text = await utils.stream_to_text_async(http_res)
1161
- raise models.SDKError(
1162
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1163
- http_res.status_code,
1164
- http_res_text,
1165
- http_res,
1166
- )
1273
+ raise models.SDKError("Unexpected response received", http_res)
1167
1274
 
1168
1275
  def get_history(
1169
1276
  self,
@@ -1239,31 +1346,20 @@ class Conversations(BaseSDK):
1239
1346
 
1240
1347
  response_data: Any = None
1241
1348
  if utils.match_response(http_res, "200", "application/json"):
1242
- return utils.unmarshal_json(http_res.text, models.ConversationHistory)
1349
+ return unmarshal_json_response(models.ConversationHistory, http_res)
1243
1350
  if utils.match_response(http_res, "422", "application/json"):
1244
- response_data = utils.unmarshal_json(
1245
- http_res.text, models.HTTPValidationErrorData
1351
+ response_data = unmarshal_json_response(
1352
+ models.HTTPValidationErrorData, http_res
1246
1353
  )
1247
- raise models.HTTPValidationError(data=response_data)
1354
+ raise models.HTTPValidationError(response_data, http_res)
1248
1355
  if utils.match_response(http_res, "4XX", "*"):
1249
1356
  http_res_text = utils.stream_to_text(http_res)
1250
- raise models.SDKError(
1251
- "API error occurred", http_res.status_code, http_res_text, http_res
1252
- )
1357
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1253
1358
  if utils.match_response(http_res, "5XX", "*"):
1254
1359
  http_res_text = utils.stream_to_text(http_res)
1255
- raise models.SDKError(
1256
- "API error occurred", http_res.status_code, http_res_text, http_res
1257
- )
1360
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1258
1361
 
1259
- content_type = http_res.headers.get("Content-Type")
1260
- http_res_text = utils.stream_to_text(http_res)
1261
- raise models.SDKError(
1262
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1263
- http_res.status_code,
1264
- http_res_text,
1265
- http_res,
1266
- )
1362
+ raise models.SDKError("Unexpected response received", http_res)
1267
1363
 
1268
1364
  async def get_history_async(
1269
1365
  self,
@@ -1339,31 +1435,20 @@ class Conversations(BaseSDK):
1339
1435
 
1340
1436
  response_data: Any = None
1341
1437
  if utils.match_response(http_res, "200", "application/json"):
1342
- return utils.unmarshal_json(http_res.text, models.ConversationHistory)
1438
+ return unmarshal_json_response(models.ConversationHistory, http_res)
1343
1439
  if utils.match_response(http_res, "422", "application/json"):
1344
- response_data = utils.unmarshal_json(
1345
- http_res.text, models.HTTPValidationErrorData
1440
+ response_data = unmarshal_json_response(
1441
+ models.HTTPValidationErrorData, http_res
1346
1442
  )
1347
- raise models.HTTPValidationError(data=response_data)
1443
+ raise models.HTTPValidationError(response_data, http_res)
1348
1444
  if utils.match_response(http_res, "4XX", "*"):
1349
1445
  http_res_text = await utils.stream_to_text_async(http_res)
1350
- raise models.SDKError(
1351
- "API error occurred", http_res.status_code, http_res_text, http_res
1352
- )
1446
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1353
1447
  if utils.match_response(http_res, "5XX", "*"):
1354
1448
  http_res_text = await utils.stream_to_text_async(http_res)
1355
- raise models.SDKError(
1356
- "API error occurred", http_res.status_code, http_res_text, http_res
1357
- )
1449
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1358
1450
 
1359
- content_type = http_res.headers.get("Content-Type")
1360
- http_res_text = await utils.stream_to_text_async(http_res)
1361
- raise models.SDKError(
1362
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1363
- http_res.status_code,
1364
- http_res_text,
1365
- http_res,
1366
- )
1451
+ raise models.SDKError("Unexpected response received", http_res)
1367
1452
 
1368
1453
  def get_messages(
1369
1454
  self,
@@ -1439,31 +1524,20 @@ class Conversations(BaseSDK):
1439
1524
 
1440
1525
  response_data: Any = None
1441
1526
  if utils.match_response(http_res, "200", "application/json"):
1442
- return utils.unmarshal_json(http_res.text, models.ConversationMessages)
1527
+ return unmarshal_json_response(models.ConversationMessages, http_res)
1443
1528
  if utils.match_response(http_res, "422", "application/json"):
1444
- response_data = utils.unmarshal_json(
1445
- http_res.text, models.HTTPValidationErrorData
1529
+ response_data = unmarshal_json_response(
1530
+ models.HTTPValidationErrorData, http_res
1446
1531
  )
1447
- raise models.HTTPValidationError(data=response_data)
1532
+ raise models.HTTPValidationError(response_data, http_res)
1448
1533
  if utils.match_response(http_res, "4XX", "*"):
1449
1534
  http_res_text = utils.stream_to_text(http_res)
1450
- raise models.SDKError(
1451
- "API error occurred", http_res.status_code, http_res_text, http_res
1452
- )
1535
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1453
1536
  if utils.match_response(http_res, "5XX", "*"):
1454
1537
  http_res_text = utils.stream_to_text(http_res)
1455
- raise models.SDKError(
1456
- "API error occurred", http_res.status_code, http_res_text, http_res
1457
- )
1538
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1458
1539
 
1459
- content_type = http_res.headers.get("Content-Type")
1460
- http_res_text = utils.stream_to_text(http_res)
1461
- raise models.SDKError(
1462
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1463
- http_res.status_code,
1464
- http_res_text,
1465
- http_res,
1466
- )
1540
+ raise models.SDKError("Unexpected response received", http_res)
1467
1541
 
1468
1542
  async def get_messages_async(
1469
1543
  self,
@@ -1539,31 +1613,20 @@ class Conversations(BaseSDK):
1539
1613
 
1540
1614
  response_data: Any = None
1541
1615
  if utils.match_response(http_res, "200", "application/json"):
1542
- return utils.unmarshal_json(http_res.text, models.ConversationMessages)
1616
+ return unmarshal_json_response(models.ConversationMessages, http_res)
1543
1617
  if utils.match_response(http_res, "422", "application/json"):
1544
- response_data = utils.unmarshal_json(
1545
- http_res.text, models.HTTPValidationErrorData
1618
+ response_data = unmarshal_json_response(
1619
+ models.HTTPValidationErrorData, http_res
1546
1620
  )
1547
- raise models.HTTPValidationError(data=response_data)
1621
+ raise models.HTTPValidationError(response_data, http_res)
1548
1622
  if utils.match_response(http_res, "4XX", "*"):
1549
1623
  http_res_text = await utils.stream_to_text_async(http_res)
1550
- raise models.SDKError(
1551
- "API error occurred", http_res.status_code, http_res_text, http_res
1552
- )
1624
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1553
1625
  if utils.match_response(http_res, "5XX", "*"):
1554
1626
  http_res_text = await utils.stream_to_text_async(http_res)
1555
- raise models.SDKError(
1556
- "API error occurred", http_res.status_code, http_res_text, http_res
1557
- )
1627
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1558
1628
 
1559
- content_type = http_res.headers.get("Content-Type")
1560
- http_res_text = await utils.stream_to_text_async(http_res)
1561
- raise models.SDKError(
1562
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1563
- http_res.status_code,
1564
- http_res_text,
1565
- http_res,
1566
- )
1629
+ raise models.SDKError("Unexpected response received", http_res)
1567
1630
 
1568
1631
  def restart(
1569
1632
  self,
@@ -1579,6 +1642,8 @@ class Conversations(BaseSDK):
1579
1642
  completion_args: Optional[
1580
1643
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
1581
1644
  ] = None,
1645
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
1646
+ agent_version: OptionalNullable[int] = UNSET,
1582
1647
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
1583
1648
  server_url: Optional[str] = None,
1584
1649
  timeout_ms: Optional[int] = None,
@@ -1595,6 +1660,8 @@ class Conversations(BaseSDK):
1595
1660
  :param store: Whether to store the results into our servers or not.
1596
1661
  :param handoff_execution:
1597
1662
  :param completion_args: White-listed arguments from the completion API
1663
+ :param metadata: Custom metadata for the conversation.
1664
+ :param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
1598
1665
  :param retries: Override the default retry configuration for this method
1599
1666
  :param server_url: Override the default server URL for this method
1600
1667
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1620,7 +1687,9 @@ class Conversations(BaseSDK):
1620
1687
  completion_args=utils.get_pydantic_model(
1621
1688
  completion_args, Optional[models.CompletionArgs]
1622
1689
  ),
1690
+ metadata=metadata,
1623
1691
  from_entry_id=from_entry_id,
1692
+ agent_version=agent_version,
1624
1693
  ),
1625
1694
  )
1626
1695
 
@@ -1672,31 +1741,20 @@ class Conversations(BaseSDK):
1672
1741
 
1673
1742
  response_data: Any = None
1674
1743
  if utils.match_response(http_res, "200", "application/json"):
1675
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
1744
+ return unmarshal_json_response(models.ConversationResponse, http_res)
1676
1745
  if utils.match_response(http_res, "422", "application/json"):
1677
- response_data = utils.unmarshal_json(
1678
- http_res.text, models.HTTPValidationErrorData
1746
+ response_data = unmarshal_json_response(
1747
+ models.HTTPValidationErrorData, http_res
1679
1748
  )
1680
- raise models.HTTPValidationError(data=response_data)
1749
+ raise models.HTTPValidationError(response_data, http_res)
1681
1750
  if utils.match_response(http_res, "4XX", "*"):
1682
1751
  http_res_text = utils.stream_to_text(http_res)
1683
- raise models.SDKError(
1684
- "API error occurred", http_res.status_code, http_res_text, http_res
1685
- )
1752
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1686
1753
  if utils.match_response(http_res, "5XX", "*"):
1687
1754
  http_res_text = utils.stream_to_text(http_res)
1688
- raise models.SDKError(
1689
- "API error occurred", http_res.status_code, http_res_text, http_res
1690
- )
1755
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1691
1756
 
1692
- content_type = http_res.headers.get("Content-Type")
1693
- http_res_text = utils.stream_to_text(http_res)
1694
- raise models.SDKError(
1695
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1696
- http_res.status_code,
1697
- http_res_text,
1698
- http_res,
1699
- )
1757
+ raise models.SDKError("Unexpected response received", http_res)
1700
1758
 
1701
1759
  async def restart_async(
1702
1760
  self,
@@ -1712,6 +1770,8 @@ class Conversations(BaseSDK):
1712
1770
  completion_args: Optional[
1713
1771
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
1714
1772
  ] = None,
1773
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
1774
+ agent_version: OptionalNullable[int] = UNSET,
1715
1775
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
1716
1776
  server_url: Optional[str] = None,
1717
1777
  timeout_ms: Optional[int] = None,
@@ -1728,6 +1788,8 @@ class Conversations(BaseSDK):
1728
1788
  :param store: Whether to store the results into our servers or not.
1729
1789
  :param handoff_execution:
1730
1790
  :param completion_args: White-listed arguments from the completion API
1791
+ :param metadata: Custom metadata for the conversation.
1792
+ :param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
1731
1793
  :param retries: Override the default retry configuration for this method
1732
1794
  :param server_url: Override the default server URL for this method
1733
1795
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1753,7 +1815,9 @@ class Conversations(BaseSDK):
1753
1815
  completion_args=utils.get_pydantic_model(
1754
1816
  completion_args, Optional[models.CompletionArgs]
1755
1817
  ),
1818
+ metadata=metadata,
1756
1819
  from_entry_id=from_entry_id,
1820
+ agent_version=agent_version,
1757
1821
  ),
1758
1822
  )
1759
1823
 
@@ -1805,31 +1869,20 @@ class Conversations(BaseSDK):
1805
1869
 
1806
1870
  response_data: Any = None
1807
1871
  if utils.match_response(http_res, "200", "application/json"):
1808
- return utils.unmarshal_json(http_res.text, models.ConversationResponse)
1872
+ return unmarshal_json_response(models.ConversationResponse, http_res)
1809
1873
  if utils.match_response(http_res, "422", "application/json"):
1810
- response_data = utils.unmarshal_json(
1811
- http_res.text, models.HTTPValidationErrorData
1874
+ response_data = unmarshal_json_response(
1875
+ models.HTTPValidationErrorData, http_res
1812
1876
  )
1813
- raise models.HTTPValidationError(data=response_data)
1877
+ raise models.HTTPValidationError(response_data, http_res)
1814
1878
  if utils.match_response(http_res, "4XX", "*"):
1815
1879
  http_res_text = await utils.stream_to_text_async(http_res)
1816
- raise models.SDKError(
1817
- "API error occurred", http_res.status_code, http_res_text, http_res
1818
- )
1880
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1819
1881
  if utils.match_response(http_res, "5XX", "*"):
1820
1882
  http_res_text = await utils.stream_to_text_async(http_res)
1821
- raise models.SDKError(
1822
- "API error occurred", http_res.status_code, http_res_text, http_res
1823
- )
1883
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1824
1884
 
1825
- content_type = http_res.headers.get("Content-Type")
1826
- http_res_text = await utils.stream_to_text_async(http_res)
1827
- raise models.SDKError(
1828
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1829
- http_res.status_code,
1830
- http_res_text,
1831
- http_res,
1832
- )
1885
+ raise models.SDKError("Unexpected response received", http_res)
1833
1886
 
1834
1887
  def start_stream(
1835
1888
  self,
@@ -1841,18 +1894,20 @@ class Conversations(BaseSDK):
1841
1894
  models.ConversationStreamRequestHandoffExecution
1842
1895
  ] = UNSET,
1843
1896
  instructions: OptionalNullable[str] = UNSET,
1844
- tools: OptionalNullable[
1897
+ tools: Optional[
1845
1898
  Union[
1846
1899
  List[models.ConversationStreamRequestTools],
1847
1900
  List[models.ConversationStreamRequestToolsTypedDict],
1848
1901
  ]
1849
- ] = UNSET,
1902
+ ] = None,
1850
1903
  completion_args: OptionalNullable[
1851
1904
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
1852
1905
  ] = UNSET,
1853
1906
  name: OptionalNullable[str] = UNSET,
1854
1907
  description: OptionalNullable[str] = UNSET,
1908
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
1855
1909
  agent_id: OptionalNullable[str] = UNSET,
1910
+ agent_version: OptionalNullable[int] = UNSET,
1856
1911
  model: OptionalNullable[str] = UNSET,
1857
1912
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
1858
1913
  server_url: Optional[str] = None,
@@ -1868,11 +1923,13 @@ class Conversations(BaseSDK):
1868
1923
  :param store:
1869
1924
  :param handoff_execution:
1870
1925
  :param instructions:
1871
- :param tools:
1926
+ :param tools: List of tools which are available to the model during the conversation.
1872
1927
  :param completion_args:
1873
1928
  :param name:
1874
1929
  :param description:
1930
+ :param metadata:
1875
1931
  :param agent_id:
1932
+ :param agent_version:
1876
1933
  :param model:
1877
1934
  :param retries: Override the default retry configuration for this method
1878
1935
  :param server_url: Override the default server URL for this method
@@ -1896,14 +1953,16 @@ class Conversations(BaseSDK):
1896
1953
  handoff_execution=handoff_execution,
1897
1954
  instructions=instructions,
1898
1955
  tools=utils.get_pydantic_model(
1899
- tools, OptionalNullable[List[models.ConversationStreamRequestTools]]
1956
+ tools, Optional[List[models.ConversationStreamRequestTools]]
1900
1957
  ),
1901
1958
  completion_args=utils.get_pydantic_model(
1902
1959
  completion_args, OptionalNullable[models.CompletionArgs]
1903
1960
  ),
1904
1961
  name=name,
1905
1962
  description=description,
1963
+ metadata=metadata,
1906
1964
  agent_id=agent_id,
1965
+ agent_version=agent_version,
1907
1966
  model=model,
1908
1967
  )
1909
1968
 
@@ -1955,32 +2014,23 @@ class Conversations(BaseSDK):
1955
2014
  return eventstreaming.EventStream(
1956
2015
  http_res,
1957
2016
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2017
+ client_ref=self,
1958
2018
  )
1959
2019
  if utils.match_response(http_res, "422", "application/json"):
1960
2020
  http_res_text = utils.stream_to_text(http_res)
1961
- response_data = utils.unmarshal_json(
1962
- http_res_text, models.HTTPValidationErrorData
2021
+ response_data = unmarshal_json_response(
2022
+ models.HTTPValidationErrorData, http_res, http_res_text
1963
2023
  )
1964
- raise models.HTTPValidationError(data=response_data)
2024
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
1965
2025
  if utils.match_response(http_res, "4XX", "*"):
1966
2026
  http_res_text = utils.stream_to_text(http_res)
1967
- raise models.SDKError(
1968
- "API error occurred", http_res.status_code, http_res_text, http_res
1969
- )
2027
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1970
2028
  if utils.match_response(http_res, "5XX", "*"):
1971
2029
  http_res_text = utils.stream_to_text(http_res)
1972
- raise models.SDKError(
1973
- "API error occurred", http_res.status_code, http_res_text, http_res
1974
- )
2030
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1975
2031
 
1976
- content_type = http_res.headers.get("Content-Type")
1977
2032
  http_res_text = utils.stream_to_text(http_res)
1978
- raise models.SDKError(
1979
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1980
- http_res.status_code,
1981
- http_res_text,
1982
- http_res,
1983
- )
2033
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
1984
2034
 
1985
2035
  async def start_stream_async(
1986
2036
  self,
@@ -1992,18 +2042,20 @@ class Conversations(BaseSDK):
1992
2042
  models.ConversationStreamRequestHandoffExecution
1993
2043
  ] = UNSET,
1994
2044
  instructions: OptionalNullable[str] = UNSET,
1995
- tools: OptionalNullable[
2045
+ tools: Optional[
1996
2046
  Union[
1997
2047
  List[models.ConversationStreamRequestTools],
1998
2048
  List[models.ConversationStreamRequestToolsTypedDict],
1999
2049
  ]
2000
- ] = UNSET,
2050
+ ] = None,
2001
2051
  completion_args: OptionalNullable[
2002
2052
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
2003
2053
  ] = UNSET,
2004
2054
  name: OptionalNullable[str] = UNSET,
2005
2055
  description: OptionalNullable[str] = UNSET,
2056
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
2006
2057
  agent_id: OptionalNullable[str] = UNSET,
2058
+ agent_version: OptionalNullable[int] = UNSET,
2007
2059
  model: OptionalNullable[str] = UNSET,
2008
2060
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
2009
2061
  server_url: Optional[str] = None,
@@ -2019,11 +2071,13 @@ class Conversations(BaseSDK):
2019
2071
  :param store:
2020
2072
  :param handoff_execution:
2021
2073
  :param instructions:
2022
- :param tools:
2074
+ :param tools: List of tools which are available to the model during the conversation.
2023
2075
  :param completion_args:
2024
2076
  :param name:
2025
2077
  :param description:
2078
+ :param metadata:
2026
2079
  :param agent_id:
2080
+ :param agent_version:
2027
2081
  :param model:
2028
2082
  :param retries: Override the default retry configuration for this method
2029
2083
  :param server_url: Override the default server URL for this method
@@ -2047,14 +2101,16 @@ class Conversations(BaseSDK):
2047
2101
  handoff_execution=handoff_execution,
2048
2102
  instructions=instructions,
2049
2103
  tools=utils.get_pydantic_model(
2050
- tools, OptionalNullable[List[models.ConversationStreamRequestTools]]
2104
+ tools, Optional[List[models.ConversationStreamRequestTools]]
2051
2105
  ),
2052
2106
  completion_args=utils.get_pydantic_model(
2053
2107
  completion_args, OptionalNullable[models.CompletionArgs]
2054
2108
  ),
2055
2109
  name=name,
2056
2110
  description=description,
2111
+ metadata=metadata,
2057
2112
  agent_id=agent_id,
2113
+ agent_version=agent_version,
2058
2114
  model=model,
2059
2115
  )
2060
2116
 
@@ -2106,32 +2162,23 @@ class Conversations(BaseSDK):
2106
2162
  return eventstreaming.EventStreamAsync(
2107
2163
  http_res,
2108
2164
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2165
+ client_ref=self,
2109
2166
  )
2110
2167
  if utils.match_response(http_res, "422", "application/json"):
2111
2168
  http_res_text = await utils.stream_to_text_async(http_res)
2112
- response_data = utils.unmarshal_json(
2113
- http_res_text, models.HTTPValidationErrorData
2169
+ response_data = unmarshal_json_response(
2170
+ models.HTTPValidationErrorData, http_res, http_res_text
2114
2171
  )
2115
- raise models.HTTPValidationError(data=response_data)
2172
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
2116
2173
  if utils.match_response(http_res, "4XX", "*"):
2117
2174
  http_res_text = await utils.stream_to_text_async(http_res)
2118
- raise models.SDKError(
2119
- "API error occurred", http_res.status_code, http_res_text, http_res
2120
- )
2175
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2121
2176
  if utils.match_response(http_res, "5XX", "*"):
2122
2177
  http_res_text = await utils.stream_to_text_async(http_res)
2123
- raise models.SDKError(
2124
- "API error occurred", http_res.status_code, http_res_text, http_res
2125
- )
2178
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2126
2179
 
2127
- content_type = http_res.headers.get("Content-Type")
2128
2180
  http_res_text = await utils.stream_to_text_async(http_res)
2129
- raise models.SDKError(
2130
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2131
- http_res.status_code,
2132
- http_res_text,
2133
- http_res,
2134
- )
2181
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
2135
2182
 
2136
2183
  def append_stream(
2137
2184
  self,
@@ -2241,32 +2288,23 @@ class Conversations(BaseSDK):
2241
2288
  return eventstreaming.EventStream(
2242
2289
  http_res,
2243
2290
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2291
+ client_ref=self,
2244
2292
  )
2245
2293
  if utils.match_response(http_res, "422", "application/json"):
2246
2294
  http_res_text = utils.stream_to_text(http_res)
2247
- response_data = utils.unmarshal_json(
2248
- http_res_text, models.HTTPValidationErrorData
2295
+ response_data = unmarshal_json_response(
2296
+ models.HTTPValidationErrorData, http_res, http_res_text
2249
2297
  )
2250
- raise models.HTTPValidationError(data=response_data)
2298
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
2251
2299
  if utils.match_response(http_res, "4XX", "*"):
2252
2300
  http_res_text = utils.stream_to_text(http_res)
2253
- raise models.SDKError(
2254
- "API error occurred", http_res.status_code, http_res_text, http_res
2255
- )
2301
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2256
2302
  if utils.match_response(http_res, "5XX", "*"):
2257
2303
  http_res_text = utils.stream_to_text(http_res)
2258
- raise models.SDKError(
2259
- "API error occurred", http_res.status_code, http_res_text, http_res
2260
- )
2304
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2261
2305
 
2262
- content_type = http_res.headers.get("Content-Type")
2263
2306
  http_res_text = utils.stream_to_text(http_res)
2264
- raise models.SDKError(
2265
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2266
- http_res.status_code,
2267
- http_res_text,
2268
- http_res,
2269
- )
2307
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
2270
2308
 
2271
2309
  async def append_stream_async(
2272
2310
  self,
@@ -2376,32 +2414,23 @@ class Conversations(BaseSDK):
2376
2414
  return eventstreaming.EventStreamAsync(
2377
2415
  http_res,
2378
2416
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2417
+ client_ref=self,
2379
2418
  )
2380
2419
  if utils.match_response(http_res, "422", "application/json"):
2381
2420
  http_res_text = await utils.stream_to_text_async(http_res)
2382
- response_data = utils.unmarshal_json(
2383
- http_res_text, models.HTTPValidationErrorData
2421
+ response_data = unmarshal_json_response(
2422
+ models.HTTPValidationErrorData, http_res, http_res_text
2384
2423
  )
2385
- raise models.HTTPValidationError(data=response_data)
2424
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
2386
2425
  if utils.match_response(http_res, "4XX", "*"):
2387
2426
  http_res_text = await utils.stream_to_text_async(http_res)
2388
- raise models.SDKError(
2389
- "API error occurred", http_res.status_code, http_res_text, http_res
2390
- )
2427
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2391
2428
  if utils.match_response(http_res, "5XX", "*"):
2392
2429
  http_res_text = await utils.stream_to_text_async(http_res)
2393
- raise models.SDKError(
2394
- "API error occurred", http_res.status_code, http_res_text, http_res
2395
- )
2430
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2396
2431
 
2397
- content_type = http_res.headers.get("Content-Type")
2398
2432
  http_res_text = await utils.stream_to_text_async(http_res)
2399
- raise models.SDKError(
2400
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2401
- http_res.status_code,
2402
- http_res_text,
2403
- http_res,
2404
- )
2433
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
2405
2434
 
2406
2435
  def restart_stream(
2407
2436
  self,
@@ -2417,6 +2446,8 @@ class Conversations(BaseSDK):
2417
2446
  completion_args: Optional[
2418
2447
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
2419
2448
  ] = None,
2449
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
2450
+ agent_version: OptionalNullable[int] = UNSET,
2420
2451
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
2421
2452
  server_url: Optional[str] = None,
2422
2453
  timeout_ms: Optional[int] = None,
@@ -2433,6 +2464,8 @@ class Conversations(BaseSDK):
2433
2464
  :param store: Whether to store the results into our servers or not.
2434
2465
  :param handoff_execution:
2435
2466
  :param completion_args: White-listed arguments from the completion API
2467
+ :param metadata: Custom metadata for the conversation.
2468
+ :param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
2436
2469
  :param retries: Override the default retry configuration for this method
2437
2470
  :param server_url: Override the default server URL for this method
2438
2471
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -2458,7 +2491,9 @@ class Conversations(BaseSDK):
2458
2491
  completion_args=utils.get_pydantic_model(
2459
2492
  completion_args, Optional[models.CompletionArgs]
2460
2493
  ),
2494
+ metadata=metadata,
2461
2495
  from_entry_id=from_entry_id,
2496
+ agent_version=agent_version,
2462
2497
  ),
2463
2498
  )
2464
2499
 
@@ -2514,32 +2549,23 @@ class Conversations(BaseSDK):
2514
2549
  return eventstreaming.EventStream(
2515
2550
  http_res,
2516
2551
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2552
+ client_ref=self,
2517
2553
  )
2518
2554
  if utils.match_response(http_res, "422", "application/json"):
2519
2555
  http_res_text = utils.stream_to_text(http_res)
2520
- response_data = utils.unmarshal_json(
2521
- http_res_text, models.HTTPValidationErrorData
2556
+ response_data = unmarshal_json_response(
2557
+ models.HTTPValidationErrorData, http_res, http_res_text
2522
2558
  )
2523
- raise models.HTTPValidationError(data=response_data)
2559
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
2524
2560
  if utils.match_response(http_res, "4XX", "*"):
2525
2561
  http_res_text = utils.stream_to_text(http_res)
2526
- raise models.SDKError(
2527
- "API error occurred", http_res.status_code, http_res_text, http_res
2528
- )
2562
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2529
2563
  if utils.match_response(http_res, "5XX", "*"):
2530
2564
  http_res_text = utils.stream_to_text(http_res)
2531
- raise models.SDKError(
2532
- "API error occurred", http_res.status_code, http_res_text, http_res
2533
- )
2565
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2534
2566
 
2535
- content_type = http_res.headers.get("Content-Type")
2536
2567
  http_res_text = utils.stream_to_text(http_res)
2537
- raise models.SDKError(
2538
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2539
- http_res.status_code,
2540
- http_res_text,
2541
- http_res,
2542
- )
2568
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
2543
2569
 
2544
2570
  async def restart_stream_async(
2545
2571
  self,
@@ -2555,6 +2581,8 @@ class Conversations(BaseSDK):
2555
2581
  completion_args: Optional[
2556
2582
  Union[models.CompletionArgs, models.CompletionArgsTypedDict]
2557
2583
  ] = None,
2584
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
2585
+ agent_version: OptionalNullable[int] = UNSET,
2558
2586
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
2559
2587
  server_url: Optional[str] = None,
2560
2588
  timeout_ms: Optional[int] = None,
@@ -2571,6 +2599,8 @@ class Conversations(BaseSDK):
2571
2599
  :param store: Whether to store the results into our servers or not.
2572
2600
  :param handoff_execution:
2573
2601
  :param completion_args: White-listed arguments from the completion API
2602
+ :param metadata: Custom metadata for the conversation.
2603
+ :param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
2574
2604
  :param retries: Override the default retry configuration for this method
2575
2605
  :param server_url: Override the default server URL for this method
2576
2606
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -2596,7 +2626,9 @@ class Conversations(BaseSDK):
2596
2626
  completion_args=utils.get_pydantic_model(
2597
2627
  completion_args, Optional[models.CompletionArgs]
2598
2628
  ),
2629
+ metadata=metadata,
2599
2630
  from_entry_id=from_entry_id,
2631
+ agent_version=agent_version,
2600
2632
  ),
2601
2633
  )
2602
2634
 
@@ -2652,29 +2684,20 @@ class Conversations(BaseSDK):
2652
2684
  return eventstreaming.EventStreamAsync(
2653
2685
  http_res,
2654
2686
  lambda raw: utils.unmarshal_json(raw, models.ConversationEvents),
2687
+ client_ref=self,
2655
2688
  )
2656
2689
  if utils.match_response(http_res, "422", "application/json"):
2657
2690
  http_res_text = await utils.stream_to_text_async(http_res)
2658
- response_data = utils.unmarshal_json(
2659
- http_res_text, models.HTTPValidationErrorData
2691
+ response_data = unmarshal_json_response(
2692
+ models.HTTPValidationErrorData, http_res, http_res_text
2660
2693
  )
2661
- raise models.HTTPValidationError(data=response_data)
2694
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
2662
2695
  if utils.match_response(http_res, "4XX", "*"):
2663
2696
  http_res_text = await utils.stream_to_text_async(http_res)
2664
- raise models.SDKError(
2665
- "API error occurred", http_res.status_code, http_res_text, http_res
2666
- )
2697
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2667
2698
  if utils.match_response(http_res, "5XX", "*"):
2668
2699
  http_res_text = await utils.stream_to_text_async(http_res)
2669
- raise models.SDKError(
2670
- "API error occurred", http_res.status_code, http_res_text, http_res
2671
- )
2700
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2672
2701
 
2673
- content_type = http_res.headers.get("Content-Type")
2674
2702
  http_res_text = await utils.stream_to_text_async(http_res)
2675
- raise models.SDKError(
2676
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2677
- http_res.status_code,
2678
- http_res_text,
2679
- http_res,
2680
- )
2703
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)