syllable-sdk 0.35.32__py3-none-any.whl → 0.35.34__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 +80 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +132 -329
  6. syllable_sdk/campaigns.py +74 -183
  7. syllable_sdk/channels.py +30 -73
  8. syllable_sdk/conversations.py +16 -37
  9. syllable_sdk/custom_messages.py +74 -183
  10. syllable_sdk/dashboards.py +64 -195
  11. syllable_sdk/data_sources.py +74 -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 +16 -37
  19. syllable_sdk/folders.py +116 -295
  20. syllable_sdk/full_summary.py +16 -37
  21. syllable_sdk/incidents.py +84 -215
  22. syllable_sdk/insights_sdk.py +16 -41
  23. syllable_sdk/insights_tools.py +96 -253
  24. syllable_sdk/language_groups.py +86 -215
  25. syllable_sdk/latency.py +16 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +44 -113
  28. syllable_sdk/organizations.py +52 -139
  29. syllable_sdk/permissions.py +12 -33
  30. syllable_sdk/prompts.py +94 -251
  31. syllable_sdk/roles.py +72 -181
  32. syllable_sdk/services.py +72 -185
  33. syllable_sdk/session_debug.py +44 -109
  34. syllable_sdk/session_labels.py +44 -109
  35. syllable_sdk/sessions.py +56 -141
  36. syllable_sdk/takeouts.py +36 -99
  37. syllable_sdk/targets.py +74 -187
  38. syllable_sdk/test.py +16 -37
  39. syllable_sdk/tools.py +72 -181
  40. syllable_sdk/transcript.py +18 -39
  41. syllable_sdk/twilio.py +44 -109
  42. syllable_sdk/users.py +94 -247
  43. syllable_sdk/utils/serializers.py +3 -2
  44. syllable_sdk/utils/unmarshal_json_response.py +24 -0
  45. syllable_sdk/v1.py +94 -247
  46. syllable_sdk/workflows.py +116 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/RECORD +49 -44
  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.34.dist-info}/WHEEL +0 -0
syllable_sdk/prompts.py CHANGED
@@ -1,10 +1,11 @@
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
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, List, Mapping, Optional, Union, cast
9
10
 
10
11
 
@@ -109,33 +110,20 @@ class Prompts(BaseSDK):
109
110
 
110
111
  response_data: Any = None
111
112
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(
113
- http_res.text, models.ListResponsePromptResponse
114
- )
113
+ return unmarshal_json_response(models.ListResponsePromptResponse, http_res)
115
114
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
115
+ response_data = unmarshal_json_response(
116
+ errors.HTTPValidationErrorData, http_res
118
117
  )
119
- raise models.HTTPValidationError(data=response_data)
118
+ raise errors.HTTPValidationError(response_data, http_res)
120
119
  if utils.match_response(http_res, "4XX", "*"):
121
120
  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
- )
121
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
122
  if utils.match_response(http_res, "5XX", "*"):
126
123
  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
- )
124
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
125
 
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
- )
126
+ raise errors.APIError("Unexpected response received", http_res)
139
127
 
140
128
  async def list_async(
141
129
  self,
@@ -235,33 +223,20 @@ class Prompts(BaseSDK):
235
223
 
236
224
  response_data: Any = None
237
225
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponsePromptResponse
240
- )
226
+ return unmarshal_json_response(models.ListResponsePromptResponse, http_res)
241
227
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
228
+ response_data = unmarshal_json_response(
229
+ errors.HTTPValidationErrorData, http_res
244
230
  )
245
- raise models.HTTPValidationError(data=response_data)
231
+ raise errors.HTTPValidationError(response_data, http_res)
246
232
  if utils.match_response(http_res, "4XX", "*"):
247
233
  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
- )
234
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
235
  if utils.match_response(http_res, "5XX", "*"):
252
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
238
 
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
- )
239
+ raise errors.APIError("Unexpected response received", http_res)
265
240
 
