letta-client 0.1.120__py3-none-any.whl → 0.1.122__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.

Potentially problematic release.


This version of letta-client might be problematic. Click here for more details.

Files changed (50) hide show
  1. letta_client/__init__.py +7 -6
  2. letta_client/agents/__init__.py +2 -1
  3. letta_client/agents/client.py +90 -581
  4. letta_client/agents/groups/client.py +167 -0
  5. letta_client/agents/messages/client.py +145 -0
  6. letta_client/agents/passages/client.py +289 -0
  7. letta_client/base_client.py +12 -0
  8. letta_client/batches/__init__.py +2 -0
  9. letta_client/{messages/batches → batches}/client.py +19 -19
  10. letta_client/blocks/__init__.py +3 -0
  11. letta_client/blocks/agents/__init__.py +2 -0
  12. letta_client/blocks/agents/client.py +149 -0
  13. letta_client/blocks/client.py +4 -127
  14. letta_client/core/client_wrapper.py +1 -1
  15. letta_client/embeddings/__init__.py +2 -0
  16. letta_client/embeddings/client.py +108 -0
  17. letta_client/groups/client.py +0 -124
  18. letta_client/groups/messages/client.py +124 -0
  19. letta_client/identities/__init__.py +3 -0
  20. letta_client/identities/client.py +4 -154
  21. letta_client/identities/properties/__init__.py +2 -0
  22. letta_client/identities/properties/client.py +181 -0
  23. letta_client/messages/__init__.py +0 -3
  24. letta_client/messages/client.py +0 -4
  25. letta_client/models/client.py +4 -97
  26. letta_client/providers/client.py +173 -10
  27. letta_client/runs/__init__.py +3 -0
  28. letta_client/runs/client.py +34 -480
  29. letta_client/runs/messages/__init__.py +2 -0
  30. letta_client/runs/messages/client.py +234 -0
  31. letta_client/runs/steps/__init__.py +2 -0
  32. letta_client/runs/steps/client.py +217 -0
  33. letta_client/runs/usage/__init__.py +2 -0
  34. letta_client/runs/usage/client.py +145 -0
  35. letta_client/sources/client.py +6 -4
  36. letta_client/steps/client.py +78 -4
  37. letta_client/tags/__init__.py +2 -0
  38. letta_client/tags/client.py +92 -0
  39. letta_client/templates/__init__.py +5 -6
  40. letta_client/templates/agents/__init__.py +5 -0
  41. letta_client/templates/agents/client.py +208 -0
  42. letta_client/templates/agents/types/__init__.py +5 -0
  43. letta_client/templates/{types/templates_create_agents_response.py → agents/types/agents_create_response.py} +4 -4
  44. letta_client/templates/client.py +6 -191
  45. letta_client/templates/types/__init__.py +1 -6
  46. letta_client/tools/client.py +4 -4
  47. {letta_client-0.1.120.dist-info → letta_client-0.1.122.dist-info}/METADATA +1 -1
  48. {letta_client-0.1.120.dist-info → letta_client-0.1.122.dist-info}/RECORD +50 -31
  49. /letta_client/{messages/batches → agents/groups}/__init__.py +0 -0
  50. {letta_client-0.1.120.dist-info → letta_client-0.1.122.dist-info}/WHEEL +0 -0
