syllable-sdk 0.35.32__py3-none-any.whl → 0.35.33__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/__init__.py +0 -1
  2. syllable_sdk/_version.py +3 -3
  3. syllable_sdk/agents.py +83 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +131 -329
  6. syllable_sdk/campaigns.py +73 -183
  7. syllable_sdk/channels.py +29 -73
  8. syllable_sdk/conversations.py +19 -37
  9. syllable_sdk/custom_messages.py +73 -183
  10. syllable_sdk/dashboards.py +67 -195
  11. syllable_sdk/data_sources.py +85 -183
  12. syllable_sdk/errors/__init__.py +55 -0
  13. syllable_sdk/errors/apierror.py +38 -0
  14. syllable_sdk/errors/httpvalidationerror.py +26 -0
  15. syllable_sdk/errors/no_response_error.py +13 -0
  16. syllable_sdk/errors/responsevalidationerror.py +25 -0
  17. syllable_sdk/errors/syllablesdkerror.py +26 -0
  18. syllable_sdk/events.py +15 -37
  19. syllable_sdk/folders.py +121 -293
  20. syllable_sdk/full_summary.py +19 -37
  21. syllable_sdk/incidents.py +83 -215
  22. syllable_sdk/insights_sdk.py +17 -39
  23. syllable_sdk/insights_tools.py +97 -251
  24. syllable_sdk/language_groups.py +85 -215
  25. syllable_sdk/latency.py +19 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +53 -111
  28. syllable_sdk/organizations.py +51 -139
  29. syllable_sdk/permissions.py +11 -33
  30. syllable_sdk/prompts.py +95 -249
  31. syllable_sdk/roles.py +75 -181
  32. syllable_sdk/services.py +73 -183
  33. syllable_sdk/session_debug.py +43 -109
  34. syllable_sdk/session_labels.py +47 -109
  35. syllable_sdk/sessions.py +59 -141
  36. syllable_sdk/takeouts.py +35 -99
  37. syllable_sdk/targets.py +75 -185
  38. syllable_sdk/test.py +15 -37
  39. syllable_sdk/tools.py +75 -181
  40. syllable_sdk/transcript.py +17 -39
  41. syllable_sdk/twilio.py +43 -109
  42. syllable_sdk/users.py +97 -247
  43. syllable_sdk/utils/__init__.py +3 -0
  44. syllable_sdk/utils/serializers.py +21 -3
  45. syllable_sdk/v1.py +97 -247
  46. syllable_sdk/workflows.py +115 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
  49. syllable_sdk/models/apierror.py +0 -22
  50. syllable_sdk/models/httpvalidationerror.py +0 -21
  51. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