266
241
  def create(
267
242
  self,
@@ -340,31 +315,20 @@ class Prompts(BaseSDK):
340
315
 
341
316
  response_data: Any = None
342
317
  if utils.match_response(http_res, "200", "application/json"):
343
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
318
+ return unmarshal_json_response(models.PromptResponse, http_res)
344
319
  if utils.match_response(http_res, "422", "application/json"):
345
- response_data = utils.unmarshal_json(
346
- http_res.text, models.HTTPValidationErrorData
320
+ response_data = unmarshal_json_response(
321
+ errors.HTTPValidationErrorData, http_res
347
322
  )
348
- raise models.HTTPValidationError(data=response_data)
323
+ raise errors.HTTPValidationError(response_data, http_res)
349
324
  if utils.match_response(http_res, "4XX", "*"):
350
325
  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
- )
326
+ raise errors.APIError("API error occurred", http_res, http_res_text)
354
327
  if utils.match_response(http_res, "5XX", "*"):
355
328
  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
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
359
330
 
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
- )
331
+ raise errors.APIError("Unexpected response received", http_res)
368
332
 
369
333
  async def create_async(
370
334
  self,
@@ -443,31 +407,20 @@ class Prompts(BaseSDK):
443
407
 
444
408
  response_data: Any = None
445
409
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
410
+ return unmarshal_json_response(models.PromptResponse, http_res)
447
411
  if utils.match_response(http_res, "422", "application/json"):
448
- response_data = utils.unmarshal_json(
449
- http_res.text, models.HTTPValidationErrorData
412
+ response_data = unmarshal_json_response(
413
+ errors.HTTPValidationErrorData, http_res
450
414
  )
451
- raise models.HTTPValidationError(data=response_data)
415
+ raise errors.HTTPValidationError(response_data, http_res)
452
416
  if utils.match_response(http_res, "4XX", "*"):
453
417
  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
- )
418
+ raise errors.APIError("API error occurred", http_res, http_res_text)
457
419
  if utils.match_response(http_res, "5XX", "*"):
458
420
  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
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
462
422
 
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
- )
423
+ raise errors.APIError("Unexpected response received", http_res)
471
424
 
472
425
  def update(
473
426
  self,
@@ -546,31 +499,20 @@ class Prompts(BaseSDK):
546
499
 
547
500
  response_data: Any = None
548
501
  if utils.match_response(http_res, "200", "application/json"):
549
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
502
+ return unmarshal_json_response(models.PromptResponse, http_res)
550
503
  if utils.match_response(http_res, "422", "application/json"):
551
- response_data = utils.unmarshal_json(
552
- http_res.text, models.HTTPValidationErrorData
504
+ response_data = unmarshal_json_response(
505
+ errors.HTTPValidationErrorData, http_res
553
506
  )
554
- raise models.HTTPValidationError(data=response_data)
507
+ raise errors.HTTPValidationError(response_data, http_res)
555
508
  if utils.match_response(http_res, "4XX", "*"):
556
509
  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
- )
510
+ raise errors.APIError("API error occurred", http_res, http_res_text)
560
511
  if utils.match_response(http_res, "5XX", "*"):
561
512
  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
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
565
514
 
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
- )
515
+ raise errors.APIError("Unexpected response received", http_res)
574
516
 
575
517
  async def update_async(
576
518
  self,
@@ -649,31 +591,20 @@ class Prompts(BaseSDK):
649
591
 
650
592
  response_data: Any = None
651
593
  if utils.match_response(http_res, "200", "application/json"):
652
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
594
+ return unmarshal_json_response(models.PromptResponse, http_res)
653
595
  if utils.match_response(http_res, "422", "application/json"):
654
- response_data = utils.unmarshal_json(
655
- http_res.text, models.HTTPValidationErrorData
596
+ response_data = unmarshal_json_response(
597
+ errors.HTTPValidationErrorData, http_res
656
598
  )
657
- raise models.HTTPValidationError(data=response_data)
599
+ raise errors.HTTPValidationError(response_data, http_res)
658
600
  if utils.match_response(http_res, "4XX", "*"):
659
601
  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
- )
602
+ raise errors.APIError("API error occurred", http_res, http_res_text)
663
603
  if utils.match_response(http_res, "5XX", "*"):
664
604
  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
- )
605
+ raise errors.APIError("API error occurred", http_res, http_res_text)
668
606
 
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
- )
607
+ raise errors.APIError("Unexpected response received", http_res)
677
608
 
