syllable-sdk 0.35.27__py3-none-any.whl → 0.35.31__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 (51) hide show
  1. syllable_sdk/_version.py +3 -3
  2. syllable_sdk/agents.py +210 -82
  3. syllable_sdk/basesdk.py +4 -4
  4. syllable_sdk/batches.py +328 -130
  5. syllable_sdk/campaigns.py +182 -72
  6. syllable_sdk/channels.py +72 -28
  7. syllable_sdk/conversations.py +36 -18
  8. syllable_sdk/custom_messages.py +182 -72
  9. syllable_sdk/dashboards.py +194 -66
  10. syllable_sdk/data_sources.py +182 -84
  11. syllable_sdk/events.py +36 -14
  12. syllable_sdk/folders.py +292 -120
  13. syllable_sdk/full_summary.py +36 -18
  14. syllable_sdk/incidents.py +214 -82
  15. syllable_sdk/insights_sdk.py +38 -16
  16. syllable_sdk/insights_tools.py +250 -96
  17. syllable_sdk/language_groups.py +214 -84
  18. syllable_sdk/latency.py +36 -18
  19. syllable_sdk/models/__init__.py +6 -19
  20. syllable_sdk/models/apierror.py +14 -30
  21. syllable_sdk/models/dialogtoolcall.py +37 -1
  22. syllable_sdk/models/httpvalidationerror.py +6 -11
  23. syllable_sdk/models/testmessageresponse.py +38 -15
  24. syllable_sdk/models/tooldefinition.py +10 -2
  25. syllable_sdk/models/tooloptions.py +20 -0
  26. syllable_sdk/numbers.py +110 -52
  27. syllable_sdk/organizations.py +138 -50
  28. syllable_sdk/permissions.py +32 -10
  29. syllable_sdk/prompts.py +248 -94
  30. syllable_sdk/roles.py +180 -74
  31. syllable_sdk/services.py +182 -72
  32. syllable_sdk/session_debug.py +108 -42
  33. syllable_sdk/session_labels.py +108 -46
  34. syllable_sdk/sessions.py +140 -58
  35. syllable_sdk/takeouts.py +98 -34
  36. syllable_sdk/targets.py +184 -74
  37. syllable_sdk/test.py +36 -14
  38. syllable_sdk/tools.py +180 -74
  39. syllable_sdk/transcript.py +38 -16
  40. syllable_sdk/twilio.py +108 -42
  41. syllable_sdk/users.py +246 -96
  42. syllable_sdk/utils/__init__.py +0 -3
  43. syllable_sdk/utils/serializers.py +3 -21
  44. syllable_sdk/v1.py +246 -96
  45. syllable_sdk/workflows.py +290 -114
  46. {syllable_sdk-0.35.27.dist-info → syllable_sdk-0.35.31.dist-info}/METADATA +24 -44
  47. {syllable_sdk-0.35.27.dist-info → syllable_sdk-0.35.31.dist-info}/RECORD +48 -50
  48. syllable_sdk/models/no_response_error.py +0 -13
  49. syllable_sdk/models/responsevalidationerror.py +0 -25
  50. syllable_sdk/models/syllablesdkerror.py +0 -26
  51. {syllable_sdk-0.35.27.dist-info → syllable_sdk-0.35.31.dist-info}/WHEEL +0 -0
@@ -109,22 +109,33 @@ class DataSources(BaseSDK):
109
109
 
110
110
  response_data: Any = None