@@ -0,0 +1,167 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.client_wrapper import SyncClientWrapper
4
+ import typing
5
+ from ...core.request_options import RequestOptions
6
+ from ...types.group import Group
7
+ from ...core.jsonable_encoder import jsonable_encoder
8
+ from ...core.unchecked_base_model import construct_type
9
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
10
+ from ...types.http_validation_error import HttpValidationError
11
+ from json.decoder import JSONDecodeError
12
+ from ...core.api_error import ApiError
13
+ from ...core.client_wrapper import AsyncClientWrapper
14
+
15
+
16
+ class GroupsClient:
17
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
18
+ self._client_wrapper = client_wrapper
19
+
20
+ def list(
21
+ self,
22
+ agent_id: str,
23
+ *,
24
+ manager_type: typing.Optional[str] = None,
25
+ request_options: typing.Optional[RequestOptions] = None,
26
+ ) -> typing.List[Group]:
27
+ """
28
+ Lists the groups for an agent
29
+
30
+ Parameters
31
+ ----------
32
+ agent_id : str
33
+
34
+ manager_type : typing.Optional[str]
35
+ Manager type to filter groups by
36
+
37
+ request_options : typing.Optional[RequestOptions]
38
+ Request-specific configuration.
39
+
40
+ Returns
41
+ -------
42
+ typing.List[Group]
43
+ Successful Response
44
+
45
+ Examples
46
+ --------
47
+ from letta_client import Letta
48
+
49
+ client = Letta(
50
+ token="YOUR_TOKEN",
51
+ )
52
+ client.agents.groups.list(
53
+ agent_id="agent_id",
54
+ )
55
+ """
56
+ _response = self._client_wrapper.httpx_client.request(
57
+ f"v1/agents/{jsonable_encoder(agent_id)}/groups",
58
+ method="GET",
59
+ params={
60
+ "manager_type": manager_type,
61
+ },
62
+ request_options=request_options,
63
+ )
64
+ try:
65
+ if 200 <= _response.status_code < 300:
66
+ return typing.cast(
67
+ typing.List[Group],
68
+ construct_type(
69
+ type_=typing.List[Group], # type: ignore
70
+ object_=_response.json(),
71
+ ),
72
+ )
73
+ if _response.status_code == 422:
74
+ raise UnprocessableEntityError(
75
+ typing.cast(
76
+ HttpValidationError,
77
+ construct_type(
78
+ type_=HttpValidationError, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ )
82
+ )
83
+ _response_json = _response.json()
84
+ except JSONDecodeError:
85
+ raise ApiError(status_code=_response.status_code, body=_response.text)
86
+ raise ApiError(status_code=_response.status_code, body=_response_json)
87
+
88
+
89
+ class AsyncGroupsClient:
90
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
91
+ self._client_wrapper = client_wrapper
92
+
93
+ async def list(
94
+ self,
95
+ agent_id: str,
96
+ *,
97
+ manager_type: typing.Optional[str] = None,
98
+ request_options: typing.Optional[RequestOptions] = None,
99
+ ) -> typing.List[Group]:
100
+ """
101
+ Lists the groups for an agent
102
+
103
+ Parameters
104
+ ----------
105
+ agent_id : str
106
+
107
+ manager_type : typing.Optional[str]
108
+ Manager type to filter groups by
109
+
110
+ request_options : typing.Optional[RequestOptions]
111
+ Request-specific configuration.
112
+
113
+ Returns
114
+ -------
115
+ typing.List[Group]
116
+ Successful Response
117
+
118
+ Examples
119
+ --------
120
+ import asyncio
121
+
122
+ from letta_client import AsyncLetta
123
+
124
+ client = AsyncLetta(
125
+ token="YOUR_TOKEN",
126
+ )
127
+
128
+
129
+ async def main() -> None:
130
+ await client.agents.groups.list(
131
+ agent_id="agent_id",
132
+ )
133
+
134
+
135
+ asyncio.run(main())
136
+ """
137
+ _response = await self._client_wrapper.httpx_client.request(
138
+ f"v1/agents/{jsonable_encoder(agent_id)}/groups",
139
+ method="GET",
140
+ params={
141
+ "manager_type": manager_type,
142
+ },
143
+ request_options=request_options,
144
+ )
145
+ try:
146
+ if 200 <= _response.status_code < 300:
147
+ return typing.cast(
148
+ typing.List[Group],
149
+ construct_type(
150
+ type_=typing.List[Group], # type: ignore
151
+ object_=_response.json(),
152
+ ),
153
+ )
154
+ if _response.status_code == 422:
155
+ raise UnprocessableEntityError(
156
+ typing.cast(
157
+ HttpValidationError,
158
+ construct_type(
159
+ type_=HttpValidationError, # type: ignore
160
+ object_=_response.json(),
161
+ ),
162
+ )
163
+ )
164
+ _response_json = _response.json()
165
+ except JSONDecodeError:
166
+ raise ApiError(status_code=_response.status_code, body=_response.text)
167
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -19,6 +19,7 @@ from .types.letta_streaming_response import LettaStreamingResponse
19
19
  import httpx_sse
20
20
  import json
21
21
  from ...types.run import Run
22
+ from ...types.agent_state import AgentState
22
23
  from ...core.client_wrapper import AsyncClientWrapper
23
24
 
24
25
  # this is used as the default value for optional parameters
@@ -508,6 +509,74 @@ class MessagesClient:
508
509
  raise ApiError(status_code=_response.status_code, body=_response.text)
509
510
  raise ApiError(status_code=_response.status_code, body=_response_json)
510
511
 
512
+ def reset(
513
+ self,
514
+ agent_id: str,
515
+ *,
516
+ add_default_initial_messages: typing.Optional[bool] = None,
517
+ request_options: typing.Optional[RequestOptions] = None,
518
+ ) -> AgentState:
519
+ """
520
+ Resets the messages for an agent
521
+
522
+ Parameters
523
+ ----------
524
+ agent_id : str
525
+
526
+ add_default_initial_messages : typing.Optional[bool]
527
+ If true, adds the default initial messages after resetting.
528
+
529
+ request_options : typing.Optional[RequestOptions]
530
+ Request-specific configuration.
531
+
532
+ Returns
533
+ -------
534
+ AgentState
535
+ Successful Response
536
+
537
+ Examples
538
+ --------
539
+ from letta_client import Letta
540
+
541
+ client = Letta(
542
+ token="YOUR_TOKEN",
543
+ )
544
+ client.agents.messages.reset(
545
+ agent_id="agent_id",
546
+ )
547
+ """
548
+ _response = self._client_wrapper.httpx_client.request(
549
+ f"v1/agents/{jsonable_encoder(agent_id)}/reset-messages",
550
+ method="PATCH",
551
+ params={
552
+ "add_default_initial_messages": add_default_initial_messages,
553
+ },
554
+ request_options=request_options,
555
+ )
556
+ try:
557
+ if 200 <= _response.status_code < 300:
558
+ return typing.cast(
559
+ AgentState,
560
+ construct_type(
561
+ type_=AgentState, # type: ignore
562
+ object_=_response.json(),
563
+ ),
564
+ )
565
+ if _response.status_code == 422:
566
+ raise UnprocessableEntityError(
567
+ typing.cast(
568
+ HttpValidationError,
569
+ construct_type(
570
+ type_=HttpValidationError, # type: ignore
571
+ object_=_response.json(),
572
+ ),
573
+ )
574
+ )
575
+ _response_json = _response.json()
576
+ except JSONDecodeError:
577
+ raise ApiError(status_code=_response.status_code, body=_response.text)
578
+ raise ApiError(status_code=_response.status_code, body=_response_json)
579
+
511
580
 
512
581
  class AsyncMessagesClient:
513
582
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -1031,3 +1100,79 @@ class AsyncMessagesClient:
1031
1100
  except JSONDecodeError:
1032
1101
  raise ApiError(status_code=_response.status_code, body=_response.text)
1033
1102
  raise ApiError(status_code=_response.status_code, body=_response_json)
1103
+
1104
+ async def reset(
1105
+ self,
1106
+ agent_id: str,
1107
+ *,
1108
+ add_default_initial_messages: typing.Optional[bool] = None,
1109
+ request_options: typing.Optional[RequestOptions] = None,
1110
+ ) -> AgentState:
1111
+ """
1112
+ Resets the messages for an agent
1113
+
1114
+ Parameters
1115
+ ----------
1116
+ agent_id : str
1117
+
1118
+ add_default_initial_messages : typing.Optional[bool]
1119
+ If true, adds the default initial messages after resetting.
1120
+
1121
+ request_options : typing.Optional[RequestOptions]
1122
+ Request-specific configuration.
1123
+
1124
+ Returns
1125
+ -------
1126
+ AgentState
1127
+ Successful Response
1128
+
1129
+ Examples
1130
+ --------
1131
+ import asyncio
1132
+
1133
+ from letta_client import AsyncLetta
1134
+
1135
+ client = AsyncLetta(
1136
+ token="YOUR_TOKEN",
1137
+ )
1138
+
1139
+
1140
+ async def main() -> None:
1141
+ await client.agents.messages.reset(
1142
+ agent_id="agent_id",
1143
+ )
1144
+
1145
+
1146
+ asyncio.run(main())
1147
+ """
1148
+ _response = await self._client_wrapper.httpx_client.request(
1149
+ f"v1/agents/{jsonable_encoder(agent_id)}/reset-messages",
1150
+ method="PATCH",
1151
+ params={
1152
+ "add_default_initial_messages": add_default_initial_messages,
1153
+ },
1154
+ request_options=request_options,
1155
+ )
1156
+ try:
1157
+ if 200 <= _response.status_code < 300:
1158
+ return typing.cast(
1159
+ AgentState,
1160
+ construct_type(
1161
+ type_=AgentState, # type: ignore
1162
+ object_=_response.json(),
1163
+ ),
1164
+ )
1165
+ if _response.status_code == 422:
1166
+ raise UnprocessableEntityError(
1167
+ typing.cast(
1168
+ HttpValidationError,
1169
+ construct_type(
1170
+ type_=HttpValidationError, # type: ignore
1171
+ object_=_response.json(),
1172
+ ),
1173
+ )
1174
+ )
1175
+ _response_json = _response.json()
1176
+ except JSONDecodeError:
1177
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1178
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -10,6 +10,9 @@ from ...errors.unprocessable_entity_error import UnprocessableEntityError
10
10
  from ...types.http_validation_error import HttpValidationError
11
11
  from json.decoder import JSONDecodeError
12
12
  from ...core.api_error import ApiError
13
+ import datetime as dt
14
+ from ...types.embedding_config import EmbeddingConfig
15
+ from ...core.serialization import convert_and_respect_annotation_metadata
13
16
  from ...core.client_wrapper import AsyncClientWrapper
14
17
 
15
18
  # this is used as the default value for optional parameters
@@ -238,6 +241,145 @@ class PassagesClient:
238
241
  raise ApiError(status_code=_response.status_code, body=_response.text)
239
242
  raise ApiError(status_code=_response.status_code, body=_response_json)
240
243
 
244
+ def modify(
245
+ self,
246
+ agent_id: str,
247
+ memory_id: str,
248
+ *,
249
+ id: str,
250
+ created_by_id: typing.Optional[str] = OMIT,
251
+ last_updated_by_id: typing.Optional[str] = OMIT,
252
+ created_at: typing.Optional[dt.datetime] = OMIT,
253
+ updated_at: typing.Optional[dt.datetime] = OMIT,
254
+ is_deleted: typing.Optional[bool] = OMIT,
255
+ passage_update_agent_id: typing.Optional[str] = OMIT,
256
+ source_id: typing.Optional[str] = OMIT,
257
+ file_id: typing.Optional[str] = OMIT,
258
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
259
+ text: typing.Optional[str] = OMIT,
260
+ embedding: typing.Optional[typing.Sequence[float]] = OMIT,
261
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
262
+ request_options: typing.Optional[RequestOptions] = None,
263
+ ) -> typing.List[Passage]:
264
+ """
265
+ Modify a memory in the agent's archival memory store.
266
+
267
+ Parameters
268
+ ----------
269
+ agent_id : str
270
+
271
+ memory_id : str
272
+
273
+ id : str
274
+ The unique identifier of the passage.
275
+
276
+ created_by_id : typing.Optional[str]
277
+ The id of the user that made this object.
278
+
279
+ last_updated_by_id : typing.Optional[str]
280
+ The id of the user that made this object.
281
+
282
+ created_at : typing.Optional[dt.datetime]
283
+ The timestamp when the object was created.
284
+
285
+ updated_at : typing.Optional[dt.datetime]
286
+ The timestamp when the object was last updated.
287
+
288
+ is_deleted : typing.Optional[bool]
289
+ Whether this passage is deleted or not.
290
+
291
+ passage_update_agent_id : typing.Optional[str]
292
+ The unique identifier of the agent associated with the passage.
293
+
294
+ source_id : typing.Optional[str]
295
+ The data source of the passage.
296
+
297
+ file_id : typing.Optional[str]
298
+ The unique identifier of the file associated with the passage.
299
+
300
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
301
+ The metadata of the passage.
302
+
303
+ text : typing.Optional[str]
304
+ The text of the passage.
305
+
306
+ embedding : typing.Optional[typing.Sequence[float]]
307
+ The embedding of the passage.
308
+
309
+ embedding_config : typing.Optional[EmbeddingConfig]
310
+ The embedding configuration used by the passage.
311
+
312
+ request_options : typing.Optional[RequestOptions]
313
+ Request-specific configuration.
314
+
315
+ Returns
316
+ -------
317
+ typing.List[Passage]
318
+ Successful Response
319
+
320
+ Examples
321
+ --------
322
+ from letta_client import Letta
323
+
324
+ client = Letta(
325
+ token="YOUR_TOKEN",
326
+ )
327
+ client.agents.passages.modify(
328
+ agent_id="agent_id",
329
+ memory_id="memory_id",
330
+ id="id",
331
+ )
332
+ """
333
+ _response = self._client_wrapper.httpx_client.request(
334
+ f"v1/agents/{jsonable_encoder(agent_id)}/archival-memory/{jsonable_encoder(memory_id)}",
335
+ method="PATCH",
336
+ json={
337
+ "created_by_id": created_by_id,
338
+ "last_updated_by_id": last_updated_by_id,
339
+ "created_at": created_at,
340
+ "updated_at": updated_at,
341
+ "is_deleted": is_deleted,
342
+ "agent_id": passage_update_agent_id,
343
+ "source_id": source_id,
344
+ "file_id": file_id,
345
+ "metadata_": metadata,
346
+ "text": text,
347
+ "embedding": embedding,
348
+ "embedding_config": convert_and_respect_annotation_metadata(
349
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
350
+ ),
351
+ "id": id,
352
+ },
353
+ headers={
354
+ "content-type": "application/json",
355
+ },
356
+ request_options=request_options,
357
+ omit=OMIT,
358
+ )
359
+ try:
360
+ if 200 <= _response.status_code < 300:
361
+ return typing.cast(
362
+ typing.List[Passage],
363
+ construct_type(
364
+ type_=typing.List[Passage], # type: ignore
365
+ object_=_response.json(),
366
+ ),
367
+ )
368
+ if _response.status_code == 422:
369
+ raise UnprocessableEntityError(
370
+ typing.cast(
371
+ HttpValidationError,
372
+ construct_type(
373
+ type_=HttpValidationError, # type: ignore
374
+ object_=_response.json(),
375
+ ),
376
+ )
377
+ )
378
+ _response_json = _response.json()
379
+ except JSONDecodeError:
380
+ raise ApiError(status_code=_response.status_code, body=_response.text)
381
+ raise ApiError(status_code=_response.status_code, body=_response_json)
382
+
241
383
 
242
384
  class AsyncPassagesClient:
243
385
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -484,3 +626,150 @@ class AsyncPassagesClient:
484
626
  except JSONDecodeError:
485
627
  raise ApiError(status_code=_response.status_code, body=_response.text)
486
628
  raise ApiError(status_code=_response.status_code, body=_response_json)
629
+
630
+ async def modify(
631
+ self,
632
+ agent_id: str,
633
+ memory_id: str,
634
+ *,
635
+ id: str,
636
+ created_by_id: typing.Optional[str] = OMIT,
637
+ last_updated_by_id: typing.Optional[str] = OMIT,
638
+ created_at: typing.Optional[dt.datetime] = OMIT,
639
+ updated_at: typing.Optional[dt.datetime] = OMIT,
640
+ is_deleted: typing.Optional[bool] = OMIT,
641
+ passage_update_agent_id: typing.Optional[str] = OMIT,
642
+ source_id: typing.Optional[str] = OMIT,
643
+ file_id: typing.Optional[str] = OMIT,
644
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
645
+ text: typing.Optional[str] = OMIT,
646
+ embedding: typing.Optional[typing.Sequence[float]] = OMIT,
647
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
648
+ request_options: typing.Optional[RequestOptions] = None,
649
+ ) -> typing.List[Passage]:
650
+ """
651
+ Modify a memory in the agent's archival memory store.
652
+
653
+ Parameters
654
+ ----------
655
+ agent_id : str
656
+
657
+ memory_id : str
658
+
659
+ id : str
660
+ The unique identifier of the passage.
661
+
662
+ created_by_id : typing.Optional[str]
663
+ The id of the user that made this object.
664
+
665
+ last_updated_by_id : typing.Optional[str]
666
+ The id of the user that made this object.
667
+
668
+ created_at : typing.Optional[dt.datetime]
669
+ The timestamp when the object was created.
670
+
671
+ updated_at : typing.Optional[dt.datetime]
672
+ The timestamp when the object was last updated.
673
+
674
+ is_deleted : typing.Optional[bool]
675
+ Whether this passage is deleted or not.
676
+
677
+ passage_update_agent_id : typing.Optional[str]
678
+ The unique identifier of the agent associated with the passage.
679
+
680
+ source_id : typing.Optional[str]
681
+ The data source of the passage.
682
+
683
+ file_id : typing.Optional[str]
684
+ The unique identifier of the file associated with the passage.
685
+
686
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
687
+ The metadata of the passage.
688
+
689
+ text : typing.Optional[str]
690
+ The text of the passage.
691
+
692
+ embedding : typing.Optional[typing.Sequence[float]]
693
+ The embedding of the passage.
694
+
695
+ embedding_config : typing.Optional[EmbeddingConfig]
696
+ The embedding configuration used by the passage.
697
+
698
+ request_options : typing.Optional[RequestOptions]
699
+ Request-specific configuration.
700
+
701
+ Returns
702
+ -------
703
+ typing.List[Passage]
704
+ Successful Response
705
+
706
+ Examples
707
+ --------
708
+ import asyncio
709
+
710
+ from letta_client import AsyncLetta
711
+
712
+ client = AsyncLetta(
713
+ token="YOUR_TOKEN",
714
+ )
715
+
716
+
717
+ async def main() -> None:
718
+ await client.agents.passages.modify(
719
+ agent_id="agent_id",
720
+ memory_id="memory_id",
721
+ id="id",
722
+ )
723
+
724
+
725
+ asyncio.run(main())
726
+ """
727
+ _response = await self._client_wrapper.httpx_client.request(
728
+ f"v1/agents/{jsonable_encoder(agent_id)}/archival-memory/{jsonable_encoder(memory_id)}",
729
+ method="PATCH",
730
+ json={
731
+ "created_by_id": created_by_id,
732
+ "last_updated_by_id": last_updated_by_id,
733
+ "created_at": created_at,
734
+ "updated_at": updated_at,
735
+ "is_deleted": is_deleted,
736
+ "agent_id": passage_update_agent_id,
737
+ "source_id": source_id,
738
+ "file_id": file_id,
739
+ "metadata_": metadata,
740
+ "text": text,
741
+ "embedding": embedding,
742
+ "embedding_config": convert_and_respect_annotation_metadata(
743
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
744
+ ),
745
+ "id": id,
746
+ },
747
+ headers={
748
+ "content-type": "application/json",
749
+ },
750
+ request_options=request_options,
751
+ omit=OMIT,
752
+ )
753
+ try:
754
+ if 200 <= _response.status_code < 300:
755
+ return typing.cast(
756
+ typing.List[Passage],
757
+ construct_type(
758
+ type_=typing.List[Passage], # type: ignore
759
+ object_=_response.json(),
760
+ ),
761
+ )
762
+ if _response.status_code == 422:
763
+ raise UnprocessableEntityError(
764
+ typing.cast(
765
+ HttpValidationError,
766
+ construct_type(
767
+ type_=HttpValidationError, # type: ignore
768
+ object_=_response.json(),
769
+ ),
770
+ )
771
+ )
772
+ _response_json = _response.json()
773
+ except JSONDecodeError:
774
+ raise ApiError(status_code=_response.status_code, body=_response.text)
775
+ raise ApiError(status_code=_response.status_code, body=_response_json)