678
609
  def get_by_id(
679
610
  self,
@@ -749,31 +680,20 @@ class Prompts(BaseSDK):
749
680
 
750
681
  response_data: Any = None
751
682
  if utils.match_response(http_res, "200", "application/json"):
752
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
683
+ return unmarshal_json_response(models.PromptResponse, http_res)
753
684
  if utils.match_response(http_res, "422", "application/json"):
754
- response_data = utils.unmarshal_json(
755
- http_res.text, models.HTTPValidationErrorData
685
+ response_data = unmarshal_json_response(
686
+ errors.HTTPValidationErrorData, http_res
756
687
  )
757
- raise models.HTTPValidationError(data=response_data)
688
+ raise errors.HTTPValidationError(response_data, http_res)
758
689
  if utils.match_response(http_res, "4XX", "*"):
759
690
  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
- )
691
+ raise errors.APIError("API error occurred", http_res, http_res_text)
763
692
  if utils.match_response(http_res, "5XX", "*"):
764
693
  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
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
768
695
 
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
- )
696
+ raise errors.APIError("Unexpected response received", http_res)
777
697
 
778
698
  async def get_by_id_async(
779
699
  self,
@@ -849,31 +769,20 @@ class Prompts(BaseSDK):
849
769
 
850
770
  response_data: Any = None
851
771
  if utils.match_response(http_res, "200", "application/json"):
852
- return utils.unmarshal_json(http_res.text, models.PromptResponse)
772
+ return unmarshal_json_response(models.PromptResponse, http_res)
853
773
  if utils.match_response(http_res, "422", "application/json"):
854
- response_data = utils.unmarshal_json(
855
- http_res.text, models.HTTPValidationErrorData
774
+ response_data = unmarshal_json_response(
775
+ errors.HTTPValidationErrorData, http_res
856
776
  )
857
- raise models.HTTPValidationError(data=response_data)
777
+ raise errors.HTTPValidationError(response_data, http_res)
858
778
  if utils.match_response(http_res, "4XX", "*"):
859
779
  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
- )
780
+ raise errors.APIError("API error occurred", http_res, http_res_text)
863
781
  if utils.match_response(http_res, "5XX", "*"):
864
782
  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
- )
783
+ raise errors.APIError("API error occurred", http_res, http_res_text)
868
784
 
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
- )
785
+ raise errors.APIError("Unexpected response received", http_res)
877
786
 
878
787
  def delete(
879
788
  self,
@@ -952,31 +861,20 @@ class Prompts(BaseSDK):
952
861
 
953
862
  response_data: Any = None
954
863
  if utils.match_response(http_res, "200", "application/json"):
955
- return utils.unmarshal_json(http_res.text, Any)
864
+ return unmarshal_json_response(Any, http_res)
956
865
  if utils.match_response(http_res, "422", "application/json"):
957
- response_data = utils.unmarshal_json(
958
- http_res.text, models.HTTPValidationErrorData
866
+ response_data = unmarshal_json_response(
867
+ errors.HTTPValidationErrorData, http_res
959
868
  )
960
- raise models.HTTPValidationError(data=response_data)
869
+ raise errors.HTTPValidationError(response_data, http_res)
961
870
  if utils.match_response(http_res, "4XX", "*"):
962
871
  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
- )
872
+ raise errors.APIError("API error occurred", http_res, http_res_text)
966
873
  if utils.match_response(http_res, "5XX", "*"):
967
874
  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
- )
875
+ raise errors.APIError("API error occurred", http_res, http_res_text)
971
876
 
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
- )
877
+ raise errors.APIError("Unexpected response received", http_res)
980
878
 
981
879
  async def delete_async(
982
880
  self,
@@ -1055,31 +953,20 @@ class Prompts(BaseSDK):
1055
953
 
1056
954
  response_data: Any = None
1057
955
  if utils.match_response(http_res, "200", "application/json"):
1058
- return utils.unmarshal_json(http_res.text, Any)
956
+ return unmarshal_json_response(Any, http_res)
1059
957
  if utils.match_response(http_res, "422", "application/json"):
1060
- response_data = utils.unmarshal_json(
1061
- http_res.text, models.HTTPValidationErrorData
958
+ response_data = unmarshal_json_response(
959
+ errors.HTTPValidationErrorData, http_res
1062
960
  )
1063
- raise models.HTTPValidationError(data=response_data)
961
+ raise errors.HTTPValidationError(response_data, http_res)
1064
962
  if utils.match_response(http_res, "4XX", "*"):
1065
963
  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
- )
964
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1069
965
  if utils.match_response(http_res, "5XX", "*"):
1070
966
  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
- )
967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1074
968
 
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
- )
969
+ raise errors.APIError("Unexpected response received", http_res)
1083
970
 
