letta-client 0.1.6__py3-none-any.whl → 0.1.10__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 (216) hide show
  1. {letta → letta_client}/__init__.py +33 -27
  2. {letta → letta_client}/agents/__init__.py +40 -29
  3. {letta → letta_client}/agents/archival_memory/client.py +25 -25
  4. letta_client/agents/client.py +1328 -0
  5. {letta → letta_client}/agents/context/client.py +7 -7
  6. letta_client/agents/core_memory/client.py +1080 -0
  7. letta_client/agents/memory_variables/__init__.py +5 -0
  8. {letta/agents/memory → letta_client/agents/memory_variables}/client.py +43 -42
  9. letta_client/agents/memory_variables/types/__init__.py +5 -0
  10. letta/agents/types/agents_get_agent_variables_response.py → letta_client/agents/memory_variables/types/memory_variables_get_response.py +3 -3
  11. {letta → letta_client}/agents/messages/client.py +240 -25
  12. {letta → letta_client}/agents/messages/types/letta_streaming_response.py +21 -16
  13. {letta → letta_client}/agents/messages/types/messages_list_response_item.py +19 -14
  14. {letta → letta_client}/agents/recall_memory/client.py +7 -7
  15. {letta → letta_client}/agents/sources/client.py +7 -7
  16. letta_client/agents/templates/__init__.py +5 -0
  17. letta_client/agents/templates/client.py +578 -0
  18. letta_client/agents/templates/types/__init__.py +5 -0
  19. letta/agents/types/agents_migrate_response.py → letta_client/agents/templates/types/templates_migrate_response.py +3 -3
  20. {letta → letta_client}/agents/tools/client.py +19 -19
  21. letta_client/agents/types/__init__.py +33 -0
  22. letta_client/agents/types/agents_search_request_combinator.py +5 -0
  23. letta/agents/types/agents_search_deployed_agents_request_search_item.py → letta_client/agents/types/agents_search_request_search_item.py +17 -20
  24. letta/agents/types/agents_search_deployed_agents_request_search_item_name.py → letta_client/agents/types/agents_search_request_search_item_name.py +4 -6
  25. letta_client/agents/types/agents_search_request_search_item_name_operator.py +5 -0
  26. letta_client/agents/types/agents_search_request_search_item_order_by.py +22 -0
  27. letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
  28. letta_client/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
  29. letta/agents/types/agents_search_deployed_agents_request_search_item_version.py → letta_client/agents/types/agents_search_request_search_item_version.py +2 -2
  30. {letta → letta_client}/blocks/client.py +39 -39
  31. {letta → letta_client}/client.py +10 -2
  32. {letta → letta_client}/core/__init__.py +4 -0
  33. {letta → letta_client}/core/client_wrapper.py +1 -1
  34. letta_client/core/unchecked_base_model.py +305 -0
  35. {letta → letta_client}/health/client.py +5 -5
  36. {letta → letta_client}/jobs/client.py +25 -25
  37. {letta → letta_client}/models/client.py +9 -9
  38. letta_client/providers/client.py +597 -0
  39. letta_client/runs/client.py +876 -0
  40. {letta → letta_client}/sources/client.py +49 -49
  41. {letta → letta_client}/sources/files/client.py +17 -17
  42. {letta → letta_client}/sources/passages/client.py +7 -7
  43. letta_client/tools/__init__.py +2 -0
  44. {letta → letta_client}/tools/client.py +101 -81
  45. {letta → letta_client}/types/__init__.py +8 -0
  46. {letta → letta_client}/types/action_model.py +2 -2
  47. {letta → letta_client}/types/action_parameters_model.py +2 -2
  48. {letta → letta_client}/types/action_response_model.py +2 -2
  49. {letta → letta_client}/types/agent_environment_variable.py +2 -7
  50. {letta → letta_client}/types/agent_state.py +5 -8
  51. letta_client/types/agent_type.py +7 -0
  52. {letta → letta_client}/types/app_auth_scheme.py +2 -2
  53. {letta → letta_client}/types/app_model.py +2 -2
  54. {letta → letta_client}/types/archival_memory_summary.py +2 -2
  55. {letta → letta_client}/types/assistant_file.py +2 -2
  56. {letta → letta_client}/types/assistant_message_input.py +2 -2
  57. {letta → letta_client}/types/assistant_message_output.py +2 -2
  58. {letta → letta_client}/types/auth_request.py +2 -2
  59. {letta → letta_client}/types/auth_response.py +2 -2
  60. {letta → letta_client}/types/auth_scheme_field.py +2 -2
  61. {letta → letta_client}/types/block.py +2 -7
  62. {letta → letta_client}/types/block_update.py +2 -2
  63. {letta → letta_client}/types/chat_completion_request.py +2 -2
  64. {letta → letta_client}/types/chat_completion_response.py +2 -2
  65. {letta → letta_client}/types/child_tool_rule.py +2 -2
  66. {letta → letta_client}/types/choice.py +2 -2
  67. {letta → letta_client}/types/conditional_tool_rule.py +2 -2
  68. {letta → letta_client}/types/conflict_error_body.py +2 -2
  69. {letta → letta_client}/types/context_window_overview.py +2 -2
  70. {letta → letta_client}/types/create_assistant_file_request.py +2 -2
  71. {letta → letta_client}/types/create_assistant_request.py +2 -2
  72. {letta → letta_client}/types/create_block.py +2 -2
  73. {letta → letta_client}/types/delete_assistant_file_response.py +2 -2
  74. {letta → letta_client}/types/delete_assistant_response.py +2 -2
  75. {letta → letta_client}/types/e_2_b_sandbox_config.py +2 -2
  76. {letta → letta_client}/types/embedding_config.py +2 -2
  77. {letta → letta_client}/types/file_metadata.py +2 -7
  78. {letta → letta_client}/types/function_call_input.py +2 -2
  79. {letta → letta_client}/types/function_call_output.py +2 -2
  80. {letta → letta_client}/types/function_schema.py +2 -2
  81. {letta → letta_client}/types/health.py +2 -2
  82. {letta → letta_client}/types/http_validation_error.py +2 -2
  83. {letta → letta_client}/types/init_tool_rule.py +2 -2
  84. {letta → letta_client}/types/internal_server_error_body.py +2 -2
  85. {letta → letta_client}/types/job.py +7 -6
  86. letta_client/types/job_type.py +5 -0
  87. {letta → letta_client}/types/letta_request.py +7 -2
  88. {letta → letta_client}/types/letta_response.py +2 -2
  89. {letta → letta_client}/types/letta_response_messages_item.py +19 -14
  90. {letta → letta_client}/types/letta_schemas_letta_message_tool_call.py +2 -2
  91. {letta → letta_client}/types/letta_schemas_message_message.py +2 -7
  92. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
  93. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
  94. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
  95. {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
  96. {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
  97. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
  98. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
  99. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
  100. {letta → letta_client}/types/letta_schemas_tool_tool.py +9 -8
  101. {letta → letta_client}/types/letta_usage_statistics.py +2 -2
  102. {letta → letta_client}/types/llm_config.py +2 -2
  103. {letta → letta_client}/types/local_sandbox_config.py +2 -2
  104. {letta → letta_client}/types/log_prob_token.py +2 -2
  105. {letta → letta_client}/types/memory.py +2 -2
  106. {letta → letta_client}/types/message_content_log_prob.py +2 -2
  107. {letta → letta_client}/types/message_create.py +2 -2
  108. {letta → letta_client}/types/not_found_error_body.py +2 -2
  109. {letta → letta_client}/types/open_ai_assistant.py +2 -2
  110. {letta → letta_client}/types/organization.py +2 -2
  111. {letta → letta_client}/types/organization_create.py +2 -2
  112. {letta → letta_client}/types/passage.py +2 -7
  113. letta_client/types/provider.py +38 -0
  114. {letta → letta_client}/types/reasoning_message.py +2 -2
  115. {letta → letta_client}/types/recall_memory_summary.py +2 -2
  116. {letta → letta_client}/types/response_format.py +2 -2
  117. letta_client/types/run.py +77 -0
  118. {letta → letta_client}/types/sandbox_config.py +2 -7
  119. {letta → letta_client}/types/sandbox_config_create.py +2 -2
  120. {letta → letta_client}/types/sandbox_config_update.py +2 -2
  121. {letta → letta_client}/types/sandbox_environment_variable.py +2 -7
  122. {letta → letta_client}/types/sandbox_environment_variable_create.py +2 -2
  123. {letta → letta_client}/types/sandbox_environment_variable_update.py +2 -2
  124. {letta → letta_client}/types/source.py +2 -7
  125. {letta → letta_client}/types/system_message_input.py +2 -2
  126. {letta → letta_client}/types/system_message_output.py +2 -2
  127. {letta → letta_client}/types/terminal_tool_rule.py +2 -2
  128. {letta → letta_client}/types/tool_call_delta.py +2 -2
  129. {letta → letta_client}/types/tool_call_function_output.py +2 -2
  130. {letta → letta_client}/types/tool_call_message.py +2 -2
  131. {letta → letta_client}/types/tool_create.py +2 -2
  132. {letta → letta_client}/types/tool_function_choice.py +2 -2
  133. {letta → letta_client}/types/tool_input.py +2 -2
  134. {letta → letta_client}/types/tool_message.py +2 -2
  135. {letta → letta_client}/types/tool_return_message.py +2 -2
  136. letta_client/types/tool_type.py +5 -0
  137. {letta → letta_client}/types/usage_statistics.py +2 -2
  138. {letta → letta_client}/types/user.py +2 -7
  139. {letta → letta_client}/types/user_create.py +2 -7
  140. {letta → letta_client}/types/user_message_input.py +2 -2
  141. {letta → letta_client}/types/user_message_output.py +2 -2
  142. {letta → letta_client}/types/user_update.py +2 -7
  143. {letta → letta_client}/types/validation_error.py +2 -2
  144. {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/METADATA +7 -7
  145. letta_client-0.1.10.dist-info/RECORD +204 -0
  146. letta/agents/client.py +0 -2644
  147. letta/agents/memory/__init__.py +0 -5
  148. letta/agents/memory/messages/client.py +0 -147
  149. letta/agents/memory_blocks/client.py +0 -364
  150. letta/agents/types/__init__.py +0 -47
  151. letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
  152. letta/agents/types/agents_search_deployed_agents_request_search_item_name_operator.py +0 -7
  153. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by.py +0 -26
  154. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_direction.py +0 -5
  155. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_value.py +0 -7
  156. letta/types/agent_type.py +0 -8
  157. letta_client-0.1.6.dist-info/RECORD +0 -193
  158. {letta → letta_client}/agents/archival_memory/__init__.py +0 -0
  159. {letta → letta_client}/agents/context/__init__.py +0 -0
  160. {letta/agents/memory/messages → letta_client/agents/core_memory}/__init__.py +0 -0
  161. {letta → letta_client}/agents/messages/__init__.py +0 -0
  162. {letta → letta_client}/agents/messages/types/__init__.py +0 -0
  163. {letta → letta_client}/agents/messages/types/messages_list_response.py +0 -0
  164. {letta/agents/memory_blocks → letta_client/agents/recall_memory}/__init__.py +0 -0
  165. {letta/agents/recall_memory → letta_client/agents/sources}/__init__.py +0 -0
  166. {letta/agents/sources → letta_client/agents/tools}/__init__.py +0 -0
  167. {letta → letta_client}/agents/types/create_agent_request_tool_rules_item.py +0 -0
  168. {letta → letta_client}/agents/types/update_agent_tool_rules_item.py +0 -0
  169. {letta/agents/tools → letta_client/blocks}/__init__.py +0 -0
  170. {letta → letta_client}/core/api_error.py +0 -0
  171. {letta → letta_client}/core/datetime_utils.py +0 -0
  172. {letta → letta_client}/core/file.py +0 -0
  173. {letta → letta_client}/core/http_client.py +0 -0
  174. {letta → letta_client}/core/jsonable_encoder.py +0 -0
  175. {letta → letta_client}/core/pydantic_utilities.py +0 -0
  176. {letta → letta_client}/core/query_encoder.py +0 -0
  177. {letta → letta_client}/core/remove_none_from_dict.py +0 -0
  178. {letta → letta_client}/core/request_options.py +0 -0
  179. {letta → letta_client}/core/serialization.py +0 -0
  180. {letta → letta_client}/environment.py +0 -0
  181. {letta → letta_client}/errors/__init__.py +0 -0
  182. {letta → letta_client}/errors/conflict_error.py +0 -0
  183. {letta → letta_client}/errors/internal_server_error.py +0 -0
  184. {letta → letta_client}/errors/not_found_error.py +0 -0
  185. {letta → letta_client}/errors/unprocessable_entity_error.py +0 -0
  186. {letta/blocks → letta_client/health}/__init__.py +0 -0
  187. {letta/health → letta_client/jobs}/__init__.py +0 -0
  188. {letta/jobs → letta_client/models}/__init__.py +0 -0
  189. {letta/models → letta_client/providers}/__init__.py +0 -0
  190. {letta → letta_client}/py.typed +0 -0
  191. {letta/sources/files → letta_client/runs}/__init__.py +0 -0
  192. {letta → letta_client}/sources/__init__.py +0 -0
  193. {letta/sources/passages → letta_client/sources/files}/__init__.py +0 -0
  194. {letta/tools → letta_client/sources/passages}/__init__.py +0 -0
  195. {letta → letta_client}/types/agent_state_tool_rules_item.py +0 -0
  196. {letta → letta_client}/types/app_auth_scheme_auth_mode.py +0 -0
  197. {letta → letta_client}/types/chat_completion_request_function_call.py +0 -0
  198. {letta → letta_client}/types/chat_completion_request_messages_item.py +0 -0
  199. {letta → letta_client}/types/chat_completion_request_stop.py +0 -0
  200. {letta → letta_client}/types/chat_completion_request_tool_choice.py +0 -0
  201. {letta → letta_client}/types/embedding_config_embedding_endpoint_type.py +0 -0
  202. {letta → letta_client}/types/job_status.py +0 -0
  203. {letta → letta_client}/types/llm_config_model_endpoint_type.py +0 -0
  204. {letta → letta_client}/types/message_create_role.py +0 -0
  205. {letta → letta_client}/types/message_role.py +0 -0
  206. {letta → letta_client}/types/not_found_error_body_message.py +0 -0
  207. {letta → letta_client}/types/sandbox_config_create_config.py +0 -0
  208. {letta → letta_client}/types/sandbox_config_update_config.py +0 -0
  209. {letta → letta_client}/types/sandbox_type.py +0 -0
  210. {letta → letta_client}/types/tool_call_message_tool_call.py +0 -0
  211. {letta → letta_client}/types/tool_return_message_status.py +0 -0
  212. {letta → letta_client}/types/tool_rule_type.py +0 -0
  213. {letta → letta_client}/types/user_message_input_content.py +0 -0
  214. {letta → letta_client}/types/validation_error_loc_item.py +0 -0
  215. {letta → letta_client}/version.py +0 -0
  216. {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1080 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ...core.client_wrapper import SyncClientWrapper
5
+ from ...core.request_options import RequestOptions
6
+ from ...types.letta_schemas_message_message import LettaSchemasMessageMessage
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 ...types.memory import Memory
14
+ from ...types.block import Block
15
+ from ...core.client_wrapper import AsyncClientWrapper
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class CoreMemoryClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def list_in_context(
26
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
27
+ ) -> typing.List[LettaSchemasMessageMessage]:
28
+ """
29
+ Retrieve the messages in the context of a specific agent.
30
+
31
+ Parameters
32
+ ----------
33
+ agent_id : str
34
+
35
+ request_options : typing.Optional[RequestOptions]
36
+ Request-specific configuration.
37
+
38
+ Returns
39
+ -------
40
+ typing.List[LettaSchemasMessageMessage]
41
+ Successful Response
42
+
43
+ Examples
44
+ --------
45
+ from letta_client import Letta
46
+
47
+ client = Letta(
48
+ token="YOUR_TOKEN",
49
+ )
50
+ client.agents.core_memory.list_in_context(
51
+ agent_id="agent_id",
52
+ )
53
+ """
54
+ _response = self._client_wrapper.httpx_client.request(
55
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/messages",
56
+ method="GET",
57
+ request_options=request_options,
58
+ )
59
+ try:
60
+ if 200 <= _response.status_code < 300:
61
+ return typing.cast(
62
+ typing.List[LettaSchemasMessageMessage],
63
+ construct_type(
64
+ type_=typing.List[LettaSchemasMessageMessage], # type: ignore
65
+ object_=_response.json(),
66
+ ),
67
+ )
68
+ if _response.status_code == 422:
69
+ raise UnprocessableEntityError(
70
+ typing.cast(
71
+ HttpValidationError,
72
+ construct_type(
73
+ type_=HttpValidationError, # type: ignore
74
+ object_=_response.json(),
75
+ ),
76
+ )
77
+ )
78
+ _response_json = _response.json()
79
+ except JSONDecodeError:
80
+ raise ApiError(status_code=_response.status_code, body=_response.text)
81
+ raise ApiError(status_code=_response.status_code, body=_response_json)
82
+
83
+ def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
84
+ """
85
+ Retrieve the memory state of a specific agent.
86
+ This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
87
+
88
+ Parameters
89
+ ----------
90
+ agent_id : str
91
+
92
+ request_options : typing.Optional[RequestOptions]
93
+ Request-specific configuration.
94
+
95
+ Returns
96
+ -------
97
+ Memory
98
+ Successful Response
99
+
100
+ Examples
101
+ --------
102
+ from letta_client import Letta
103
+
104
+ client = Letta(
105
+ token="YOUR_TOKEN",
106
+ )
107
+ client.agents.core_memory.get(
108
+ agent_id="agent_id",
109
+ )
110
+ """
111
+ _response = self._client_wrapper.httpx_client.request(
112
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory",
113
+ method="GET",
114
+ request_options=request_options,
115
+ )
116
+ try:
117
+ if 200 <= _response.status_code < 300:
118
+ return typing.cast(
119
+ Memory,
120
+ construct_type(
121
+ type_=Memory, # type: ignore
122
+ object_=_response.json(),
123
+ ),
124
+ )
125
+ if _response.status_code == 422:
126
+ raise UnprocessableEntityError(
127
+ typing.cast(
128
+ HttpValidationError,
129
+ construct_type(
130
+ type_=HttpValidationError, # type: ignore
131
+ object_=_response.json(),
132
+ ),
133
+ )
134
+ )
135
+ _response_json = _response.json()
136
+ except JSONDecodeError:
137
+ raise ApiError(status_code=_response.status_code, body=_response.text)
138
+ raise ApiError(status_code=_response.status_code, body=_response_json)
139
+
140
+ def get_block(
141
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
142
+ ) -> Block:
143
+ """
144
+ Retrieve a memory block from an agent.
145
+
146
+ Parameters
147
+ ----------
148
+ agent_id : str
149
+
150
+ block_label : str
151
+
152
+ request_options : typing.Optional[RequestOptions]
153
+ Request-specific configuration.
154
+
155
+ Returns
156
+ -------
157
+ Block
158
+ Successful Response
159
+
160
+ Examples
161
+ --------
162
+ from letta_client import Letta
163
+
164
+ client = Letta(
165
+ token="YOUR_TOKEN",
166
+ )
167
+ client.agents.core_memory.get_block(
168
+ agent_id="agent_id",
169
+ block_label="block_label",
170
+ )
171
+ """
172
+ _response = self._client_wrapper.httpx_client.request(
173
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
174
+ method="GET",
175
+ request_options=request_options,
176
+ )
177
+ try:
178
+ if 200 <= _response.status_code < 300:
179
+ return typing.cast(
180
+ Block,
181
+ construct_type(
182
+ type_=Block, # type: ignore
183
+ object_=_response.json(),
184
+ ),
185
+ )
186
+ if _response.status_code == 422:
187
+ raise UnprocessableEntityError(
188
+ typing.cast(
189
+ HttpValidationError,
190
+ construct_type(
191
+ type_=HttpValidationError, # type: ignore
192
+ object_=_response.json(),
193
+ ),
194
+ )
195
+ )
196
+ _response_json = _response.json()
197
+ except JSONDecodeError:
198
+ raise ApiError(status_code=_response.status_code, body=_response.text)
199
+ raise ApiError(status_code=_response.status_code, body=_response_json)
200
+
201
+ def remove_block(
202
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
203
+ ) -> Memory:
204
+ """
205
+ Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
206
+
207
+ Parameters
208
+ ----------
209
+ agent_id : str
210
+
211
+ block_label : str
212
+
213
+ request_options : typing.Optional[RequestOptions]
214
+ Request-specific configuration.
215
+
216
+ Returns
217
+ -------
218
+ Memory
219
+ Successful Response
220
+
221
+ Examples
222
+ --------
223
+ from letta_client import Letta
224
+
225
+ client = Letta(
226
+ token="YOUR_TOKEN",
227
+ )
228
+ client.agents.core_memory.remove_block(
229
+ agent_id="agent_id",
230
+ block_label="block_label",
231
+ )
232
+ """
233
+ _response = self._client_wrapper.httpx_client.request(
234
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
235
+ method="DELETE",
236
+ request_options=request_options,
237
+ )
238
+ try:
239
+ if 200 <= _response.status_code < 300:
240
+ return typing.cast(
241
+ Memory,
242
+ construct_type(
243
+ type_=Memory, # type: ignore
244
+ object_=_response.json(),
245
+ ),
246
+ )
247
+ if _response.status_code == 422:
248
+ raise UnprocessableEntityError(
249
+ typing.cast(
250
+ HttpValidationError,
251
+ construct_type(
252
+ type_=HttpValidationError, # type: ignore
253
+ object_=_response.json(),
254
+ ),
255
+ )
256
+ )
257
+ _response_json = _response.json()
258
+ except JSONDecodeError:
259
+ raise ApiError(status_code=_response.status_code, body=_response.text)
260
+ raise ApiError(status_code=_response.status_code, body=_response_json)
261
+
262
+ def update_block(
263
+ self,
264
+ agent_id: str,
265
+ block_label: str,
266
+ *,
267
+ value: typing.Optional[str] = OMIT,
268
+ limit: typing.Optional[int] = OMIT,
269
+ name: typing.Optional[str] = OMIT,
270
+ is_template: typing.Optional[bool] = OMIT,
271
+ label: typing.Optional[str] = OMIT,
272
+ description: typing.Optional[str] = OMIT,
273
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
274
+ request_options: typing.Optional[RequestOptions] = None,
275
+ ) -> Block:
276
+ """
277
+ Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
278
+
279
+ Parameters
280
+ ----------
281
+ agent_id : str
282
+
283
+ block_label : str
284
+
285
+ value : typing.Optional[str]
286
+ Value of the block.
287
+
288
+ limit : typing.Optional[int]
289
+ Character limit of the block.
290
+
291
+ name : typing.Optional[str]
292
+ Name of the block if it is a template.
293
+
294
+ is_template : typing.Optional[bool]
295
+ Whether the block is a template (e.g. saved human/persona options).
296
+
297
+ label : typing.Optional[str]
298
+ Label of the block (e.g. 'human', 'persona') in the context window.
299
+
300
+ description : typing.Optional[str]
301
+ Description of the block.
302
+
303
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
304
+ Metadata of the block.
305
+
306
+ request_options : typing.Optional[RequestOptions]
307
+ Request-specific configuration.
308
+
309
+ Returns
310
+ -------
311
+ Block
312
+ Successful Response
313
+
314
+ Examples
315
+ --------
316
+ from letta_client import Letta
317
+
318
+ client = Letta(
319
+ token="YOUR_TOKEN",
320
+ )
321
+ client.agents.core_memory.update_block(
322
+ agent_id="agent_id",
323
+ block_label="block_label",
324
+ )
325
+ """
326
+ _response = self._client_wrapper.httpx_client.request(
327
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
328
+ method="PATCH",
329
+ json={
330
+ "value": value,
331
+ "limit": limit,
332
+ "name": name,
333
+ "is_template": is_template,
334
+ "label": label,
335
+ "description": description,
336
+ "metadata_": metadata,
337
+ },
338
+ request_options=request_options,
339
+ omit=OMIT,
340
+ )
341
+ try:
342
+ if 200 <= _response.status_code < 300:
343
+ return typing.cast(
344
+ Block,
345
+ construct_type(
346
+ type_=Block, # type: ignore
347
+ object_=_response.json(),
348
+ ),
349
+ )
350
+ if _response.status_code == 422:
351
+ raise UnprocessableEntityError(
352
+ typing.cast(
353
+ HttpValidationError,
354
+ construct_type(
355
+ type_=HttpValidationError, # type: ignore
356
+ object_=_response.json(),
357
+ ),
358
+ )
359
+ )
360
+ _response_json = _response.json()
361
+ except JSONDecodeError:
362
+ raise ApiError(status_code=_response.status_code, body=_response.text)
363
+ raise ApiError(status_code=_response.status_code, body=_response_json)
364
+
365
+ def get_blocks(
366
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
367
+ ) -> typing.List[Block]:
368
+ """
369
+ Retrieve the memory blocks of a specific agent.
370
+
371
+ Parameters
372
+ ----------
373
+ agent_id : str
374
+
375
+ request_options : typing.Optional[RequestOptions]
376
+ Request-specific configuration.
377
+
378
+ Returns
379
+ -------
380
+ typing.List[Block]
381
+ Successful Response
382
+
383
+ Examples
384
+ --------
385
+ from letta_client import Letta
386
+
387
+ client = Letta(
388
+ token="YOUR_TOKEN",
389
+ )
390
+ client.agents.core_memory.get_blocks(
391
+ agent_id="agent_id",
392
+ )
393
+ """
394
+ _response = self._client_wrapper.httpx_client.request(
395
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
396
+ method="GET",
397
+ request_options=request_options,
398
+ )
399
+ try:
400
+ if 200 <= _response.status_code < 300:
401
+ return typing.cast(
402
+ typing.List[Block],
403
+ construct_type(
404
+ type_=typing.List[Block], # type: ignore
405
+ object_=_response.json(),
406
+ ),
407
+ )
408
+ if _response.status_code == 422:
409
+ raise UnprocessableEntityError(
410
+ typing.cast(
411
+ HttpValidationError,
412
+ construct_type(
413
+ type_=HttpValidationError, # type: ignore
414
+ object_=_response.json(),
415
+ ),
416
+ )
417
+ )
418
+ _response_json = _response.json()
419
+ except JSONDecodeError:
420
+ raise ApiError(status_code=_response.status_code, body=_response.text)
421
+ raise ApiError(status_code=_response.status_code, body=_response_json)
422
+
423
+ def add_block(
424
+ self,
425
+ agent_id: str,
426
+ *,
427
+ value: str,
428
+ label: str,
429
+ limit: typing.Optional[int] = OMIT,
430
+ name: typing.Optional[str] = OMIT,
431
+ is_template: typing.Optional[bool] = OMIT,
432
+ description: typing.Optional[str] = OMIT,
433
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
434
+ request_options: typing.Optional[RequestOptions] = None,
435
+ ) -> Memory:
436
+ """
437
+ Creates a memory block and links it to the agent.
438
+
439
+ Parameters
440
+ ----------
441
+ agent_id : str
442
+
443
+ value : str
444
+ Value of the block.
445
+
446
+ label : str
447
+ Label of the block.
448
+
449
+ limit : typing.Optional[int]
450
+ Character limit of the block.
451
+
452
+ name : typing.Optional[str]
453
+ Name of the block if it is a template.
454
+
455
+ is_template : typing.Optional[bool]
456
+
457
+ description : typing.Optional[str]
458
+ Description of the block.
459
+
460
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
461
+ Metadata of the block.
462
+
463
+ request_options : typing.Optional[RequestOptions]
464
+ Request-specific configuration.
465
+
466
+ Returns
467
+ -------
468
+ Memory
469
+ Successful Response
470
+
471
+ Examples
472
+ --------
473
+ from letta_client import Letta
474
+
475
+ client = Letta(
476
+ token="YOUR_TOKEN",
477
+ )
478
+ client.agents.core_memory.add_block(
479
+ agent_id="agent_id",
480
+ value="value",
481
+ label="label",
482
+ )
483
+ """
484
+ _response = self._client_wrapper.httpx_client.request(
485
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
486
+ method="POST",
487
+ json={
488
+ "value": value,
489
+ "limit": limit,
490
+ "name": name,
491
+ "is_template": is_template,
492
+ "label": label,
493
+ "description": description,
494
+ "metadata_": metadata,
495
+ },
496
+ request_options=request_options,
497
+ omit=OMIT,
498
+ )
499
+ try:
500
+ if 200 <= _response.status_code < 300:
501
+ return typing.cast(
502
+ Memory,
503
+ construct_type(
504
+ type_=Memory, # type: ignore
505
+ object_=_response.json(),
506
+ ),
507
+ )
508
+ if _response.status_code == 422:
509
+ raise UnprocessableEntityError(
510
+ typing.cast(
511
+ HttpValidationError,
512
+ construct_type(
513
+ type_=HttpValidationError, # type: ignore
514
+ object_=_response.json(),
515
+ ),
516
+ )
517
+ )
518
+ _response_json = _response.json()
519
+ except JSONDecodeError:
520
+ raise ApiError(status_code=_response.status_code, body=_response.text)
521
+ raise ApiError(status_code=_response.status_code, body=_response_json)
522
+
523
+
524
+ class AsyncCoreMemoryClient:
525
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
526
+ self._client_wrapper = client_wrapper
527
+
528
+ async def list_in_context(
529
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
530
+ ) -> typing.List[LettaSchemasMessageMessage]:
531
+ """
532
+ Retrieve the messages in the context of a specific agent.
533
+
534
+ Parameters
535
+ ----------
536
+ agent_id : str
537
+
538
+ request_options : typing.Optional[RequestOptions]
539
+ Request-specific configuration.
540
+
541
+ Returns
542
+ -------
543
+ typing.List[LettaSchemasMessageMessage]
544
+ Successful Response
545
+
546
+ Examples
547
+ --------
548
+ import asyncio
549
+
550
+ from letta_client import AsyncLetta
551
+
552
+ client = AsyncLetta(
553
+ token="YOUR_TOKEN",
554
+ )
555
+
556
+
557
+ async def main() -> None:
558
+ await client.agents.core_memory.list_in_context(
559
+ agent_id="agent_id",
560
+ )
561
+
562
+
563
+ asyncio.run(main())
564
+ """
565
+ _response = await self._client_wrapper.httpx_client.request(
566
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/messages",
567
+ method="GET",
568
+ request_options=request_options,
569
+ )
570
+ try:
571
+ if 200 <= _response.status_code < 300:
572
+ return typing.cast(
573
+ typing.List[LettaSchemasMessageMessage],
574
+ construct_type(
575
+ type_=typing.List[LettaSchemasMessageMessage], # type: ignore
576
+ object_=_response.json(),
577
+ ),
578
+ )
579
+ if _response.status_code == 422:
580
+ raise UnprocessableEntityError(
581
+ typing.cast(
582
+ HttpValidationError,
583
+ construct_type(
584
+ type_=HttpValidationError, # type: ignore
585
+ object_=_response.json(),
586
+ ),
587
+ )
588
+ )
589
+ _response_json = _response.json()
590
+ except JSONDecodeError:
591
+ raise ApiError(status_code=_response.status_code, body=_response.text)
592
+ raise ApiError(status_code=_response.status_code, body=_response_json)
593
+
594
+ async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
595
+ """
596
+ Retrieve the memory state of a specific agent.
597
+ This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
598
+
599
+ Parameters
600
+ ----------
601
+ agent_id : str
602
+
603
+ request_options : typing.Optional[RequestOptions]
604
+ Request-specific configuration.
605
+
606
+ Returns
607
+ -------
608
+ Memory
609
+ Successful Response
610
+
611
+ Examples
612
+ --------
613
+ import asyncio
614
+
615
+ from letta_client import AsyncLetta
616
+
617
+ client = AsyncLetta(
618
+ token="YOUR_TOKEN",
619
+ )
620
+
621
+
622
+ async def main() -> None:
623
+ await client.agents.core_memory.get(
624
+ agent_id="agent_id",
625
+ )
626
+
627
+
628
+ asyncio.run(main())
629
+ """
630
+ _response = await self._client_wrapper.httpx_client.request(
631
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory",
632
+ method="GET",
633
+ request_options=request_options,
634
+ )
635
+ try:
636
+ if 200 <= _response.status_code < 300:
637
+ return typing.cast(
638
+ Memory,
639
+ construct_type(
640
+ type_=Memory, # type: ignore
641
+ object_=_response.json(),
642
+ ),
643
+ )
644
+ if _response.status_code == 422:
645
+ raise UnprocessableEntityError(
646
+ typing.cast(
647
+ HttpValidationError,
648
+ construct_type(
649
+ type_=HttpValidationError, # type: ignore
650
+ object_=_response.json(),
651
+ ),
652
+ )
653
+ )
654
+ _response_json = _response.json()
655
+ except JSONDecodeError:
656
+ raise ApiError(status_code=_response.status_code, body=_response.text)
657
+ raise ApiError(status_code=_response.status_code, body=_response_json)
658
+
659
+ async def get_block(
660
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
661
+ ) -> Block:
662
+ """
663
+ Retrieve a memory block from an agent.
664
+
665
+ Parameters
666
+ ----------
667
+ agent_id : str
668
+
669
+ block_label : str
670
+
671
+ request_options : typing.Optional[RequestOptions]
672
+ Request-specific configuration.
673
+
674
+ Returns
675
+ -------
676
+ Block
677
+ Successful Response
678
+
679
+ Examples
680
+ --------
681
+ import asyncio
682
+
683
+ from letta_client import AsyncLetta
684
+
685
+ client = AsyncLetta(
686
+ token="YOUR_TOKEN",
687
+ )
688
+
689
+
690
+ async def main() -> None:
691
+ await client.agents.core_memory.get_block(
692
+ agent_id="agent_id",
693
+ block_label="block_label",
694
+ )
695
+
696
+
697
+ asyncio.run(main())
698
+ """
699
+ _response = await self._client_wrapper.httpx_client.request(
700
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
701
+ method="GET",
702
+ request_options=request_options,
703
+ )
704
+ try:
705
+ if 200 <= _response.status_code < 300:
706
+ return typing.cast(
707
+ Block,
708
+ construct_type(
709
+ type_=Block, # type: ignore
710
+ object_=_response.json(),
711
+ ),
712
+ )
713
+ if _response.status_code == 422:
714
+ raise UnprocessableEntityError(
715
+ typing.cast(
716
+ HttpValidationError,
717
+ construct_type(
718
+ type_=HttpValidationError, # type: ignore
719
+ object_=_response.json(),
720
+ ),
721
+ )
722
+ )
723
+ _response_json = _response.json()
724
+ except JSONDecodeError:
725
+ raise ApiError(status_code=_response.status_code, body=_response.text)
726
+ raise ApiError(status_code=_response.status_code, body=_response_json)
727
+
728
+ async def remove_block(
729
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
730
+ ) -> Memory:
731
+ """
732
+ Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
733
+
734
+ Parameters
735
+ ----------
736
+ agent_id : str
737
+
738
+ block_label : str
739
+
740
+ request_options : typing.Optional[RequestOptions]
741
+ Request-specific configuration.
742
+
743
+ Returns
744
+ -------
745
+ Memory
746
+ Successful Response
747
+
748
+ Examples
749
+ --------
750
+ import asyncio
751
+
752
+ from letta_client import AsyncLetta
753
+
754
+ client = AsyncLetta(
755
+ token="YOUR_TOKEN",
756
+ )
757
+
758
+
759
+ async def main() -> None:
760
+ await client.agents.core_memory.remove_block(
761
+ agent_id="agent_id",
762
+ block_label="block_label",
763
+ )
764
+
765
+
766
+ asyncio.run(main())
767
+ """
768
+ _response = await self._client_wrapper.httpx_client.request(
769
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
770
+ method="DELETE",
771
+ request_options=request_options,
772
+ )
773
+ try:
774
+ if 200 <= _response.status_code < 300:
775
+ return typing.cast(
776
+ Memory,
777
+ construct_type(
778
+ type_=Memory, # type: ignore
779
+ object_=_response.json(),
780
+ ),
781
+ )
782
+ if _response.status_code == 422:
783
+ raise UnprocessableEntityError(
784
+ typing.cast(
785
+ HttpValidationError,
786
+ construct_type(
787
+ type_=HttpValidationError, # type: ignore
788
+ object_=_response.json(),
789
+ ),
790
+ )
791
+ )
792
+ _response_json = _response.json()
793
+ except JSONDecodeError:
794
+ raise ApiError(status_code=_response.status_code, body=_response.text)
795
+ raise ApiError(status_code=_response.status_code, body=_response_json)
796
+
797
+ async def update_block(
798
+ self,
799
+ agent_id: str,
800
+ block_label: str,
801
+ *,
802
+ value: typing.Optional[str] = OMIT,
803
+ limit: typing.Optional[int] = OMIT,
804
+ name: typing.Optional[str] = OMIT,
805
+ is_template: typing.Optional[bool] = OMIT,
806
+ label: typing.Optional[str] = OMIT,
807
+ description: typing.Optional[str] = OMIT,
808
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
809
+ request_options: typing.Optional[RequestOptions] = None,
810
+ ) -> Block:
811
+ """
812
+ Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
813
+
814
+ Parameters
815
+ ----------
816
+ agent_id : str
817
+
818
+ block_label : str
819
+
820
+ value : typing.Optional[str]
821
+ Value of the block.
822
+
823
+ limit : typing.Optional[int]
824
+ Character limit of the block.
825
+
826
+ name : typing.Optional[str]
827
+ Name of the block if it is a template.
828
+
829
+ is_template : typing.Optional[bool]
830
+ Whether the block is a template (e.g. saved human/persona options).
831
+
832
+ label : typing.Optional[str]
833
+ Label of the block (e.g. 'human', 'persona') in the context window.
834
+
835
+ description : typing.Optional[str]
836
+ Description of the block.
837
+
838
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
839
+ Metadata of the block.
840
+
841
+ request_options : typing.Optional[RequestOptions]
842
+ Request-specific configuration.
843
+
844
+ Returns
845
+ -------
846
+ Block
847
+ Successful Response
848
+
849
+ Examples
850
+ --------
851
+ import asyncio
852
+
853
+ from letta_client import AsyncLetta
854
+
855
+ client = AsyncLetta(
856
+ token="YOUR_TOKEN",
857
+ )
858
+
859
+
860
+ async def main() -> None:
861
+ await client.agents.core_memory.update_block(
862
+ agent_id="agent_id",
863
+ block_label="block_label",
864
+ )
865
+
866
+
867
+ asyncio.run(main())
868
+ """
869
+ _response = await self._client_wrapper.httpx_client.request(
870
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
871
+ method="PATCH",
872
+ json={
873
+ "value": value,
874
+ "limit": limit,
875
+ "name": name,
876
+ "is_template": is_template,
877
+ "label": label,
878
+ "description": description,
879
+ "metadata_": metadata,
880
+ },
881
+ request_options=request_options,
882
+ omit=OMIT,
883
+ )
884
+ try:
885
+ if 200 <= _response.status_code < 300:
886
+ return typing.cast(
887
+ Block,
888
+ construct_type(
889
+ type_=Block, # type: ignore
890
+ object_=_response.json(),
891
+ ),
892
+ )
893
+ if _response.status_code == 422:
894
+ raise UnprocessableEntityError(
895
+ typing.cast(
896
+ HttpValidationError,
897
+ construct_type(
898
+ type_=HttpValidationError, # type: ignore
899
+ object_=_response.json(),
900
+ ),
901
+ )
902
+ )
903
+ _response_json = _response.json()
904
+ except JSONDecodeError:
905
+ raise ApiError(status_code=_response.status_code, body=_response.text)
906
+ raise ApiError(status_code=_response.status_code, body=_response_json)
907
+
908
+ async def get_blocks(
909
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
910
+ ) -> typing.List[Block]:
911
+ """
912
+ Retrieve the memory blocks of a specific agent.
913
+
914
+ Parameters
915
+ ----------
916
+ agent_id : str
917
+
918
+ request_options : typing.Optional[RequestOptions]
919
+ Request-specific configuration.
920
+
921
+ Returns
922
+ -------
923
+ typing.List[Block]
924
+ Successful Response
925
+
926
+ Examples
927
+ --------
928
+ import asyncio
929
+
930
+ from letta_client import AsyncLetta
931
+
932
+ client = AsyncLetta(
933
+ token="YOUR_TOKEN",
934
+ )
935
+
936
+
937
+ async def main() -> None:
938
+ await client.agents.core_memory.get_blocks(
939
+ agent_id="agent_id",
940
+ )
941
+
942
+
943
+ asyncio.run(main())
944
+ """
945
+ _response = await self._client_wrapper.httpx_client.request(
946
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
947
+ method="GET",
948
+ request_options=request_options,
949
+ )
950
+ try:
951
+ if 200 <= _response.status_code < 300:
952
+ return typing.cast(
953
+ typing.List[Block],
954
+ construct_type(
955
+ type_=typing.List[Block], # type: ignore
956
+ object_=_response.json(),
957
+ ),
958
+ )
959
+ if _response.status_code == 422:
960
+ raise UnprocessableEntityError(
961
+ typing.cast(
962
+ HttpValidationError,
963
+ construct_type(
964
+ type_=HttpValidationError, # type: ignore
965
+ object_=_response.json(),
966
+ ),
967
+ )
968
+ )
969
+ _response_json = _response.json()
970
+ except JSONDecodeError:
971
+ raise ApiError(status_code=_response.status_code, body=_response.text)
972
+ raise ApiError(status_code=_response.status_code, body=_response_json)
973
+
974
+ async def add_block(
975
+ self,
976
+ agent_id: str,
977
+ *,
978
+ value: str,
979
+ label: str,
980
+ limit: typing.Optional[int] = OMIT,
981
+ name: typing.Optional[str] = OMIT,
982
+ is_template: typing.Optional[bool] = OMIT,
983
+ description: typing.Optional[str] = OMIT,
984
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
985
+ request_options: typing.Optional[RequestOptions] = None,
986
+ ) -> Memory:
987
+ """
988
+ Creates a memory block and links it to the agent.
989
+
990
+ Parameters
991
+ ----------
992
+ agent_id : str
993
+
994
+ value : str
995
+ Value of the block.
996
+
997
+ label : str
998
+ Label of the block.
999
+
1000
+ limit : typing.Optional[int]
1001
+ Character limit of the block.
1002
+
1003
+ name : typing.Optional[str]
1004
+ Name of the block if it is a template.
1005
+
1006
+ is_template : typing.Optional[bool]
1007
+
1008
+ description : typing.Optional[str]
1009
+ Description of the block.
1010
+
1011
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1012
+ Metadata of the block.
1013
+
1014
+ request_options : typing.Optional[RequestOptions]
1015
+ Request-specific configuration.
1016
+
1017
+ Returns
1018
+ -------
1019
+ Memory
1020
+ Successful Response
1021
+
1022
+ Examples
1023
+ --------
1024
+ import asyncio
1025
+
1026
+ from letta_client import AsyncLetta
1027
+
1028
+ client = AsyncLetta(
1029
+ token="YOUR_TOKEN",
1030
+ )
1031
+
1032
+
1033
+ async def main() -> None:
1034
+ await client.agents.core_memory.add_block(
1035
+ agent_id="agent_id",
1036
+ value="value",
1037
+ label="label",
1038
+ )
1039
+
1040
+
1041
+ asyncio.run(main())
1042
+ """
1043
+ _response = await self._client_wrapper.httpx_client.request(
1044
+ f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
1045
+ method="POST",
1046
+ json={
1047
+ "value": value,
1048
+ "limit": limit,
1049
+ "name": name,
1050
+ "is_template": is_template,
1051
+ "label": label,
1052
+ "description": description,
1053
+ "metadata_": metadata,
1054
+ },
1055
+ request_options=request_options,
1056
+ omit=OMIT,
1057
+ )
1058
+ try:
1059
+ if 200 <= _response.status_code < 300:
1060
+ return typing.cast(
1061
+ Memory,
1062
+ construct_type(
1063
+ type_=Memory, # type: ignore
1064
+ object_=_response.json(),
1065
+ ),
1066
+ )
1067
+ if _response.status_code == 422:
1068
+ raise UnprocessableEntityError(
1069
+ typing.cast(
1070
+ HttpValidationError,
1071
+ construct_type(
1072
+ type_=HttpValidationError, # type: ignore
1073
+ object_=_response.json(),
1074
+ ),
1075
+ )
1076
+ )
1077
+ _response_json = _response.json()
1078
+ except JSONDecodeError:
1079
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1080
+ raise ApiError(status_code=_response.status_code, body=_response_json)