letta-client 0.1.4__py3-none-any.whl → 0.1.9__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.
- letta/__init__.py +44 -21
- letta/agents/__init__.py +71 -24
- letta/agents/archival_memory/client.py +17 -17
- letta/agents/client.py +424 -1700
- letta/agents/context/client.py +5 -5
- letta/agents/core_memory/client.py +1080 -0
- letta/agents/memory_variables/__init__.py +5 -0
- letta/agents/{memory → memory_variables}/client.py +41 -40
- letta/agents/memory_variables/types/__init__.py +5 -0
- letta/agents/{types/agents_get_agent_variables_response.py → memory_variables/types/memory_variables_get_response.py} +3 -3
- letta/agents/messages/__init__.py +36 -2
- letta/agents/messages/client.py +278 -17
- letta/agents/messages/types/__init__.py +37 -3
- letta/agents/messages/types/letta_streaming_response.py +139 -16
- letta/agents/messages/types/messages_list_response_item.py +121 -9
- letta/agents/recall_memory/client.py +5 -5
- letta/agents/sources/client.py +5 -5
- letta/agents/templates/__init__.py +5 -0
- letta/agents/templates/client.py +578 -0
- letta/agents/templates/types/__init__.py +5 -0
- letta/agents/templates/types/templates_migrate_response.py +19 -0
- letta/agents/tools/client.py +13 -13
- letta/agents/types/__init__.py +23 -29
- letta/agents/types/agents_search_request_combinator.py +5 -0
- letta/agents/types/agents_search_request_search_item.py +64 -0
- letta/agents/types/{agents_search_deployed_agents_request_search_item_zero.py → agents_search_request_search_item_name.py} +5 -4
- letta/agents/types/agents_search_request_search_item_name_operator.py +5 -0
- letta/agents/types/agents_search_request_search_item_order_by.py +22 -0
- letta/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
- letta/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
- letta/agents/types/{agents_migrate_response.py → agents_search_request_search_item_version.py} +3 -3
- letta/blocks/client.py +25 -25
- letta/client.py +8 -4
- letta/core/__init__.py +4 -0
- letta/core/client_wrapper.py +7 -18
- letta/core/unchecked_base_model.py +305 -0
- letta/health/client.py +3 -3
- letta/jobs/client.py +17 -17
- letta/models/client.py +5 -5
- letta/providers/client.py +597 -0
- letta/sources/client.py +33 -33
- letta/sources/files/client.py +11 -11
- letta/sources/passages/client.py +5 -5
- letta/tools/client.py +77 -57
- letta/types/__init__.py +22 -0
- letta/types/action_model.py +2 -2
- letta/types/action_parameters_model.py +2 -2
- letta/types/action_response_model.py +2 -2
- letta/types/agent_environment_variable.py +63 -0
- letta/types/agent_state.py +19 -16
- letta/types/agent_type.py +1 -2
- letta/types/app_auth_scheme.py +2 -2
- letta/types/app_model.py +2 -2
- letta/types/archival_memory_summary.py +2 -2
- letta/types/assistant_file.py +2 -2
- letta/types/assistant_message_input.py +2 -2
- letta/types/assistant_message_output.py +3 -4
- letta/types/auth_request.py +2 -2
- letta/types/auth_response.py +2 -2
- letta/types/auth_scheme_field.py +2 -2
- letta/types/block.py +11 -16
- letta/types/block_update.py +2 -2
- letta/types/chat_completion_request.py +2 -2
- letta/types/chat_completion_response.py +2 -2
- letta/types/child_tool_rule.py +2 -2
- letta/types/choice.py +2 -2
- letta/types/conditional_tool_rule.py +2 -2
- letta/types/conflict_error_body.py +2 -2
- letta/types/context_window_overview.py +7 -2
- letta/types/create_assistant_file_request.py +2 -2
- letta/types/create_assistant_request.py +2 -2
- letta/types/create_block.py +2 -2
- letta/types/delete_assistant_file_response.py +2 -2
- letta/types/delete_assistant_response.py +2 -2
- letta/types/e_2_b_sandbox_config.py +2 -2
- letta/types/embedding_config.py +10 -10
- letta/types/file_metadata.py +2 -7
- letta/types/function_call_input.py +2 -2
- letta/types/function_call_output.py +2 -2
- letta/types/function_schema.py +2 -2
- letta/types/health.py +2 -2
- letta/types/http_validation_error.py +2 -2
- letta/types/init_tool_rule.py +2 -2
- letta/types/internal_server_error_body.py +2 -2
- letta/types/job.py +7 -12
- letta/types/letta_request.py +7 -2
- letta/types/letta_response.py +6 -5
- letta/types/letta_response_messages_item.py +125 -0
- letta/types/letta_schemas_letta_message_tool_call.py +2 -2
- letta/types/letta_schemas_message_message.py +12 -17
- letta/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
- letta/types/letta_schemas_tool_tool.py +14 -13
- letta/types/letta_usage_statistics.py +6 -7
- letta/types/llm_config.py +9 -9
- letta/types/local_sandbox_config.py +2 -2
- letta/types/log_prob_token.py +2 -2
- letta/types/memory.py +2 -2
- letta/types/message_content_log_prob.py +2 -2
- letta/types/message_create.py +2 -2
- letta/types/not_found_error_body.py +2 -2
- letta/types/open_ai_assistant.py +2 -2
- letta/types/organization.py +2 -2
- letta/types/organization_create.py +2 -2
- letta/types/passage.py +10 -15
- letta/types/provider.py +38 -0
- letta/types/reasoning_message.py +6 -7
- letta/types/recall_memory_summary.py +2 -2
- letta/types/response_format.py +2 -2
- letta/types/sandbox_config.py +2 -7
- letta/types/sandbox_config_create.py +2 -2
- letta/types/sandbox_config_update.py +2 -2
- letta/types/sandbox_environment_variable.py +2 -7
- letta/types/sandbox_environment_variable_create.py +2 -2
- letta/types/sandbox_environment_variable_update.py +2 -6
- letta/types/source.py +8 -13
- letta/types/system_message_input.py +2 -2
- letta/types/system_message_output.py +6 -7
- letta/types/terminal_tool_rule.py +2 -2
- letta/types/tool_call_delta.py +2 -2
- letta/types/tool_call_function_output.py +2 -2
- letta/types/tool_call_message.py +6 -7
- letta/types/tool_create.py +2 -2
- letta/types/tool_function_choice.py +2 -2
- letta/types/tool_input.py +2 -2
- letta/types/tool_message.py +2 -2
- letta/types/tool_return_message.py +10 -11
- letta/types/tool_type.py +5 -0
- letta/types/usage_statistics.py +2 -2
- letta/types/user.py +5 -10
- letta/types/user_create.py +2 -7
- letta/types/user_message_input.py +2 -2
- letta/types/user_message_output.py +6 -7
- letta/types/user_update.py +2 -7
- letta/types/validation_error.py +2 -2
- {letta_client-0.1.4.dist-info → letta_client-0.1.9.dist-info}/METADATA +1 -1
- letta_client-0.1.9.dist-info/RECORD +200 -0
- letta/agents/memory/__init__.py +0 -5
- letta/agents/memory/messages/client.py +0 -147
- letta/agents/memory_blocks/client.py +0 -364
- letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item.py +0 -16
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction.py +0 -27
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_direction.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_value.py +0 -7
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator.py +0 -24
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator_operator.py +0 -7
- letta_client-0.1.4.dist-info/RECORD +0 -191
- /letta/agents/{memory/messages → core_memory}/__init__.py +0 -0
- /letta/{agents/memory_blocks → providers}/__init__.py +0 -0
- {letta_client-0.1.4.dist-info → letta_client-0.1.9.dist-info}/WHEEL +0 -0
letta/agents/client.py
CHANGED
|
@@ -5,14 +5,15 @@ from ..core.client_wrapper import SyncClientWrapper
|
|
|
5
5
|
from .context.client import ContextClient
|
|
6
6
|
from .tools.client import ToolsClient
|
|
7
7
|
from .sources.client import SourcesClient
|
|
8
|
-
from .
|
|
9
|
-
from .memory_blocks.client import MemoryBlocksClient
|
|
8
|
+
from .core_memory.client import CoreMemoryClient
|
|
10
9
|
from .recall_memory.client import RecallMemoryClient
|
|
11
10
|
from .archival_memory.client import ArchivalMemoryClient
|
|
12
11
|
from .messages.client import MessagesClient
|
|
12
|
+
from .templates.client import TemplatesClient
|
|
13
|
+
from .memory_variables.client import MemoryVariablesClient
|
|
13
14
|
from ..core.request_options import RequestOptions
|
|
14
15
|
from ..types.agent_state import AgentState
|
|
15
|
-
from ..core.
|
|
16
|
+
from ..core.unchecked_base_model import construct_type
|
|
16
17
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
17
18
|
from ..types.http_validation_error import HttpValidationError
|
|
18
19
|
from json.decoder import JSONDecodeError
|
|
@@ -26,25 +27,18 @@ from ..types.message_create import MessageCreate
|
|
|
26
27
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
27
28
|
from ..core.jsonable_encoder import jsonable_encoder
|
|
28
29
|
from .types.update_agent_tool_rules_item import UpdateAgentToolRulesItem
|
|
29
|
-
from
|
|
30
|
-
from
|
|
31
|
-
from .types.agents_search_deployed_agents_request_search_item import AgentsSearchDeployedAgentsRequestSearchItem
|
|
32
|
-
from .types.agents_search_deployed_agents_request_combinator import AgentsSearchDeployedAgentsRequestCombinator
|
|
33
|
-
from ..errors.not_found_error import NotFoundError
|
|
34
|
-
from ..errors.internal_server_error import InternalServerError
|
|
35
|
-
from .types.agents_migrate_response import AgentsMigrateResponse
|
|
36
|
-
from ..errors.conflict_error import ConflictError
|
|
37
|
-
from ..types.conflict_error_body import ConflictErrorBody
|
|
38
|
-
from .types.agents_get_agent_variables_response import AgentsGetAgentVariablesResponse
|
|
30
|
+
from .types.agents_search_request_search_item import AgentsSearchRequestSearchItem
|
|
31
|
+
from .types.agents_search_request_combinator import AgentsSearchRequestCombinator
|
|
39
32
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
40
33
|
from .context.client import AsyncContextClient
|
|
41
34
|
from .tools.client import AsyncToolsClient
|
|
42
35
|
from .sources.client import AsyncSourcesClient
|
|
43
|
-
from .
|
|
44
|
-
from .memory_blocks.client import AsyncMemoryBlocksClient
|
|
36
|
+
from .core_memory.client import AsyncCoreMemoryClient
|
|
45
37
|
from .recall_memory.client import AsyncRecallMemoryClient
|
|
46
38
|
from .archival_memory.client import AsyncArchivalMemoryClient
|
|
47
39
|
from .messages.client import AsyncMessagesClient
|
|
40
|
+
from .templates.client import AsyncTemplatesClient
|
|
41
|
+
from .memory_variables.client import AsyncMemoryVariablesClient
|
|
48
42
|
|
|
49
43
|
# this is used as the default value for optional parameters
|
|
50
44
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -56,11 +50,12 @@ class AgentsClient:
|
|
|
56
50
|
self.context = ContextClient(client_wrapper=self._client_wrapper)
|
|
57
51
|
self.tools = ToolsClient(client_wrapper=self._client_wrapper)
|
|
58
52
|
self.sources = SourcesClient(client_wrapper=self._client_wrapper)
|
|
59
|
-
self.
|
|
60
|
-
self.memory_blocks = MemoryBlocksClient(client_wrapper=self._client_wrapper)
|
|
53
|
+
self.core_memory = CoreMemoryClient(client_wrapper=self._client_wrapper)
|
|
61
54
|
self.recall_memory = RecallMemoryClient(client_wrapper=self._client_wrapper)
|
|
62
55
|
self.archival_memory = ArchivalMemoryClient(client_wrapper=self._client_wrapper)
|
|
63
56
|
self.messages = MessagesClient(client_wrapper=self._client_wrapper)
|
|
57
|
+
self.templates = TemplatesClient(client_wrapper=self._client_wrapper)
|
|
58
|
+
self.memory_variables = MemoryVariablesClient(client_wrapper=self._client_wrapper)
|
|
64
59
|
|
|
65
60
|
def list(
|
|
66
61
|
self,
|
|
@@ -68,6 +63,8 @@ class AgentsClient:
|
|
|
68
63
|
name: typing.Optional[str] = None,
|
|
69
64
|
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
70
65
|
match_all_tags: typing.Optional[bool] = None,
|
|
66
|
+
cursor: typing.Optional[int] = None,
|
|
67
|
+
limit: typing.Optional[int] = None,
|
|
71
68
|
request_options: typing.Optional[RequestOptions] = None,
|
|
72
69
|
) -> typing.List[AgentState]:
|
|
73
70
|
"""
|
|
@@ -85,6 +82,12 @@ class AgentsClient:
|
|
|
85
82
|
match_all_tags : typing.Optional[bool]
|
|
86
83
|
If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
|
|
87
84
|
|
|
85
|
+
cursor : typing.Optional[int]
|
|
86
|
+
Cursor for pagination
|
|
87
|
+
|
|
88
|
+
limit : typing.Optional[int]
|
|
89
|
+
Limit for pagination
|
|
90
|
+
|
|
88
91
|
request_options : typing.Optional[RequestOptions]
|
|
89
92
|
Request-specific configuration.
|
|
90
93
|
|
|
@@ -109,6 +112,8 @@ class AgentsClient:
|
|
|
109
112
|
"name": name,
|
|
110
113
|
"tags": tags,
|
|
111
114
|
"match_all_tags": match_all_tags,
|
|
115
|
+
"cursor": cursor,
|
|
116
|
+
"limit": limit,
|
|
112
117
|
},
|
|
113
118
|
request_options=request_options,
|
|
114
119
|
)
|
|
@@ -116,7 +121,7 @@ class AgentsClient:
|
|
|
116
121
|
if 200 <= _response.status_code < 300:
|
|
117
122
|
return typing.cast(
|
|
118
123
|
typing.List[AgentState],
|
|
119
|
-
|
|
124
|
+
construct_type(
|
|
120
125
|
type_=typing.List[AgentState], # type: ignore
|
|
121
126
|
object_=_response.json(),
|
|
122
127
|
),
|
|
@@ -125,7 +130,7 @@ class AgentsClient:
|
|
|
125
130
|
raise UnprocessableEntityError(
|
|
126
131
|
typing.cast(
|
|
127
132
|
HttpValidationError,
|
|
128
|
-
|
|
133
|
+
construct_type(
|
|
129
134
|
type_=HttpValidationError, # type: ignore
|
|
130
135
|
object_=_response.json(),
|
|
131
136
|
),
|
|
@@ -161,7 +166,8 @@ class AgentsClient:
|
|
|
161
166
|
embedding_chunk_size: typing.Optional[int] = OMIT,
|
|
162
167
|
from_template: typing.Optional[str] = OMIT,
|
|
163
168
|
project_id: typing.Optional[str] = OMIT,
|
|
164
|
-
|
|
169
|
+
tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
170
|
+
variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
165
171
|
request_options: typing.Optional[RequestOptions] = None,
|
|
166
172
|
) -> AgentState:
|
|
167
173
|
"""
|
|
@@ -235,7 +241,11 @@ class AgentsClient:
|
|
|
235
241
|
project_id : typing.Optional[str]
|
|
236
242
|
The project id that the agent will be associated with.
|
|
237
243
|
|
|
238
|
-
|
|
244
|
+
tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
245
|
+
The environment variables for tool execution specific to this agent.
|
|
246
|
+
|
|
247
|
+
variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
248
|
+
The variables that should be set for the agent.
|
|
239
249
|
|
|
240
250
|
request_options : typing.Optional[RequestOptions]
|
|
241
251
|
Request-specific configuration.
|
|
@@ -297,7 +307,8 @@ class AgentsClient:
|
|
|
297
307
|
"embedding_chunk_size": embedding_chunk_size,
|
|
298
308
|
"from_template": from_template,
|
|
299
309
|
"project_id": project_id,
|
|
300
|
-
"
|
|
310
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
311
|
+
"variables": variables,
|
|
301
312
|
},
|
|
302
313
|
headers={
|
|
303
314
|
"content-type": "application/json",
|
|
@@ -309,7 +320,7 @@ class AgentsClient:
|
|
|
309
320
|
if 200 <= _response.status_code < 300:
|
|
310
321
|
return typing.cast(
|
|
311
322
|
AgentState,
|
|
312
|
-
|
|
323
|
+
construct_type(
|
|
313
324
|
type_=AgentState, # type: ignore
|
|
314
325
|
object_=_response.json(),
|
|
315
326
|
),
|
|
@@ -318,7 +329,7 @@ class AgentsClient:
|
|
|
318
329
|
raise UnprocessableEntityError(
|
|
319
330
|
typing.cast(
|
|
320
331
|
HttpValidationError,
|
|
321
|
-
|
|
332
|
+
construct_type(
|
|
322
333
|
type_=HttpValidationError, # type: ignore
|
|
323
334
|
object_=_response.json(),
|
|
324
335
|
),
|
|
@@ -365,7 +376,7 @@ class AgentsClient:
|
|
|
365
376
|
if 200 <= _response.status_code < 300:
|
|
366
377
|
return typing.cast(
|
|
367
378
|
AgentState,
|
|
368
|
-
|
|
379
|
+
construct_type(
|
|
369
380
|
type_=AgentState, # type: ignore
|
|
370
381
|
object_=_response.json(),
|
|
371
382
|
),
|
|
@@ -374,7 +385,7 @@ class AgentsClient:
|
|
|
374
385
|
raise UnprocessableEntityError(
|
|
375
386
|
typing.cast(
|
|
376
387
|
HttpValidationError,
|
|
377
|
-
|
|
388
|
+
construct_type(
|
|
378
389
|
type_=HttpValidationError, # type: ignore
|
|
379
390
|
object_=_response.json(),
|
|
380
391
|
),
|
|
@@ -423,7 +434,7 @@ class AgentsClient:
|
|
|
423
434
|
if 200 <= _response.status_code < 300:
|
|
424
435
|
return typing.cast(
|
|
425
436
|
typing.Optional[typing.Any],
|
|
426
|
-
|
|
437
|
+
construct_type(
|
|
427
438
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
428
439
|
object_=_response.json(),
|
|
429
440
|
),
|
|
@@ -432,7 +443,7 @@ class AgentsClient:
|
|
|
432
443
|
raise UnprocessableEntityError(
|
|
433
444
|
typing.cast(
|
|
434
445
|
HttpValidationError,
|
|
435
|
-
|
|
446
|
+
construct_type(
|
|
436
447
|
type_=HttpValidationError, # type: ignore
|
|
437
448
|
object_=_response.json(),
|
|
438
449
|
),
|
|
@@ -459,6 +470,7 @@ class AgentsClient:
|
|
|
459
470
|
message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
460
471
|
description: typing.Optional[str] = OMIT,
|
|
461
472
|
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
473
|
+
tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
462
474
|
request_options: typing.Optional[RequestOptions] = None,
|
|
463
475
|
) -> AgentState:
|
|
464
476
|
"""
|
|
@@ -504,6 +516,9 @@ class AgentsClient:
|
|
|
504
516
|
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
505
517
|
The metadata of the agent.
|
|
506
518
|
|
|
519
|
+
tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
520
|
+
The environment variables for tool execution specific to this agent.
|
|
521
|
+
|
|
507
522
|
request_options : typing.Optional[RequestOptions]
|
|
508
523
|
Request-specific configuration.
|
|
509
524
|
|
|
@@ -545,6 +560,7 @@ class AgentsClient:
|
|
|
545
560
|
"message_ids": message_ids,
|
|
546
561
|
"description": description,
|
|
547
562
|
"metadata_": metadata,
|
|
563
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
548
564
|
},
|
|
549
565
|
headers={
|
|
550
566
|
"content-type": "application/json",
|
|
@@ -556,7 +572,7 @@ class AgentsClient:
|
|
|
556
572
|
if 200 <= _response.status_code < 300:
|
|
557
573
|
return typing.cast(
|
|
558
574
|
AgentState,
|
|
559
|
-
|
|
575
|
+
construct_type(
|
|
560
576
|
type_=AgentState, # type: ignore
|
|
561
577
|
object_=_response.json(),
|
|
562
578
|
),
|
|
@@ -565,68 +581,7 @@ class AgentsClient:
|
|
|
565
581
|
raise UnprocessableEntityError(
|
|
566
582
|
typing.cast(
|
|
567
583
|
HttpValidationError,
|
|
568
|
-
|
|
569
|
-
type_=HttpValidationError, # type: ignore
|
|
570
|
-
object_=_response.json(),
|
|
571
|
-
),
|
|
572
|
-
)
|
|
573
|
-
)
|
|
574
|
-
_response_json = _response.json()
|
|
575
|
-
except JSONDecodeError:
|
|
576
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
577
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
578
|
-
|
|
579
|
-
def get_agent_memory_block(
|
|
580
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
581
|
-
) -> Block:
|
|
582
|
-
"""
|
|
583
|
-
Retrieve a memory block from an agent.
|
|
584
|
-
|
|
585
|
-
Parameters
|
|
586
|
-
----------
|
|
587
|
-
agent_id : str
|
|
588
|
-
|
|
589
|
-
block_label : str
|
|
590
|
-
|
|
591
|
-
request_options : typing.Optional[RequestOptions]
|
|
592
|
-
Request-specific configuration.
|
|
593
|
-
|
|
594
|
-
Returns
|
|
595
|
-
-------
|
|
596
|
-
Block
|
|
597
|
-
Successful Response
|
|
598
|
-
|
|
599
|
-
Examples
|
|
600
|
-
--------
|
|
601
|
-
from letta import Letta
|
|
602
|
-
|
|
603
|
-
client = Letta(
|
|
604
|
-
token="YOUR_TOKEN",
|
|
605
|
-
)
|
|
606
|
-
client.agents.get_agent_memory_block(
|
|
607
|
-
agent_id="agent_id",
|
|
608
|
-
block_label="block_label",
|
|
609
|
-
)
|
|
610
|
-
"""
|
|
611
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
612
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
|
|
613
|
-
method="GET",
|
|
614
|
-
request_options=request_options,
|
|
615
|
-
)
|
|
616
|
-
try:
|
|
617
|
-
if 200 <= _response.status_code < 300:
|
|
618
|
-
return typing.cast(
|
|
619
|
-
Block,
|
|
620
|
-
parse_obj_as(
|
|
621
|
-
type_=Block, # type: ignore
|
|
622
|
-
object_=_response.json(),
|
|
623
|
-
),
|
|
624
|
-
)
|
|
625
|
-
if _response.status_code == 422:
|
|
626
|
-
raise UnprocessableEntityError(
|
|
627
|
-
typing.cast(
|
|
628
|
-
HttpValidationError,
|
|
629
|
-
parse_obj_as(
|
|
584
|
+
construct_type(
|
|
630
585
|
type_=HttpValidationError, # type: ignore
|
|
631
586
|
object_=_response.json(),
|
|
632
587
|
),
|
|
@@ -637,57 +592,39 @@ class AgentsClient:
|
|
|
637
592
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
638
593
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
639
594
|
|
|
640
|
-
def
|
|
595
|
+
def search(
|
|
641
596
|
self,
|
|
642
|
-
agent_id: str,
|
|
643
|
-
block_label: str,
|
|
644
597
|
*,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
description: typing.Optional[str] = OMIT,
|
|
651
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
598
|
+
search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
|
|
599
|
+
project_id: typing.Optional[str] = OMIT,
|
|
600
|
+
combinator: typing.Optional[AgentsSearchRequestCombinator] = OMIT,
|
|
601
|
+
limit: typing.Optional[float] = OMIT,
|
|
602
|
+
offset: typing.Optional[float] = OMIT,
|
|
652
603
|
request_options: typing.Optional[RequestOptions] = None,
|
|
653
|
-
) ->
|
|
604
|
+
) -> None:
|
|
654
605
|
"""
|
|
655
|
-
|
|
606
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
607
|
+
|
|
608
|
+
Search deployed agents.
|
|
656
609
|
|
|
657
610
|
Parameters
|
|
658
611
|
----------
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
block_label : str
|
|
662
|
-
|
|
663
|
-
value : typing.Optional[str]
|
|
664
|
-
Value of the block.
|
|
665
|
-
|
|
666
|
-
limit : typing.Optional[int]
|
|
667
|
-
Character limit of the block.
|
|
668
|
-
|
|
669
|
-
name : typing.Optional[str]
|
|
670
|
-
Name of the block if it is a template.
|
|
612
|
+
search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
|
|
671
613
|
|
|
672
|
-
|
|
673
|
-
Whether the block is a template (e.g. saved human/persona options).
|
|
614
|
+
project_id : typing.Optional[str]
|
|
674
615
|
|
|
675
|
-
|
|
676
|
-
Label of the block (e.g. 'human', 'persona') in the context window.
|
|
616
|
+
combinator : typing.Optional[AgentsSearchRequestCombinator]
|
|
677
617
|
|
|
678
|
-
|
|
679
|
-
Description of the block.
|
|
618
|
+
limit : typing.Optional[float]
|
|
680
619
|
|
|
681
|
-
|
|
682
|
-
Metadata of the block.
|
|
620
|
+
offset : typing.Optional[float]
|
|
683
621
|
|
|
684
622
|
request_options : typing.Optional[RequestOptions]
|
|
685
623
|
Request-specific configuration.
|
|
686
624
|
|
|
687
625
|
Returns
|
|
688
626
|
-------
|
|
689
|
-
|
|
690
|
-
Successful Response
|
|
627
|
+
None
|
|
691
628
|
|
|
692
629
|
Examples
|
|
693
630
|
--------
|
|
@@ -696,178 +633,122 @@ class AgentsClient:
|
|
|
696
633
|
client = Letta(
|
|
697
634
|
token="YOUR_TOKEN",
|
|
698
635
|
)
|
|
699
|
-
client.agents.
|
|
700
|
-
agent_id="agent_id",
|
|
701
|
-
block_label="block_label",
|
|
702
|
-
)
|
|
636
|
+
client.agents.search()
|
|
703
637
|
"""
|
|
704
638
|
_response = self._client_wrapper.httpx_client.request(
|
|
705
|
-
|
|
706
|
-
method="
|
|
639
|
+
"v1/agents/search",
|
|
640
|
+
method="POST",
|
|
707
641
|
json={
|
|
708
|
-
"
|
|
642
|
+
"search": convert_and_respect_annotation_metadata(
|
|
643
|
+
object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
|
|
644
|
+
),
|
|
645
|
+
"project_id": project_id,
|
|
646
|
+
"combinator": combinator,
|
|
709
647
|
"limit": limit,
|
|
710
|
-
"
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
"
|
|
714
|
-
"metadata_": metadata,
|
|
648
|
+
"offset": offset,
|
|
649
|
+
},
|
|
650
|
+
headers={
|
|
651
|
+
"content-type": "application/json",
|
|
715
652
|
},
|
|
716
653
|
request_options=request_options,
|
|
717
654
|
omit=OMIT,
|
|
718
655
|
)
|
|
719
656
|
try:
|
|
720
657
|
if 200 <= _response.status_code < 300:
|
|
721
|
-
return
|
|
722
|
-
Block,
|
|
723
|
-
parse_obj_as(
|
|
724
|
-
type_=Block, # type: ignore
|
|
725
|
-
object_=_response.json(),
|
|
726
|
-
),
|
|
727
|
-
)
|
|
728
|
-
if _response.status_code == 422:
|
|
729
|
-
raise UnprocessableEntityError(
|
|
730
|
-
typing.cast(
|
|
731
|
-
HttpValidationError,
|
|
732
|
-
parse_obj_as(
|
|
733
|
-
type_=HttpValidationError, # type: ignore
|
|
734
|
-
object_=_response.json(),
|
|
735
|
-
),
|
|
736
|
-
)
|
|
737
|
-
)
|
|
658
|
+
return
|
|
738
659
|
_response_json = _response.json()
|
|
739
660
|
except JSONDecodeError:
|
|
740
661
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
741
662
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
742
663
|
|
|
743
|
-
def get_agent_memory_blocks(
|
|
744
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
745
|
-
) -> typing.List[Block]:
|
|
746
|
-
"""
|
|
747
|
-
Retrieve the memory blocks of a specific agent.
|
|
748
|
-
|
|
749
|
-
Parameters
|
|
750
|
-
----------
|
|
751
|
-
agent_id : str
|
|
752
|
-
|
|
753
|
-
request_options : typing.Optional[RequestOptions]
|
|
754
|
-
Request-specific configuration.
|
|
755
|
-
|
|
756
|
-
Returns
|
|
757
|
-
-------
|
|
758
|
-
typing.List[Block]
|
|
759
|
-
Successful Response
|
|
760
|
-
|
|
761
|
-
Examples
|
|
762
|
-
--------
|
|
763
|
-
from letta import Letta
|
|
764
664
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
)
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
)
|
|
777
|
-
try:
|
|
778
|
-
if 200 <= _response.status_code < 300:
|
|
779
|
-
return typing.cast(
|
|
780
|
-
typing.List[Block],
|
|
781
|
-
parse_obj_as(
|
|
782
|
-
type_=typing.List[Block], # type: ignore
|
|
783
|
-
object_=_response.json(),
|
|
784
|
-
),
|
|
785
|
-
)
|
|
786
|
-
if _response.status_code == 422:
|
|
787
|
-
raise UnprocessableEntityError(
|
|
788
|
-
typing.cast(
|
|
789
|
-
HttpValidationError,
|
|
790
|
-
parse_obj_as(
|
|
791
|
-
type_=HttpValidationError, # type: ignore
|
|
792
|
-
object_=_response.json(),
|
|
793
|
-
),
|
|
794
|
-
)
|
|
795
|
-
)
|
|
796
|
-
_response_json = _response.json()
|
|
797
|
-
except JSONDecodeError:
|
|
798
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
799
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
665
|
+
class AsyncAgentsClient:
|
|
666
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
667
|
+
self._client_wrapper = client_wrapper
|
|
668
|
+
self.context = AsyncContextClient(client_wrapper=self._client_wrapper)
|
|
669
|
+
self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
|
|
670
|
+
self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
|
|
671
|
+
self.core_memory = AsyncCoreMemoryClient(client_wrapper=self._client_wrapper)
|
|
672
|
+
self.recall_memory = AsyncRecallMemoryClient(client_wrapper=self._client_wrapper)
|
|
673
|
+
self.archival_memory = AsyncArchivalMemoryClient(client_wrapper=self._client_wrapper)
|
|
674
|
+
self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
|
|
675
|
+
self.templates = AsyncTemplatesClient(client_wrapper=self._client_wrapper)
|
|
676
|
+
self.memory_variables = AsyncMemoryVariablesClient(client_wrapper=self._client_wrapper)
|
|
800
677
|
|
|
801
|
-
def
|
|
678
|
+
async def list(
|
|
802
679
|
self,
|
|
803
|
-
agent_id: str,
|
|
804
680
|
*,
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
681
|
+
name: typing.Optional[str] = None,
|
|
682
|
+
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
683
|
+
match_all_tags: typing.Optional[bool] = None,
|
|
684
|
+
cursor: typing.Optional[int] = None,
|
|
685
|
+
limit: typing.Optional[int] = None,
|
|
808
686
|
request_options: typing.Optional[RequestOptions] = None,
|
|
809
|
-
) ->
|
|
687
|
+
) -> typing.List[AgentState]:
|
|
810
688
|
"""
|
|
811
|
-
|
|
812
|
-
|
|
689
|
+
List all agents associated with a given user.
|
|
690
|
+
This endpoint retrieves a list of all agents and their configurations associated with the specified user ID.
|
|
813
691
|
|
|
814
692
|
Parameters
|
|
815
693
|
----------
|
|
816
|
-
|
|
694
|
+
name : typing.Optional[str]
|
|
695
|
+
Name of the agent
|
|
696
|
+
|
|
697
|
+
tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
698
|
+
List of tags to filter agents by
|
|
817
699
|
|
|
818
|
-
|
|
819
|
-
|
|
700
|
+
match_all_tags : typing.Optional[bool]
|
|
701
|
+
If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
|
|
820
702
|
|
|
821
|
-
|
|
822
|
-
|
|
703
|
+
cursor : typing.Optional[int]
|
|
704
|
+
Cursor for pagination
|
|
823
705
|
|
|
824
|
-
|
|
825
|
-
|
|
706
|
+
limit : typing.Optional[int]
|
|
707
|
+
Limit for pagination
|
|
826
708
|
|
|
827
709
|
request_options : typing.Optional[RequestOptions]
|
|
828
710
|
Request-specific configuration.
|
|
829
711
|
|
|
830
712
|
Returns
|
|
831
713
|
-------
|
|
832
|
-
|
|
714
|
+
typing.List[AgentState]
|
|
833
715
|
Successful Response
|
|
834
716
|
|
|
835
717
|
Examples
|
|
836
718
|
--------
|
|
837
|
-
|
|
719
|
+
import asyncio
|
|
838
720
|
|
|
839
|
-
|
|
721
|
+
from letta import AsyncLetta
|
|
722
|
+
|
|
723
|
+
client = AsyncLetta(
|
|
840
724
|
token="YOUR_TOKEN",
|
|
841
725
|
)
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
],
|
|
850
|
-
)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
async def main() -> None:
|
|
729
|
+
await client.agents.list()
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
asyncio.run(main())
|
|
851
733
|
"""
|
|
852
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
853
|
-
|
|
854
|
-
method="
|
|
855
|
-
|
|
856
|
-
"
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
"
|
|
860
|
-
"
|
|
734
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
735
|
+
"v1/agents/",
|
|
736
|
+
method="GET",
|
|
737
|
+
params={
|
|
738
|
+
"name": name,
|
|
739
|
+
"tags": tags,
|
|
740
|
+
"match_all_tags": match_all_tags,
|
|
741
|
+
"cursor": cursor,
|
|
742
|
+
"limit": limit,
|
|
861
743
|
},
|
|
862
744
|
request_options=request_options,
|
|
863
|
-
omit=OMIT,
|
|
864
745
|
)
|
|
865
746
|
try:
|
|
866
747
|
if 200 <= _response.status_code < 300:
|
|
867
748
|
return typing.cast(
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
type_=
|
|
749
|
+
typing.List[AgentState],
|
|
750
|
+
construct_type(
|
|
751
|
+
type_=typing.List[AgentState], # type: ignore
|
|
871
752
|
object_=_response.json(),
|
|
872
753
|
),
|
|
873
754
|
)
|
|
@@ -875,7 +756,7 @@ class AgentsClient:
|
|
|
875
756
|
raise UnprocessableEntityError(
|
|
876
757
|
typing.cast(
|
|
877
758
|
HttpValidationError,
|
|
878
|
-
|
|
759
|
+
construct_type(
|
|
879
760
|
type_=HttpValidationError, # type: ignore
|
|
880
761
|
object_=_response.json(),
|
|
881
762
|
),
|
|
@@ -886,1242 +767,125 @@ class AgentsClient:
|
|
|
886
767
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
887
768
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
888
769
|
|
|
889
|
-
def
|
|
770
|
+
async def create(
|
|
890
771
|
self,
|
|
891
772
|
*,
|
|
892
|
-
|
|
773
|
+
memory_blocks: typing.Sequence[CreateBlock],
|
|
774
|
+
name: typing.Optional[str] = OMIT,
|
|
775
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
776
|
+
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
777
|
+
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
778
|
+
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
779
|
+
tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
|
|
780
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
781
|
+
system: typing.Optional[str] = OMIT,
|
|
782
|
+
agent_type: typing.Optional[AgentType] = OMIT,
|
|
783
|
+
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
784
|
+
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
785
|
+
initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
|
|
786
|
+
include_base_tools: typing.Optional[bool] = OMIT,
|
|
787
|
+
description: typing.Optional[str] = OMIT,
|
|
788
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
789
|
+
llm: typing.Optional[str] = OMIT,
|
|
790
|
+
embedding: typing.Optional[str] = OMIT,
|
|
791
|
+
context_window_limit: typing.Optional[int] = OMIT,
|
|
792
|
+
embedding_chunk_size: typing.Optional[int] = OMIT,
|
|
793
|
+
from_template: typing.Optional[str] = OMIT,
|
|
893
794
|
project_id: typing.Optional[str] = OMIT,
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
offset: typing.Optional[float] = OMIT,
|
|
795
|
+
tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
796
|
+
variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
897
797
|
request_options: typing.Optional[RequestOptions] = None,
|
|
898
|
-
) ->
|
|
798
|
+
) -> AgentState:
|
|
899
799
|
"""
|
|
900
|
-
|
|
800
|
+
Create a new agent with the specified configuration.
|
|
901
801
|
|
|
902
802
|
Parameters
|
|
903
803
|
----------
|
|
904
|
-
|
|
804
|
+
memory_blocks : typing.Sequence[CreateBlock]
|
|
805
|
+
The blocks to create in the agent's in-context memory.
|
|
905
806
|
|
|
906
|
-
|
|
807
|
+
name : typing.Optional[str]
|
|
808
|
+
The name of the agent.
|
|
907
809
|
|
|
908
|
-
|
|
810
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
811
|
+
The tools used by the agent.
|
|
909
812
|
|
|
910
|
-
|
|
813
|
+
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
814
|
+
The ids of the tools used by the agent.
|
|
911
815
|
|
|
912
|
-
|
|
816
|
+
source_ids : typing.Optional[typing.Sequence[str]]
|
|
817
|
+
The ids of the sources used by the agent.
|
|
913
818
|
|
|
914
|
-
|
|
915
|
-
|
|
819
|
+
block_ids : typing.Optional[typing.Sequence[str]]
|
|
820
|
+
The ids of the blocks used by the agent.
|
|
916
821
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
None
|
|
920
|
-
|
|
921
|
-
Examples
|
|
922
|
-
--------
|
|
923
|
-
from letta import Letta
|
|
924
|
-
|
|
925
|
-
client = Letta(
|
|
926
|
-
token="YOUR_TOKEN",
|
|
927
|
-
)
|
|
928
|
-
client.agents.searchdeployedagents()
|
|
929
|
-
"""
|
|
930
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
931
|
-
"v1/agents/search",
|
|
932
|
-
method="POST",
|
|
933
|
-
json={
|
|
934
|
-
"search": convert_and_respect_annotation_metadata(
|
|
935
|
-
object_=search,
|
|
936
|
-
annotation=typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem],
|
|
937
|
-
direction="write",
|
|
938
|
-
),
|
|
939
|
-
"project_id": project_id,
|
|
940
|
-
"combinator": combinator,
|
|
941
|
-
"limit": limit,
|
|
942
|
-
"offset": offset,
|
|
943
|
-
},
|
|
944
|
-
headers={
|
|
945
|
-
"content-type": "application/json",
|
|
946
|
-
},
|
|
947
|
-
request_options=request_options,
|
|
948
|
-
omit=OMIT,
|
|
949
|
-
)
|
|
950
|
-
try:
|
|
951
|
-
if 200 <= _response.status_code < 300:
|
|
952
|
-
return
|
|
953
|
-
_response_json = _response.json()
|
|
954
|
-
except JSONDecodeError:
|
|
955
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
956
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
957
|
-
|
|
958
|
-
def create_version(
|
|
959
|
-
self,
|
|
960
|
-
agent_id: str,
|
|
961
|
-
*,
|
|
962
|
-
return_agent_state: typing.Optional[bool] = None,
|
|
963
|
-
migrate_deployed_agents: typing.Optional[bool] = OMIT,
|
|
964
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
965
|
-
) -> None:
|
|
966
|
-
"""
|
|
967
|
-
Creates a versioned version of an agent
|
|
968
|
-
|
|
969
|
-
Parameters
|
|
970
|
-
----------
|
|
971
|
-
agent_id : str
|
|
972
|
-
The agent ID of the agent to migrate, if this agent is not a template, it will create a agent template from the agent provided as well
|
|
973
|
-
|
|
974
|
-
return_agent_state : typing.Optional[bool]
|
|
975
|
-
|
|
976
|
-
migrate_deployed_agents : typing.Optional[bool]
|
|
977
|
-
|
|
978
|
-
request_options : typing.Optional[RequestOptions]
|
|
979
|
-
Request-specific configuration.
|
|
980
|
-
|
|
981
|
-
Returns
|
|
982
|
-
-------
|
|
983
|
-
None
|
|
984
|
-
|
|
985
|
-
Examples
|
|
986
|
-
--------
|
|
987
|
-
from letta import Letta
|
|
988
|
-
|
|
989
|
-
client = Letta(
|
|
990
|
-
token="YOUR_TOKEN",
|
|
991
|
-
)
|
|
992
|
-
client.agents.create_version(
|
|
993
|
-
agent_id="agent_id",
|
|
994
|
-
)
|
|
995
|
-
"""
|
|
996
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
997
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/version-template",
|
|
998
|
-
method="POST",
|
|
999
|
-
params={
|
|
1000
|
-
"returnAgentState": return_agent_state,
|
|
1001
|
-
},
|
|
1002
|
-
json={
|
|
1003
|
-
"migrate_deployed_agents": migrate_deployed_agents,
|
|
1004
|
-
},
|
|
1005
|
-
headers={
|
|
1006
|
-
"content-type": "application/json",
|
|
1007
|
-
},
|
|
1008
|
-
request_options=request_options,
|
|
1009
|
-
omit=OMIT,
|
|
1010
|
-
)
|
|
1011
|
-
try:
|
|
1012
|
-
if 200 <= _response.status_code < 300:
|
|
1013
|
-
return
|
|
1014
|
-
if _response.status_code == 404:
|
|
1015
|
-
raise NotFoundError(
|
|
1016
|
-
typing.cast(
|
|
1017
|
-
typing.Optional[typing.Any],
|
|
1018
|
-
parse_obj_as(
|
|
1019
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1020
|
-
object_=_response.json(),
|
|
1021
|
-
),
|
|
1022
|
-
)
|
|
1023
|
-
)
|
|
1024
|
-
if _response.status_code == 500:
|
|
1025
|
-
raise InternalServerError(
|
|
1026
|
-
typing.cast(
|
|
1027
|
-
typing.Optional[typing.Any],
|
|
1028
|
-
parse_obj_as(
|
|
1029
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1030
|
-
object_=_response.json(),
|
|
1031
|
-
),
|
|
1032
|
-
)
|
|
1033
|
-
)
|
|
1034
|
-
_response_json = _response.json()
|
|
1035
|
-
except JSONDecodeError:
|
|
1036
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1037
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1038
|
-
|
|
1039
|
-
def migrate(
|
|
1040
|
-
self,
|
|
1041
|
-
agent_id: str,
|
|
1042
|
-
*,
|
|
1043
|
-
to_template: str,
|
|
1044
|
-
preserve_core_memories: bool,
|
|
1045
|
-
variables: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
1046
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1047
|
-
) -> AgentsMigrateResponse:
|
|
1048
|
-
"""
|
|
1049
|
-
Migrate an agent to a new versioned agent template
|
|
1050
|
-
|
|
1051
|
-
Parameters
|
|
1052
|
-
----------
|
|
1053
|
-
agent_id : str
|
|
1054
|
-
|
|
1055
|
-
to_template : str
|
|
1056
|
-
|
|
1057
|
-
preserve_core_memories : bool
|
|
1058
|
-
|
|
1059
|
-
variables : typing.Optional[typing.Dict[str, str]]
|
|
1060
|
-
If you chose to not preserve core memories, you should provide the new variables for the core memories
|
|
1061
|
-
|
|
1062
|
-
request_options : typing.Optional[RequestOptions]
|
|
1063
|
-
Request-specific configuration.
|
|
1064
|
-
|
|
1065
|
-
Returns
|
|
1066
|
-
-------
|
|
1067
|
-
AgentsMigrateResponse
|
|
1068
|
-
200
|
|
1069
|
-
|
|
1070
|
-
Examples
|
|
1071
|
-
--------
|
|
1072
|
-
from letta import Letta
|
|
1073
|
-
|
|
1074
|
-
client = Letta(
|
|
1075
|
-
token="YOUR_TOKEN",
|
|
1076
|
-
)
|
|
1077
|
-
client.agents.migrate(
|
|
1078
|
-
agent_id="agent_id",
|
|
1079
|
-
to_template="to_template",
|
|
1080
|
-
preserve_core_memories=True,
|
|
1081
|
-
)
|
|
1082
|
-
"""
|
|
1083
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
1084
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/migrate",
|
|
1085
|
-
method="POST",
|
|
1086
|
-
json={
|
|
1087
|
-
"to_template": to_template,
|
|
1088
|
-
"variables": variables,
|
|
1089
|
-
"preserve_core_memories": preserve_core_memories,
|
|
1090
|
-
},
|
|
1091
|
-
headers={
|
|
1092
|
-
"content-type": "application/json",
|
|
1093
|
-
},
|
|
1094
|
-
request_options=request_options,
|
|
1095
|
-
omit=OMIT,
|
|
1096
|
-
)
|
|
1097
|
-
try:
|
|
1098
|
-
if 200 <= _response.status_code < 300:
|
|
1099
|
-
return typing.cast(
|
|
1100
|
-
AgentsMigrateResponse,
|
|
1101
|
-
parse_obj_as(
|
|
1102
|
-
type_=AgentsMigrateResponse, # type: ignore
|
|
1103
|
-
object_=_response.json(),
|
|
1104
|
-
),
|
|
1105
|
-
)
|
|
1106
|
-
if _response.status_code == 404:
|
|
1107
|
-
raise NotFoundError(
|
|
1108
|
-
typing.cast(
|
|
1109
|
-
typing.Optional[typing.Any],
|
|
1110
|
-
parse_obj_as(
|
|
1111
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1112
|
-
object_=_response.json(),
|
|
1113
|
-
),
|
|
1114
|
-
)
|
|
1115
|
-
)
|
|
1116
|
-
if _response.status_code == 409:
|
|
1117
|
-
raise ConflictError(
|
|
1118
|
-
typing.cast(
|
|
1119
|
-
ConflictErrorBody,
|
|
1120
|
-
parse_obj_as(
|
|
1121
|
-
type_=ConflictErrorBody, # type: ignore
|
|
1122
|
-
object_=_response.json(),
|
|
1123
|
-
),
|
|
1124
|
-
)
|
|
1125
|
-
)
|
|
1126
|
-
if _response.status_code == 500:
|
|
1127
|
-
raise InternalServerError(
|
|
1128
|
-
typing.cast(
|
|
1129
|
-
typing.Optional[typing.Any],
|
|
1130
|
-
parse_obj_as(
|
|
1131
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1132
|
-
object_=_response.json(),
|
|
1133
|
-
),
|
|
1134
|
-
)
|
|
1135
|
-
)
|
|
1136
|
-
_response_json = _response.json()
|
|
1137
|
-
except JSONDecodeError:
|
|
1138
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1139
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1140
|
-
|
|
1141
|
-
def createtemplatefromagent(
|
|
1142
|
-
self,
|
|
1143
|
-
agent_id: str,
|
|
1144
|
-
*,
|
|
1145
|
-
project_id: typing.Optional[str] = OMIT,
|
|
1146
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1147
|
-
) -> None:
|
|
1148
|
-
"""
|
|
1149
|
-
Create a template from an agent
|
|
1150
|
-
|
|
1151
|
-
Parameters
|
|
1152
|
-
----------
|
|
1153
|
-
agent_id : str
|
|
1154
|
-
|
|
1155
|
-
project_id : typing.Optional[str]
|
|
1156
|
-
|
|
1157
|
-
request_options : typing.Optional[RequestOptions]
|
|
1158
|
-
Request-specific configuration.
|
|
1159
|
-
|
|
1160
|
-
Returns
|
|
1161
|
-
-------
|
|
1162
|
-
None
|
|
1163
|
-
|
|
1164
|
-
Examples
|
|
1165
|
-
--------
|
|
1166
|
-
from letta import Letta
|
|
1167
|
-
|
|
1168
|
-
client = Letta(
|
|
1169
|
-
token="YOUR_TOKEN",
|
|
1170
|
-
)
|
|
1171
|
-
client.agents.createtemplatefromagent(
|
|
1172
|
-
agent_id="agent_id",
|
|
1173
|
-
)
|
|
1174
|
-
"""
|
|
1175
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
1176
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/template",
|
|
1177
|
-
method="POST",
|
|
1178
|
-
json={
|
|
1179
|
-
"project_id": project_id,
|
|
1180
|
-
},
|
|
1181
|
-
headers={
|
|
1182
|
-
"content-type": "application/json",
|
|
1183
|
-
},
|
|
1184
|
-
request_options=request_options,
|
|
1185
|
-
omit=OMIT,
|
|
1186
|
-
)
|
|
1187
|
-
try:
|
|
1188
|
-
if 200 <= _response.status_code < 300:
|
|
1189
|
-
return
|
|
1190
|
-
if _response.status_code == 404:
|
|
1191
|
-
raise NotFoundError(
|
|
1192
|
-
typing.cast(
|
|
1193
|
-
typing.Optional[typing.Any],
|
|
1194
|
-
parse_obj_as(
|
|
1195
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1196
|
-
object_=_response.json(),
|
|
1197
|
-
),
|
|
1198
|
-
)
|
|
1199
|
-
)
|
|
1200
|
-
if _response.status_code == 500:
|
|
1201
|
-
raise InternalServerError(
|
|
1202
|
-
typing.cast(
|
|
1203
|
-
typing.Optional[typing.Any],
|
|
1204
|
-
parse_obj_as(
|
|
1205
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1206
|
-
object_=_response.json(),
|
|
1207
|
-
),
|
|
1208
|
-
)
|
|
1209
|
-
)
|
|
1210
|
-
_response_json = _response.json()
|
|
1211
|
-
except JSONDecodeError:
|
|
1212
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1213
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1214
|
-
|
|
1215
|
-
def getagentvariables(
|
|
1216
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1217
|
-
) -> AgentsGetAgentVariablesResponse:
|
|
1218
|
-
"""
|
|
1219
|
-
Get the variables associated with an agent
|
|
1220
|
-
|
|
1221
|
-
Parameters
|
|
1222
|
-
----------
|
|
1223
|
-
agent_id : str
|
|
1224
|
-
|
|
1225
|
-
request_options : typing.Optional[RequestOptions]
|
|
1226
|
-
Request-specific configuration.
|
|
1227
|
-
|
|
1228
|
-
Returns
|
|
1229
|
-
-------
|
|
1230
|
-
AgentsGetAgentVariablesResponse
|
|
1231
|
-
200
|
|
1232
|
-
|
|
1233
|
-
Examples
|
|
1234
|
-
--------
|
|
1235
|
-
from letta import Letta
|
|
1236
|
-
|
|
1237
|
-
client = Letta(
|
|
1238
|
-
token="YOUR_TOKEN",
|
|
1239
|
-
)
|
|
1240
|
-
client.agents.getagentvariables(
|
|
1241
|
-
agent_id="agent_id",
|
|
1242
|
-
)
|
|
1243
|
-
"""
|
|
1244
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
1245
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/variables",
|
|
1246
|
-
method="GET",
|
|
1247
|
-
request_options=request_options,
|
|
1248
|
-
)
|
|
1249
|
-
try:
|
|
1250
|
-
if 200 <= _response.status_code < 300:
|
|
1251
|
-
return typing.cast(
|
|
1252
|
-
AgentsGetAgentVariablesResponse,
|
|
1253
|
-
parse_obj_as(
|
|
1254
|
-
type_=AgentsGetAgentVariablesResponse, # type: ignore
|
|
1255
|
-
object_=_response.json(),
|
|
1256
|
-
),
|
|
1257
|
-
)
|
|
1258
|
-
if _response.status_code == 404:
|
|
1259
|
-
raise NotFoundError(
|
|
1260
|
-
typing.cast(
|
|
1261
|
-
typing.Optional[typing.Any],
|
|
1262
|
-
parse_obj_as(
|
|
1263
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1264
|
-
object_=_response.json(),
|
|
1265
|
-
),
|
|
1266
|
-
)
|
|
1267
|
-
)
|
|
1268
|
-
_response_json = _response.json()
|
|
1269
|
-
except JSONDecodeError:
|
|
1270
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1271
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
class AsyncAgentsClient:
|
|
1275
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
1276
|
-
self._client_wrapper = client_wrapper
|
|
1277
|
-
self.context = AsyncContextClient(client_wrapper=self._client_wrapper)
|
|
1278
|
-
self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
|
|
1279
|
-
self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
|
|
1280
|
-
self.memory = AsyncMemoryClient(client_wrapper=self._client_wrapper)
|
|
1281
|
-
self.memory_blocks = AsyncMemoryBlocksClient(client_wrapper=self._client_wrapper)
|
|
1282
|
-
self.recall_memory = AsyncRecallMemoryClient(client_wrapper=self._client_wrapper)
|
|
1283
|
-
self.archival_memory = AsyncArchivalMemoryClient(client_wrapper=self._client_wrapper)
|
|
1284
|
-
self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
|
|
1285
|
-
|
|
1286
|
-
async def list(
|
|
1287
|
-
self,
|
|
1288
|
-
*,
|
|
1289
|
-
name: typing.Optional[str] = None,
|
|
1290
|
-
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1291
|
-
match_all_tags: typing.Optional[bool] = None,
|
|
1292
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1293
|
-
) -> typing.List[AgentState]:
|
|
1294
|
-
"""
|
|
1295
|
-
List all agents associated with a given user.
|
|
1296
|
-
This endpoint retrieves a list of all agents and their configurations associated with the specified user ID.
|
|
1297
|
-
|
|
1298
|
-
Parameters
|
|
1299
|
-
----------
|
|
1300
|
-
name : typing.Optional[str]
|
|
1301
|
-
Name of the agent
|
|
1302
|
-
|
|
1303
|
-
tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1304
|
-
List of tags to filter agents by
|
|
1305
|
-
|
|
1306
|
-
match_all_tags : typing.Optional[bool]
|
|
1307
|
-
If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
|
|
1308
|
-
|
|
1309
|
-
request_options : typing.Optional[RequestOptions]
|
|
1310
|
-
Request-specific configuration.
|
|
1311
|
-
|
|
1312
|
-
Returns
|
|
1313
|
-
-------
|
|
1314
|
-
typing.List[AgentState]
|
|
1315
|
-
Successful Response
|
|
1316
|
-
|
|
1317
|
-
Examples
|
|
1318
|
-
--------
|
|
1319
|
-
import asyncio
|
|
1320
|
-
|
|
1321
|
-
from letta import AsyncLetta
|
|
1322
|
-
|
|
1323
|
-
client = AsyncLetta(
|
|
1324
|
-
token="YOUR_TOKEN",
|
|
1325
|
-
)
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
async def main() -> None:
|
|
1329
|
-
await client.agents.list()
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
asyncio.run(main())
|
|
1333
|
-
"""
|
|
1334
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1335
|
-
"v1/agents/",
|
|
1336
|
-
method="GET",
|
|
1337
|
-
params={
|
|
1338
|
-
"name": name,
|
|
1339
|
-
"tags": tags,
|
|
1340
|
-
"match_all_tags": match_all_tags,
|
|
1341
|
-
},
|
|
1342
|
-
request_options=request_options,
|
|
1343
|
-
)
|
|
1344
|
-
try:
|
|
1345
|
-
if 200 <= _response.status_code < 300:
|
|
1346
|
-
return typing.cast(
|
|
1347
|
-
typing.List[AgentState],
|
|
1348
|
-
parse_obj_as(
|
|
1349
|
-
type_=typing.List[AgentState], # type: ignore
|
|
1350
|
-
object_=_response.json(),
|
|
1351
|
-
),
|
|
1352
|
-
)
|
|
1353
|
-
if _response.status_code == 422:
|
|
1354
|
-
raise UnprocessableEntityError(
|
|
1355
|
-
typing.cast(
|
|
1356
|
-
HttpValidationError,
|
|
1357
|
-
parse_obj_as(
|
|
1358
|
-
type_=HttpValidationError, # type: ignore
|
|
1359
|
-
object_=_response.json(),
|
|
1360
|
-
),
|
|
1361
|
-
)
|
|
1362
|
-
)
|
|
1363
|
-
_response_json = _response.json()
|
|
1364
|
-
except JSONDecodeError:
|
|
1365
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1366
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1367
|
-
|
|
1368
|
-
async def create(
|
|
1369
|
-
self,
|
|
1370
|
-
*,
|
|
1371
|
-
memory_blocks: typing.Sequence[CreateBlock],
|
|
1372
|
-
name: typing.Optional[str] = OMIT,
|
|
1373
|
-
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1374
|
-
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1375
|
-
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1376
|
-
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1377
|
-
tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
|
|
1378
|
-
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1379
|
-
system: typing.Optional[str] = OMIT,
|
|
1380
|
-
agent_type: typing.Optional[AgentType] = OMIT,
|
|
1381
|
-
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
1382
|
-
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
1383
|
-
initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
|
|
1384
|
-
include_base_tools: typing.Optional[bool] = OMIT,
|
|
1385
|
-
description: typing.Optional[str] = OMIT,
|
|
1386
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
1387
|
-
llm: typing.Optional[str] = OMIT,
|
|
1388
|
-
embedding: typing.Optional[str] = OMIT,
|
|
1389
|
-
context_window_limit: typing.Optional[int] = OMIT,
|
|
1390
|
-
embedding_chunk_size: typing.Optional[int] = OMIT,
|
|
1391
|
-
from_template: typing.Optional[str] = OMIT,
|
|
1392
|
-
project_id: typing.Optional[str] = OMIT,
|
|
1393
|
-
user_id: typing.Optional[str] = OMIT,
|
|
1394
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1395
|
-
) -> AgentState:
|
|
1396
|
-
"""
|
|
1397
|
-
Create a new agent with the specified configuration.
|
|
1398
|
-
|
|
1399
|
-
Parameters
|
|
1400
|
-
----------
|
|
1401
|
-
memory_blocks : typing.Sequence[CreateBlock]
|
|
1402
|
-
The blocks to create in the agent's in-context memory.
|
|
1403
|
-
|
|
1404
|
-
name : typing.Optional[str]
|
|
1405
|
-
The name of the agent.
|
|
1406
|
-
|
|
1407
|
-
tools : typing.Optional[typing.Sequence[str]]
|
|
1408
|
-
The tools used by the agent.
|
|
1409
|
-
|
|
1410
|
-
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
1411
|
-
The ids of the tools used by the agent.
|
|
1412
|
-
|
|
1413
|
-
source_ids : typing.Optional[typing.Sequence[str]]
|
|
1414
|
-
The ids of the sources used by the agent.
|
|
1415
|
-
|
|
1416
|
-
block_ids : typing.Optional[typing.Sequence[str]]
|
|
1417
|
-
The ids of the blocks used by the agent.
|
|
1418
|
-
|
|
1419
|
-
tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
|
|
1420
|
-
The tool rules governing the agent.
|
|
1421
|
-
|
|
1422
|
-
tags : typing.Optional[typing.Sequence[str]]
|
|
1423
|
-
The tags associated with the agent.
|
|
1424
|
-
|
|
1425
|
-
system : typing.Optional[str]
|
|
1426
|
-
The system prompt used by the agent.
|
|
1427
|
-
|
|
1428
|
-
agent_type : typing.Optional[AgentType]
|
|
1429
|
-
The type of agent.
|
|
1430
|
-
|
|
1431
|
-
llm_config : typing.Optional[LlmConfig]
|
|
1432
|
-
The LLM configuration used by the agent.
|
|
1433
|
-
|
|
1434
|
-
embedding_config : typing.Optional[EmbeddingConfig]
|
|
1435
|
-
The embedding configuration used by the agent.
|
|
1436
|
-
|
|
1437
|
-
initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
|
|
1438
|
-
The initial set of messages to put in the agent's in-context memory.
|
|
1439
|
-
|
|
1440
|
-
include_base_tools : typing.Optional[bool]
|
|
1441
|
-
The LLM configuration used by the agent.
|
|
1442
|
-
|
|
1443
|
-
description : typing.Optional[str]
|
|
1444
|
-
The description of the agent.
|
|
1445
|
-
|
|
1446
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1447
|
-
The metadata of the agent.
|
|
1448
|
-
|
|
1449
|
-
llm : typing.Optional[str]
|
|
1450
|
-
The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
|
|
1451
|
-
|
|
1452
|
-
embedding : typing.Optional[str]
|
|
1453
|
-
The embedding configuration handle used by the agent, specified in the format provider/model-name.
|
|
1454
|
-
|
|
1455
|
-
context_window_limit : typing.Optional[int]
|
|
1456
|
-
The context window limit used by the agent.
|
|
1457
|
-
|
|
1458
|
-
embedding_chunk_size : typing.Optional[int]
|
|
1459
|
-
The embedding chunk size used by the agent.
|
|
1460
|
-
|
|
1461
|
-
from_template : typing.Optional[str]
|
|
1462
|
-
The template id used to configure the agent
|
|
1463
|
-
|
|
1464
|
-
project_id : typing.Optional[str]
|
|
1465
|
-
The project id that the agent will be associated with.
|
|
1466
|
-
|
|
1467
|
-
user_id : typing.Optional[str]
|
|
1468
|
-
|
|
1469
|
-
request_options : typing.Optional[RequestOptions]
|
|
1470
|
-
Request-specific configuration.
|
|
1471
|
-
|
|
1472
|
-
Returns
|
|
1473
|
-
-------
|
|
1474
|
-
AgentState
|
|
1475
|
-
Successful Response
|
|
1476
|
-
|
|
1477
|
-
Examples
|
|
1478
|
-
--------
|
|
1479
|
-
import asyncio
|
|
1480
|
-
|
|
1481
|
-
from letta import AsyncLetta, CreateBlock
|
|
1482
|
-
|
|
1483
|
-
client = AsyncLetta(
|
|
1484
|
-
token="YOUR_TOKEN",
|
|
1485
|
-
)
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
async def main() -> None:
|
|
1489
|
-
await client.agents.create(
|
|
1490
|
-
memory_blocks=[
|
|
1491
|
-
CreateBlock(
|
|
1492
|
-
value="value",
|
|
1493
|
-
label="label",
|
|
1494
|
-
)
|
|
1495
|
-
],
|
|
1496
|
-
)
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
asyncio.run(main())
|
|
1500
|
-
"""
|
|
1501
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1502
|
-
"v1/agents/",
|
|
1503
|
-
method="POST",
|
|
1504
|
-
json={
|
|
1505
|
-
"name": name,
|
|
1506
|
-
"memory_blocks": convert_and_respect_annotation_metadata(
|
|
1507
|
-
object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
|
|
1508
|
-
),
|
|
1509
|
-
"tools": tools,
|
|
1510
|
-
"tool_ids": tool_ids,
|
|
1511
|
-
"source_ids": source_ids,
|
|
1512
|
-
"block_ids": block_ids,
|
|
1513
|
-
"tool_rules": convert_and_respect_annotation_metadata(
|
|
1514
|
-
object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
|
|
1515
|
-
),
|
|
1516
|
-
"tags": tags,
|
|
1517
|
-
"system": system,
|
|
1518
|
-
"agent_type": agent_type,
|
|
1519
|
-
"llm_config": convert_and_respect_annotation_metadata(
|
|
1520
|
-
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
1521
|
-
),
|
|
1522
|
-
"embedding_config": convert_and_respect_annotation_metadata(
|
|
1523
|
-
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
1524
|
-
),
|
|
1525
|
-
"initial_message_sequence": convert_and_respect_annotation_metadata(
|
|
1526
|
-
object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
|
|
1527
|
-
),
|
|
1528
|
-
"include_base_tools": include_base_tools,
|
|
1529
|
-
"description": description,
|
|
1530
|
-
"metadata_": metadata,
|
|
1531
|
-
"llm": llm,
|
|
1532
|
-
"embedding": embedding,
|
|
1533
|
-
"context_window_limit": context_window_limit,
|
|
1534
|
-
"embedding_chunk_size": embedding_chunk_size,
|
|
1535
|
-
"from_template": from_template,
|
|
1536
|
-
"project_id": project_id,
|
|
1537
|
-
"user_id": user_id,
|
|
1538
|
-
},
|
|
1539
|
-
headers={
|
|
1540
|
-
"content-type": "application/json",
|
|
1541
|
-
},
|
|
1542
|
-
request_options=request_options,
|
|
1543
|
-
omit=OMIT,
|
|
1544
|
-
)
|
|
1545
|
-
try:
|
|
1546
|
-
if 200 <= _response.status_code < 300:
|
|
1547
|
-
return typing.cast(
|
|
1548
|
-
AgentState,
|
|
1549
|
-
parse_obj_as(
|
|
1550
|
-
type_=AgentState, # type: ignore
|
|
1551
|
-
object_=_response.json(),
|
|
1552
|
-
),
|
|
1553
|
-
)
|
|
1554
|
-
if _response.status_code == 422:
|
|
1555
|
-
raise UnprocessableEntityError(
|
|
1556
|
-
typing.cast(
|
|
1557
|
-
HttpValidationError,
|
|
1558
|
-
parse_obj_as(
|
|
1559
|
-
type_=HttpValidationError, # type: ignore
|
|
1560
|
-
object_=_response.json(),
|
|
1561
|
-
),
|
|
1562
|
-
)
|
|
1563
|
-
)
|
|
1564
|
-
_response_json = _response.json()
|
|
1565
|
-
except JSONDecodeError:
|
|
1566
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1567
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1568
|
-
|
|
1569
|
-
async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
|
|
1570
|
-
"""
|
|
1571
|
-
Get the state of the agent.
|
|
1572
|
-
|
|
1573
|
-
Parameters
|
|
1574
|
-
----------
|
|
1575
|
-
agent_id : str
|
|
1576
|
-
|
|
1577
|
-
request_options : typing.Optional[RequestOptions]
|
|
1578
|
-
Request-specific configuration.
|
|
1579
|
-
|
|
1580
|
-
Returns
|
|
1581
|
-
-------
|
|
1582
|
-
AgentState
|
|
1583
|
-
Successful Response
|
|
1584
|
-
|
|
1585
|
-
Examples
|
|
1586
|
-
--------
|
|
1587
|
-
import asyncio
|
|
1588
|
-
|
|
1589
|
-
from letta import AsyncLetta
|
|
1590
|
-
|
|
1591
|
-
client = AsyncLetta(
|
|
1592
|
-
token="YOUR_TOKEN",
|
|
1593
|
-
)
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
async def main() -> None:
|
|
1597
|
-
await client.agents.get(
|
|
1598
|
-
agent_id="agent_id",
|
|
1599
|
-
)
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
asyncio.run(main())
|
|
1603
|
-
"""
|
|
1604
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1605
|
-
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1606
|
-
method="GET",
|
|
1607
|
-
request_options=request_options,
|
|
1608
|
-
)
|
|
1609
|
-
try:
|
|
1610
|
-
if 200 <= _response.status_code < 300:
|
|
1611
|
-
return typing.cast(
|
|
1612
|
-
AgentState,
|
|
1613
|
-
parse_obj_as(
|
|
1614
|
-
type_=AgentState, # type: ignore
|
|
1615
|
-
object_=_response.json(),
|
|
1616
|
-
),
|
|
1617
|
-
)
|
|
1618
|
-
if _response.status_code == 422:
|
|
1619
|
-
raise UnprocessableEntityError(
|
|
1620
|
-
typing.cast(
|
|
1621
|
-
HttpValidationError,
|
|
1622
|
-
parse_obj_as(
|
|
1623
|
-
type_=HttpValidationError, # type: ignore
|
|
1624
|
-
object_=_response.json(),
|
|
1625
|
-
),
|
|
1626
|
-
)
|
|
1627
|
-
)
|
|
1628
|
-
_response_json = _response.json()
|
|
1629
|
-
except JSONDecodeError:
|
|
1630
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1631
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1632
|
-
|
|
1633
|
-
async def delete(
|
|
1634
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1635
|
-
) -> typing.Optional[typing.Any]:
|
|
1636
|
-
"""
|
|
1637
|
-
Delete an agent.
|
|
1638
|
-
|
|
1639
|
-
Parameters
|
|
1640
|
-
----------
|
|
1641
|
-
agent_id : str
|
|
1642
|
-
|
|
1643
|
-
request_options : typing.Optional[RequestOptions]
|
|
1644
|
-
Request-specific configuration.
|
|
1645
|
-
|
|
1646
|
-
Returns
|
|
1647
|
-
-------
|
|
1648
|
-
typing.Optional[typing.Any]
|
|
1649
|
-
Successful Response
|
|
1650
|
-
|
|
1651
|
-
Examples
|
|
1652
|
-
--------
|
|
1653
|
-
import asyncio
|
|
1654
|
-
|
|
1655
|
-
from letta import AsyncLetta
|
|
1656
|
-
|
|
1657
|
-
client = AsyncLetta(
|
|
1658
|
-
token="YOUR_TOKEN",
|
|
1659
|
-
)
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
async def main() -> None:
|
|
1663
|
-
await client.agents.delete(
|
|
1664
|
-
agent_id="agent_id",
|
|
1665
|
-
)
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
asyncio.run(main())
|
|
1669
|
-
"""
|
|
1670
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1671
|
-
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1672
|
-
method="DELETE",
|
|
1673
|
-
request_options=request_options,
|
|
1674
|
-
)
|
|
1675
|
-
try:
|
|
1676
|
-
if 200 <= _response.status_code < 300:
|
|
1677
|
-
return typing.cast(
|
|
1678
|
-
typing.Optional[typing.Any],
|
|
1679
|
-
parse_obj_as(
|
|
1680
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1681
|
-
object_=_response.json(),
|
|
1682
|
-
),
|
|
1683
|
-
)
|
|
1684
|
-
if _response.status_code == 422:
|
|
1685
|
-
raise UnprocessableEntityError(
|
|
1686
|
-
typing.cast(
|
|
1687
|
-
HttpValidationError,
|
|
1688
|
-
parse_obj_as(
|
|
1689
|
-
type_=HttpValidationError, # type: ignore
|
|
1690
|
-
object_=_response.json(),
|
|
1691
|
-
),
|
|
1692
|
-
)
|
|
1693
|
-
)
|
|
1694
|
-
_response_json = _response.json()
|
|
1695
|
-
except JSONDecodeError:
|
|
1696
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1697
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1698
|
-
|
|
1699
|
-
async def update(
|
|
1700
|
-
self,
|
|
1701
|
-
agent_id: str,
|
|
1702
|
-
*,
|
|
1703
|
-
name: typing.Optional[str] = OMIT,
|
|
1704
|
-
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1705
|
-
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1706
|
-
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1707
|
-
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1708
|
-
system: typing.Optional[str] = OMIT,
|
|
1709
|
-
tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
|
|
1710
|
-
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
1711
|
-
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
1712
|
-
message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1713
|
-
description: typing.Optional[str] = OMIT,
|
|
1714
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
1715
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1716
|
-
) -> AgentState:
|
|
1717
|
-
"""
|
|
1718
|
-
Update an exsiting agent
|
|
1719
|
-
|
|
1720
|
-
Parameters
|
|
1721
|
-
----------
|
|
1722
|
-
agent_id : str
|
|
1723
|
-
|
|
1724
|
-
name : typing.Optional[str]
|
|
1725
|
-
The name of the agent.
|
|
1726
|
-
|
|
1727
|
-
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
1728
|
-
The ids of the tools used by the agent.
|
|
1729
|
-
|
|
1730
|
-
source_ids : typing.Optional[typing.Sequence[str]]
|
|
1731
|
-
The ids of the sources used by the agent.
|
|
1732
|
-
|
|
1733
|
-
block_ids : typing.Optional[typing.Sequence[str]]
|
|
1734
|
-
The ids of the blocks used by the agent.
|
|
1735
|
-
|
|
1736
|
-
tags : typing.Optional[typing.Sequence[str]]
|
|
1737
|
-
The tags associated with the agent.
|
|
1738
|
-
|
|
1739
|
-
system : typing.Optional[str]
|
|
1740
|
-
The system prompt used by the agent.
|
|
1741
|
-
|
|
1742
|
-
tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
|
|
1743
|
-
The tool rules governing the agent.
|
|
1744
|
-
|
|
1745
|
-
llm_config : typing.Optional[LlmConfig]
|
|
1746
|
-
The LLM configuration used by the agent.
|
|
1747
|
-
|
|
1748
|
-
embedding_config : typing.Optional[EmbeddingConfig]
|
|
1749
|
-
The embedding configuration used by the agent.
|
|
1750
|
-
|
|
1751
|
-
message_ids : typing.Optional[typing.Sequence[str]]
|
|
1752
|
-
The ids of the messages in the agent's in-context memory.
|
|
1753
|
-
|
|
1754
|
-
description : typing.Optional[str]
|
|
1755
|
-
The description of the agent.
|
|
1756
|
-
|
|
1757
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1758
|
-
The metadata of the agent.
|
|
1759
|
-
|
|
1760
|
-
request_options : typing.Optional[RequestOptions]
|
|
1761
|
-
Request-specific configuration.
|
|
1762
|
-
|
|
1763
|
-
Returns
|
|
1764
|
-
-------
|
|
1765
|
-
AgentState
|
|
1766
|
-
Successful Response
|
|
1767
|
-
|
|
1768
|
-
Examples
|
|
1769
|
-
--------
|
|
1770
|
-
import asyncio
|
|
1771
|
-
|
|
1772
|
-
from letta import AsyncLetta
|
|
1773
|
-
|
|
1774
|
-
client = AsyncLetta(
|
|
1775
|
-
token="YOUR_TOKEN",
|
|
1776
|
-
)
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
async def main() -> None:
|
|
1780
|
-
await client.agents.update(
|
|
1781
|
-
agent_id="agent_id",
|
|
1782
|
-
)
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
asyncio.run(main())
|
|
1786
|
-
"""
|
|
1787
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1788
|
-
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1789
|
-
method="PATCH",
|
|
1790
|
-
json={
|
|
1791
|
-
"name": name,
|
|
1792
|
-
"tool_ids": tool_ids,
|
|
1793
|
-
"source_ids": source_ids,
|
|
1794
|
-
"block_ids": block_ids,
|
|
1795
|
-
"tags": tags,
|
|
1796
|
-
"system": system,
|
|
1797
|
-
"tool_rules": convert_and_respect_annotation_metadata(
|
|
1798
|
-
object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
|
|
1799
|
-
),
|
|
1800
|
-
"llm_config": convert_and_respect_annotation_metadata(
|
|
1801
|
-
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
1802
|
-
),
|
|
1803
|
-
"embedding_config": convert_and_respect_annotation_metadata(
|
|
1804
|
-
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
1805
|
-
),
|
|
1806
|
-
"message_ids": message_ids,
|
|
1807
|
-
"description": description,
|
|
1808
|
-
"metadata_": metadata,
|
|
1809
|
-
},
|
|
1810
|
-
headers={
|
|
1811
|
-
"content-type": "application/json",
|
|
1812
|
-
},
|
|
1813
|
-
request_options=request_options,
|
|
1814
|
-
omit=OMIT,
|
|
1815
|
-
)
|
|
1816
|
-
try:
|
|
1817
|
-
if 200 <= _response.status_code < 300:
|
|
1818
|
-
return typing.cast(
|
|
1819
|
-
AgentState,
|
|
1820
|
-
parse_obj_as(
|
|
1821
|
-
type_=AgentState, # type: ignore
|
|
1822
|
-
object_=_response.json(),
|
|
1823
|
-
),
|
|
1824
|
-
)
|
|
1825
|
-
if _response.status_code == 422:
|
|
1826
|
-
raise UnprocessableEntityError(
|
|
1827
|
-
typing.cast(
|
|
1828
|
-
HttpValidationError,
|
|
1829
|
-
parse_obj_as(
|
|
1830
|
-
type_=HttpValidationError, # type: ignore
|
|
1831
|
-
object_=_response.json(),
|
|
1832
|
-
),
|
|
1833
|
-
)
|
|
1834
|
-
)
|
|
1835
|
-
_response_json = _response.json()
|
|
1836
|
-
except JSONDecodeError:
|
|
1837
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1838
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1839
|
-
|
|
1840
|
-
async def get_agent_memory_block(
|
|
1841
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1842
|
-
) -> Block:
|
|
1843
|
-
"""
|
|
1844
|
-
Retrieve a memory block from an agent.
|
|
1845
|
-
|
|
1846
|
-
Parameters
|
|
1847
|
-
----------
|
|
1848
|
-
agent_id : str
|
|
1849
|
-
|
|
1850
|
-
block_label : str
|
|
1851
|
-
|
|
1852
|
-
request_options : typing.Optional[RequestOptions]
|
|
1853
|
-
Request-specific configuration.
|
|
1854
|
-
|
|
1855
|
-
Returns
|
|
1856
|
-
-------
|
|
1857
|
-
Block
|
|
1858
|
-
Successful Response
|
|
1859
|
-
|
|
1860
|
-
Examples
|
|
1861
|
-
--------
|
|
1862
|
-
import asyncio
|
|
1863
|
-
|
|
1864
|
-
from letta import AsyncLetta
|
|
1865
|
-
|
|
1866
|
-
client = AsyncLetta(
|
|
1867
|
-
token="YOUR_TOKEN",
|
|
1868
|
-
)
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
async def main() -> None:
|
|
1872
|
-
await client.agents.get_agent_memory_block(
|
|
1873
|
-
agent_id="agent_id",
|
|
1874
|
-
block_label="block_label",
|
|
1875
|
-
)
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
asyncio.run(main())
|
|
1879
|
-
"""
|
|
1880
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1881
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
|
|
1882
|
-
method="GET",
|
|
1883
|
-
request_options=request_options,
|
|
1884
|
-
)
|
|
1885
|
-
try:
|
|
1886
|
-
if 200 <= _response.status_code < 300:
|
|
1887
|
-
return typing.cast(
|
|
1888
|
-
Block,
|
|
1889
|
-
parse_obj_as(
|
|
1890
|
-
type_=Block, # type: ignore
|
|
1891
|
-
object_=_response.json(),
|
|
1892
|
-
),
|
|
1893
|
-
)
|
|
1894
|
-
if _response.status_code == 422:
|
|
1895
|
-
raise UnprocessableEntityError(
|
|
1896
|
-
typing.cast(
|
|
1897
|
-
HttpValidationError,
|
|
1898
|
-
parse_obj_as(
|
|
1899
|
-
type_=HttpValidationError, # type: ignore
|
|
1900
|
-
object_=_response.json(),
|
|
1901
|
-
),
|
|
1902
|
-
)
|
|
1903
|
-
)
|
|
1904
|
-
_response_json = _response.json()
|
|
1905
|
-
except JSONDecodeError:
|
|
1906
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1907
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1908
|
-
|
|
1909
|
-
async def update_agent_memory_block_by_label(
|
|
1910
|
-
self,
|
|
1911
|
-
agent_id: str,
|
|
1912
|
-
block_label: str,
|
|
1913
|
-
*,
|
|
1914
|
-
value: typing.Optional[str] = OMIT,
|
|
1915
|
-
limit: typing.Optional[int] = OMIT,
|
|
1916
|
-
name: typing.Optional[str] = OMIT,
|
|
1917
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
1918
|
-
label: typing.Optional[str] = OMIT,
|
|
1919
|
-
description: typing.Optional[str] = OMIT,
|
|
1920
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
1921
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1922
|
-
) -> Block:
|
|
1923
|
-
"""
|
|
1924
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
822
|
+
tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
|
|
823
|
+
The tool rules governing the agent.
|
|
1925
824
|
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
agent_id : str
|
|
825
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
826
|
+
The tags associated with the agent.
|
|
1929
827
|
|
|
1930
|
-
|
|
828
|
+
system : typing.Optional[str]
|
|
829
|
+
The system prompt used by the agent.
|
|
1931
830
|
|
|
1932
|
-
|
|
1933
|
-
|
|
831
|
+
agent_type : typing.Optional[AgentType]
|
|
832
|
+
The type of agent.
|
|
1934
833
|
|
|
1935
|
-
|
|
1936
|
-
|
|
834
|
+
llm_config : typing.Optional[LlmConfig]
|
|
835
|
+
The LLM configuration used by the agent.
|
|
1937
836
|
|
|
1938
|
-
|
|
1939
|
-
|
|
837
|
+
embedding_config : typing.Optional[EmbeddingConfig]
|
|
838
|
+
The embedding configuration used by the agent.
|
|
1940
839
|
|
|
1941
|
-
|
|
1942
|
-
|
|
840
|
+
initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
|
|
841
|
+
The initial set of messages to put in the agent's in-context memory.
|
|
1943
842
|
|
|
1944
|
-
|
|
1945
|
-
|
|
843
|
+
include_base_tools : typing.Optional[bool]
|
|
844
|
+
The LLM configuration used by the agent.
|
|
1946
845
|
|
|
1947
846
|
description : typing.Optional[str]
|
|
1948
|
-
|
|
847
|
+
The description of the agent.
|
|
1949
848
|
|
|
1950
849
|
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
request_options : typing.Optional[RequestOptions]
|
|
1954
|
-
Request-specific configuration.
|
|
1955
|
-
|
|
1956
|
-
Returns
|
|
1957
|
-
-------
|
|
1958
|
-
Block
|
|
1959
|
-
Successful Response
|
|
1960
|
-
|
|
1961
|
-
Examples
|
|
1962
|
-
--------
|
|
1963
|
-
import asyncio
|
|
1964
|
-
|
|
1965
|
-
from letta import AsyncLetta
|
|
1966
|
-
|
|
1967
|
-
client = AsyncLetta(
|
|
1968
|
-
token="YOUR_TOKEN",
|
|
1969
|
-
)
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
async def main() -> None:
|
|
1973
|
-
await client.agents.update_agent_memory_block_by_label(
|
|
1974
|
-
agent_id="agent_id",
|
|
1975
|
-
block_label="block_label",
|
|
1976
|
-
)
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
asyncio.run(main())
|
|
1980
|
-
"""
|
|
1981
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1982
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
|
|
1983
|
-
method="PATCH",
|
|
1984
|
-
json={
|
|
1985
|
-
"value": value,
|
|
1986
|
-
"limit": limit,
|
|
1987
|
-
"name": name,
|
|
1988
|
-
"is_template": is_template,
|
|
1989
|
-
"label": label,
|
|
1990
|
-
"description": description,
|
|
1991
|
-
"metadata_": metadata,
|
|
1992
|
-
},
|
|
1993
|
-
request_options=request_options,
|
|
1994
|
-
omit=OMIT,
|
|
1995
|
-
)
|
|
1996
|
-
try:
|
|
1997
|
-
if 200 <= _response.status_code < 300:
|
|
1998
|
-
return typing.cast(
|
|
1999
|
-
Block,
|
|
2000
|
-
parse_obj_as(
|
|
2001
|
-
type_=Block, # type: ignore
|
|
2002
|
-
object_=_response.json(),
|
|
2003
|
-
),
|
|
2004
|
-
)
|
|
2005
|
-
if _response.status_code == 422:
|
|
2006
|
-
raise UnprocessableEntityError(
|
|
2007
|
-
typing.cast(
|
|
2008
|
-
HttpValidationError,
|
|
2009
|
-
parse_obj_as(
|
|
2010
|
-
type_=HttpValidationError, # type: ignore
|
|
2011
|
-
object_=_response.json(),
|
|
2012
|
-
),
|
|
2013
|
-
)
|
|
2014
|
-
)
|
|
2015
|
-
_response_json = _response.json()
|
|
2016
|
-
except JSONDecodeError:
|
|
2017
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2018
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2019
|
-
|
|
2020
|
-
async def get_agent_memory_blocks(
|
|
2021
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2022
|
-
) -> typing.List[Block]:
|
|
2023
|
-
"""
|
|
2024
|
-
Retrieve the memory blocks of a specific agent.
|
|
2025
|
-
|
|
2026
|
-
Parameters
|
|
2027
|
-
----------
|
|
2028
|
-
agent_id : str
|
|
2029
|
-
|
|
2030
|
-
request_options : typing.Optional[RequestOptions]
|
|
2031
|
-
Request-specific configuration.
|
|
2032
|
-
|
|
2033
|
-
Returns
|
|
2034
|
-
-------
|
|
2035
|
-
typing.List[Block]
|
|
2036
|
-
Successful Response
|
|
2037
|
-
|
|
2038
|
-
Examples
|
|
2039
|
-
--------
|
|
2040
|
-
import asyncio
|
|
2041
|
-
|
|
2042
|
-
from letta import AsyncLetta
|
|
2043
|
-
|
|
2044
|
-
client = AsyncLetta(
|
|
2045
|
-
token="YOUR_TOKEN",
|
|
2046
|
-
)
|
|
2047
|
-
|
|
850
|
+
The metadata of the agent.
|
|
2048
851
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
agent_id="agent_id",
|
|
2052
|
-
)
|
|
852
|
+
llm : typing.Optional[str]
|
|
853
|
+
The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
|
|
2053
854
|
|
|
855
|
+
embedding : typing.Optional[str]
|
|
856
|
+
The embedding configuration handle used by the agent, specified in the format provider/model-name.
|
|
2054
857
|
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
2058
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
|
|
2059
|
-
method="GET",
|
|
2060
|
-
request_options=request_options,
|
|
2061
|
-
)
|
|
2062
|
-
try:
|
|
2063
|
-
if 200 <= _response.status_code < 300:
|
|
2064
|
-
return typing.cast(
|
|
2065
|
-
typing.List[Block],
|
|
2066
|
-
parse_obj_as(
|
|
2067
|
-
type_=typing.List[Block], # type: ignore
|
|
2068
|
-
object_=_response.json(),
|
|
2069
|
-
),
|
|
2070
|
-
)
|
|
2071
|
-
if _response.status_code == 422:
|
|
2072
|
-
raise UnprocessableEntityError(
|
|
2073
|
-
typing.cast(
|
|
2074
|
-
HttpValidationError,
|
|
2075
|
-
parse_obj_as(
|
|
2076
|
-
type_=HttpValidationError, # type: ignore
|
|
2077
|
-
object_=_response.json(),
|
|
2078
|
-
),
|
|
2079
|
-
)
|
|
2080
|
-
)
|
|
2081
|
-
_response_json = _response.json()
|
|
2082
|
-
except JSONDecodeError:
|
|
2083
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2084
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
858
|
+
context_window_limit : typing.Optional[int]
|
|
859
|
+
The context window limit used by the agent.
|
|
2085
860
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
agent_id: str,
|
|
2089
|
-
*,
|
|
2090
|
-
messages: typing.Sequence[MessageCreate],
|
|
2091
|
-
assistant_message_tool_name: typing.Optional[str] = OMIT,
|
|
2092
|
-
assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
|
|
2093
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
2094
|
-
) -> Job:
|
|
2095
|
-
"""
|
|
2096
|
-
Asynchronously process a user message and return a job ID.
|
|
2097
|
-
The actual processing happens in the background, and the status can be checked using the job ID.
|
|
861
|
+
embedding_chunk_size : typing.Optional[int]
|
|
862
|
+
The embedding chunk size used by the agent.
|
|
2098
863
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
agent_id : str
|
|
864
|
+
from_template : typing.Optional[str]
|
|
865
|
+
The template id used to configure the agent
|
|
2102
866
|
|
|
2103
|
-
|
|
2104
|
-
The
|
|
867
|
+
project_id : typing.Optional[str]
|
|
868
|
+
The project id that the agent will be associated with.
|
|
2105
869
|
|
|
2106
|
-
|
|
2107
|
-
The
|
|
870
|
+
tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
871
|
+
The environment variables for tool execution specific to this agent.
|
|
2108
872
|
|
|
2109
|
-
|
|
2110
|
-
The
|
|
873
|
+
variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
874
|
+
The variables that should be set for the agent.
|
|
2111
875
|
|
|
2112
876
|
request_options : typing.Optional[RequestOptions]
|
|
2113
877
|
Request-specific configuration.
|
|
2114
878
|
|
|
2115
879
|
Returns
|
|
2116
880
|
-------
|
|
2117
|
-
|
|
881
|
+
AgentState
|
|
2118
882
|
Successful Response
|
|
2119
883
|
|
|
2120
884
|
Examples
|
|
2121
885
|
--------
|
|
2122
886
|
import asyncio
|
|
2123
887
|
|
|
2124
|
-
from letta import AsyncLetta,
|
|
888
|
+
from letta import AsyncLetta, CreateBlock
|
|
2125
889
|
|
|
2126
890
|
client = AsyncLetta(
|
|
2127
891
|
token="YOUR_TOKEN",
|
|
@@ -2129,12 +893,11 @@ class AsyncAgentsClient:
|
|
|
2129
893
|
|
|
2130
894
|
|
|
2131
895
|
async def main() -> None:
|
|
2132
|
-
await client.agents.
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
text="text",
|
|
896
|
+
await client.agents.create(
|
|
897
|
+
memory_blocks=[
|
|
898
|
+
CreateBlock(
|
|
899
|
+
value="value",
|
|
900
|
+
label="label",
|
|
2138
901
|
)
|
|
2139
902
|
],
|
|
2140
903
|
)
|
|
@@ -2143,104 +906,43 @@ class AsyncAgentsClient:
|
|
|
2143
906
|
asyncio.run(main())
|
|
2144
907
|
"""
|
|
2145
908
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2146
|
-
|
|
909
|
+
"v1/agents/",
|
|
2147
910
|
method="POST",
|
|
2148
911
|
json={
|
|
2149
|
-
"
|
|
2150
|
-
|
|
912
|
+
"name": name,
|
|
913
|
+
"memory_blocks": convert_and_respect_annotation_metadata(
|
|
914
|
+
object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
|
|
2151
915
|
),
|
|
2152
|
-
"
|
|
2153
|
-
"
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
if _response.status_code == 422:
|
|
2168
|
-
raise UnprocessableEntityError(
|
|
2169
|
-
typing.cast(
|
|
2170
|
-
HttpValidationError,
|
|
2171
|
-
parse_obj_as(
|
|
2172
|
-
type_=HttpValidationError, # type: ignore
|
|
2173
|
-
object_=_response.json(),
|
|
2174
|
-
),
|
|
2175
|
-
)
|
|
2176
|
-
)
|
|
2177
|
-
_response_json = _response.json()
|
|
2178
|
-
except JSONDecodeError:
|
|
2179
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2180
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2181
|
-
|
|
2182
|
-
async def searchdeployedagents(
|
|
2183
|
-
self,
|
|
2184
|
-
*,
|
|
2185
|
-
search: typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]] = OMIT,
|
|
2186
|
-
project_id: typing.Optional[str] = OMIT,
|
|
2187
|
-
combinator: typing.Optional[AgentsSearchDeployedAgentsRequestCombinator] = OMIT,
|
|
2188
|
-
limit: typing.Optional[float] = OMIT,
|
|
2189
|
-
offset: typing.Optional[float] = OMIT,
|
|
2190
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
2191
|
-
) -> None:
|
|
2192
|
-
"""
|
|
2193
|
-
Search deployed agents
|
|
2194
|
-
|
|
2195
|
-
Parameters
|
|
2196
|
-
----------
|
|
2197
|
-
search : typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]]
|
|
2198
|
-
|
|
2199
|
-
project_id : typing.Optional[str]
|
|
2200
|
-
|
|
2201
|
-
combinator : typing.Optional[AgentsSearchDeployedAgentsRequestCombinator]
|
|
2202
|
-
|
|
2203
|
-
limit : typing.Optional[float]
|
|
2204
|
-
|
|
2205
|
-
offset : typing.Optional[float]
|
|
2206
|
-
|
|
2207
|
-
request_options : typing.Optional[RequestOptions]
|
|
2208
|
-
Request-specific configuration.
|
|
2209
|
-
|
|
2210
|
-
Returns
|
|
2211
|
-
-------
|
|
2212
|
-
None
|
|
2213
|
-
|
|
2214
|
-
Examples
|
|
2215
|
-
--------
|
|
2216
|
-
import asyncio
|
|
2217
|
-
|
|
2218
|
-
from letta import AsyncLetta
|
|
2219
|
-
|
|
2220
|
-
client = AsyncLetta(
|
|
2221
|
-
token="YOUR_TOKEN",
|
|
2222
|
-
)
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
async def main() -> None:
|
|
2226
|
-
await client.agents.searchdeployedagents()
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
asyncio.run(main())
|
|
2230
|
-
"""
|
|
2231
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
2232
|
-
"v1/agents/search",
|
|
2233
|
-
method="POST",
|
|
2234
|
-
json={
|
|
2235
|
-
"search": convert_and_respect_annotation_metadata(
|
|
2236
|
-
object_=search,
|
|
2237
|
-
annotation=typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem],
|
|
2238
|
-
direction="write",
|
|
916
|
+
"tools": tools,
|
|
917
|
+
"tool_ids": tool_ids,
|
|
918
|
+
"source_ids": source_ids,
|
|
919
|
+
"block_ids": block_ids,
|
|
920
|
+
"tool_rules": convert_and_respect_annotation_metadata(
|
|
921
|
+
object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
|
|
922
|
+
),
|
|
923
|
+
"tags": tags,
|
|
924
|
+
"system": system,
|
|
925
|
+
"agent_type": agent_type,
|
|
926
|
+
"llm_config": convert_and_respect_annotation_metadata(
|
|
927
|
+
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
928
|
+
),
|
|
929
|
+
"embedding_config": convert_and_respect_annotation_metadata(
|
|
930
|
+
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
2239
931
|
),
|
|
932
|
+
"initial_message_sequence": convert_and_respect_annotation_metadata(
|
|
933
|
+
object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
|
|
934
|
+
),
|
|
935
|
+
"include_base_tools": include_base_tools,
|
|
936
|
+
"description": description,
|
|
937
|
+
"metadata_": metadata,
|
|
938
|
+
"llm": llm,
|
|
939
|
+
"embedding": embedding,
|
|
940
|
+
"context_window_limit": context_window_limit,
|
|
941
|
+
"embedding_chunk_size": embedding_chunk_size,
|
|
942
|
+
"from_template": from_template,
|
|
2240
943
|
"project_id": project_id,
|
|
2241
|
-
"
|
|
2242
|
-
"
|
|
2243
|
-
"offset": offset,
|
|
944
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
945
|
+
"variables": variables,
|
|
2244
946
|
},
|
|
2245
947
|
headers={
|
|
2246
948
|
"content-type": "application/json",
|
|
@@ -2250,38 +952,43 @@ class AsyncAgentsClient:
|
|
|
2250
952
|
)
|
|
2251
953
|
try:
|
|
2252
954
|
if 200 <= _response.status_code < 300:
|
|
2253
|
-
return
|
|
955
|
+
return typing.cast(
|
|
956
|
+
AgentState,
|
|
957
|
+
construct_type(
|
|
958
|
+
type_=AgentState, # type: ignore
|
|
959
|
+
object_=_response.json(),
|
|
960
|
+
),
|
|
961
|
+
)
|
|
962
|
+
if _response.status_code == 422:
|
|
963
|
+
raise UnprocessableEntityError(
|
|
964
|
+
typing.cast(
|
|
965
|
+
HttpValidationError,
|
|
966
|
+
construct_type(
|
|
967
|
+
type_=HttpValidationError, # type: ignore
|
|
968
|
+
object_=_response.json(),
|
|
969
|
+
),
|
|
970
|
+
)
|
|
971
|
+
)
|
|
2254
972
|
_response_json = _response.json()
|
|
2255
973
|
except JSONDecodeError:
|
|
2256
974
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2257
975
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2258
976
|
|
|
2259
|
-
async def
|
|
2260
|
-
self,
|
|
2261
|
-
agent_id: str,
|
|
2262
|
-
*,
|
|
2263
|
-
return_agent_state: typing.Optional[bool] = None,
|
|
2264
|
-
migrate_deployed_agents: typing.Optional[bool] = OMIT,
|
|
2265
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
2266
|
-
) -> None:
|
|
977
|
+
async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
|
|
2267
978
|
"""
|
|
2268
|
-
|
|
979
|
+
Get the state of the agent.
|
|
2269
980
|
|
|
2270
981
|
Parameters
|
|
2271
982
|
----------
|
|
2272
983
|
agent_id : str
|
|
2273
|
-
The agent ID of the agent to migrate, if this agent is not a template, it will create a agent template from the agent provided as well
|
|
2274
|
-
|
|
2275
|
-
return_agent_state : typing.Optional[bool]
|
|
2276
|
-
|
|
2277
|
-
migrate_deployed_agents : typing.Optional[bool]
|
|
2278
984
|
|
|
2279
985
|
request_options : typing.Optional[RequestOptions]
|
|
2280
986
|
Request-specific configuration.
|
|
2281
987
|
|
|
2282
988
|
Returns
|
|
2283
989
|
-------
|
|
2284
|
-
|
|
990
|
+
AgentState
|
|
991
|
+
Successful Response
|
|
2285
992
|
|
|
2286
993
|
Examples
|
|
2287
994
|
--------
|
|
@@ -2295,7 +1002,7 @@ class AsyncAgentsClient:
|
|
|
2295
1002
|
|
|
2296
1003
|
|
|
2297
1004
|
async def main() -> None:
|
|
2298
|
-
await client.agents.
|
|
1005
|
+
await client.agents.get(
|
|
2299
1006
|
agent_id="agent_id",
|
|
2300
1007
|
)
|
|
2301
1008
|
|
|
@@ -2303,39 +1010,25 @@ class AsyncAgentsClient:
|
|
|
2303
1010
|
asyncio.run(main())
|
|
2304
1011
|
"""
|
|
2305
1012
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2306
|
-
f"v1/agents/{jsonable_encoder(agent_id)}
|
|
2307
|
-
method="
|
|
2308
|
-
params={
|
|
2309
|
-
"returnAgentState": return_agent_state,
|
|
2310
|
-
},
|
|
2311
|
-
json={
|
|
2312
|
-
"migrate_deployed_agents": migrate_deployed_agents,
|
|
2313
|
-
},
|
|
2314
|
-
headers={
|
|
2315
|
-
"content-type": "application/json",
|
|
2316
|
-
},
|
|
1013
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1014
|
+
method="GET",
|
|
2317
1015
|
request_options=request_options,
|
|
2318
|
-
omit=OMIT,
|
|
2319
1016
|
)
|
|
2320
1017
|
try:
|
|
2321
1018
|
if 200 <= _response.status_code < 300:
|
|
2322
|
-
return
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
2329
|
-
object_=_response.json(),
|
|
2330
|
-
),
|
|
2331
|
-
)
|
|
1019
|
+
return typing.cast(
|
|
1020
|
+
AgentState,
|
|
1021
|
+
construct_type(
|
|
1022
|
+
type_=AgentState, # type: ignore
|
|
1023
|
+
object_=_response.json(),
|
|
1024
|
+
),
|
|
2332
1025
|
)
|
|
2333
|
-
if _response.status_code ==
|
|
2334
|
-
raise
|
|
1026
|
+
if _response.status_code == 422:
|
|
1027
|
+
raise UnprocessableEntityError(
|
|
2335
1028
|
typing.cast(
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
type_=
|
|
1029
|
+
HttpValidationError,
|
|
1030
|
+
construct_type(
|
|
1031
|
+
type_=HttpValidationError, # type: ignore
|
|
2339
1032
|
object_=_response.json(),
|
|
2340
1033
|
),
|
|
2341
1034
|
)
|
|
@@ -2345,36 +1038,23 @@ class AsyncAgentsClient:
|
|
|
2345
1038
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2346
1039
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2347
1040
|
|
|
2348
|
-
async def
|
|
2349
|
-
self,
|
|
2350
|
-
|
|
2351
|
-
*,
|
|
2352
|
-
to_template: str,
|
|
2353
|
-
preserve_core_memories: bool,
|
|
2354
|
-
variables: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
2355
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
2356
|
-
) -> AgentsMigrateResponse:
|
|
1041
|
+
async def delete(
|
|
1042
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1043
|
+
) -> typing.Optional[typing.Any]:
|
|
2357
1044
|
"""
|
|
2358
|
-
|
|
1045
|
+
Delete an agent.
|
|
2359
1046
|
|
|
2360
1047
|
Parameters
|
|
2361
1048
|
----------
|
|
2362
1049
|
agent_id : str
|
|
2363
1050
|
|
|
2364
|
-
to_template : str
|
|
2365
|
-
|
|
2366
|
-
preserve_core_memories : bool
|
|
2367
|
-
|
|
2368
|
-
variables : typing.Optional[typing.Dict[str, str]]
|
|
2369
|
-
If you chose to not preserve core memories, you should provide the new variables for the core memories
|
|
2370
|
-
|
|
2371
1051
|
request_options : typing.Optional[RequestOptions]
|
|
2372
1052
|
Request-specific configuration.
|
|
2373
1053
|
|
|
2374
1054
|
Returns
|
|
2375
1055
|
-------
|
|
2376
|
-
|
|
2377
|
-
|
|
1056
|
+
typing.Optional[typing.Any]
|
|
1057
|
+
Successful Response
|
|
2378
1058
|
|
|
2379
1059
|
Examples
|
|
2380
1060
|
--------
|
|
@@ -2388,64 +1068,33 @@ class AsyncAgentsClient:
|
|
|
2388
1068
|
|
|
2389
1069
|
|
|
2390
1070
|
async def main() -> None:
|
|
2391
|
-
await client.agents.
|
|
1071
|
+
await client.agents.delete(
|
|
2392
1072
|
agent_id="agent_id",
|
|
2393
|
-
to_template="to_template",
|
|
2394
|
-
preserve_core_memories=True,
|
|
2395
1073
|
)
|
|
2396
1074
|
|
|
2397
1075
|
|
|
2398
1076
|
asyncio.run(main())
|
|
2399
1077
|
"""
|
|
2400
1078
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2401
|
-
f"v1/agents/{jsonable_encoder(agent_id)}
|
|
2402
|
-
method="
|
|
2403
|
-
json={
|
|
2404
|
-
"to_template": to_template,
|
|
2405
|
-
"variables": variables,
|
|
2406
|
-
"preserve_core_memories": preserve_core_memories,
|
|
2407
|
-
},
|
|
2408
|
-
headers={
|
|
2409
|
-
"content-type": "application/json",
|
|
2410
|
-
},
|
|
1079
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1080
|
+
method="DELETE",
|
|
2411
1081
|
request_options=request_options,
|
|
2412
|
-
omit=OMIT,
|
|
2413
1082
|
)
|
|
2414
1083
|
try:
|
|
2415
1084
|
if 200 <= _response.status_code < 300:
|
|
2416
1085
|
return typing.cast(
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
type_=
|
|
1086
|
+
typing.Optional[typing.Any],
|
|
1087
|
+
construct_type(
|
|
1088
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2420
1089
|
object_=_response.json(),
|
|
2421
1090
|
),
|
|
2422
1091
|
)
|
|
2423
|
-
if _response.status_code ==
|
|
2424
|
-
raise
|
|
2425
|
-
typing.cast(
|
|
2426
|
-
typing.Optional[typing.Any],
|
|
2427
|
-
parse_obj_as(
|
|
2428
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
2429
|
-
object_=_response.json(),
|
|
2430
|
-
),
|
|
2431
|
-
)
|
|
2432
|
-
)
|
|
2433
|
-
if _response.status_code == 409:
|
|
2434
|
-
raise ConflictError(
|
|
2435
|
-
typing.cast(
|
|
2436
|
-
ConflictErrorBody,
|
|
2437
|
-
parse_obj_as(
|
|
2438
|
-
type_=ConflictErrorBody, # type: ignore
|
|
2439
|
-
object_=_response.json(),
|
|
2440
|
-
),
|
|
2441
|
-
)
|
|
2442
|
-
)
|
|
2443
|
-
if _response.status_code == 500:
|
|
2444
|
-
raise InternalServerError(
|
|
1092
|
+
if _response.status_code == 422:
|
|
1093
|
+
raise UnprocessableEntityError(
|
|
2445
1094
|
typing.cast(
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
type_=
|
|
1095
|
+
HttpValidationError,
|
|
1096
|
+
construct_type(
|
|
1097
|
+
type_=HttpValidationError, # type: ignore
|
|
2449
1098
|
object_=_response.json(),
|
|
2450
1099
|
),
|
|
2451
1100
|
)
|
|
@@ -2455,28 +1104,78 @@ class AsyncAgentsClient:
|
|
|
2455
1104
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2456
1105
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2457
1106
|
|
|
2458
|
-
async def
|
|
1107
|
+
async def update(
|
|
2459
1108
|
self,
|
|
2460
1109
|
agent_id: str,
|
|
2461
1110
|
*,
|
|
2462
|
-
|
|
1111
|
+
name: typing.Optional[str] = OMIT,
|
|
1112
|
+
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1113
|
+
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1114
|
+
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1115
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1116
|
+
system: typing.Optional[str] = OMIT,
|
|
1117
|
+
tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
|
|
1118
|
+
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
1119
|
+
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
1120
|
+
message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1121
|
+
description: typing.Optional[str] = OMIT,
|
|
1122
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
1123
|
+
tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
|
2463
1124
|
request_options: typing.Optional[RequestOptions] = None,
|
|
2464
|
-
) ->
|
|
1125
|
+
) -> AgentState:
|
|
2465
1126
|
"""
|
|
2466
|
-
|
|
1127
|
+
Update an exsiting agent
|
|
2467
1128
|
|
|
2468
1129
|
Parameters
|
|
2469
1130
|
----------
|
|
2470
1131
|
agent_id : str
|
|
2471
1132
|
|
|
2472
|
-
|
|
1133
|
+
name : typing.Optional[str]
|
|
1134
|
+
The name of the agent.
|
|
1135
|
+
|
|
1136
|
+
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
1137
|
+
The ids of the tools used by the agent.
|
|
1138
|
+
|
|
1139
|
+
source_ids : typing.Optional[typing.Sequence[str]]
|
|
1140
|
+
The ids of the sources used by the agent.
|
|
1141
|
+
|
|
1142
|
+
block_ids : typing.Optional[typing.Sequence[str]]
|
|
1143
|
+
The ids of the blocks used by the agent.
|
|
1144
|
+
|
|
1145
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1146
|
+
The tags associated with the agent.
|
|
1147
|
+
|
|
1148
|
+
system : typing.Optional[str]
|
|
1149
|
+
The system prompt used by the agent.
|
|
1150
|
+
|
|
1151
|
+
tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
|
|
1152
|
+
The tool rules governing the agent.
|
|
1153
|
+
|
|
1154
|
+
llm_config : typing.Optional[LlmConfig]
|
|
1155
|
+
The LLM configuration used by the agent.
|
|
1156
|
+
|
|
1157
|
+
embedding_config : typing.Optional[EmbeddingConfig]
|
|
1158
|
+
The embedding configuration used by the agent.
|
|
1159
|
+
|
|
1160
|
+
message_ids : typing.Optional[typing.Sequence[str]]
|
|
1161
|
+
The ids of the messages in the agent's in-context memory.
|
|
1162
|
+
|
|
1163
|
+
description : typing.Optional[str]
|
|
1164
|
+
The description of the agent.
|
|
1165
|
+
|
|
1166
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1167
|
+
The metadata of the agent.
|
|
1168
|
+
|
|
1169
|
+
tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
1170
|
+
The environment variables for tool execution specific to this agent.
|
|
2473
1171
|
|
|
2474
1172
|
request_options : typing.Optional[RequestOptions]
|
|
2475
1173
|
Request-specific configuration.
|
|
2476
1174
|
|
|
2477
1175
|
Returns
|
|
2478
1176
|
-------
|
|
2479
|
-
|
|
1177
|
+
AgentState
|
|
1178
|
+
Successful Response
|
|
2480
1179
|
|
|
2481
1180
|
Examples
|
|
2482
1181
|
--------
|
|
@@ -2490,7 +1189,7 @@ class AsyncAgentsClient:
|
|
|
2490
1189
|
|
|
2491
1190
|
|
|
2492
1191
|
async def main() -> None:
|
|
2493
|
-
await client.agents.
|
|
1192
|
+
await client.agents.update(
|
|
2494
1193
|
agent_id="agent_id",
|
|
2495
1194
|
)
|
|
2496
1195
|
|
|
@@ -2498,10 +1197,28 @@ class AsyncAgentsClient:
|
|
|
2498
1197
|
asyncio.run(main())
|
|
2499
1198
|
"""
|
|
2500
1199
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2501
|
-
f"v1/agents/{jsonable_encoder(agent_id)}
|
|
2502
|
-
method="
|
|
1200
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1201
|
+
method="PATCH",
|
|
2503
1202
|
json={
|
|
2504
|
-
"
|
|
1203
|
+
"name": name,
|
|
1204
|
+
"tool_ids": tool_ids,
|
|
1205
|
+
"source_ids": source_ids,
|
|
1206
|
+
"block_ids": block_ids,
|
|
1207
|
+
"tags": tags,
|
|
1208
|
+
"system": system,
|
|
1209
|
+
"tool_rules": convert_and_respect_annotation_metadata(
|
|
1210
|
+
object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
|
|
1211
|
+
),
|
|
1212
|
+
"llm_config": convert_and_respect_annotation_metadata(
|
|
1213
|
+
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
1214
|
+
),
|
|
1215
|
+
"embedding_config": convert_and_respect_annotation_metadata(
|
|
1216
|
+
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
1217
|
+
),
|
|
1218
|
+
"message_ids": message_ids,
|
|
1219
|
+
"description": description,
|
|
1220
|
+
"metadata_": metadata,
|
|
1221
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
2505
1222
|
},
|
|
2506
1223
|
headers={
|
|
2507
1224
|
"content-type": "application/json",
|
|
@@ -2511,23 +1228,19 @@ class AsyncAgentsClient:
|
|
|
2511
1228
|
)
|
|
2512
1229
|
try:
|
|
2513
1230
|
if 200 <= _response.status_code < 300:
|
|
2514
|
-
return
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
2521
|
-
object_=_response.json(),
|
|
2522
|
-
),
|
|
2523
|
-
)
|
|
1231
|
+
return typing.cast(
|
|
1232
|
+
AgentState,
|
|
1233
|
+
construct_type(
|
|
1234
|
+
type_=AgentState, # type: ignore
|
|
1235
|
+
object_=_response.json(),
|
|
1236
|
+
),
|
|
2524
1237
|
)
|
|
2525
|
-
if _response.status_code ==
|
|
2526
|
-
raise
|
|
1238
|
+
if _response.status_code == 422:
|
|
1239
|
+
raise UnprocessableEntityError(
|
|
2527
1240
|
typing.cast(
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
type_=
|
|
1241
|
+
HttpValidationError,
|
|
1242
|
+
construct_type(
|
|
1243
|
+
type_=HttpValidationError, # type: ignore
|
|
2531
1244
|
object_=_response.json(),
|
|
2532
1245
|
),
|
|
2533
1246
|
)
|
|
@@ -2537,23 +1250,39 @@ class AsyncAgentsClient:
|
|
|
2537
1250
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2538
1251
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2539
1252
|
|
|
2540
|
-
async def
|
|
2541
|
-
self,
|
|
2542
|
-
|
|
1253
|
+
async def search(
|
|
1254
|
+
self,
|
|
1255
|
+
*,
|
|
1256
|
+
search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
|
|
1257
|
+
project_id: typing.Optional[str] = OMIT,
|
|
1258
|
+
combinator: typing.Optional[AgentsSearchRequestCombinator] = OMIT,
|
|
1259
|
+
limit: typing.Optional[float] = OMIT,
|
|
1260
|
+
offset: typing.Optional[float] = OMIT,
|
|
1261
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1262
|
+
) -> None:
|
|
2543
1263
|
"""
|
|
2544
|
-
|
|
1264
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
1265
|
+
|
|
1266
|
+
Search deployed agents.
|
|
2545
1267
|
|
|
2546
1268
|
Parameters
|
|
2547
1269
|
----------
|
|
2548
|
-
|
|
1270
|
+
search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
|
|
1271
|
+
|
|
1272
|
+
project_id : typing.Optional[str]
|
|
1273
|
+
|
|
1274
|
+
combinator : typing.Optional[AgentsSearchRequestCombinator]
|
|
1275
|
+
|
|
1276
|
+
limit : typing.Optional[float]
|
|
1277
|
+
|
|
1278
|
+
offset : typing.Optional[float]
|
|
2549
1279
|
|
|
2550
1280
|
request_options : typing.Optional[RequestOptions]
|
|
2551
1281
|
Request-specific configuration.
|
|
2552
1282
|
|
|
2553
1283
|
Returns
|
|
2554
1284
|
-------
|
|
2555
|
-
|
|
2556
|
-
200
|
|
1285
|
+
None
|
|
2557
1286
|
|
|
2558
1287
|
Examples
|
|
2559
1288
|
--------
|
|
@@ -2567,37 +1296,32 @@ class AsyncAgentsClient:
|
|
|
2567
1296
|
|
|
2568
1297
|
|
|
2569
1298
|
async def main() -> None:
|
|
2570
|
-
await client.agents.
|
|
2571
|
-
agent_id="agent_id",
|
|
2572
|
-
)
|
|
1299
|
+
await client.agents.search()
|
|
2573
1300
|
|
|
2574
1301
|
|
|
2575
1302
|
asyncio.run(main())
|
|
2576
1303
|
"""
|
|
2577
1304
|
_response = await self._client_wrapper.httpx_client.request(
|
|
2578
|
-
|
|
2579
|
-
method="
|
|
1305
|
+
"v1/agents/search",
|
|
1306
|
+
method="POST",
|
|
1307
|
+
json={
|
|
1308
|
+
"search": convert_and_respect_annotation_metadata(
|
|
1309
|
+
object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
|
|
1310
|
+
),
|
|
1311
|
+
"project_id": project_id,
|
|
1312
|
+
"combinator": combinator,
|
|
1313
|
+
"limit": limit,
|
|
1314
|
+
"offset": offset,
|
|
1315
|
+
},
|
|
1316
|
+
headers={
|
|
1317
|
+
"content-type": "application/json",
|
|
1318
|
+
},
|
|
2580
1319
|
request_options=request_options,
|
|
1320
|
+
omit=OMIT,
|
|
2581
1321
|
)
|
|
2582
1322
|
try:
|
|
2583
1323
|
if 200 <= _response.status_code < 300:
|
|
2584
|
-
return
|
|
2585
|
-
AgentsGetAgentVariablesResponse,
|
|
2586
|
-
parse_obj_as(
|
|
2587
|
-
type_=AgentsGetAgentVariablesResponse, # type: ignore
|
|
2588
|
-
object_=_response.json(),
|
|
2589
|
-
),
|
|
2590
|
-
)
|
|
2591
|
-
if _response.status_code == 404:
|
|
2592
|
-
raise NotFoundError(
|
|
2593
|
-
typing.cast(
|
|
2594
|
-
typing.Optional[typing.Any],
|
|
2595
|
-
parse_obj_as(
|
|
2596
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
2597
|
-
object_=_response.json(),
|
|
2598
|
-
),
|
|
2599
|
-
)
|
|
2600
|
-
)
|
|
1324
|
+
return
|
|
2601
1325
|
_response_json = _response.json()
|
|
2602
1326
|
except JSONDecodeError:
|
|
2603
1327
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|