syllable_sdk/prompts.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -109,33 +109,22 @@ class Prompts(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(
113
- http_res.text, models.ListResponsePromptResponse
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponsePromptResponse, http_res
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
116
+ response_data = utils.unmarshal_json_response(
117
+ errors.HTTPValidationErrorData, http_res
118
118
  )
119
- raise models.HTTPValidationError(data=response_data)
119
+ raise errors.HTTPValidationError(response_data, http_res)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError(
123
- "API error occurred", http_res.status_code, http_res_text, http_res
124
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
123
  if utils.match_response(http_res, "5XX", "*"):
126
124
  http_res_text = utils.stream_to_text(http_res)
127
- raise models.APIError(
128
- "API error occurred", http_res.status_code, http_res_text, http_res
129
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
126
 
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
- )
127
+ raise errors.APIError("Unexpected response received", http_res)
139
128
 
140
129
  async def list_async(
141
130
  self,
@@ -235,33 +224,22 @@ class Prompts(BaseSDK):
235
224
 
236
225
  response_data: Any = None
237
226
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponsePromptResponse
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponsePromptResponse, http_res
240
229
  )
241
230
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
231
+ response_data = utils.unmarshal_json_response(
232
+ errors.HTTPValidationErrorData, http_res
244
233
  )
245
- raise models.HTTPValidationError(data=response_data)
234
+ raise errors.HTTPValidationError(response_data, http_res)
246
235
  if utils.match_response(http_res, "4XX", "*"):
247
236
  http_res_text = await utils.stream_to_text_async(http_res)
248
- raise models.APIError(
249
- "API error occurred", http_res.status_code, http_res_text, http_res
250
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
238
  if utils.match_response(http_res, "5XX", "*"):
252
239
  http_res_text = await utils.stream_to_text_async(http_res)
253
- raise models.APIError(
254
- "API error occurred", http_res.status_code, http_res_text, http_res
255
- )
240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
241
 
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
- )
242
+ raise errors.APIError("Unexpected response received", http_res)
265
243
 
266
244
  def create(
267
245
  self,
@@ -340,31 +318,20 @@ class Prompts(BaseSDK):
340
318
 
341
319
  response_data: Any = None
342
320
  if utils.match_response(http_res, "200", "application/json"):
343
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
321
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
344
322
  if utils.match_response(http_res, "422", "application/json"):
345
- response_data = utils.unmarshal_json(
346
- http_res.text, models.HTTPValidationErrorData
323
+ response_data = utils.unmarshal_json_response(
324
+ errors.HTTPValidationErrorData, http_res
347
325
  )
348
- raise models.HTTPValidationError(data=response_data)
326
+ raise errors.HTTPValidationError(response_data, http_res)
349
327
  if utils.match_response(http_res, "4XX", "*"):
350
328
  http_res_text = utils.stream_to_text(http_res)
351
- raise models.APIError(
352
- "API error occurred", http_res.status_code, http_res_text, http_res
353
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
354
330
  if utils.match_response(http_res, "5XX", "*"):
355
331
  http_res_text = utils.stream_to_text(http_res)
356
- raise models.APIError(
357
- "API error occurred", http_res.status_code, http_res_text, http_res
358
- )
332
+ raise errors.APIError("API error occurred", http_res, http_res_text)
359
333
 
360
- content_type = http_res.headers.get("Content-Type")
361
- http_res_text = utils.stream_to_text(http_res)
362
- raise models.APIError(
363
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
364
- http_res.status_code,
365
- http_res_text,
366
- http_res,
367
- )
334
+ raise errors.APIError("Unexpected response received", http_res)
368
335
 
369
336
  async def create_async(
370
337
  self,
@@ -443,31 +410,20 @@ class Prompts(BaseSDK):
443
410
 
444
411
  response_data: Any = None
445
412
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
413
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
447
414
  if utils.match_response(http_res, "422", "application/json"):
448
- response_data = utils.unmarshal_json(
449
- http_res.text, models.HTTPValidationErrorData
415
+ response_data = utils.unmarshal_json_response(
416
+ errors.HTTPValidationErrorData, http_res
450
417
  )
451
- raise models.HTTPValidationError(data=response_data)
418
+ raise errors.HTTPValidationError(response_data, http_res)
452
419
  if utils.match_response(http_res, "4XX", "*"):
453
420
  http_res_text = await utils.stream_to_text_async(http_res)
454
- raise models.APIError(
455
- "API error occurred", http_res.status_code, http_res_text, http_res
456
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
457
422
  if utils.match_response(http_res, "5XX", "*"):
458
423
  http_res_text = await utils.stream_to_text_async(http_res)
459
- raise models.APIError(
460
- "API error occurred", http_res.status_code, http_res_text, http_res
461
- )
424
+ raise errors.APIError("API error occurred", http_res, http_res_text)
462
425
 
463
- content_type = http_res.headers.get("Content-Type")
464
- http_res_text = await utils.stream_to_text_async(http_res)
465
- raise models.APIError(
466
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
467
- http_res.status_code,
468
- http_res_text,
469
- http_res,
470
- )
426
+ raise errors.APIError("Unexpected response received", http_res)
471
427
 
472
428
  def update(
473
429
  self,
@@ -546,31 +502,20 @@ class Prompts(BaseSDK):
546
502
 
547
503
  response_data: Any = None
548
504
  if utils.match_response(http_res, "200", "application/json"):
549
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
505
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
550
506
  if utils.match_response(http_res, "422", "application/json"):
551
- response_data = utils.unmarshal_json(
552
- http_res.text, models.HTTPValidationErrorData
507
+ response_data = utils.unmarshal_json_response(
508
+ errors.HTTPValidationErrorData, http_res
553
509
  )
554
- raise models.HTTPValidationError(data=response_data)
510
+ raise errors.HTTPValidationError(response_data, http_res)
555
511
  if utils.match_response(http_res, "4XX", "*"):
556
512
  http_res_text = utils.stream_to_text(http_res)
557
- raise models.APIError(
558
- "API error occurred", http_res.status_code, http_res_text, http_res
559
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
560
514
  if utils.match_response(http_res, "5XX", "*"):
561
515
  http_res_text = utils.stream_to_text(http_res)
562
- raise models.APIError(
563
- "API error occurred", http_res.status_code, http_res_text, http_res
564
- )
516
+ raise errors.APIError("API error occurred", http_res, http_res_text)
565
517
 
566
- content_type = http_res.headers.get("Content-Type")
567
- http_res_text = utils.stream_to_text(http_res)
568
- raise models.APIError(
569
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
570
- http_res.status_code,
571
- http_res_text,
572
- http_res,
573
- )
518
+ raise errors.APIError("Unexpected response received", http_res)
574
519
 
575
520
  async def update_async(
576
521
  self,
@@ -649,31 +594,20 @@ class Prompts(BaseSDK):
649
594
 
650
595
  response_data: Any = None
651
596
  if utils.match_response(http_res, "200", "application/json"):
652
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
597
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
653
598
  if utils.match_response(http_res, "422", "application/json"):
654
- response_data = utils.unmarshal_json(
655
- http_res.text, models.HTTPValidationErrorData
599
+ response_data = utils.unmarshal_json_response(
600
+ errors.HTTPValidationErrorData, http_res
656
601
  )
657
- raise models.HTTPValidationError(data=response_data)
602
+ raise errors.HTTPValidationError(response_data, http_res)
658
603
  if utils.match_response(http_res, "4XX", "*"):
659
604
  http_res_text = await utils.stream_to_text_async(http_res)
660
- raise models.APIError(
661
- "API error occurred", http_res.status_code, http_res_text, http_res
662
- )
605
+ raise errors.APIError("API error occurred", http_res, http_res_text)
663
606
  if utils.match_response(http_res, "5XX", "*"):
664
607
  http_res_text = await utils.stream_to_text_async(http_res)
665
- raise models.APIError(
666
- "API error occurred", http_res.status_code, http_res_text, http_res
667
- )
608
+ raise errors.APIError("API error occurred", http_res, http_res_text)
668
609
 
669
- content_type = http_res.headers.get("Content-Type")
670
- http_res_text = await utils.stream_to_text_async(http_res)
671
- raise models.APIError(
672
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
673
- http_res.status_code,
674
- http_res_text,
675
- http_res,
676
- )
610
+ raise errors.APIError("Unexpected response received", http_res)
677
611
 
678
612
  def get_by_id(
679
613
  self,
@@ -749,31 +683,20 @@ class Prompts(BaseSDK):
749
683
 
750
684
  response_data: Any = None
751
685
  if utils.match_response(http_res, "200", "application/json"):
752
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
686
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
753
687
  if utils.match_response(http_res, "422", "application/json"):
754
- response_data = utils.unmarshal_json(
755
- http_res.text, models.HTTPValidationErrorData
688
+ response_data = utils.unmarshal_json_response(
689
+ errors.HTTPValidationErrorData, http_res
756
690
  )
757
- raise models.HTTPValidationError(data=response_data)
691
+ raise errors.HTTPValidationError(response_data, http_res)
758
692
  if utils.match_response(http_res, "4XX", "*"):
759
693
  http_res_text = utils.stream_to_text(http_res)
760
- raise models.APIError(
761
- "API error occurred", http_res.status_code, http_res_text, http_res
762
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
763
695
  if utils.match_response(http_res, "5XX", "*"):
764
696
  http_res_text = utils.stream_to_text(http_res)
765
- raise models.APIError(
766
- "API error occurred", http_res.status_code, http_res_text, http_res
767
- )
697
+ raise errors.APIError("API error occurred", http_res, http_res_text)
768
698
 
769
- content_type = http_res.headers.get("Content-Type")
770
- http_res_text = utils.stream_to_text(http_res)
771
- raise models.APIError(
772
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
773
- http_res.status_code,
774
- http_res_text,
775
- http_res,
776
- )
699
+ raise errors.APIError("Unexpected response received", http_res)
777
700
 
778
701
  async def get_by_id_async(
779
702
  self,
@@ -849,31 +772,20 @@ class Prompts(BaseSDK):
849
772
 
850
773
  response_data: Any = None
851
774
  if utils.match_response(http_res, "200", "application/json"):
852
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
775
+ return utils.unmarshal_json_response(models.PromptResponse, http_res)
853
776
  if utils.match_response(http_res, "422", "application/json"):
854
- response_data = utils.unmarshal_json(
855
- http_res.text, models.HTTPValidationErrorData
777
+ response_data = utils.unmarshal_json_response(
778
+ errors.HTTPValidationErrorData, http_res
856
779
  )
857
- raise models.HTTPValidationError(data=response_data)
780
+ raise errors.HTTPValidationError(response_data, http_res)
858
781
  if utils.match_response(http_res, "4XX", "*"):
859
782
  http_res_text = await utils.stream_to_text_async(http_res)
860
- raise models.APIError(
861
- "API error occurred", http_res.status_code, http_res_text, http_res
862
- )
783
+ raise errors.APIError("API error occurred", http_res, http_res_text)
863
784
  if utils.match_response(http_res, "5XX", "*"):
864
785
  http_res_text = await utils.stream_to_text_async(http_res)
865
- raise models.APIError(
866
- "API error occurred", http_res.status_code, http_res_text, http_res
867
- )
786
+ raise errors.APIError("API error occurred", http_res, http_res_text)
868
787
 
869
- content_type = http_res.headers.get("Content-Type")
870
- http_res_text = await utils.stream_to_text_async(http_res)
871
- raise models.APIError(
872
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
873
- http_res.status_code,
874
- http_res_text,
875
- http_res,
876
- )
788
+ raise errors.APIError("Unexpected response received", http_res)
877
789
 
878
790
  def delete(
879
791
  self,
@@ -952,31 +864,20 @@ class Prompts(BaseSDK):
952
864
 
953
865
  response_data: Any = None
954
866
  if utils.match_response(http_res, "200", "application/json"):
955
- return utils.unmarshal_json(http_res.text, Any)
867
+ return utils.unmarshal_json_response(Any, http_res)
956
868
  if utils.match_response(http_res, "422", "application/json"):
957
- response_data = utils.unmarshal_json(
958
- http_res.text, models.HTTPValidationErrorData
869
+ response_data = utils.unmarshal_json_response(
870
+ errors.HTTPValidationErrorData, http_res
959
871
  )
960
- raise models.HTTPValidationError(data=response_data)
872
+ raise errors.HTTPValidationError(response_data, http_res)
961
873
  if utils.match_response(http_res, "4XX", "*"):
962
874
  http_res_text = utils.stream_to_text(http_res)
963
- raise models.APIError(
964
- "API error occurred", http_res.status_code, http_res_text, http_res
965
- )
875
+ raise errors.APIError("API error occurred", http_res, http_res_text)
966
876
  if utils.match_response(http_res, "5XX", "*"):
967
877
  http_res_text = utils.stream_to_text(http_res)
968
- raise models.APIError(
969
- "API error occurred", http_res.status_code, http_res_text, http_res
970
- )
878
+ raise errors.APIError("API error occurred", http_res, http_res_text)
971
879
 
972
- content_type = http_res.headers.get("Content-Type")
973
- http_res_text = utils.stream_to_text(http_res)
974
- raise models.APIError(
975
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
976
- http_res.status_code,
977
- http_res_text,
978
- http_res,
979
- )
880
+ raise errors.APIError("Unexpected response received", http_res)
980
881
 
981
882
  async def delete_async(
982
883
  self,
@@ -1055,31 +956,20 @@ class Prompts(BaseSDK):
1055
956
 
1056
957
  response_data: Any = None
1057
958
  if utils.match_response(http_res, "200", "application/json"):
1058
- return utils.unmarshal_json(http_res.text, Any)
959
+ return utils.unmarshal_json_response(Any, http_res)
1059
960
  if utils.match_response(http_res, "422", "application/json"):
1060
- response_data = utils.unmarshal_json(
1061
- http_res.text, models.HTTPValidationErrorData
961
+ response_data = utils.unmarshal_json_response(
962
+ errors.HTTPValidationErrorData, http_res
1062
963
  )
1063
- raise models.HTTPValidationError(data=response_data)
964
+ raise errors.HTTPValidationError(response_data, http_res)
1064
965
  if utils.match_response(http_res, "4XX", "*"):
1065
966
  http_res_text = await utils.stream_to_text_async(http_res)
1066
- raise models.APIError(
1067
- "API error occurred", http_res.status_code, http_res_text, http_res
1068
- )
967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1069
968
  if utils.match_response(http_res, "5XX", "*"):
1070
969
  http_res_text = await utils.stream_to_text_async(http_res)
1071
- raise models.APIError(
1072
- "API error occurred", http_res.status_code, http_res_text, http_res
1073
- )
970
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1074
971
 
1075
- content_type = http_res.headers.get("Content-Type")
1076
- http_res_text = await utils.stream_to_text_async(http_res)
1077
- raise models.APIError(
1078
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1079
- http_res.status_code,
1080
- http_res_text,
1081
- http_res,
1082
- )
972
+ raise errors.APIError("Unexpected response received", http_res)
1083
973
 
1084
974
  def prompts_history(
1085
975
  self,
@@ -1155,31 +1045,20 @@ class Prompts(BaseSDK):
1155
1045
 
1156
1046
  response_data: Any = None
1157
1047
  if utils.match_response(http_res, "200", "application/json"):
1158
- return utils.unmarshal_json(http_res.text, List[models.PromptHistory])
1048
+ return utils.unmarshal_json_response(List[models.PromptHistory], http_res)
1159
1049
  if utils.match_response(http_res, "422", "application/json"):
1160
- response_data = utils.unmarshal_json(
1161
- http_res.text, models.HTTPValidationErrorData
1050
+ response_data = utils.unmarshal_json_response(
1051
+ errors.HTTPValidationErrorData, http_res
1162
1052
  )
1163
- raise models.HTTPValidationError(data=response_data)
1053
+ raise errors.HTTPValidationError(response_data, http_res)
1164
1054
  if utils.match_response(http_res, "4XX", "*"):
1165
1055
  http_res_text = utils.stream_to_text(http_res)
1166
- raise models.APIError(
1167
- "API error occurred", http_res.status_code, http_res_text, http_res
1168
- )
1056
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1169
1057
  if utils.match_response(http_res, "5XX", "*"):
1170
1058
  http_res_text = utils.stream_to_text(http_res)
1171
- raise models.APIError(
1172
- "API error occurred", http_res.status_code, http_res_text, http_res
1173
- )
1059
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1174
1060
 
1175
- content_type = http_res.headers.get("Content-Type")
1176
- http_res_text = utils.stream_to_text(http_res)
1177
- raise models.APIError(
1178
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1179
- http_res.status_code,
1180
- http_res_text,
1181
- http_res,
1182
- )
1061
+ raise errors.APIError("Unexpected response received", http_res)
1183
1062
 
1184
1063
  async def prompts_history_async(
1185
1064
  self,
@@ -1255,31 +1134,20 @@ class Prompts(BaseSDK):
1255
1134
 
1256
1135
  response_data: Any = None
1257
1136
  if utils.match_response(http_res, "200", "application/json"):
1258
- return utils.unmarshal_json(http_res.text, List[models.PromptHistory])
1137
+ return utils.unmarshal_json_response(List[models.PromptHistory], http_res)
1259
1138
  if utils.match_response(http_res, "422", "application/json"):
1260
- response_data = utils.unmarshal_json(
1261
- http_res.text, models.HTTPValidationErrorData
1139
+ response_data = utils.unmarshal_json_response(
1140
+ errors.HTTPValidationErrorData, http_res
1262
1141
  )
1263
- raise models.HTTPValidationError(data=response_data)
1142
+ raise errors.HTTPValidationError(response_data, http_res)
1264
1143
  if utils.match_response(http_res, "4XX", "*"):
1265
1144
  http_res_text = await utils.stream_to_text_async(http_res)
1266
- raise models.APIError(
1267
- "API error occurred", http_res.status_code, http_res_text, http_res
1268
- )
1145
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1269
1146
  if utils.match_response(http_res, "5XX", "*"):
1270
1147
  http_res_text = await utils.stream_to_text_async(http_res)
1271
- raise models.APIError(
1272
- "API error occurred", http_res.status_code, http_res_text, http_res
1273
- )
1148
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1274
1149
 
1275
- content_type = http_res.headers.get("Content-Type")
1276
- http_res_text = await utils.stream_to_text_async(http_res)
1277
- raise models.APIError(
1278
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1279
- http_res.status_code,
1280
- http_res_text,
1281
- http_res,
1282
- )
1150
+ raise errors.APIError("Unexpected response received", http_res)
1283
1151
 
1284
1152
  def prompt_get_supported_llms(
1285
1153
  self,
@@ -1347,26 +1215,15 @@ class Prompts(BaseSDK):
1347
1215
  )
1348
1216
 
1349
1217
  if utils.match_response(http_res, "200", "application/json"):
1350
- return utils.unmarshal_json(http_res.text, List[models.SupportedLlm])
1218
+ return utils.unmarshal_json_response(List[models.SupportedLlm], http_res)
1351
1219
  if utils.match_response(http_res, "4XX", "*"):
1352
1220
  http_res_text = utils.stream_to_text(http_res)
1353
- raise models.APIError(
1354
- "API error occurred", http_res.status_code, http_res_text, http_res
1355
- )
1221
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1356
1222
  if utils.match_response(http_res, "5XX", "*"):
1357
1223
  http_res_text = utils.stream_to_text(http_res)
1358
- raise models.APIError(
1359
- "API error occurred", http_res.status_code, http_res_text, http_res
1360
- )
1224
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1361
1225
 
1362
- content_type = http_res.headers.get("Content-Type")
1363
- http_res_text = utils.stream_to_text(http_res)
1364
- raise models.APIError(
1365
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1366
- http_res.status_code,
1367
- http_res_text,
1368
- http_res,
1369
- )
1226
+ raise errors.APIError("Unexpected response received", http_res)
1370
1227
 
1371
1228
  async def prompt_get_supported_llms_async(
1372
1229
  self,
@@ -1434,23 +1291,12 @@ class Prompts(BaseSDK):
1434
1291
  )
1435
1292
 
1436
1293
  if utils.match_response(http_res, "200", "application/json"):
1437
- return utils.unmarshal_json(http_res.text, List[models.SupportedLlm])
1294
+ return utils.unmarshal_json_response(List[models.SupportedLlm], http_res)
1438
1295
  if utils.match_response(http_res, "4XX", "*"):
1439
1296
  http_res_text = await utils.stream_to_text_async(http_res)
1440
- raise models.APIError(
1441
- "API error occurred", http_res.status_code, http_res_text, http_res
1442
- )
1297
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1443
1298
  if utils.match_response(http_res, "5XX", "*"):
1444
1299
  http_res_text = await utils.stream_to_text_async(http_res)
1445
- raise models.APIError(
1446
- "API error occurred", http_res.status_code, http_res_text, http_res
1447
- )
1300
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1448
1301
 
1449
- content_type = http_res.headers.get("Content-Type")
1450
- http_res_text = await utils.stream_to_text_async(http_res)
1451
- raise models.APIError(
1452
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1453
- http_res.status_code,
1454
- http_res_text,
1455
- http_res,
1456
- )
1302
+ raise errors.APIError("Unexpected response received", http_res)