111
111
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json_response(
113
- models.ListResponseDataSourceMetadataResponse, http_res
112
+ return utils.unmarshal_json(
113
+ http_res.text, models.ListResponseDataSourceMetadataResponse
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json_response(
117
- models.HTTPValidationErrorData, http_res
116
+ response_data = utils.unmarshal_json(
117
+ http_res.text, models.HTTPValidationErrorData
118
118
  )
119
- raise models.HTTPValidationError(response_data, http_res)
119
+ raise models.HTTPValidationError(data=response_data)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError("API error occurred", http_res, http_res_text)
122
+ raise models.APIError(
123
+ "API error occurred", http_res.status_code, http_res_text, http_res
124
+ )
123
125
  if utils.match_response(http_res, "5XX", "*"):
124
126
  http_res_text = utils.stream_to_text(http_res)
125
- raise models.APIError("API error occurred", http_res, http_res_text)
127
+ raise models.APIError(
128
+ "API error occurred", http_res.status_code, http_res_text, http_res
129
+ )
126
130
 
127
- raise models.APIError("Unexpected response received", http_res)
131
+ content_type = http_res.headers.get("Content-Type")
132
+ http_res_text = utils.stream_to_text(http_res)
133
+ raise models.APIError(
134
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
135
+ http_res.status_code,
136
+ http_res_text,
137
+ http_res,
138
+ )
128
139
 
129
140
  async def list_async(
130
141
  self,
@@ -224,22 +235,33 @@ class DataSources(BaseSDK):
224
235
 
225
236
  response_data: Any = None
226
237
  if utils.match_response(http_res, "200", "application/json"):
227
- return utils.unmarshal_json_response(
228
- models.ListResponseDataSourceMetadataResponse, http_res
238
+ return utils.unmarshal_json(
239
+ http_res.text, models.ListResponseDataSourceMetadataResponse
229
240
  )
230
241
  if utils.match_response(http_res, "422", "application/json"):
231
- response_data = utils.unmarshal_json_response(
232
- models.HTTPValidationErrorData, http_res
242
+ response_data = utils.unmarshal_json(
243
+ http_res.text, models.HTTPValidationErrorData
233
244
  )
234
- raise models.HTTPValidationError(response_data, http_res)
245
+ raise models.HTTPValidationError(data=response_data)
235
246
  if utils.match_response(http_res, "4XX", "*"):
236
247
  http_res_text = await utils.stream_to_text_async(http_res)
237
- raise models.APIError("API error occurred", http_res, http_res_text)
248
+ raise models.APIError(
249
+ "API error occurred", http_res.status_code, http_res_text, http_res
250
+ )
238
251
  if utils.match_response(http_res, "5XX", "*"):
239
252
  http_res_text = await utils.stream_to_text_async(http_res)
240
- raise models.APIError("API error occurred", http_res, http_res_text)
253
+ raise models.APIError(
254
+ "API error occurred", http_res.status_code, http_res_text, http_res
255
+ )
241
256
 
242
- raise models.APIError("Unexpected response received", http_res)
257
+ content_type = http_res.headers.get("Content-Type")
258
+ http_res_text = await utils.stream_to_text_async(http_res)
259
+ raise models.APIError(
260
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
261
+ http_res.status_code,
262
+ http_res_text,
263
+ http_res,
264
+ )
243
265
 
244
266
  def create(
245
267
  self,
@@ -320,22 +342,31 @@ class DataSources(BaseSDK):
320
342
 
321
343
  response_data: Any = None
322
344
  if utils.match_response(http_res, "200", "application/json"):
323
- return utils.unmarshal_json_response(
324
- models.DataSourceDetailResponse, http_res
325
- )
345
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
326
346
  if utils.match_response(http_res, "422", "application/json"):
327
- response_data = utils.unmarshal_json_response(
328
- models.HTTPValidationErrorData, http_res
347
+ response_data = utils.unmarshal_json(
348
+ http_res.text, models.HTTPValidationErrorData
329
349
  )
330
- raise models.HTTPValidationError(response_data, http_res)
350
+ raise models.HTTPValidationError(data=response_data)
331
351
  if utils.match_response(http_res, "4XX", "*"):
332
352
  http_res_text = utils.stream_to_text(http_res)
333
- raise models.APIError("API error occurred", http_res, http_res_text)
353
+ raise models.APIError(
354
+ "API error occurred", http_res.status_code, http_res_text, http_res
355
+ )
334
356
  if utils.match_response(http_res, "5XX", "*"):
335
357
  http_res_text = utils.stream_to_text(http_res)
336
- raise models.APIError("API error occurred", http_res, http_res_text)
358
+ raise models.APIError(
359
+ "API error occurred", http_res.status_code, http_res_text, http_res
360
+ )
337
361
 
338
- raise models.APIError("Unexpected response received", http_res)
362
+ content_type = http_res.headers.get("Content-Type")
363
+ http_res_text = utils.stream_to_text(http_res)
364
+ raise models.APIError(
365
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
366
+ http_res.status_code,
367
+ http_res_text,
368
+ http_res,
369
+ )
339
370
 
340
371
  async def create_async(
341
372
  self,
@@ -416,22 +447,31 @@ class DataSources(BaseSDK):
416
447
 
417
448
  response_data: Any = None
418
449
  if utils.match_response(http_res, "200", "application/json"):
419
- return utils.unmarshal_json_response(
420
- models.DataSourceDetailResponse, http_res
421
- )
450
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
422
451
  if utils.match_response(http_res, "422", "application/json"):
423
- response_data = utils.unmarshal_json_response(
424
- models.HTTPValidationErrorData, http_res
452
+ response_data = utils.unmarshal_json(
453
+ http_res.text, models.HTTPValidationErrorData
425
454
  )
426
- raise models.HTTPValidationError(response_data, http_res)
455
+ raise models.HTTPValidationError(data=response_data)
427
456
  if utils.match_response(http_res, "4XX", "*"):
428
457
  http_res_text = await utils.stream_to_text_async(http_res)
429
- raise models.APIError("API error occurred", http_res, http_res_text)
458
+ raise models.APIError(
459
+ "API error occurred", http_res.status_code, http_res_text, http_res
460
+ )
430
461
  if utils.match_response(http_res, "5XX", "*"):
431
462
  http_res_text = await utils.stream_to_text_async(http_res)
432
- raise models.APIError("API error occurred", http_res, http_res_text)
463
+ raise models.APIError(
464
+ "API error occurred", http_res.status_code, http_res_text, http_res
465
+ )
433
466
 
434
- raise models.APIError("Unexpected response received", http_res)
467
+ content_type = http_res.headers.get("Content-Type")
468
+ http_res_text = await utils.stream_to_text_async(http_res)
469
+ raise models.APIError(
470
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
471
+ http_res.status_code,
472
+ http_res_text,
473
+ http_res,
474
+ )
435
475
 
436
476
  def update(
437
477
  self,
@@ -512,22 +552,31 @@ class DataSources(BaseSDK):
512
552
 
513
553
  response_data: Any = None
514
554
  if utils.match_response(http_res, "200", "application/json"):
515
- return utils.unmarshal_json_response(
516
- models.DataSourceDetailResponse, http_res
517
- )
555
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
518
556
  if utils.match_response(http_res, "422", "application/json"):
519
- response_data = utils.unmarshal_json_response(
520
- models.HTTPValidationErrorData, http_res
557
+ response_data = utils.unmarshal_json(
558
+ http_res.text, models.HTTPValidationErrorData
521
559
  )
522
- raise models.HTTPValidationError(response_data, http_res)
560
+ raise models.HTTPValidationError(data=response_data)
523
561
  if utils.match_response(http_res, "4XX", "*"):
524
562
  http_res_text = utils.stream_to_text(http_res)
525
- raise models.APIError("API error occurred", http_res, http_res_text)
563
+ raise models.APIError(
564
+ "API error occurred", http_res.status_code, http_res_text, http_res
565
+ )
526
566
  if utils.match_response(http_res, "5XX", "*"):
527
567
  http_res_text = utils.stream_to_text(http_res)
528
- raise models.APIError("API error occurred", http_res, http_res_text)
568
+ raise models.APIError(
569
+ "API error occurred", http_res.status_code, http_res_text, http_res
570
+ )
529
571
 
530
- raise models.APIError("Unexpected response received", http_res)
572
+ content_type = http_res.headers.get("Content-Type")
573
+ http_res_text = utils.stream_to_text(http_res)
574
+ raise models.APIError(
575
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
576
+ http_res.status_code,
577
+ http_res_text,
578
+ http_res,
579
+ )
531
580
 
532
581
  async def update_async(
533
582
  self,
@@ -608,22 +657,31 @@ class DataSources(BaseSDK):
608
657
 
609
658
  response_data: Any = None
610
659
  if utils.match_response(http_res, "200", "application/json"):
611
- return utils.unmarshal_json_response(
612
- models.DataSourceDetailResponse, http_res
613
- )
660
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
614
661
  if utils.match_response(http_res, "422", "application/json"):
615
- response_data = utils.unmarshal_json_response(
616
- models.HTTPValidationErrorData, http_res
662
+ response_data = utils.unmarshal_json(
663
+ http_res.text, models.HTTPValidationErrorData
617
664
  )
618
- raise models.HTTPValidationError(response_data, http_res)
665
+ raise models.HTTPValidationError(data=response_data)
619
666
  if utils.match_response(http_res, "4XX", "*"):
620
667
  http_res_text = await utils.stream_to_text_async(http_res)
621
- raise models.APIError("API error occurred", http_res, http_res_text)
668
+ raise models.APIError(
669
+ "API error occurred", http_res.status_code, http_res_text, http_res
670
+ )
622
671
  if utils.match_response(http_res, "5XX", "*"):
623
672
  http_res_text = await utils.stream_to_text_async(http_res)
624
- raise models.APIError("API error occurred", http_res, http_res_text)
673
+ raise models.APIError(
674
+ "API error occurred", http_res.status_code, http_res_text, http_res
675
+ )
625
676
 
626
- raise models.APIError("Unexpected response received", http_res)
677
+ content_type = http_res.headers.get("Content-Type")
678
+ http_res_text = await utils.stream_to_text_async(http_res)
679
+ raise models.APIError(
680
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
681
+ http_res.status_code,
682
+ http_res_text,
683
+ http_res,
684
+ )
627
685
 
628
686
  def get_by_id(
629
687
  self,
@@ -699,22 +757,31 @@ class DataSources(BaseSDK):
699
757
 
700
758
  response_data: Any = None
701
759
  if utils.match_response(http_res, "200", "application/json"):
702
- return utils.unmarshal_json_response(
703
- models.DataSourceDetailResponse, http_res
704
- )
760
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
705
761
  if utils.match_response(http_res, "422", "application/json"):
706
- response_data = utils.unmarshal_json_response(
707
- models.HTTPValidationErrorData, http_res
762
+ response_data = utils.unmarshal_json(
763
+ http_res.text, models.HTTPValidationErrorData
708
764
  )
709
- raise models.HTTPValidationError(response_data, http_res)
765
+ raise models.HTTPValidationError(data=response_data)
710
766
  if utils.match_response(http_res, "4XX", "*"):
711
767
  http_res_text = utils.stream_to_text(http_res)
712
- raise models.APIError("API error occurred", http_res, http_res_text)
768
+ raise models.APIError(
769
+ "API error occurred", http_res.status_code, http_res_text, http_res
770
+ )
713
771
  if utils.match_response(http_res, "5XX", "*"):
714
772
  http_res_text = utils.stream_to_text(http_res)
715
- raise models.APIError("API error occurred", http_res, http_res_text)
773
+ raise models.APIError(
774
+ "API error occurred", http_res.status_code, http_res_text, http_res
775
+ )
716
776
 
717
- raise models.APIError("Unexpected response received", http_res)
777
+ content_type = http_res.headers.get("Content-Type")
778
+ http_res_text = utils.stream_to_text(http_res)
779
+ raise models.APIError(
780
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
781
+ http_res.status_code,
782
+ http_res_text,
783
+ http_res,
784
+ )
718
785
 
719
786
  async def get_by_id_async(
720
787
  self,
@@ -790,22 +857,31 @@ class DataSources(BaseSDK):
790
857
 
791
858
  response_data: Any = None
792
859
  if utils.match_response(http_res, "200", "application/json"):
793
- return utils.unmarshal_json_response(
794
- models.DataSourceDetailResponse, http_res
795
- )
860
+ return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
796
861
  if utils.match_response(http_res, "422", "application/json"):
797
- response_data = utils.unmarshal_json_response(
798
- models.HTTPValidationErrorData, http_res
862
+ response_data = utils.unmarshal_json(
863
+ http_res.text, models.HTTPValidationErrorData
799
864
  )
800
- raise models.HTTPValidationError(response_data, http_res)
865
+ raise models.HTTPValidationError(data=response_data)
801
866
  if utils.match_response(http_res, "4XX", "*"):
802
867
  http_res_text = await utils.stream_to_text_async(http_res)
803
- raise models.APIError("API error occurred", http_res, http_res_text)
868
+ raise models.APIError(
869
+ "API error occurred", http_res.status_code, http_res_text, http_res
870
+ )
804
871
  if utils.match_response(http_res, "5XX", "*"):
805
872
  http_res_text = await utils.stream_to_text_async(http_res)
806
- raise models.APIError("API error occurred", http_res, http_res_text)
873
+ raise models.APIError(
874
+ "API error occurred", http_res.status_code, http_res_text, http_res
875
+ )
807
876
 
808
- raise models.APIError("Unexpected response received", http_res)
877
+ content_type = http_res.headers.get("Content-Type")
878
+ http_res_text = await utils.stream_to_text_async(http_res)
879
+ raise models.APIError(
880
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
881
+ http_res.status_code,
882
+ http_res_text,
883
+ http_res,
884
+ )
809
885
 
810
886
  def delete(
811
887
  self,
@@ -884,20 +960,31 @@ class DataSources(BaseSDK):
884
960
 
885
961
  response_data: Any = None
886
962
  if utils.match_response(http_res, "200", "application/json"):
887
- return utils.unmarshal_json_response(Any, http_res)
963
+ return utils.unmarshal_json(http_res.text, Any)
888
964
  if utils.match_response(http_res, "422", "application/json"):
889
- response_data = utils.unmarshal_json_response(
890
- models.HTTPValidationErrorData, http_res
965
+ response_data = utils.unmarshal_json(
966
+ http_res.text, models.HTTPValidationErrorData
891
967
  )
892
- raise models.HTTPValidationError(response_data, http_res)
968
+ raise models.HTTPValidationError(data=response_data)
893
969
  if utils.match_response(http_res, "4XX", "*"):
894
970
  http_res_text = utils.stream_to_text(http_res)
895
- raise models.APIError("API error occurred", http_res, http_res_text)
971
+ raise models.APIError(
972
+ "API error occurred", http_res.status_code, http_res_text, http_res
973
+ )
896
974
  if utils.match_response(http_res, "5XX", "*"):
897
975
  http_res_text = utils.stream_to_text(http_res)
898
- raise models.APIError("API error occurred", http_res, http_res_text)
976
+ raise models.APIError(
977
+ "API error occurred", http_res.status_code, http_res_text, http_res
978
+ )
899
979
 
900
- raise models.APIError("Unexpected response received", http_res)
980
+ content_type = http_res.headers.get("Content-Type")
981
+ http_res_text = utils.stream_to_text(http_res)
982
+ raise models.APIError(
983
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
984
+ http_res.status_code,
985
+ http_res_text,
986
+ http_res,
987
+ )
901
988
 
902
989
  async def delete_async(
903
990
  self,
@@ -976,17 +1063,28 @@ class DataSources(BaseSDK):
976
1063
 
977
1064
  response_data: Any = None
978
1065
  if utils.match_response(http_res, "200", "application/json"):
979
- return utils.unmarshal_json_response(Any, http_res)
1066
+ return utils.unmarshal_json(http_res.text, Any)
980
1067
  if utils.match_response(http_res, "422", "application/json"):
981
- response_data = utils.unmarshal_json_response(
982
- models.HTTPValidationErrorData, http_res
1068
+ response_data = utils.unmarshal_json(
1069
+ http_res.text, models.HTTPValidationErrorData
983
1070
  )
984
- raise models.HTTPValidationError(response_data, http_res)
1071
+ raise models.HTTPValidationError(data=response_data)
985
1072
  if utils.match_response(http_res, "4XX", "*"):
986
1073
  http_res_text = await utils.stream_to_text_async(http_res)
987
- raise models.APIError("API error occurred", http_res, http_res_text)
1074
+ raise models.APIError(
1075
+ "API error occurred", http_res.status_code, http_res_text, http_res
1076
+ )
988
1077
  if utils.match_response(http_res, "5XX", "*"):
989
1078
  http_res_text = await utils.stream_to_text_async(http_res)
990
- raise models.APIError("API error occurred", http_res, http_res_text)
1079
+ raise models.APIError(
1080
+ "API error occurred", http_res.status_code, http_res_text, http_res
1081
+ )
991
1082
 
992
- raise models.APIError("Unexpected response received", http_res)
1083
+ content_type = http_res.headers.get("Content-Type")
1084
+ http_res_text = await utils.stream_to_text_async(http_res)
1085
+ raise models.APIError(
1086
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1087
+ http_res.status_code,
1088
+ http_res_text,
1089
+ http_res,
1090
+ )
syllable_sdk/events.py CHANGED
@@ -107,20 +107,31 @@ class Events(BaseSDK):
107
107
 
108
108
  response_data: Any = None
109
109
  if utils.match_response(http_res, "200", "application/json"):
110
- return utils.unmarshal_json_response(models.ListResponseEvent, http_res)
110
+ return utils.unmarshal_json(http_res.text, models.ListResponseEvent)
111
111
  if utils.match_response(http_res, "422", "application/json"):
112
- response_data = utils.unmarshal_json_response(
113
- models.HTTPValidationErrorData, http_res
112
+ response_data = utils.unmarshal_json(
113
+ http_res.text, models.HTTPValidationErrorData
114
114
  )
115
- raise models.HTTPValidationError(response_data, http_res)
115
+ raise models.HTTPValidationError(data=response_data)
116
116
  if utils.match_response(http_res, "4XX", "*"):
117
117
  http_res_text = utils.stream_to_text(http_res)
118
- raise models.APIError("API error occurred", http_res, http_res_text)
118
+ raise models.APIError(
119
+ "API error occurred", http_res.status_code, http_res_text, http_res
120
+ )
119
121
  if utils.match_response(http_res, "5XX", "*"):
120
122
  http_res_text = utils.stream_to_text(http_res)
121
- raise models.APIError("API error occurred", http_res, http_res_text)
123
+ raise models.APIError(
124
+ "API error occurred", http_res.status_code, http_res_text, http_res
125
+ )
122
126
 
123
- raise models.APIError("Unexpected response received", http_res)
127
+ content_type = http_res.headers.get("Content-Type")
128
+ http_res_text = utils.stream_to_text(http_res)
129
+ raise models.APIError(
130
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
131
+ http_res.status_code,
132
+ http_res_text,
133
+ http_res,
134
+ )
124
135
 
125
136
  async def list_async(
126
137
  self,
@@ -218,17 +229,28 @@ class Events(BaseSDK):
218
229
 
219
230
  response_data: Any = None
220
231
  if utils.match_response(http_res, "200", "application/json"):
221
- return utils.unmarshal_json_response(models.ListResponseEvent, http_res)
232
+ return utils.unmarshal_json(http_res.text, models.ListResponseEvent)
222
233
  if utils.match_response(http_res, "422", "application/json"):
223
- response_data = utils.unmarshal_json_response(
224
- models.HTTPValidationErrorData, http_res
234
+ response_data = utils.unmarshal_json(
235
+ http_res.text, models.HTTPValidationErrorData
225
236
  )
226
- raise models.HTTPValidationError(response_data, http_res)
237
+ raise models.HTTPValidationError(data=response_data)
227
238
  if utils.match_response(http_res, "4XX", "*"):
228
239
  http_res_text = await utils.stream_to_text_async(http_res)
229
- raise models.APIError("API error occurred", http_res, http_res_text)
240
+ raise models.APIError(
241
+ "API error occurred", http_res.status_code, http_res_text, http_res
242
+ )
230
243
  if utils.match_response(http_res, "5XX", "*"):
231
244
  http_res_text = await utils.stream_to_text_async(http_res)
232
- raise models.APIError("API error occurred", http_res, http_res_text)
245
+ raise models.APIError(
246
+ "API error occurred", http_res.status_code, http_res_text, http_res
247
+ )
233
248
 
234
- raise models.APIError("Unexpected response received", http_res)
249
+ content_type = http_res.headers.get("Content-Type")
250
+ http_res_text = await utils.stream_to_text_async(http_res)
251
+ raise models.APIError(
252
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
253
+ http_res.status_code,
254
+ http_res_text,
255
+ http_res,
256
+ )