letta-client 0.1.16__py3-none-any.whl → 0.1.19__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.
- letta_client/__init__.py +34 -120
- letta_client/agents/__init__.py +18 -54
- letta_client/agents/archival_memory/client.py +25 -343
- letta_client/agents/client.py +1640 -347
- letta_client/agents/context/client.py +6 -4
- letta_client/agents/core_memory/client.py +95 -624
- letta_client/agents/memory_variables/__init__.py +2 -2
- letta_client/agents/memory_variables/client.py +15 -15
- letta_client/agents/memory_variables/types/__init__.py +2 -2
- letta_client/agents/memory_variables/types/{memory_variables_get_response.py → memory_variables_list_response.py} +1 -1
- letta_client/agents/messages/__init__.py +2 -22
- letta_client/agents/messages/client.py +32 -38
- letta_client/agents/messages/types/__init__.py +2 -21
- letta_client/agents/messages/types/letta_streaming_response.py +16 -139
- letta_client/agents/messages/types/messages_list_response.py +2 -2
- letta_client/agents/sources/client.py +266 -5
- letta_client/agents/tools/client.py +25 -27
- letta_client/agents/types/__init__.py +15 -25
- letta_client/agents/types/agents_search_request_search_item.py +10 -78
- letta_client/agents/types/{agents_search_request_search_item_order_by.py → agents_search_request_search_item_direction.py} +7 -6
- letta_client/agents/types/agents_search_request_search_item_direction_direction.py +5 -0
- letta_client/agents/types/agents_search_request_search_item_direction_value.py +5 -0
- letta_client/agents/types/{agents_search_request_search_item_name.py → agents_search_request_search_item_one.py} +5 -4
- letta_client/agents/types/agents_search_request_search_item_one_operator.py +5 -0
- letta_client/agents/types/{agents_search_request_search_item_tags.py → agents_search_request_search_item_two.py} +2 -1
- letta_client/agents/types/{agents_search_request_search_item_version.py → agents_search_request_search_item_zero.py} +3 -2
- letta_client/blocks/client.py +12 -260
- letta_client/client.py +3 -3
- letta_client/core/client_wrapper.py +1 -1
- letta_client/jobs/client.py +4 -4
- letta_client/providers/client.py +74 -74
- letta_client/runs/client.py +14 -12
- letta_client/sources/client.py +12 -288
- letta_client/tools/client.py +63 -189
- letta_client/types/__init__.py +21 -103
- letta_client/types/agent_state.py +3 -7
- letta_client/types/{assistant_message_output.py → assistant_message.py} +3 -2
- letta_client/types/block.py +2 -6
- letta_client/types/block_update.py +1 -5
- letta_client/types/{archival_memory_summary.py → chat_completion_message_tool_call.py} +7 -7
- letta_client/types/context_window_overview.py +4 -6
- letta_client/types/create_block.py +1 -5
- letta_client/types/embedding_config_embedding_endpoint_type.py +1 -0
- letta_client/types/{function_call_output.py → function.py} +1 -1
- letta_client/types/{function_schema.py → function_definition.py} +2 -1
- letta_client/types/{create_assistant_file_request.py → function_tool.py} +6 -7
- letta_client/types/job.py +1 -5
- letta_client/types/letta_message_union.py +9 -121
- letta_client/types/letta_usage_statistics.py +1 -0
- letta_client/types/llm_config_model_endpoint_type.py +1 -0
- letta_client/types/{letta_schemas_message_message.py → message.py} +9 -6
- letta_client/types/passage.py +1 -5
- letta_client/types/reasoning_message.py +2 -1
- letta_client/types/run.py +1 -5
- letta_client/types/source.py +2 -6
- letta_client/types/{system_message_output.py → system_message.py} +3 -2
- letta_client/types/{letta_schemas_tool_tool.py → tool.py} +1 -1
- letta_client/types/{letta_schemas_letta_message_tool_call.py → tool_call.py} +1 -1
- letta_client/types/tool_call_message.py +2 -1
- letta_client/types/tool_call_message_tool_call.py +2 -2
- letta_client/types/tool_return_message.py +2 -1
- letta_client/types/tool_type.py +2 -1
- letta_client/types/{user_message_output.py → user_message.py} +3 -2
- {letta_client-0.1.16.dist-info → letta_client-0.1.19.dist-info}/METADATA +2 -2
- {letta_client-0.1.16.dist-info → letta_client-0.1.19.dist-info}/RECORD +66 -101
- letta_client/agents/recall_memory/__init__.py +0 -2
- letta_client/agents/recall_memory/client.py +0 -147
- letta_client/agents/types/agents_search_request_search_item_name_operator.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_order_by_value.py +0 -5
- letta_client/types/assistant_file.py +0 -33
- letta_client/types/assistant_message_input.py +0 -23
- letta_client/types/chat_completion_request.py +0 -49
- letta_client/types/chat_completion_request_function_call.py +0 -6
- letta_client/types/chat_completion_request_messages_item.py +0 -11
- letta_client/types/chat_completion_request_stop.py +0 -5
- letta_client/types/chat_completion_request_tool_choice.py +0 -8
- letta_client/types/chat_completion_response.py +0 -32
- letta_client/types/choice.py +0 -25
- letta_client/types/create_assistant_request.py +0 -57
- letta_client/types/delete_assistant_file_response.py +0 -28
- letta_client/types/delete_assistant_response.py +0 -28
- letta_client/types/function_call_input.py +0 -19
- letta_client/types/letta_schemas_openai_chat_completion_request_tool.py +0 -21
- letta_client/types/letta_schemas_openai_chat_completion_request_tool_call.py +0 -24
- letta_client/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +0 -20
- letta_client/types/letta_schemas_openai_chat_completion_response_message.py +0 -24
- letta_client/types/letta_schemas_openai_chat_completion_response_tool_call.py +0 -22
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_function.py +0 -27
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_input.py +0 -29
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_output.py +0 -29
- letta_client/types/log_prob_token.py +0 -21
- letta_client/types/message_content_log_prob.py +0 -23
- letta_client/types/open_ai_assistant.py +0 -67
- letta_client/types/recall_memory_summary.py +0 -22
- letta_client/types/response_format.py +0 -19
- letta_client/types/system_message_input.py +0 -21
- letta_client/types/tool_call_function_output.py +0 -27
- letta_client/types/tool_function_choice.py +0 -21
- letta_client/types/tool_input.py +0 -21
- letta_client/types/tool_message.py +0 -21
- letta_client/types/user_message_input.py +0 -22
- letta_client/types/user_message_input_content.py +0 -5
- {letta_client-0.1.16.dist-info → letta_client-0.1.19.dist-info}/WHEEL +0 -0
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import typing
|
|
4
3
|
from ...core.client_wrapper import SyncClientWrapper
|
|
4
|
+
import typing
|
|
5
5
|
from ...core.request_options import RequestOptions
|
|
6
|
-
from ...types.letta_schemas_message_message import LettaSchemasMessageMessage
|
|
7
6
|
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
7
|
from json.decoder import JSONDecodeError
|
|
12
8
|
from ...core.api_error import ApiError
|
|
13
|
-
from ...types.memory import Memory
|
|
14
|
-
from ...types.block import Block
|
|
15
9
|
from ...core.client_wrapper import AsyncClientWrapper
|
|
16
10
|
|
|
17
|
-
# this is used as the default value for optional parameters
|
|
18
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
19
|
-
|
|
20
11
|
|
|
21
12
|
class CoreMemoryClient:
|
|
22
13
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
14
|
self._client_wrapper = client_wrapper
|
|
24
15
|
|
|
25
|
-
def
|
|
26
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
27
|
-
) -> typing.List[LettaSchemasMessageMessage]:
|
|
16
|
+
def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
28
17
|
"""
|
|
29
|
-
Retrieve the messages in the context of a specific agent.
|
|
30
|
-
|
|
31
18
|
Parameters
|
|
32
19
|
----------
|
|
33
20
|
agent_id : str
|
|
@@ -37,8 +24,7 @@ class CoreMemoryClient:
|
|
|
37
24
|
|
|
38
25
|
Returns
|
|
39
26
|
-------
|
|
40
|
-
|
|
41
|
-
Successful Response
|
|
27
|
+
None
|
|
42
28
|
|
|
43
29
|
Examples
|
|
44
30
|
--------
|
|
@@ -47,44 +33,25 @@ class CoreMemoryClient:
|
|
|
47
33
|
client = Letta(
|
|
48
34
|
token="YOUR_TOKEN",
|
|
49
35
|
)
|
|
50
|
-
client.agents.core_memory.
|
|
36
|
+
client.agents.core_memory.retrieve(
|
|
51
37
|
agent_id="agent_id",
|
|
52
38
|
)
|
|
53
39
|
"""
|
|
54
40
|
_response = self._client_wrapper.httpx_client.request(
|
|
55
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
41
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
|
|
56
42
|
method="GET",
|
|
57
43
|
request_options=request_options,
|
|
58
44
|
)
|
|
59
45
|
try:
|
|
60
46
|
if 200 <= _response.status_code < 300:
|
|
61
|
-
return
|
|
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
|
-
)
|
|
47
|
+
return
|
|
78
48
|
_response_json = _response.json()
|
|
79
49
|
except JSONDecodeError:
|
|
80
50
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
81
51
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
82
52
|
|
|
83
|
-
def
|
|
53
|
+
def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
84
54
|
"""
|
|
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
55
|
Parameters
|
|
89
56
|
----------
|
|
90
57
|
agent_id : str
|
|
@@ -94,8 +61,7 @@ class CoreMemoryClient:
|
|
|
94
61
|
|
|
95
62
|
Returns
|
|
96
63
|
-------
|
|
97
|
-
|
|
98
|
-
Successful Response
|
|
64
|
+
None
|
|
99
65
|
|
|
100
66
|
Examples
|
|
101
67
|
--------
|
|
@@ -104,58 +70,39 @@ class CoreMemoryClient:
|
|
|
104
70
|
client = Letta(
|
|
105
71
|
token="YOUR_TOKEN",
|
|
106
72
|
)
|
|
107
|
-
client.agents.core_memory.
|
|
73
|
+
client.agents.core_memory.list_blocks(
|
|
108
74
|
agent_id="agent_id",
|
|
109
75
|
)
|
|
110
76
|
"""
|
|
111
77
|
_response = self._client_wrapper.httpx_client.request(
|
|
112
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
78
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
113
79
|
method="GET",
|
|
114
80
|
request_options=request_options,
|
|
115
81
|
)
|
|
116
82
|
try:
|
|
117
83
|
if 200 <= _response.status_code < 300:
|
|
118
|
-
return
|
|
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
|
-
)
|
|
84
|
+
return
|
|
135
85
|
_response_json = _response.json()
|
|
136
86
|
except JSONDecodeError:
|
|
137
87
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
138
88
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
139
89
|
|
|
140
|
-
def
|
|
141
|
-
self, agent_id: str,
|
|
142
|
-
) ->
|
|
90
|
+
def attach_block(
|
|
91
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
92
|
+
) -> None:
|
|
143
93
|
"""
|
|
144
|
-
Retrieve a memory block from an agent.
|
|
145
|
-
|
|
146
94
|
Parameters
|
|
147
95
|
----------
|
|
148
96
|
agent_id : str
|
|
149
97
|
|
|
150
|
-
|
|
98
|
+
block_id : str
|
|
151
99
|
|
|
152
100
|
request_options : typing.Optional[RequestOptions]
|
|
153
101
|
Request-specific configuration.
|
|
154
102
|
|
|
155
103
|
Returns
|
|
156
104
|
-------
|
|
157
|
-
|
|
158
|
-
Successful Response
|
|
105
|
+
None
|
|
159
106
|
|
|
160
107
|
Examples
|
|
161
108
|
--------
|
|
@@ -164,59 +111,40 @@ class CoreMemoryClient:
|
|
|
164
111
|
client = Letta(
|
|
165
112
|
token="YOUR_TOKEN",
|
|
166
113
|
)
|
|
167
|
-
client.agents.core_memory.
|
|
114
|
+
client.agents.core_memory.attach_block(
|
|
168
115
|
agent_id="agent_id",
|
|
169
|
-
|
|
116
|
+
block_id="block_id",
|
|
170
117
|
)
|
|
171
118
|
"""
|
|
172
119
|
_response = self._client_wrapper.httpx_client.request(
|
|
173
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
174
|
-
method="
|
|
120
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
|
|
121
|
+
method="PATCH",
|
|
175
122
|
request_options=request_options,
|
|
176
123
|
)
|
|
177
124
|
try:
|
|
178
125
|
if 200 <= _response.status_code < 300:
|
|
179
|
-
return
|
|
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
|
-
)
|
|
126
|
+
return
|
|
196
127
|
_response_json = _response.json()
|
|
197
128
|
except JSONDecodeError:
|
|
198
129
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
199
130
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
200
131
|
|
|
201
|
-
def
|
|
202
|
-
self, agent_id: str,
|
|
203
|
-
) ->
|
|
132
|
+
def detach_block(
|
|
133
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
134
|
+
) -> None:
|
|
204
135
|
"""
|
|
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
136
|
Parameters
|
|
208
137
|
----------
|
|
209
138
|
agent_id : str
|
|
210
139
|
|
|
211
|
-
|
|
140
|
+
block_id : str
|
|
212
141
|
|
|
213
142
|
request_options : typing.Optional[RequestOptions]
|
|
214
143
|
Request-specific configuration.
|
|
215
144
|
|
|
216
145
|
Returns
|
|
217
146
|
-------
|
|
218
|
-
|
|
219
|
-
Successful Response
|
|
147
|
+
None
|
|
220
148
|
|
|
221
149
|
Examples
|
|
222
150
|
--------
|
|
@@ -225,91 +153,40 @@ class CoreMemoryClient:
|
|
|
225
153
|
client = Letta(
|
|
226
154
|
token="YOUR_TOKEN",
|
|
227
155
|
)
|
|
228
|
-
client.agents.core_memory.
|
|
156
|
+
client.agents.core_memory.detach_block(
|
|
229
157
|
agent_id="agent_id",
|
|
230
|
-
|
|
158
|
+
block_id="block_id",
|
|
231
159
|
)
|
|
232
160
|
"""
|
|
233
161
|
_response = self._client_wrapper.httpx_client.request(
|
|
234
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
235
|
-
method="
|
|
162
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
|
|
163
|
+
method="PATCH",
|
|
236
164
|
request_options=request_options,
|
|
237
165
|
)
|
|
238
166
|
try:
|
|
239
167
|
if 200 <= _response.status_code < 300:
|
|
240
|
-
return
|
|
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
|
-
)
|
|
168
|
+
return
|
|
257
169
|
_response_json = _response.json()
|
|
258
170
|
except JSONDecodeError:
|
|
259
171
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
260
172
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
261
173
|
|
|
262
|
-
def
|
|
263
|
-
self,
|
|
264
|
-
|
|
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:
|
|
174
|
+
def retrieve_block(
|
|
175
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
176
|
+
) -> None:
|
|
276
177
|
"""
|
|
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
178
|
Parameters
|
|
280
179
|
----------
|
|
281
180
|
agent_id : str
|
|
282
181
|
|
|
283
182
|
block_label : str
|
|
284
183
|
|
|
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
184
|
request_options : typing.Optional[RequestOptions]
|
|
307
185
|
Request-specific configuration.
|
|
308
186
|
|
|
309
187
|
Returns
|
|
310
188
|
-------
|
|
311
|
-
|
|
312
|
-
Successful Response
|
|
189
|
+
None
|
|
313
190
|
|
|
314
191
|
Examples
|
|
315
192
|
--------
|
|
@@ -318,155 +195,40 @@ class CoreMemoryClient:
|
|
|
318
195
|
client = Letta(
|
|
319
196
|
token="YOUR_TOKEN",
|
|
320
197
|
)
|
|
321
|
-
client.agents.core_memory.
|
|
198
|
+
client.agents.core_memory.retrieve_block(
|
|
322
199
|
agent_id="agent_id",
|
|
323
200
|
block_label="block_label",
|
|
324
201
|
)
|
|
325
202
|
"""
|
|
326
203
|
_response = self._client_wrapper.httpx_client.request(
|
|
327
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
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",
|
|
204
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
396
205
|
method="GET",
|
|
397
206
|
request_options=request_options,
|
|
398
207
|
)
|
|
399
208
|
try:
|
|
400
209
|
if 200 <= _response.status_code < 300:
|
|
401
|
-
return
|
|
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
|
-
)
|
|
210
|
+
return
|
|
418
211
|
_response_json = _response.json()
|
|
419
212
|
except JSONDecodeError:
|
|
420
213
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
421
214
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
422
215
|
|
|
423
|
-
def
|
|
424
|
-
self,
|
|
425
|
-
|
|
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:
|
|
216
|
+
def modify_block(
|
|
217
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
218
|
+
) -> None:
|
|
436
219
|
"""
|
|
437
|
-
Creates a memory block and links it to the agent.
|
|
438
|
-
|
|
439
220
|
Parameters
|
|
440
221
|
----------
|
|
441
222
|
agent_id : str
|
|
442
223
|
|
|
443
|
-
|
|
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.
|
|
224
|
+
block_label : str
|
|
462
225
|
|
|
463
226
|
request_options : typing.Optional[RequestOptions]
|
|
464
227
|
Request-specific configuration.
|
|
465
228
|
|
|
466
229
|
Returns
|
|
467
230
|
-------
|
|
468
|
-
|
|
469
|
-
Successful Response
|
|
231
|
+
None
|
|
470
232
|
|
|
471
233
|
Examples
|
|
472
234
|
--------
|
|
@@ -475,46 +237,19 @@ class CoreMemoryClient:
|
|
|
475
237
|
client = Letta(
|
|
476
238
|
token="YOUR_TOKEN",
|
|
477
239
|
)
|
|
478
|
-
client.agents.core_memory.
|
|
240
|
+
client.agents.core_memory.modify_block(
|
|
479
241
|
agent_id="agent_id",
|
|
480
|
-
|
|
481
|
-
label="label",
|
|
242
|
+
block_label="block_label",
|
|
482
243
|
)
|
|
483
244
|
"""
|
|
484
245
|
_response = self._client_wrapper.httpx_client.request(
|
|
485
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
486
|
-
method="
|
|
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
|
-
},
|
|
246
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
247
|
+
method="PATCH",
|
|
496
248
|
request_options=request_options,
|
|
497
|
-
omit=OMIT,
|
|
498
249
|
)
|
|
499
250
|
try:
|
|
500
251
|
if 200 <= _response.status_code < 300:
|
|
501
|
-
return
|
|
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
|
-
)
|
|
252
|
+
return
|
|
518
253
|
_response_json = _response.json()
|
|
519
254
|
except JSONDecodeError:
|
|
520
255
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -525,12 +260,8 @@ class AsyncCoreMemoryClient:
|
|
|
525
260
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
526
261
|
self._client_wrapper = client_wrapper
|
|
527
262
|
|
|
528
|
-
async def
|
|
529
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
530
|
-
) -> typing.List[LettaSchemasMessageMessage]:
|
|
263
|
+
async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
531
264
|
"""
|
|
532
|
-
Retrieve the messages in the context of a specific agent.
|
|
533
|
-
|
|
534
265
|
Parameters
|
|
535
266
|
----------
|
|
536
267
|
agent_id : str
|
|
@@ -540,8 +271,7 @@ class AsyncCoreMemoryClient:
|
|
|
540
271
|
|
|
541
272
|
Returns
|
|
542
273
|
-------
|
|
543
|
-
|
|
544
|
-
Successful Response
|
|
274
|
+
None
|
|
545
275
|
|
|
546
276
|
Examples
|
|
547
277
|
--------
|
|
@@ -555,7 +285,7 @@ class AsyncCoreMemoryClient:
|
|
|
555
285
|
|
|
556
286
|
|
|
557
287
|
async def main() -> None:
|
|
558
|
-
await client.agents.core_memory.
|
|
288
|
+
await client.agents.core_memory.retrieve(
|
|
559
289
|
agent_id="agent_id",
|
|
560
290
|
)
|
|
561
291
|
|
|
@@ -563,39 +293,20 @@ class AsyncCoreMemoryClient:
|
|
|
563
293
|
asyncio.run(main())
|
|
564
294
|
"""
|
|
565
295
|
_response = await self._client_wrapper.httpx_client.request(
|
|
566
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
296
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
|
|
567
297
|
method="GET",
|
|
568
298
|
request_options=request_options,
|
|
569
299
|
)
|
|
570
300
|
try:
|
|
571
301
|
if 200 <= _response.status_code < 300:
|
|
572
|
-
return
|
|
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
|
-
)
|
|
302
|
+
return
|
|
589
303
|
_response_json = _response.json()
|
|
590
304
|
except JSONDecodeError:
|
|
591
305
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
592
306
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
593
307
|
|
|
594
|
-
async def
|
|
308
|
+
async def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
595
309
|
"""
|
|
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
310
|
Parameters
|
|
600
311
|
----------
|
|
601
312
|
agent_id : str
|
|
@@ -605,8 +316,7 @@ class AsyncCoreMemoryClient:
|
|
|
605
316
|
|
|
606
317
|
Returns
|
|
607
318
|
-------
|
|
608
|
-
|
|
609
|
-
Successful Response
|
|
319
|
+
None
|
|
610
320
|
|
|
611
321
|
Examples
|
|
612
322
|
--------
|
|
@@ -620,7 +330,7 @@ class AsyncCoreMemoryClient:
|
|
|
620
330
|
|
|
621
331
|
|
|
622
332
|
async def main() -> None:
|
|
623
|
-
await client.agents.core_memory.
|
|
333
|
+
await client.agents.core_memory.list_blocks(
|
|
624
334
|
agent_id="agent_id",
|
|
625
335
|
)
|
|
626
336
|
|
|
@@ -628,53 +338,34 @@ class AsyncCoreMemoryClient:
|
|
|
628
338
|
asyncio.run(main())
|
|
629
339
|
"""
|
|
630
340
|
_response = await self._client_wrapper.httpx_client.request(
|
|
631
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
341
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
632
342
|
method="GET",
|
|
633
343
|
request_options=request_options,
|
|
634
344
|
)
|
|
635
345
|
try:
|
|
636
346
|
if 200 <= _response.status_code < 300:
|
|
637
|
-
return
|
|
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
|
-
)
|
|
347
|
+
return
|
|
654
348
|
_response_json = _response.json()
|
|
655
349
|
except JSONDecodeError:
|
|
656
350
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
657
351
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
658
352
|
|
|
659
|
-
async def
|
|
660
|
-
self, agent_id: str,
|
|
661
|
-
) ->
|
|
353
|
+
async def attach_block(
|
|
354
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
355
|
+
) -> None:
|
|
662
356
|
"""
|
|
663
|
-
Retrieve a memory block from an agent.
|
|
664
|
-
|
|
665
357
|
Parameters
|
|
666
358
|
----------
|
|
667
359
|
agent_id : str
|
|
668
360
|
|
|
669
|
-
|
|
361
|
+
block_id : str
|
|
670
362
|
|
|
671
363
|
request_options : typing.Optional[RequestOptions]
|
|
672
364
|
Request-specific configuration.
|
|
673
365
|
|
|
674
366
|
Returns
|
|
675
367
|
-------
|
|
676
|
-
|
|
677
|
-
Successful Response
|
|
368
|
+
None
|
|
678
369
|
|
|
679
370
|
Examples
|
|
680
371
|
--------
|
|
@@ -688,62 +379,43 @@ class AsyncCoreMemoryClient:
|
|
|
688
379
|
|
|
689
380
|
|
|
690
381
|
async def main() -> None:
|
|
691
|
-
await client.agents.core_memory.
|
|
382
|
+
await client.agents.core_memory.attach_block(
|
|
692
383
|
agent_id="agent_id",
|
|
693
|
-
|
|
384
|
+
block_id="block_id",
|
|
694
385
|
)
|
|
695
386
|
|
|
696
387
|
|
|
697
388
|
asyncio.run(main())
|
|
698
389
|
"""
|
|
699
390
|
_response = await self._client_wrapper.httpx_client.request(
|
|
700
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
701
|
-
method="
|
|
391
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
|
|
392
|
+
method="PATCH",
|
|
702
393
|
request_options=request_options,
|
|
703
394
|
)
|
|
704
395
|
try:
|
|
705
396
|
if 200 <= _response.status_code < 300:
|
|
706
|
-
return
|
|
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
|
-
)
|
|
397
|
+
return
|
|
723
398
|
_response_json = _response.json()
|
|
724
399
|
except JSONDecodeError:
|
|
725
400
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
726
401
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
727
402
|
|
|
728
|
-
async def
|
|
729
|
-
self, agent_id: str,
|
|
730
|
-
) ->
|
|
403
|
+
async def detach_block(
|
|
404
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
405
|
+
) -> None:
|
|
731
406
|
"""
|
|
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
407
|
Parameters
|
|
735
408
|
----------
|
|
736
409
|
agent_id : str
|
|
737
410
|
|
|
738
|
-
|
|
411
|
+
block_id : str
|
|
739
412
|
|
|
740
413
|
request_options : typing.Optional[RequestOptions]
|
|
741
414
|
Request-specific configuration.
|
|
742
415
|
|
|
743
416
|
Returns
|
|
744
417
|
-------
|
|
745
|
-
|
|
746
|
-
Successful Response
|
|
418
|
+
None
|
|
747
419
|
|
|
748
420
|
Examples
|
|
749
421
|
--------
|
|
@@ -757,94 +429,43 @@ class AsyncCoreMemoryClient:
|
|
|
757
429
|
|
|
758
430
|
|
|
759
431
|
async def main() -> None:
|
|
760
|
-
await client.agents.core_memory.
|
|
432
|
+
await client.agents.core_memory.detach_block(
|
|
761
433
|
agent_id="agent_id",
|
|
762
|
-
|
|
434
|
+
block_id="block_id",
|
|
763
435
|
)
|
|
764
436
|
|
|
765
437
|
|
|
766
438
|
asyncio.run(main())
|
|
767
439
|
"""
|
|
768
440
|
_response = await self._client_wrapper.httpx_client.request(
|
|
769
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
770
|
-
method="
|
|
441
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
|
|
442
|
+
method="PATCH",
|
|
771
443
|
request_options=request_options,
|
|
772
444
|
)
|
|
773
445
|
try:
|
|
774
446
|
if 200 <= _response.status_code < 300:
|
|
775
|
-
return
|
|
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
|
-
)
|
|
447
|
+
return
|
|
792
448
|
_response_json = _response.json()
|
|
793
449
|
except JSONDecodeError:
|
|
794
450
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
795
451
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
796
452
|
|
|
797
|
-
async def
|
|
798
|
-
self,
|
|
799
|
-
|
|
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:
|
|
453
|
+
async def retrieve_block(
|
|
454
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
455
|
+
) -> None:
|
|
811
456
|
"""
|
|
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
457
|
Parameters
|
|
815
458
|
----------
|
|
816
459
|
agent_id : str
|
|
817
460
|
|
|
818
461
|
block_label : str
|
|
819
462
|
|
|
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
463
|
request_options : typing.Optional[RequestOptions]
|
|
842
464
|
Request-specific configuration.
|
|
843
465
|
|
|
844
466
|
Returns
|
|
845
467
|
-------
|
|
846
|
-
|
|
847
|
-
Successful Response
|
|
468
|
+
None
|
|
848
469
|
|
|
849
470
|
Examples
|
|
850
471
|
--------
|
|
@@ -858,7 +479,7 @@ class AsyncCoreMemoryClient:
|
|
|
858
479
|
|
|
859
480
|
|
|
860
481
|
async def main() -> None:
|
|
861
|
-
await client.agents.core_memory.
|
|
482
|
+
await client.agents.core_memory.retrieve_block(
|
|
862
483
|
agent_id="agent_id",
|
|
863
484
|
block_label="block_label",
|
|
864
485
|
)
|
|
@@ -867,157 +488,34 @@ class AsyncCoreMemoryClient:
|
|
|
867
488
|
asyncio.run(main())
|
|
868
489
|
"""
|
|
869
490
|
_response = await self._client_wrapper.httpx_client.request(
|
|
870
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
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",
|
|
491
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
947
492
|
method="GET",
|
|
948
493
|
request_options=request_options,
|
|
949
494
|
)
|
|
950
495
|
try:
|
|
951
496
|
if 200 <= _response.status_code < 300:
|
|
952
|
-
return
|
|
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
|
-
)
|
|
497
|
+
return
|
|
969
498
|
_response_json = _response.json()
|
|
970
499
|
except JSONDecodeError:
|
|
971
500
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
972
501
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
973
502
|
|
|
974
|
-
async def
|
|
975
|
-
self,
|
|
976
|
-
|
|
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:
|
|
503
|
+
async def modify_block(
|
|
504
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
505
|
+
) -> None:
|
|
987
506
|
"""
|
|
988
|
-
Creates a memory block and links it to the agent.
|
|
989
|
-
|
|
990
507
|
Parameters
|
|
991
508
|
----------
|
|
992
509
|
agent_id : str
|
|
993
510
|
|
|
994
|
-
|
|
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.
|
|
511
|
+
block_label : str
|
|
1013
512
|
|
|
1014
513
|
request_options : typing.Optional[RequestOptions]
|
|
1015
514
|
Request-specific configuration.
|
|
1016
515
|
|
|
1017
516
|
Returns
|
|
1018
517
|
-------
|
|
1019
|
-
|
|
1020
|
-
Successful Response
|
|
518
|
+
None
|
|
1021
519
|
|
|
1022
520
|
Examples
|
|
1023
521
|
--------
|
|
@@ -1031,49 +529,22 @@ class AsyncCoreMemoryClient:
|
|
|
1031
529
|
|
|
1032
530
|
|
|
1033
531
|
async def main() -> None:
|
|
1034
|
-
await client.agents.core_memory.
|
|
532
|
+
await client.agents.core_memory.modify_block(
|
|
1035
533
|
agent_id="agent_id",
|
|
1036
|
-
|
|
1037
|
-
label="label",
|
|
534
|
+
block_label="block_label",
|
|
1038
535
|
)
|
|
1039
536
|
|
|
1040
537
|
|
|
1041
538
|
asyncio.run(main())
|
|
1042
539
|
"""
|
|
1043
540
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1044
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/
|
|
1045
|
-
method="
|
|
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
|
-
},
|
|
541
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
542
|
+
method="PATCH",
|
|
1055
543
|
request_options=request_options,
|
|
1056
|
-
omit=OMIT,
|
|
1057
544
|
)
|
|
1058
545
|
try:
|
|
1059
546
|
if 200 <= _response.status_code < 300:
|
|
1060
|
-
return
|
|
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
|
-
)
|
|
547
|
+
return
|
|
1077
548
|
_response_json = _response.json()
|
|
1078
549
|
except JSONDecodeError:
|
|
1079
550
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|