1084
971
  def prompts_history(
1085
972
  self,
@@ -1155,31 +1042,20 @@ class Prompts(BaseSDK):
1155
1042
 
1156
1043
  response_data: Any = None
1157
1044
  if utils.match_response(http_res, "200", "application/json"):
1158
- return utils.unmarshal_json(http_res.text, List[models.PromptHistory])
1045
+ return unmarshal_json_response(List[models.PromptHistory], http_res)
1159
1046
  if utils.match_response(http_res, "422", "application/json"):
1160
- response_data = utils.unmarshal_json(
1161
- http_res.text, models.HTTPValidationErrorData
1047
+ response_data = unmarshal_json_response(
1048
+ errors.HTTPValidationErrorData, http_res
1162
1049
  )
1163
- raise models.HTTPValidationError(data=response_data)
1050
+ raise errors.HTTPValidationError(response_data, http_res)
1164
1051
  if utils.match_response(http_res, "4XX", "*"):
1165
1052
  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
- )
1053
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1169
1054
  if utils.match_response(http_res, "5XX", "*"):
1170
1055
  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
- )
1056
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1174
1057
 
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
- )
1058
+ raise errors.APIError("Unexpected response received", http_res)
1183
1059
 
1184
1060
  async def prompts_history_async(
1185
1061
  self,
@@ -1255,31 +1131,20 @@ class Prompts(BaseSDK):
1255
1131
 
1256
1132
  response_data: Any = None
1257
1133
  if utils.match_response(http_res, "200", "application/json"):
1258
- return utils.unmarshal_json(http_res.text, List[models.PromptHistory])
1134
+ return unmarshal_json_response(List[models.PromptHistory], http_res)
1259
1135
  if utils.match_response(http_res, "422", "application/json"):
1260
- response_data = utils.unmarshal_json(
1261
- http_res.text, models.HTTPValidationErrorData
1136
+ response_data = unmarshal_json_response(
1137
+ errors.HTTPValidationErrorData, http_res
1262
1138
  )
1263
- raise models.HTTPValidationError(data=response_data)
1139
+ raise errors.HTTPValidationError(response_data, http_res)
1264
1140
  if utils.match_response(http_res, "4XX", "*"):
1265
1141
  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
- )
1142
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1269
1143
  if utils.match_response(http_res, "5XX", "*"):
1270
1144
  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
- )
1145
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1274
1146
 
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
- )
1147
+ raise errors.APIError("Unexpected response received", http_res)
1283
1148
 
1284
1149
  def prompt_get_supported_llms(
1285
1150
  self,
@@ -1347,26 +1212,15 @@ class Prompts(BaseSDK):
1347
1212
  )
1348
1213
 
1349
1214
  if utils.match_response(http_res, "200", "application/json"):
1350
- return utils.unmarshal_json(http_res.text, List[models.SupportedLlm])
1215
+ return unmarshal_json_response(List[models.SupportedLlm], http_res)
1351
1216
  if utils.match_response(http_res, "4XX", "*"):
1352
1217
  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
- )
1218
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1356
1219
  if utils.match_response(http_res, "5XX", "*"):
1357
1220
  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
- )
1221
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1361
1222
 
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
- )
1223
+ raise errors.APIError("Unexpected response received", http_res)
1370
1224
 
1371
1225
  async def prompt_get_supported_llms_async(
1372
1226
  self,
@@ -1434,23 +1288,12 @@ class Prompts(BaseSDK):
1434
1288
  )
1435
1289
 
1436
1290
  if utils.match_response(http_res, "200", "application/json"):
1437
- return utils.unmarshal_json(http_res.text, List[models.SupportedLlm])
1291
+ return unmarshal_json_response(List[models.SupportedLlm], http_res)
1438
1292
  if utils.match_response(http_res, "4XX", "*"):
1439
1293
  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
- )
1294
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1443
1295
  if utils.match_response(http_res, "5XX", "*"):
1444
1296
  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
- )
1297
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1448
1298
 
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
- )
1299
+ raise errors.APIError("Unexpected response received", http_res)