letta-client 0.1.17__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 -116
- letta_client/agents/__init__.py +17 -42
- letta_client/agents/archival_memory/client.py +19 -212
- letta_client/agents/client.py +1633 -336
- letta_client/agents/context/client.py +6 -4
- letta_client/agents/core_memory/client.py +97 -499
- letta_client/agents/memory_variables/__init__.py +2 -2
- letta_client/agents/memory_variables/client.py +13 -13
- 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 +20 -26
- 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 +4 -4
- letta_client/runs/client.py +14 -12
- letta_client/sources/client.py +12 -288
- letta_client/tools/client.py +63 -69
- letta_client/types/__init__.py +21 -99
- 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/{create_assistant_file_request.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/{function_call_output.py → function.py} +1 -1
- letta_client/types/{function_schema.py → function_definition.py} +2 -1
- letta_client/types/{function_call_input.py → function_tool.py} +5 -3
- 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/{letta_schemas_message_message.py → message.py} +4 -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.17.dist-info → letta_client-0.1.19.dist-info}/METADATA +1 -1
- {letta_client-0.1.17.dist-info → letta_client-0.1.19.dist-info}/RECORD +64 -95
- 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/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/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.17.dist-info → letta_client-0.1.19.dist-info}/WHEEL +0 -0
|
@@ -1,31 +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.memory import Memory
|
|
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.block import Block
|
|
14
9
|
from ...core.client_wrapper import AsyncClientWrapper
|
|
15
10
|
|
|
16
|
-
# this is used as the default value for optional parameters
|
|
17
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
18
|
-
|
|
19
11
|
|
|
20
12
|
class CoreMemoryClient:
|
|
21
13
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
14
|
self._client_wrapper = client_wrapper
|
|
23
15
|
|
|
24
|
-
def
|
|
16
|
+
def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
25
17
|
"""
|
|
26
|
-
Retrieve the memory state of a specific agent.
|
|
27
|
-
This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
|
|
28
|
-
|
|
29
18
|
Parameters
|
|
30
19
|
----------
|
|
31
20
|
agent_id : str
|
|
@@ -35,8 +24,7 @@ class CoreMemoryClient:
|
|
|
35
24
|
|
|
36
25
|
Returns
|
|
37
26
|
-------
|
|
38
|
-
|
|
39
|
-
Successful Response
|
|
27
|
+
None
|
|
40
28
|
|
|
41
29
|
Examples
|
|
42
30
|
--------
|
|
@@ -45,7 +33,7 @@ class CoreMemoryClient:
|
|
|
45
33
|
client = Letta(
|
|
46
34
|
token="YOUR_TOKEN",
|
|
47
35
|
)
|
|
48
|
-
client.agents.core_memory.
|
|
36
|
+
client.agents.core_memory.retrieve(
|
|
49
37
|
agent_id="agent_id",
|
|
50
38
|
)
|
|
51
39
|
"""
|
|
@@ -56,47 +44,24 @@ class CoreMemoryClient:
|
|
|
56
44
|
)
|
|
57
45
|
try:
|
|
58
46
|
if 200 <= _response.status_code < 300:
|
|
59
|
-
return
|
|
60
|
-
Memory,
|
|
61
|
-
construct_type(
|
|
62
|
-
type_=Memory, # type: ignore
|
|
63
|
-
object_=_response.json(),
|
|
64
|
-
),
|
|
65
|
-
)
|
|
66
|
-
if _response.status_code == 422:
|
|
67
|
-
raise UnprocessableEntityError(
|
|
68
|
-
typing.cast(
|
|
69
|
-
HttpValidationError,
|
|
70
|
-
construct_type(
|
|
71
|
-
type_=HttpValidationError, # type: ignore
|
|
72
|
-
object_=_response.json(),
|
|
73
|
-
),
|
|
74
|
-
)
|
|
75
|
-
)
|
|
47
|
+
return
|
|
76
48
|
_response_json = _response.json()
|
|
77
49
|
except JSONDecodeError:
|
|
78
50
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
79
51
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
80
52
|
|
|
81
|
-
def
|
|
82
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
83
|
-
) -> Block:
|
|
53
|
+
def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
84
54
|
"""
|
|
85
|
-
Retrieve a memory block from an agent.
|
|
86
|
-
|
|
87
55
|
Parameters
|
|
88
56
|
----------
|
|
89
57
|
agent_id : str
|
|
90
58
|
|
|
91
|
-
block_label : str
|
|
92
|
-
|
|
93
59
|
request_options : typing.Optional[RequestOptions]
|
|
94
60
|
Request-specific configuration.
|
|
95
61
|
|
|
96
62
|
Returns
|
|
97
63
|
-------
|
|
98
|
-
|
|
99
|
-
Successful Response
|
|
64
|
+
None
|
|
100
65
|
|
|
101
66
|
Examples
|
|
102
67
|
--------
|
|
@@ -105,59 +70,39 @@ class CoreMemoryClient:
|
|
|
105
70
|
client = Letta(
|
|
106
71
|
token="YOUR_TOKEN",
|
|
107
72
|
)
|
|
108
|
-
client.agents.core_memory.
|
|
73
|
+
client.agents.core_memory.list_blocks(
|
|
109
74
|
agent_id="agent_id",
|
|
110
|
-
block_label="block_label",
|
|
111
75
|
)
|
|
112
76
|
"""
|
|
113
77
|
_response = self._client_wrapper.httpx_client.request(
|
|
114
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks
|
|
78
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
115
79
|
method="GET",
|
|
116
80
|
request_options=request_options,
|
|
117
81
|
)
|
|
118
82
|
try:
|
|
119
83
|
if 200 <= _response.status_code < 300:
|
|
120
|
-
return
|
|
121
|
-
Block,
|
|
122
|
-
construct_type(
|
|
123
|
-
type_=Block, # type: ignore
|
|
124
|
-
object_=_response.json(),
|
|
125
|
-
),
|
|
126
|
-
)
|
|
127
|
-
if _response.status_code == 422:
|
|
128
|
-
raise UnprocessableEntityError(
|
|
129
|
-
typing.cast(
|
|
130
|
-
HttpValidationError,
|
|
131
|
-
construct_type(
|
|
132
|
-
type_=HttpValidationError, # type: ignore
|
|
133
|
-
object_=_response.json(),
|
|
134
|
-
),
|
|
135
|
-
)
|
|
136
|
-
)
|
|
84
|
+
return
|
|
137
85
|
_response_json = _response.json()
|
|
138
86
|
except JSONDecodeError:
|
|
139
87
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
140
88
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
141
89
|
|
|
142
|
-
def
|
|
143
|
-
self, agent_id: str,
|
|
144
|
-
) ->
|
|
90
|
+
def attach_block(
|
|
91
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
92
|
+
) -> None:
|
|
145
93
|
"""
|
|
146
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
147
|
-
|
|
148
94
|
Parameters
|
|
149
95
|
----------
|
|
150
96
|
agent_id : str
|
|
151
97
|
|
|
152
|
-
|
|
98
|
+
block_id : str
|
|
153
99
|
|
|
154
100
|
request_options : typing.Optional[RequestOptions]
|
|
155
101
|
Request-specific configuration.
|
|
156
102
|
|
|
157
103
|
Returns
|
|
158
104
|
-------
|
|
159
|
-
|
|
160
|
-
Successful Response
|
|
105
|
+
None
|
|
161
106
|
|
|
162
107
|
Examples
|
|
163
108
|
--------
|
|
@@ -166,91 +111,40 @@ class CoreMemoryClient:
|
|
|
166
111
|
client = Letta(
|
|
167
112
|
token="YOUR_TOKEN",
|
|
168
113
|
)
|
|
169
|
-
client.agents.core_memory.
|
|
114
|
+
client.agents.core_memory.attach_block(
|
|
170
115
|
agent_id="agent_id",
|
|
171
|
-
|
|
116
|
+
block_id="block_id",
|
|
172
117
|
)
|
|
173
118
|
"""
|
|
174
119
|
_response = self._client_wrapper.httpx_client.request(
|
|
175
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(
|
|
176
|
-
method="
|
|
120
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
|
|
121
|
+
method="PATCH",
|
|
177
122
|
request_options=request_options,
|
|
178
123
|
)
|
|
179
124
|
try:
|
|
180
125
|
if 200 <= _response.status_code < 300:
|
|
181
|
-
return
|
|
182
|
-
Memory,
|
|
183
|
-
construct_type(
|
|
184
|
-
type_=Memory, # type: ignore
|
|
185
|
-
object_=_response.json(),
|
|
186
|
-
),
|
|
187
|
-
)
|
|
188
|
-
if _response.status_code == 422:
|
|
189
|
-
raise UnprocessableEntityError(
|
|
190
|
-
typing.cast(
|
|
191
|
-
HttpValidationError,
|
|
192
|
-
construct_type(
|
|
193
|
-
type_=HttpValidationError, # type: ignore
|
|
194
|
-
object_=_response.json(),
|
|
195
|
-
),
|
|
196
|
-
)
|
|
197
|
-
)
|
|
126
|
+
return
|
|
198
127
|
_response_json = _response.json()
|
|
199
128
|
except JSONDecodeError:
|
|
200
129
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
201
130
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
202
131
|
|
|
203
|
-
def
|
|
204
|
-
self,
|
|
205
|
-
|
|
206
|
-
block_label: str,
|
|
207
|
-
*,
|
|
208
|
-
value: typing.Optional[str] = OMIT,
|
|
209
|
-
limit: typing.Optional[int] = OMIT,
|
|
210
|
-
name: typing.Optional[str] = OMIT,
|
|
211
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
212
|
-
label: typing.Optional[str] = OMIT,
|
|
213
|
-
description: typing.Optional[str] = OMIT,
|
|
214
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
215
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
216
|
-
) -> Block:
|
|
132
|
+
def detach_block(
|
|
133
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
134
|
+
) -> None:
|
|
217
135
|
"""
|
|
218
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
219
|
-
|
|
220
136
|
Parameters
|
|
221
137
|
----------
|
|
222
138
|
agent_id : str
|
|
223
139
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
value : typing.Optional[str]
|
|
227
|
-
Value of the block.
|
|
228
|
-
|
|
229
|
-
limit : typing.Optional[int]
|
|
230
|
-
Character limit of the block.
|
|
231
|
-
|
|
232
|
-
name : typing.Optional[str]
|
|
233
|
-
Name of the block if it is a template.
|
|
234
|
-
|
|
235
|
-
is_template : typing.Optional[bool]
|
|
236
|
-
Whether the block is a template (e.g. saved human/persona options).
|
|
237
|
-
|
|
238
|
-
label : typing.Optional[str]
|
|
239
|
-
Label of the block (e.g. 'human', 'persona') in the context window.
|
|
240
|
-
|
|
241
|
-
description : typing.Optional[str]
|
|
242
|
-
Description of the block.
|
|
243
|
-
|
|
244
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
245
|
-
Metadata of the block.
|
|
140
|
+
block_id : str
|
|
246
141
|
|
|
247
142
|
request_options : typing.Optional[RequestOptions]
|
|
248
143
|
Request-specific configuration.
|
|
249
144
|
|
|
250
145
|
Returns
|
|
251
146
|
-------
|
|
252
|
-
|
|
253
|
-
Successful Response
|
|
147
|
+
None
|
|
254
148
|
|
|
255
149
|
Examples
|
|
256
150
|
--------
|
|
@@ -259,65 +153,40 @@ class CoreMemoryClient:
|
|
|
259
153
|
client = Letta(
|
|
260
154
|
token="YOUR_TOKEN",
|
|
261
155
|
)
|
|
262
|
-
client.agents.core_memory.
|
|
156
|
+
client.agents.core_memory.detach_block(
|
|
263
157
|
agent_id="agent_id",
|
|
264
|
-
|
|
158
|
+
block_id="block_id",
|
|
265
159
|
)
|
|
266
160
|
"""
|
|
267
161
|
_response = self._client_wrapper.httpx_client.request(
|
|
268
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(
|
|
162
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
|
|
269
163
|
method="PATCH",
|
|
270
|
-
json={
|
|
271
|
-
"value": value,
|
|
272
|
-
"limit": limit,
|
|
273
|
-
"name": name,
|
|
274
|
-
"is_template": is_template,
|
|
275
|
-
"label": label,
|
|
276
|
-
"description": description,
|
|
277
|
-
"metadata_": metadata,
|
|
278
|
-
},
|
|
279
164
|
request_options=request_options,
|
|
280
|
-
omit=OMIT,
|
|
281
165
|
)
|
|
282
166
|
try:
|
|
283
167
|
if 200 <= _response.status_code < 300:
|
|
284
|
-
return
|
|
285
|
-
Block,
|
|
286
|
-
construct_type(
|
|
287
|
-
type_=Block, # type: ignore
|
|
288
|
-
object_=_response.json(),
|
|
289
|
-
),
|
|
290
|
-
)
|
|
291
|
-
if _response.status_code == 422:
|
|
292
|
-
raise UnprocessableEntityError(
|
|
293
|
-
typing.cast(
|
|
294
|
-
HttpValidationError,
|
|
295
|
-
construct_type(
|
|
296
|
-
type_=HttpValidationError, # type: ignore
|
|
297
|
-
object_=_response.json(),
|
|
298
|
-
),
|
|
299
|
-
)
|
|
300
|
-
)
|
|
168
|
+
return
|
|
301
169
|
_response_json = _response.json()
|
|
302
170
|
except JSONDecodeError:
|
|
303
171
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
304
172
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
305
173
|
|
|
306
|
-
def
|
|
174
|
+
def retrieve_block(
|
|
175
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
176
|
+
) -> None:
|
|
307
177
|
"""
|
|
308
|
-
Retrieve the memory blocks of a specific agent.
|
|
309
|
-
|
|
310
178
|
Parameters
|
|
311
179
|
----------
|
|
312
180
|
agent_id : str
|
|
313
181
|
|
|
182
|
+
block_label : str
|
|
183
|
+
|
|
314
184
|
request_options : typing.Optional[RequestOptions]
|
|
315
185
|
Request-specific configuration.
|
|
316
186
|
|
|
317
187
|
Returns
|
|
318
188
|
-------
|
|
319
|
-
|
|
320
|
-
Successful Response
|
|
189
|
+
None
|
|
321
190
|
|
|
322
191
|
Examples
|
|
323
192
|
--------
|
|
@@ -326,86 +195,40 @@ class CoreMemoryClient:
|
|
|
326
195
|
client = Letta(
|
|
327
196
|
token="YOUR_TOKEN",
|
|
328
197
|
)
|
|
329
|
-
client.agents.core_memory.
|
|
198
|
+
client.agents.core_memory.retrieve_block(
|
|
330
199
|
agent_id="agent_id",
|
|
200
|
+
block_label="block_label",
|
|
331
201
|
)
|
|
332
202
|
"""
|
|
333
203
|
_response = self._client_wrapper.httpx_client.request(
|
|
334
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
204
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
335
205
|
method="GET",
|
|
336
206
|
request_options=request_options,
|
|
337
207
|
)
|
|
338
208
|
try:
|
|
339
209
|
if 200 <= _response.status_code < 300:
|
|
340
|
-
return
|
|
341
|
-
typing.List[Block],
|
|
342
|
-
construct_type(
|
|
343
|
-
type_=typing.List[Block], # type: ignore
|
|
344
|
-
object_=_response.json(),
|
|
345
|
-
),
|
|
346
|
-
)
|
|
347
|
-
if _response.status_code == 422:
|
|
348
|
-
raise UnprocessableEntityError(
|
|
349
|
-
typing.cast(
|
|
350
|
-
HttpValidationError,
|
|
351
|
-
construct_type(
|
|
352
|
-
type_=HttpValidationError, # type: ignore
|
|
353
|
-
object_=_response.json(),
|
|
354
|
-
),
|
|
355
|
-
)
|
|
356
|
-
)
|
|
210
|
+
return
|
|
357
211
|
_response_json = _response.json()
|
|
358
212
|
except JSONDecodeError:
|
|
359
213
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
360
214
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
361
215
|
|
|
362
|
-
def
|
|
363
|
-
self,
|
|
364
|
-
|
|
365
|
-
*,
|
|
366
|
-
value: str,
|
|
367
|
-
label: str,
|
|
368
|
-
limit: typing.Optional[int] = OMIT,
|
|
369
|
-
name: typing.Optional[str] = OMIT,
|
|
370
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
371
|
-
description: typing.Optional[str] = OMIT,
|
|
372
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
373
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
374
|
-
) -> Memory:
|
|
216
|
+
def modify_block(
|
|
217
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
218
|
+
) -> None:
|
|
375
219
|
"""
|
|
376
|
-
Creates a memory block and links it to the agent.
|
|
377
|
-
|
|
378
220
|
Parameters
|
|
379
221
|
----------
|
|
380
222
|
agent_id : str
|
|
381
223
|
|
|
382
|
-
|
|
383
|
-
Value of the block.
|
|
384
|
-
|
|
385
|
-
label : str
|
|
386
|
-
Label of the block.
|
|
387
|
-
|
|
388
|
-
limit : typing.Optional[int]
|
|
389
|
-
Character limit of the block.
|
|
390
|
-
|
|
391
|
-
name : typing.Optional[str]
|
|
392
|
-
Name of the block if it is a template.
|
|
393
|
-
|
|
394
|
-
is_template : typing.Optional[bool]
|
|
395
|
-
|
|
396
|
-
description : typing.Optional[str]
|
|
397
|
-
Description of the block.
|
|
398
|
-
|
|
399
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
400
|
-
Metadata of the block.
|
|
224
|
+
block_label : str
|
|
401
225
|
|
|
402
226
|
request_options : typing.Optional[RequestOptions]
|
|
403
227
|
Request-specific configuration.
|
|
404
228
|
|
|
405
229
|
Returns
|
|
406
230
|
-------
|
|
407
|
-
|
|
408
|
-
Successful Response
|
|
231
|
+
None
|
|
409
232
|
|
|
410
233
|
Examples
|
|
411
234
|
--------
|
|
@@ -414,46 +237,19 @@ class CoreMemoryClient:
|
|
|
414
237
|
client = Letta(
|
|
415
238
|
token="YOUR_TOKEN",
|
|
416
239
|
)
|
|
417
|
-
client.agents.core_memory.
|
|
240
|
+
client.agents.core_memory.modify_block(
|
|
418
241
|
agent_id="agent_id",
|
|
419
|
-
|
|
420
|
-
label="label",
|
|
242
|
+
block_label="block_label",
|
|
421
243
|
)
|
|
422
244
|
"""
|
|
423
245
|
_response = self._client_wrapper.httpx_client.request(
|
|
424
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
425
|
-
method="
|
|
426
|
-
json={
|
|
427
|
-
"value": value,
|
|
428
|
-
"limit": limit,
|
|
429
|
-
"name": name,
|
|
430
|
-
"is_template": is_template,
|
|
431
|
-
"label": label,
|
|
432
|
-
"description": description,
|
|
433
|
-
"metadata_": metadata,
|
|
434
|
-
},
|
|
246
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
247
|
+
method="PATCH",
|
|
435
248
|
request_options=request_options,
|
|
436
|
-
omit=OMIT,
|
|
437
249
|
)
|
|
438
250
|
try:
|
|
439
251
|
if 200 <= _response.status_code < 300:
|
|
440
|
-
return
|
|
441
|
-
Memory,
|
|
442
|
-
construct_type(
|
|
443
|
-
type_=Memory, # type: ignore
|
|
444
|
-
object_=_response.json(),
|
|
445
|
-
),
|
|
446
|
-
)
|
|
447
|
-
if _response.status_code == 422:
|
|
448
|
-
raise UnprocessableEntityError(
|
|
449
|
-
typing.cast(
|
|
450
|
-
HttpValidationError,
|
|
451
|
-
construct_type(
|
|
452
|
-
type_=HttpValidationError, # type: ignore
|
|
453
|
-
object_=_response.json(),
|
|
454
|
-
),
|
|
455
|
-
)
|
|
456
|
-
)
|
|
252
|
+
return
|
|
457
253
|
_response_json = _response.json()
|
|
458
254
|
except JSONDecodeError:
|
|
459
255
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -464,11 +260,8 @@ class AsyncCoreMemoryClient:
|
|
|
464
260
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
465
261
|
self._client_wrapper = client_wrapper
|
|
466
262
|
|
|
467
|
-
async def
|
|
263
|
+
async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
468
264
|
"""
|
|
469
|
-
Retrieve the memory state of a specific agent.
|
|
470
|
-
This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
|
|
471
|
-
|
|
472
265
|
Parameters
|
|
473
266
|
----------
|
|
474
267
|
agent_id : str
|
|
@@ -478,8 +271,7 @@ class AsyncCoreMemoryClient:
|
|
|
478
271
|
|
|
479
272
|
Returns
|
|
480
273
|
-------
|
|
481
|
-
|
|
482
|
-
Successful Response
|
|
274
|
+
None
|
|
483
275
|
|
|
484
276
|
Examples
|
|
485
277
|
--------
|
|
@@ -493,7 +285,7 @@ class AsyncCoreMemoryClient:
|
|
|
493
285
|
|
|
494
286
|
|
|
495
287
|
async def main() -> None:
|
|
496
|
-
await client.agents.core_memory.
|
|
288
|
+
await client.agents.core_memory.retrieve(
|
|
497
289
|
agent_id="agent_id",
|
|
498
290
|
)
|
|
499
291
|
|
|
@@ -507,47 +299,24 @@ class AsyncCoreMemoryClient:
|
|
|
507
299
|
)
|
|
508
300
|
try:
|
|
509
301
|
if 200 <= _response.status_code < 300:
|
|
510
|
-
return
|
|
511
|
-
Memory,
|
|
512
|
-
construct_type(
|
|
513
|
-
type_=Memory, # type: ignore
|
|
514
|
-
object_=_response.json(),
|
|
515
|
-
),
|
|
516
|
-
)
|
|
517
|
-
if _response.status_code == 422:
|
|
518
|
-
raise UnprocessableEntityError(
|
|
519
|
-
typing.cast(
|
|
520
|
-
HttpValidationError,
|
|
521
|
-
construct_type(
|
|
522
|
-
type_=HttpValidationError, # type: ignore
|
|
523
|
-
object_=_response.json(),
|
|
524
|
-
),
|
|
525
|
-
)
|
|
526
|
-
)
|
|
302
|
+
return
|
|
527
303
|
_response_json = _response.json()
|
|
528
304
|
except JSONDecodeError:
|
|
529
305
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
530
306
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
531
307
|
|
|
532
|
-
async def
|
|
533
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
534
|
-
) -> Block:
|
|
308
|
+
async def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
535
309
|
"""
|
|
536
|
-
Retrieve a memory block from an agent.
|
|
537
|
-
|
|
538
310
|
Parameters
|
|
539
311
|
----------
|
|
540
312
|
agent_id : str
|
|
541
313
|
|
|
542
|
-
block_label : str
|
|
543
|
-
|
|
544
314
|
request_options : typing.Optional[RequestOptions]
|
|
545
315
|
Request-specific configuration.
|
|
546
316
|
|
|
547
317
|
Returns
|
|
548
318
|
-------
|
|
549
|
-
|
|
550
|
-
Successful Response
|
|
319
|
+
None
|
|
551
320
|
|
|
552
321
|
Examples
|
|
553
322
|
--------
|
|
@@ -561,62 +330,42 @@ class AsyncCoreMemoryClient:
|
|
|
561
330
|
|
|
562
331
|
|
|
563
332
|
async def main() -> None:
|
|
564
|
-
await client.agents.core_memory.
|
|
333
|
+
await client.agents.core_memory.list_blocks(
|
|
565
334
|
agent_id="agent_id",
|
|
566
|
-
block_label="block_label",
|
|
567
335
|
)
|
|
568
336
|
|
|
569
337
|
|
|
570
338
|
asyncio.run(main())
|
|
571
339
|
"""
|
|
572
340
|
_response = await self._client_wrapper.httpx_client.request(
|
|
573
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks
|
|
341
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
574
342
|
method="GET",
|
|
575
343
|
request_options=request_options,
|
|
576
344
|
)
|
|
577
345
|
try:
|
|
578
346
|
if 200 <= _response.status_code < 300:
|
|
579
|
-
return
|
|
580
|
-
Block,
|
|
581
|
-
construct_type(
|
|
582
|
-
type_=Block, # type: ignore
|
|
583
|
-
object_=_response.json(),
|
|
584
|
-
),
|
|
585
|
-
)
|
|
586
|
-
if _response.status_code == 422:
|
|
587
|
-
raise UnprocessableEntityError(
|
|
588
|
-
typing.cast(
|
|
589
|
-
HttpValidationError,
|
|
590
|
-
construct_type(
|
|
591
|
-
type_=HttpValidationError, # type: ignore
|
|
592
|
-
object_=_response.json(),
|
|
593
|
-
),
|
|
594
|
-
)
|
|
595
|
-
)
|
|
347
|
+
return
|
|
596
348
|
_response_json = _response.json()
|
|
597
349
|
except JSONDecodeError:
|
|
598
350
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
599
351
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
600
352
|
|
|
601
|
-
async def
|
|
602
|
-
self, agent_id: str,
|
|
603
|
-
) ->
|
|
353
|
+
async def attach_block(
|
|
354
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
355
|
+
) -> None:
|
|
604
356
|
"""
|
|
605
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
606
|
-
|
|
607
357
|
Parameters
|
|
608
358
|
----------
|
|
609
359
|
agent_id : str
|
|
610
360
|
|
|
611
|
-
|
|
361
|
+
block_id : str
|
|
612
362
|
|
|
613
363
|
request_options : typing.Optional[RequestOptions]
|
|
614
364
|
Request-specific configuration.
|
|
615
365
|
|
|
616
366
|
Returns
|
|
617
367
|
-------
|
|
618
|
-
|
|
619
|
-
Successful Response
|
|
368
|
+
None
|
|
620
369
|
|
|
621
370
|
Examples
|
|
622
371
|
--------
|
|
@@ -630,94 +379,43 @@ class AsyncCoreMemoryClient:
|
|
|
630
379
|
|
|
631
380
|
|
|
632
381
|
async def main() -> None:
|
|
633
|
-
await client.agents.core_memory.
|
|
382
|
+
await client.agents.core_memory.attach_block(
|
|
634
383
|
agent_id="agent_id",
|
|
635
|
-
|
|
384
|
+
block_id="block_id",
|
|
636
385
|
)
|
|
637
386
|
|
|
638
387
|
|
|
639
388
|
asyncio.run(main())
|
|
640
389
|
"""
|
|
641
390
|
_response = await self._client_wrapper.httpx_client.request(
|
|
642
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(
|
|
643
|
-
method="
|
|
391
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
|
|
392
|
+
method="PATCH",
|
|
644
393
|
request_options=request_options,
|
|
645
394
|
)
|
|
646
395
|
try:
|
|
647
396
|
if 200 <= _response.status_code < 300:
|
|
648
|
-
return
|
|
649
|
-
Memory,
|
|
650
|
-
construct_type(
|
|
651
|
-
type_=Memory, # type: ignore
|
|
652
|
-
object_=_response.json(),
|
|
653
|
-
),
|
|
654
|
-
)
|
|
655
|
-
if _response.status_code == 422:
|
|
656
|
-
raise UnprocessableEntityError(
|
|
657
|
-
typing.cast(
|
|
658
|
-
HttpValidationError,
|
|
659
|
-
construct_type(
|
|
660
|
-
type_=HttpValidationError, # type: ignore
|
|
661
|
-
object_=_response.json(),
|
|
662
|
-
),
|
|
663
|
-
)
|
|
664
|
-
)
|
|
397
|
+
return
|
|
665
398
|
_response_json = _response.json()
|
|
666
399
|
except JSONDecodeError:
|
|
667
400
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
668
401
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
669
402
|
|
|
670
|
-
async def
|
|
671
|
-
self,
|
|
672
|
-
|
|
673
|
-
block_label: str,
|
|
674
|
-
*,
|
|
675
|
-
value: typing.Optional[str] = OMIT,
|
|
676
|
-
limit: typing.Optional[int] = OMIT,
|
|
677
|
-
name: typing.Optional[str] = OMIT,
|
|
678
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
679
|
-
label: typing.Optional[str] = OMIT,
|
|
680
|
-
description: typing.Optional[str] = OMIT,
|
|
681
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
682
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
683
|
-
) -> Block:
|
|
403
|
+
async def detach_block(
|
|
404
|
+
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
405
|
+
) -> None:
|
|
684
406
|
"""
|
|
685
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
686
|
-
|
|
687
407
|
Parameters
|
|
688
408
|
----------
|
|
689
409
|
agent_id : str
|
|
690
410
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
value : typing.Optional[str]
|
|
694
|
-
Value of the block.
|
|
695
|
-
|
|
696
|
-
limit : typing.Optional[int]
|
|
697
|
-
Character limit of the block.
|
|
698
|
-
|
|
699
|
-
name : typing.Optional[str]
|
|
700
|
-
Name of the block if it is a template.
|
|
701
|
-
|
|
702
|
-
is_template : typing.Optional[bool]
|
|
703
|
-
Whether the block is a template (e.g. saved human/persona options).
|
|
704
|
-
|
|
705
|
-
label : typing.Optional[str]
|
|
706
|
-
Label of the block (e.g. 'human', 'persona') in the context window.
|
|
707
|
-
|
|
708
|
-
description : typing.Optional[str]
|
|
709
|
-
Description of the block.
|
|
710
|
-
|
|
711
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
712
|
-
Metadata of the block.
|
|
411
|
+
block_id : str
|
|
713
412
|
|
|
714
413
|
request_options : typing.Optional[RequestOptions]
|
|
715
414
|
Request-specific configuration.
|
|
716
415
|
|
|
717
416
|
Returns
|
|
718
417
|
-------
|
|
719
|
-
|
|
720
|
-
Successful Response
|
|
418
|
+
None
|
|
721
419
|
|
|
722
420
|
Examples
|
|
723
421
|
--------
|
|
@@ -731,70 +429,43 @@ class AsyncCoreMemoryClient:
|
|
|
731
429
|
|
|
732
430
|
|
|
733
431
|
async def main() -> None:
|
|
734
|
-
await client.agents.core_memory.
|
|
432
|
+
await client.agents.core_memory.detach_block(
|
|
735
433
|
agent_id="agent_id",
|
|
736
|
-
|
|
434
|
+
block_id="block_id",
|
|
737
435
|
)
|
|
738
436
|
|
|
739
437
|
|
|
740
438
|
asyncio.run(main())
|
|
741
439
|
"""
|
|
742
440
|
_response = await self._client_wrapper.httpx_client.request(
|
|
743
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(
|
|
441
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
|
|
744
442
|
method="PATCH",
|
|
745
|
-
json={
|
|
746
|
-
"value": value,
|
|
747
|
-
"limit": limit,
|
|
748
|
-
"name": name,
|
|
749
|
-
"is_template": is_template,
|
|
750
|
-
"label": label,
|
|
751
|
-
"description": description,
|
|
752
|
-
"metadata_": metadata,
|
|
753
|
-
},
|
|
754
443
|
request_options=request_options,
|
|
755
|
-
omit=OMIT,
|
|
756
444
|
)
|
|
757
445
|
try:
|
|
758
446
|
if 200 <= _response.status_code < 300:
|
|
759
|
-
return
|
|
760
|
-
Block,
|
|
761
|
-
construct_type(
|
|
762
|
-
type_=Block, # type: ignore
|
|
763
|
-
object_=_response.json(),
|
|
764
|
-
),
|
|
765
|
-
)
|
|
766
|
-
if _response.status_code == 422:
|
|
767
|
-
raise UnprocessableEntityError(
|
|
768
|
-
typing.cast(
|
|
769
|
-
HttpValidationError,
|
|
770
|
-
construct_type(
|
|
771
|
-
type_=HttpValidationError, # type: ignore
|
|
772
|
-
object_=_response.json(),
|
|
773
|
-
),
|
|
774
|
-
)
|
|
775
|
-
)
|
|
447
|
+
return
|
|
776
448
|
_response_json = _response.json()
|
|
777
449
|
except JSONDecodeError:
|
|
778
450
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
779
451
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
780
452
|
|
|
781
|
-
async def
|
|
782
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
783
|
-
) ->
|
|
453
|
+
async def retrieve_block(
|
|
454
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
455
|
+
) -> None:
|
|
784
456
|
"""
|
|
785
|
-
Retrieve the memory blocks of a specific agent.
|
|
786
|
-
|
|
787
457
|
Parameters
|
|
788
458
|
----------
|
|
789
459
|
agent_id : str
|
|
790
460
|
|
|
461
|
+
block_label : str
|
|
462
|
+
|
|
791
463
|
request_options : typing.Optional[RequestOptions]
|
|
792
464
|
Request-specific configuration.
|
|
793
465
|
|
|
794
466
|
Returns
|
|
795
467
|
-------
|
|
796
|
-
|
|
797
|
-
Successful Response
|
|
468
|
+
None
|
|
798
469
|
|
|
799
470
|
Examples
|
|
800
471
|
--------
|
|
@@ -808,89 +479,43 @@ class AsyncCoreMemoryClient:
|
|
|
808
479
|
|
|
809
480
|
|
|
810
481
|
async def main() -> None:
|
|
811
|
-
await client.agents.core_memory.
|
|
482
|
+
await client.agents.core_memory.retrieve_block(
|
|
812
483
|
agent_id="agent_id",
|
|
484
|
+
block_label="block_label",
|
|
813
485
|
)
|
|
814
486
|
|
|
815
487
|
|
|
816
488
|
asyncio.run(main())
|
|
817
489
|
"""
|
|
818
490
|
_response = await self._client_wrapper.httpx_client.request(
|
|
819
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
491
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
820
492
|
method="GET",
|
|
821
493
|
request_options=request_options,
|
|
822
494
|
)
|
|
823
495
|
try:
|
|
824
496
|
if 200 <= _response.status_code < 300:
|
|
825
|
-
return
|
|
826
|
-
typing.List[Block],
|
|
827
|
-
construct_type(
|
|
828
|
-
type_=typing.List[Block], # type: ignore
|
|
829
|
-
object_=_response.json(),
|
|
830
|
-
),
|
|
831
|
-
)
|
|
832
|
-
if _response.status_code == 422:
|
|
833
|
-
raise UnprocessableEntityError(
|
|
834
|
-
typing.cast(
|
|
835
|
-
HttpValidationError,
|
|
836
|
-
construct_type(
|
|
837
|
-
type_=HttpValidationError, # type: ignore
|
|
838
|
-
object_=_response.json(),
|
|
839
|
-
),
|
|
840
|
-
)
|
|
841
|
-
)
|
|
497
|
+
return
|
|
842
498
|
_response_json = _response.json()
|
|
843
499
|
except JSONDecodeError:
|
|
844
500
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
845
501
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
846
502
|
|
|
847
|
-
async def
|
|
848
|
-
self,
|
|
849
|
-
|
|
850
|
-
*,
|
|
851
|
-
value: str,
|
|
852
|
-
label: str,
|
|
853
|
-
limit: typing.Optional[int] = OMIT,
|
|
854
|
-
name: typing.Optional[str] = OMIT,
|
|
855
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
856
|
-
description: typing.Optional[str] = OMIT,
|
|
857
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
858
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
859
|
-
) -> Memory:
|
|
503
|
+
async def modify_block(
|
|
504
|
+
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
505
|
+
) -> None:
|
|
860
506
|
"""
|
|
861
|
-
Creates a memory block and links it to the agent.
|
|
862
|
-
|
|
863
507
|
Parameters
|
|
864
508
|
----------
|
|
865
509
|
agent_id : str
|
|
866
510
|
|
|
867
|
-
|
|
868
|
-
Value of the block.
|
|
869
|
-
|
|
870
|
-
label : str
|
|
871
|
-
Label of the block.
|
|
872
|
-
|
|
873
|
-
limit : typing.Optional[int]
|
|
874
|
-
Character limit of the block.
|
|
875
|
-
|
|
876
|
-
name : typing.Optional[str]
|
|
877
|
-
Name of the block if it is a template.
|
|
878
|
-
|
|
879
|
-
is_template : typing.Optional[bool]
|
|
880
|
-
|
|
881
|
-
description : typing.Optional[str]
|
|
882
|
-
Description of the block.
|
|
883
|
-
|
|
884
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
885
|
-
Metadata of the block.
|
|
511
|
+
block_label : str
|
|
886
512
|
|
|
887
513
|
request_options : typing.Optional[RequestOptions]
|
|
888
514
|
Request-specific configuration.
|
|
889
515
|
|
|
890
516
|
Returns
|
|
891
517
|
-------
|
|
892
|
-
|
|
893
|
-
Successful Response
|
|
518
|
+
None
|
|
894
519
|
|
|
895
520
|
Examples
|
|
896
521
|
--------
|
|
@@ -904,49 +529,22 @@ class AsyncCoreMemoryClient:
|
|
|
904
529
|
|
|
905
530
|
|
|
906
531
|
async def main() -> None:
|
|
907
|
-
await client.agents.core_memory.
|
|
532
|
+
await client.agents.core_memory.modify_block(
|
|
908
533
|
agent_id="agent_id",
|
|
909
|
-
|
|
910
|
-
label="label",
|
|
534
|
+
block_label="block_label",
|
|
911
535
|
)
|
|
912
536
|
|
|
913
537
|
|
|
914
538
|
asyncio.run(main())
|
|
915
539
|
"""
|
|
916
540
|
_response = await self._client_wrapper.httpx_client.request(
|
|
917
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
|
|
918
|
-
method="
|
|
919
|
-
json={
|
|
920
|
-
"value": value,
|
|
921
|
-
"limit": limit,
|
|
922
|
-
"name": name,
|
|
923
|
-
"is_template": is_template,
|
|
924
|
-
"label": label,
|
|
925
|
-
"description": description,
|
|
926
|
-
"metadata_": metadata,
|
|
927
|
-
},
|
|
541
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
|
|
542
|
+
method="PATCH",
|
|
928
543
|
request_options=request_options,
|
|
929
|
-
omit=OMIT,
|
|
930
544
|
)
|
|
931
545
|
try:
|
|
932
546
|
if 200 <= _response.status_code < 300:
|
|
933
|
-
return
|
|
934
|
-
Memory,
|
|
935
|
-
construct_type(
|
|
936
|
-
type_=Memory, # type: ignore
|
|
937
|
-
object_=_response.json(),
|
|
938
|
-
),
|
|
939
|
-
)
|
|
940
|
-
if _response.status_code == 422:
|
|
941
|
-
raise UnprocessableEntityError(
|
|
942
|
-
typing.cast(
|
|
943
|
-
HttpValidationError,
|
|
944
|
-
construct_type(
|
|
945
|
-
type_=HttpValidationError, # type: ignore
|
|
946
|
-
object_=_response.json(),
|
|
947
|
-
),
|
|
948
|
-
)
|
|
949
|
-
)
|
|
547
|
+
return
|
|
950
548
|
_response_json = _response.json()
|
|
951
549
|
except JSONDecodeError:
|
|
952
550
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|