letta-client 0.1.6__py3-none-any.whl → 0.1.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {letta → letta_client}/__init__.py +33 -27
- {letta → letta_client}/agents/__init__.py +40 -29
- {letta → letta_client}/agents/archival_memory/client.py +25 -25
- letta_client/agents/client.py +1328 -0
- {letta → letta_client}/agents/context/client.py +7 -7
- letta_client/agents/core_memory/client.py +1080 -0
- letta_client/agents/memory_variables/__init__.py +5 -0
- {letta/agents/memory → letta_client/agents/memory_variables}/client.py +43 -42
- letta_client/agents/memory_variables/types/__init__.py +5 -0
- letta/agents/types/agents_get_agent_variables_response.py → letta_client/agents/memory_variables/types/memory_variables_get_response.py +3 -3
- {letta → letta_client}/agents/messages/client.py +240 -25
- {letta → letta_client}/agents/messages/types/letta_streaming_response.py +21 -16
- {letta → letta_client}/agents/messages/types/messages_list_response_item.py +19 -14
- {letta → letta_client}/agents/recall_memory/client.py +7 -7
- {letta → letta_client}/agents/sources/client.py +7 -7
- letta_client/agents/templates/__init__.py +5 -0
- letta_client/agents/templates/client.py +578 -0
- letta_client/agents/templates/types/__init__.py +5 -0
- letta/agents/types/agents_migrate_response.py → letta_client/agents/templates/types/templates_migrate_response.py +3 -3
- {letta → letta_client}/agents/tools/client.py +19 -19
- letta_client/agents/types/__init__.py +33 -0
- letta_client/agents/types/agents_search_request_combinator.py +5 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item.py → letta_client/agents/types/agents_search_request_search_item.py +17 -20
- letta/agents/types/agents_search_deployed_agents_request_search_item_name.py → letta_client/agents/types/agents_search_request_search_item_name.py +4 -6
- letta_client/agents/types/agents_search_request_search_item_name_operator.py +5 -0
- letta_client/agents/types/agents_search_request_search_item_order_by.py +22 -0
- letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
- letta_client/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_version.py → letta_client/agents/types/agents_search_request_search_item_version.py +2 -2
- {letta → letta_client}/blocks/client.py +39 -39
- {letta → letta_client}/client.py +10 -2
- {letta → letta_client}/core/__init__.py +4 -0
- {letta → letta_client}/core/client_wrapper.py +1 -1
- letta_client/core/unchecked_base_model.py +305 -0
- {letta → letta_client}/health/client.py +5 -5
- {letta → letta_client}/jobs/client.py +25 -25
- {letta → letta_client}/models/client.py +9 -9
- letta_client/providers/client.py +597 -0
- letta_client/runs/client.py +876 -0
- {letta → letta_client}/sources/client.py +49 -49
- {letta → letta_client}/sources/files/client.py +17 -17
- {letta → letta_client}/sources/passages/client.py +7 -7
- letta_client/tools/__init__.py +2 -0
- {letta → letta_client}/tools/client.py +101 -81
- {letta → letta_client}/types/__init__.py +8 -0
- {letta → letta_client}/types/action_model.py +2 -2
- {letta → letta_client}/types/action_parameters_model.py +2 -2
- {letta → letta_client}/types/action_response_model.py +2 -2
- {letta → letta_client}/types/agent_environment_variable.py +2 -7
- {letta → letta_client}/types/agent_state.py +5 -8
- letta_client/types/agent_type.py +7 -0
- {letta → letta_client}/types/app_auth_scheme.py +2 -2
- {letta → letta_client}/types/app_model.py +2 -2
- {letta → letta_client}/types/archival_memory_summary.py +2 -2
- {letta → letta_client}/types/assistant_file.py +2 -2
- {letta → letta_client}/types/assistant_message_input.py +2 -2
- {letta → letta_client}/types/assistant_message_output.py +2 -2
- {letta → letta_client}/types/auth_request.py +2 -2
- {letta → letta_client}/types/auth_response.py +2 -2
- {letta → letta_client}/types/auth_scheme_field.py +2 -2
- {letta → letta_client}/types/block.py +2 -7
- {letta → letta_client}/types/block_update.py +2 -2
- {letta → letta_client}/types/chat_completion_request.py +2 -2
- {letta → letta_client}/types/chat_completion_response.py +2 -2
- {letta → letta_client}/types/child_tool_rule.py +2 -2
- {letta → letta_client}/types/choice.py +2 -2
- {letta → letta_client}/types/conditional_tool_rule.py +2 -2
- {letta → letta_client}/types/conflict_error_body.py +2 -2
- {letta → letta_client}/types/context_window_overview.py +2 -2
- {letta → letta_client}/types/create_assistant_file_request.py +2 -2
- {letta → letta_client}/types/create_assistant_request.py +2 -2
- {letta → letta_client}/types/create_block.py +2 -2
- {letta → letta_client}/types/delete_assistant_file_response.py +2 -2
- {letta → letta_client}/types/delete_assistant_response.py +2 -2
- {letta → letta_client}/types/e_2_b_sandbox_config.py +2 -2
- {letta → letta_client}/types/embedding_config.py +2 -2
- {letta → letta_client}/types/file_metadata.py +2 -7
- {letta → letta_client}/types/function_call_input.py +2 -2
- {letta → letta_client}/types/function_call_output.py +2 -2
- {letta → letta_client}/types/function_schema.py +2 -2
- {letta → letta_client}/types/health.py +2 -2
- {letta → letta_client}/types/http_validation_error.py +2 -2
- {letta → letta_client}/types/init_tool_rule.py +2 -2
- {letta → letta_client}/types/internal_server_error_body.py +2 -2
- {letta → letta_client}/types/job.py +7 -6
- letta_client/types/job_type.py +5 -0
- {letta → letta_client}/types/letta_request.py +7 -2
- {letta → letta_client}/types/letta_response.py +2 -2
- {letta → letta_client}/types/letta_response_messages_item.py +19 -14
- {letta → letta_client}/types/letta_schemas_letta_message_tool_call.py +2 -2
- {letta → letta_client}/types/letta_schemas_message_message.py +2 -7
- {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
- {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
- {letta → letta_client}/types/letta_schemas_tool_tool.py +9 -8
- {letta → letta_client}/types/letta_usage_statistics.py +2 -2
- {letta → letta_client}/types/llm_config.py +2 -2
- {letta → letta_client}/types/local_sandbox_config.py +2 -2
- {letta → letta_client}/types/log_prob_token.py +2 -2
- {letta → letta_client}/types/memory.py +2 -2
- {letta → letta_client}/types/message_content_log_prob.py +2 -2
- {letta → letta_client}/types/message_create.py +2 -2
- {letta → letta_client}/types/not_found_error_body.py +2 -2
- {letta → letta_client}/types/open_ai_assistant.py +2 -2
- {letta → letta_client}/types/organization.py +2 -2
- {letta → letta_client}/types/organization_create.py +2 -2
- {letta → letta_client}/types/passage.py +2 -7
- letta_client/types/provider.py +38 -0
- {letta → letta_client}/types/reasoning_message.py +2 -2
- {letta → letta_client}/types/recall_memory_summary.py +2 -2
- {letta → letta_client}/types/response_format.py +2 -2
- letta_client/types/run.py +77 -0
- {letta → letta_client}/types/sandbox_config.py +2 -7
- {letta → letta_client}/types/sandbox_config_create.py +2 -2
- {letta → letta_client}/types/sandbox_config_update.py +2 -2
- {letta → letta_client}/types/sandbox_environment_variable.py +2 -7
- {letta → letta_client}/types/sandbox_environment_variable_create.py +2 -2
- {letta → letta_client}/types/sandbox_environment_variable_update.py +2 -2
- {letta → letta_client}/types/source.py +2 -7
- {letta → letta_client}/types/system_message_input.py +2 -2
- {letta → letta_client}/types/system_message_output.py +2 -2
- {letta → letta_client}/types/terminal_tool_rule.py +2 -2
- {letta → letta_client}/types/tool_call_delta.py +2 -2
- {letta → letta_client}/types/tool_call_function_output.py +2 -2
- {letta → letta_client}/types/tool_call_message.py +2 -2
- {letta → letta_client}/types/tool_create.py +2 -2
- {letta → letta_client}/types/tool_function_choice.py +2 -2
- {letta → letta_client}/types/tool_input.py +2 -2
- {letta → letta_client}/types/tool_message.py +2 -2
- {letta → letta_client}/types/tool_return_message.py +2 -2
- letta_client/types/tool_type.py +5 -0
- {letta → letta_client}/types/usage_statistics.py +2 -2
- {letta → letta_client}/types/user.py +2 -7
- {letta → letta_client}/types/user_create.py +2 -7
- {letta → letta_client}/types/user_message_input.py +2 -2
- {letta → letta_client}/types/user_message_output.py +2 -2
- {letta → letta_client}/types/user_update.py +2 -7
- {letta → letta_client}/types/validation_error.py +2 -2
- {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/METADATA +7 -7
- letta_client-0.1.10.dist-info/RECORD +204 -0
- letta/agents/client.py +0 -2644
- 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/__init__.py +0 -47
- letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item_name_operator.py +0 -7
- letta/agents/types/agents_search_deployed_agents_request_search_item_order_by.py +0 -26
- letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_direction.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_value.py +0 -7
- letta/types/agent_type.py +0 -8
- letta_client-0.1.6.dist-info/RECORD +0 -193
- {letta → letta_client}/agents/archival_memory/__init__.py +0 -0
- {letta → letta_client}/agents/context/__init__.py +0 -0
- {letta/agents/memory/messages → letta_client/agents/core_memory}/__init__.py +0 -0
- {letta → letta_client}/agents/messages/__init__.py +0 -0
- {letta → letta_client}/agents/messages/types/__init__.py +0 -0
- {letta → letta_client}/agents/messages/types/messages_list_response.py +0 -0
- {letta/agents/memory_blocks → letta_client/agents/recall_memory}/__init__.py +0 -0
- {letta/agents/recall_memory → letta_client/agents/sources}/__init__.py +0 -0
- {letta/agents/sources → letta_client/agents/tools}/__init__.py +0 -0
- {letta → letta_client}/agents/types/create_agent_request_tool_rules_item.py +0 -0
- {letta → letta_client}/agents/types/update_agent_tool_rules_item.py +0 -0
- {letta/agents/tools → letta_client/blocks}/__init__.py +0 -0
- {letta → letta_client}/core/api_error.py +0 -0
- {letta → letta_client}/core/datetime_utils.py +0 -0
- {letta → letta_client}/core/file.py +0 -0
- {letta → letta_client}/core/http_client.py +0 -0
- {letta → letta_client}/core/jsonable_encoder.py +0 -0
- {letta → letta_client}/core/pydantic_utilities.py +0 -0
- {letta → letta_client}/core/query_encoder.py +0 -0
- {letta → letta_client}/core/remove_none_from_dict.py +0 -0
- {letta → letta_client}/core/request_options.py +0 -0
- {letta → letta_client}/core/serialization.py +0 -0
- {letta → letta_client}/environment.py +0 -0
- {letta → letta_client}/errors/__init__.py +0 -0
- {letta → letta_client}/errors/conflict_error.py +0 -0
- {letta → letta_client}/errors/internal_server_error.py +0 -0
- {letta → letta_client}/errors/not_found_error.py +0 -0
- {letta → letta_client}/errors/unprocessable_entity_error.py +0 -0
- {letta/blocks → letta_client/health}/__init__.py +0 -0
- {letta/health → letta_client/jobs}/__init__.py +0 -0
- {letta/jobs → letta_client/models}/__init__.py +0 -0
- {letta/models → letta_client/providers}/__init__.py +0 -0
- {letta → letta_client}/py.typed +0 -0
- {letta/sources/files → letta_client/runs}/__init__.py +0 -0
- {letta → letta_client}/sources/__init__.py +0 -0
- {letta/sources/passages → letta_client/sources/files}/__init__.py +0 -0
- {letta/tools → letta_client/sources/passages}/__init__.py +0 -0
- {letta → letta_client}/types/agent_state_tool_rules_item.py +0 -0
- {letta → letta_client}/types/app_auth_scheme_auth_mode.py +0 -0
- {letta → letta_client}/types/chat_completion_request_function_call.py +0 -0
- {letta → letta_client}/types/chat_completion_request_messages_item.py +0 -0
- {letta → letta_client}/types/chat_completion_request_stop.py +0 -0
- {letta → letta_client}/types/chat_completion_request_tool_choice.py +0 -0
- {letta → letta_client}/types/embedding_config_embedding_endpoint_type.py +0 -0
- {letta → letta_client}/types/job_status.py +0 -0
- {letta → letta_client}/types/llm_config_model_endpoint_type.py +0 -0
- {letta → letta_client}/types/message_create_role.py +0 -0
- {letta → letta_client}/types/message_role.py +0 -0
- {letta → letta_client}/types/not_found_error_body_message.py +0 -0
- {letta → letta_client}/types/sandbox_config_create_config.py +0 -0
- {letta → letta_client}/types/sandbox_config_update_config.py +0 -0
- {letta → letta_client}/types/sandbox_type.py +0 -0
- {letta → letta_client}/types/tool_call_message_tool_call.py +0 -0
- {letta → letta_client}/types/tool_return_message_status.py +0 -0
- {letta → letta_client}/types/tool_rule_type.py +0 -0
- {letta → letta_client}/types/user_message_input_content.py +0 -0
- {letta → letta_client}/types/validation_error_loc_item.py +0 -0
- {letta → letta_client}/version.py +0 -0
- {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1328 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from .context.client import ContextClient
|
|
6
|
+
from .tools.client import ToolsClient
|
|
7
|
+
from .sources.client import SourcesClient
|
|
8
|
+
from .core_memory.client import CoreMemoryClient
|
|
9
|
+
from .recall_memory.client import RecallMemoryClient
|
|
10
|
+
from .archival_memory.client import ArchivalMemoryClient
|
|
11
|
+
from .messages.client import MessagesClient
|
|
12
|
+
from .templates.client import TemplatesClient
|
|
13
|
+
from .memory_variables.client import MemoryVariablesClient
|
|
14
|
+
from ..core.request_options import RequestOptions
|
|
15
|
+
from ..types.agent_state import AgentState
|
|
16
|
+
from ..core.unchecked_base_model import construct_type
|
|
17
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
18
|
+
from ..types.http_validation_error import HttpValidationError
|
|
19
|
+
from json.decoder import JSONDecodeError
|
|
20
|
+
from ..core.api_error import ApiError
|
|
21
|
+
from ..types.create_block import CreateBlock
|
|
22
|
+
from .types.create_agent_request_tool_rules_item import CreateAgentRequestToolRulesItem
|
|
23
|
+
from ..types.agent_type import AgentType
|
|
24
|
+
from ..types.llm_config import LlmConfig
|
|
25
|
+
from ..types.embedding_config import EmbeddingConfig
|
|
26
|
+
from ..types.message_create import MessageCreate
|
|
27
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
28
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
29
|
+
from .types.update_agent_tool_rules_item import UpdateAgentToolRulesItem
|
|
30
|
+
from .types.agents_search_request_search_item import AgentsSearchRequestSearchItem
|
|
31
|
+
from .types.agents_search_request_combinator import AgentsSearchRequestCombinator
|
|
32
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
33
|
+
from .context.client import AsyncContextClient
|
|
34
|
+
from .tools.client import AsyncToolsClient
|
|
35
|
+
from .sources.client import AsyncSourcesClient
|
|
36
|
+
from .core_memory.client import AsyncCoreMemoryClient
|
|
37
|
+
from .recall_memory.client import AsyncRecallMemoryClient
|
|
38
|
+
from .archival_memory.client import AsyncArchivalMemoryClient
|
|
39
|
+
from .messages.client import AsyncMessagesClient
|
|
40
|
+
from .templates.client import AsyncTemplatesClient
|
|
41
|
+
from .memory_variables.client import AsyncMemoryVariablesClient
|
|
42
|
+
|
|
43
|
+
# this is used as the default value for optional parameters
|
|
44
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class AgentsClient:
|
|
48
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
49
|
+
self._client_wrapper = client_wrapper
|
|
50
|
+
self.context = ContextClient(client_wrapper=self._client_wrapper)
|
|
51
|
+
self.tools = ToolsClient(client_wrapper=self._client_wrapper)
|
|
52
|
+
self.sources = SourcesClient(client_wrapper=self._client_wrapper)
|
|
53
|
+
self.core_memory = CoreMemoryClient(client_wrapper=self._client_wrapper)
|
|
54
|
+
self.recall_memory = RecallMemoryClient(client_wrapper=self._client_wrapper)
|
|
55
|
+
self.archival_memory = ArchivalMemoryClient(client_wrapper=self._client_wrapper)
|
|
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)
|
|
59
|
+
|
|
60
|
+
def list(
|
|
61
|
+
self,
|
|
62
|
+
*,
|
|
63
|
+
name: typing.Optional[str] = None,
|
|
64
|
+
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
65
|
+
match_all_tags: typing.Optional[bool] = None,
|
|
66
|
+
cursor: typing.Optional[int] = None,
|
|
67
|
+
limit: typing.Optional[int] = None,
|
|
68
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
69
|
+
) -> typing.List[AgentState]:
|
|
70
|
+
"""
|
|
71
|
+
List all agents associated with a given user.
|
|
72
|
+
This endpoint retrieves a list of all agents and their configurations associated with the specified user ID.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
name : typing.Optional[str]
|
|
77
|
+
Name of the agent
|
|
78
|
+
|
|
79
|
+
tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
80
|
+
List of tags to filter agents by
|
|
81
|
+
|
|
82
|
+
match_all_tags : typing.Optional[bool]
|
|
83
|
+
If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
|
|
84
|
+
|
|
85
|
+
cursor : typing.Optional[int]
|
|
86
|
+
Cursor for pagination
|
|
87
|
+
|
|
88
|
+
limit : typing.Optional[int]
|
|
89
|
+
Limit for pagination
|
|
90
|
+
|
|
91
|
+
request_options : typing.Optional[RequestOptions]
|
|
92
|
+
Request-specific configuration.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
typing.List[AgentState]
|
|
97
|
+
Successful Response
|
|
98
|
+
|
|
99
|
+
Examples
|
|
100
|
+
--------
|
|
101
|
+
from letta_client import Letta
|
|
102
|
+
|
|
103
|
+
client = Letta(
|
|
104
|
+
token="YOUR_TOKEN",
|
|
105
|
+
)
|
|
106
|
+
client.agents.list()
|
|
107
|
+
"""
|
|
108
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
109
|
+
"v1/agents/",
|
|
110
|
+
method="GET",
|
|
111
|
+
params={
|
|
112
|
+
"name": name,
|
|
113
|
+
"tags": tags,
|
|
114
|
+
"match_all_tags": match_all_tags,
|
|
115
|
+
"cursor": cursor,
|
|
116
|
+
"limit": limit,
|
|
117
|
+
},
|
|
118
|
+
request_options=request_options,
|
|
119
|
+
)
|
|
120
|
+
try:
|
|
121
|
+
if 200 <= _response.status_code < 300:
|
|
122
|
+
return typing.cast(
|
|
123
|
+
typing.List[AgentState],
|
|
124
|
+
construct_type(
|
|
125
|
+
type_=typing.List[AgentState], # type: ignore
|
|
126
|
+
object_=_response.json(),
|
|
127
|
+
),
|
|
128
|
+
)
|
|
129
|
+
if _response.status_code == 422:
|
|
130
|
+
raise UnprocessableEntityError(
|
|
131
|
+
typing.cast(
|
|
132
|
+
HttpValidationError,
|
|
133
|
+
construct_type(
|
|
134
|
+
type_=HttpValidationError, # type: ignore
|
|
135
|
+
object_=_response.json(),
|
|
136
|
+
),
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
_response_json = _response.json()
|
|
140
|
+
except JSONDecodeError:
|
|
141
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
142
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
143
|
+
|
|
144
|
+
def create(
|
|
145
|
+
self,
|
|
146
|
+
*,
|
|
147
|
+
memory_blocks: typing.Sequence[CreateBlock],
|
|
148
|
+
name: typing.Optional[str] = OMIT,
|
|
149
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
150
|
+
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
151
|
+
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
152
|
+
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
153
|
+
tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
|
|
154
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
155
|
+
system: typing.Optional[str] = OMIT,
|
|
156
|
+
agent_type: typing.Optional[AgentType] = OMIT,
|
|
157
|
+
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
158
|
+
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
159
|
+
initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
|
|
160
|
+
include_base_tools: typing.Optional[bool] = OMIT,
|
|
161
|
+
description: typing.Optional[str] = OMIT,
|
|
162
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
163
|
+
llm: typing.Optional[str] = OMIT,
|
|
164
|
+
embedding: typing.Optional[str] = OMIT,
|
|
165
|
+
context_window_limit: typing.Optional[int] = OMIT,
|
|
166
|
+
embedding_chunk_size: typing.Optional[int] = OMIT,
|
|
167
|
+
from_template: typing.Optional[str] = OMIT,
|
|
168
|
+
project_id: typing.Optional[str] = OMIT,
|
|
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,
|
|
171
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
172
|
+
) -> AgentState:
|
|
173
|
+
"""
|
|
174
|
+
Create a new agent with the specified configuration.
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
memory_blocks : typing.Sequence[CreateBlock]
|
|
179
|
+
The blocks to create in the agent's in-context memory.
|
|
180
|
+
|
|
181
|
+
name : typing.Optional[str]
|
|
182
|
+
The name of the agent.
|
|
183
|
+
|
|
184
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
185
|
+
The tools used by the agent.
|
|
186
|
+
|
|
187
|
+
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
188
|
+
The ids of the tools used by the agent.
|
|
189
|
+
|
|
190
|
+
source_ids : typing.Optional[typing.Sequence[str]]
|
|
191
|
+
The ids of the sources used by the agent.
|
|
192
|
+
|
|
193
|
+
block_ids : typing.Optional[typing.Sequence[str]]
|
|
194
|
+
The ids of the blocks used by the agent.
|
|
195
|
+
|
|
196
|
+
tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
|
|
197
|
+
The tool rules governing the agent.
|
|
198
|
+
|
|
199
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
200
|
+
The tags associated with the agent.
|
|
201
|
+
|
|
202
|
+
system : typing.Optional[str]
|
|
203
|
+
The system prompt used by the agent.
|
|
204
|
+
|
|
205
|
+
agent_type : typing.Optional[AgentType]
|
|
206
|
+
The type of agent.
|
|
207
|
+
|
|
208
|
+
llm_config : typing.Optional[LlmConfig]
|
|
209
|
+
The LLM configuration used by the agent.
|
|
210
|
+
|
|
211
|
+
embedding_config : typing.Optional[EmbeddingConfig]
|
|
212
|
+
The embedding configuration used by the agent.
|
|
213
|
+
|
|
214
|
+
initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
|
|
215
|
+
The initial set of messages to put in the agent's in-context memory.
|
|
216
|
+
|
|
217
|
+
include_base_tools : typing.Optional[bool]
|
|
218
|
+
The LLM configuration used by the agent.
|
|
219
|
+
|
|
220
|
+
description : typing.Optional[str]
|
|
221
|
+
The description of the agent.
|
|
222
|
+
|
|
223
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
224
|
+
The metadata of the agent.
|
|
225
|
+
|
|
226
|
+
llm : typing.Optional[str]
|
|
227
|
+
The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
|
|
228
|
+
|
|
229
|
+
embedding : typing.Optional[str]
|
|
230
|
+
The embedding configuration handle used by the agent, specified in the format provider/model-name.
|
|
231
|
+
|
|
232
|
+
context_window_limit : typing.Optional[int]
|
|
233
|
+
The context window limit used by the agent.
|
|
234
|
+
|
|
235
|
+
embedding_chunk_size : typing.Optional[int]
|
|
236
|
+
The embedding chunk size used by the agent.
|
|
237
|
+
|
|
238
|
+
from_template : typing.Optional[str]
|
|
239
|
+
The template id used to configure the agent
|
|
240
|
+
|
|
241
|
+
project_id : typing.Optional[str]
|
|
242
|
+
The project id that the agent will be associated with.
|
|
243
|
+
|
|
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.
|
|
249
|
+
|
|
250
|
+
request_options : typing.Optional[RequestOptions]
|
|
251
|
+
Request-specific configuration.
|
|
252
|
+
|
|
253
|
+
Returns
|
|
254
|
+
-------
|
|
255
|
+
AgentState
|
|
256
|
+
Successful Response
|
|
257
|
+
|
|
258
|
+
Examples
|
|
259
|
+
--------
|
|
260
|
+
from letta_client import CreateBlock, Letta
|
|
261
|
+
|
|
262
|
+
client = Letta(
|
|
263
|
+
token="YOUR_TOKEN",
|
|
264
|
+
)
|
|
265
|
+
client.agents.create(
|
|
266
|
+
memory_blocks=[
|
|
267
|
+
CreateBlock(
|
|
268
|
+
value="value",
|
|
269
|
+
label="label",
|
|
270
|
+
)
|
|
271
|
+
],
|
|
272
|
+
)
|
|
273
|
+
"""
|
|
274
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
275
|
+
"v1/agents/",
|
|
276
|
+
method="POST",
|
|
277
|
+
json={
|
|
278
|
+
"name": name,
|
|
279
|
+
"memory_blocks": convert_and_respect_annotation_metadata(
|
|
280
|
+
object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
|
|
281
|
+
),
|
|
282
|
+
"tools": tools,
|
|
283
|
+
"tool_ids": tool_ids,
|
|
284
|
+
"source_ids": source_ids,
|
|
285
|
+
"block_ids": block_ids,
|
|
286
|
+
"tool_rules": convert_and_respect_annotation_metadata(
|
|
287
|
+
object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
|
|
288
|
+
),
|
|
289
|
+
"tags": tags,
|
|
290
|
+
"system": system,
|
|
291
|
+
"agent_type": agent_type,
|
|
292
|
+
"llm_config": convert_and_respect_annotation_metadata(
|
|
293
|
+
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
294
|
+
),
|
|
295
|
+
"embedding_config": convert_and_respect_annotation_metadata(
|
|
296
|
+
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
297
|
+
),
|
|
298
|
+
"initial_message_sequence": convert_and_respect_annotation_metadata(
|
|
299
|
+
object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
|
|
300
|
+
),
|
|
301
|
+
"include_base_tools": include_base_tools,
|
|
302
|
+
"description": description,
|
|
303
|
+
"metadata_": metadata,
|
|
304
|
+
"llm": llm,
|
|
305
|
+
"embedding": embedding,
|
|
306
|
+
"context_window_limit": context_window_limit,
|
|
307
|
+
"embedding_chunk_size": embedding_chunk_size,
|
|
308
|
+
"from_template": from_template,
|
|
309
|
+
"project_id": project_id,
|
|
310
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
311
|
+
"variables": variables,
|
|
312
|
+
},
|
|
313
|
+
headers={
|
|
314
|
+
"content-type": "application/json",
|
|
315
|
+
},
|
|
316
|
+
request_options=request_options,
|
|
317
|
+
omit=OMIT,
|
|
318
|
+
)
|
|
319
|
+
try:
|
|
320
|
+
if 200 <= _response.status_code < 300:
|
|
321
|
+
return typing.cast(
|
|
322
|
+
AgentState,
|
|
323
|
+
construct_type(
|
|
324
|
+
type_=AgentState, # type: ignore
|
|
325
|
+
object_=_response.json(),
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
if _response.status_code == 422:
|
|
329
|
+
raise UnprocessableEntityError(
|
|
330
|
+
typing.cast(
|
|
331
|
+
HttpValidationError,
|
|
332
|
+
construct_type(
|
|
333
|
+
type_=HttpValidationError, # type: ignore
|
|
334
|
+
object_=_response.json(),
|
|
335
|
+
),
|
|
336
|
+
)
|
|
337
|
+
)
|
|
338
|
+
_response_json = _response.json()
|
|
339
|
+
except JSONDecodeError:
|
|
340
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
341
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
342
|
+
|
|
343
|
+
def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
|
|
344
|
+
"""
|
|
345
|
+
Get the state of the agent.
|
|
346
|
+
|
|
347
|
+
Parameters
|
|
348
|
+
----------
|
|
349
|
+
agent_id : str
|
|
350
|
+
|
|
351
|
+
request_options : typing.Optional[RequestOptions]
|
|
352
|
+
Request-specific configuration.
|
|
353
|
+
|
|
354
|
+
Returns
|
|
355
|
+
-------
|
|
356
|
+
AgentState
|
|
357
|
+
Successful Response
|
|
358
|
+
|
|
359
|
+
Examples
|
|
360
|
+
--------
|
|
361
|
+
from letta_client import Letta
|
|
362
|
+
|
|
363
|
+
client = Letta(
|
|
364
|
+
token="YOUR_TOKEN",
|
|
365
|
+
)
|
|
366
|
+
client.agents.get(
|
|
367
|
+
agent_id="agent_id",
|
|
368
|
+
)
|
|
369
|
+
"""
|
|
370
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
371
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
372
|
+
method="GET",
|
|
373
|
+
request_options=request_options,
|
|
374
|
+
)
|
|
375
|
+
try:
|
|
376
|
+
if 200 <= _response.status_code < 300:
|
|
377
|
+
return typing.cast(
|
|
378
|
+
AgentState,
|
|
379
|
+
construct_type(
|
|
380
|
+
type_=AgentState, # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
if _response.status_code == 422:
|
|
385
|
+
raise UnprocessableEntityError(
|
|
386
|
+
typing.cast(
|
|
387
|
+
HttpValidationError,
|
|
388
|
+
construct_type(
|
|
389
|
+
type_=HttpValidationError, # type: ignore
|
|
390
|
+
object_=_response.json(),
|
|
391
|
+
),
|
|
392
|
+
)
|
|
393
|
+
)
|
|
394
|
+
_response_json = _response.json()
|
|
395
|
+
except JSONDecodeError:
|
|
396
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
397
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
398
|
+
|
|
399
|
+
def delete(
|
|
400
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
401
|
+
) -> typing.Optional[typing.Any]:
|
|
402
|
+
"""
|
|
403
|
+
Delete an agent.
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
----------
|
|
407
|
+
agent_id : str
|
|
408
|
+
|
|
409
|
+
request_options : typing.Optional[RequestOptions]
|
|
410
|
+
Request-specific configuration.
|
|
411
|
+
|
|
412
|
+
Returns
|
|
413
|
+
-------
|
|
414
|
+
typing.Optional[typing.Any]
|
|
415
|
+
Successful Response
|
|
416
|
+
|
|
417
|
+
Examples
|
|
418
|
+
--------
|
|
419
|
+
from letta_client import Letta
|
|
420
|
+
|
|
421
|
+
client = Letta(
|
|
422
|
+
token="YOUR_TOKEN",
|
|
423
|
+
)
|
|
424
|
+
client.agents.delete(
|
|
425
|
+
agent_id="agent_id",
|
|
426
|
+
)
|
|
427
|
+
"""
|
|
428
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
429
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
430
|
+
method="DELETE",
|
|
431
|
+
request_options=request_options,
|
|
432
|
+
)
|
|
433
|
+
try:
|
|
434
|
+
if 200 <= _response.status_code < 300:
|
|
435
|
+
return typing.cast(
|
|
436
|
+
typing.Optional[typing.Any],
|
|
437
|
+
construct_type(
|
|
438
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
439
|
+
object_=_response.json(),
|
|
440
|
+
),
|
|
441
|
+
)
|
|
442
|
+
if _response.status_code == 422:
|
|
443
|
+
raise UnprocessableEntityError(
|
|
444
|
+
typing.cast(
|
|
445
|
+
HttpValidationError,
|
|
446
|
+
construct_type(
|
|
447
|
+
type_=HttpValidationError, # type: ignore
|
|
448
|
+
object_=_response.json(),
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
)
|
|
452
|
+
_response_json = _response.json()
|
|
453
|
+
except JSONDecodeError:
|
|
454
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
455
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
456
|
+
|
|
457
|
+
def update(
|
|
458
|
+
self,
|
|
459
|
+
agent_id: str,
|
|
460
|
+
*,
|
|
461
|
+
name: typing.Optional[str] = OMIT,
|
|
462
|
+
tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
463
|
+
source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
464
|
+
block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
465
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
466
|
+
system: typing.Optional[str] = OMIT,
|
|
467
|
+
tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
|
|
468
|
+
llm_config: typing.Optional[LlmConfig] = OMIT,
|
|
469
|
+
embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
|
|
470
|
+
message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
471
|
+
description: typing.Optional[str] = OMIT,
|
|
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,
|
|
474
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
475
|
+
) -> AgentState:
|
|
476
|
+
"""
|
|
477
|
+
Update an exsiting agent
|
|
478
|
+
|
|
479
|
+
Parameters
|
|
480
|
+
----------
|
|
481
|
+
agent_id : str
|
|
482
|
+
|
|
483
|
+
name : typing.Optional[str]
|
|
484
|
+
The name of the agent.
|
|
485
|
+
|
|
486
|
+
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
487
|
+
The ids of the tools used by the agent.
|
|
488
|
+
|
|
489
|
+
source_ids : typing.Optional[typing.Sequence[str]]
|
|
490
|
+
The ids of the sources used by the agent.
|
|
491
|
+
|
|
492
|
+
block_ids : typing.Optional[typing.Sequence[str]]
|
|
493
|
+
The ids of the blocks used by the agent.
|
|
494
|
+
|
|
495
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
496
|
+
The tags associated with the agent.
|
|
497
|
+
|
|
498
|
+
system : typing.Optional[str]
|
|
499
|
+
The system prompt used by the agent.
|
|
500
|
+
|
|
501
|
+
tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
|
|
502
|
+
The tool rules governing the agent.
|
|
503
|
+
|
|
504
|
+
llm_config : typing.Optional[LlmConfig]
|
|
505
|
+
The LLM configuration used by the agent.
|
|
506
|
+
|
|
507
|
+
embedding_config : typing.Optional[EmbeddingConfig]
|
|
508
|
+
The embedding configuration used by the agent.
|
|
509
|
+
|
|
510
|
+
message_ids : typing.Optional[typing.Sequence[str]]
|
|
511
|
+
The ids of the messages in the agent's in-context memory.
|
|
512
|
+
|
|
513
|
+
description : typing.Optional[str]
|
|
514
|
+
The description of the agent.
|
|
515
|
+
|
|
516
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
517
|
+
The metadata of the agent.
|
|
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
|
+
|
|
522
|
+
request_options : typing.Optional[RequestOptions]
|
|
523
|
+
Request-specific configuration.
|
|
524
|
+
|
|
525
|
+
Returns
|
|
526
|
+
-------
|
|
527
|
+
AgentState
|
|
528
|
+
Successful Response
|
|
529
|
+
|
|
530
|
+
Examples
|
|
531
|
+
--------
|
|
532
|
+
from letta_client import Letta
|
|
533
|
+
|
|
534
|
+
client = Letta(
|
|
535
|
+
token="YOUR_TOKEN",
|
|
536
|
+
)
|
|
537
|
+
client.agents.update(
|
|
538
|
+
agent_id="agent_id",
|
|
539
|
+
)
|
|
540
|
+
"""
|
|
541
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
542
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
543
|
+
method="PATCH",
|
|
544
|
+
json={
|
|
545
|
+
"name": name,
|
|
546
|
+
"tool_ids": tool_ids,
|
|
547
|
+
"source_ids": source_ids,
|
|
548
|
+
"block_ids": block_ids,
|
|
549
|
+
"tags": tags,
|
|
550
|
+
"system": system,
|
|
551
|
+
"tool_rules": convert_and_respect_annotation_metadata(
|
|
552
|
+
object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
|
|
553
|
+
),
|
|
554
|
+
"llm_config": convert_and_respect_annotation_metadata(
|
|
555
|
+
object_=llm_config, annotation=LlmConfig, direction="write"
|
|
556
|
+
),
|
|
557
|
+
"embedding_config": convert_and_respect_annotation_metadata(
|
|
558
|
+
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
559
|
+
),
|
|
560
|
+
"message_ids": message_ids,
|
|
561
|
+
"description": description,
|
|
562
|
+
"metadata_": metadata,
|
|
563
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
564
|
+
},
|
|
565
|
+
headers={
|
|
566
|
+
"content-type": "application/json",
|
|
567
|
+
},
|
|
568
|
+
request_options=request_options,
|
|
569
|
+
omit=OMIT,
|
|
570
|
+
)
|
|
571
|
+
try:
|
|
572
|
+
if 200 <= _response.status_code < 300:
|
|
573
|
+
return typing.cast(
|
|
574
|
+
AgentState,
|
|
575
|
+
construct_type(
|
|
576
|
+
type_=AgentState, # type: ignore
|
|
577
|
+
object_=_response.json(),
|
|
578
|
+
),
|
|
579
|
+
)
|
|
580
|
+
if _response.status_code == 422:
|
|
581
|
+
raise UnprocessableEntityError(
|
|
582
|
+
typing.cast(
|
|
583
|
+
HttpValidationError,
|
|
584
|
+
construct_type(
|
|
585
|
+
type_=HttpValidationError, # type: ignore
|
|
586
|
+
object_=_response.json(),
|
|
587
|
+
),
|
|
588
|
+
)
|
|
589
|
+
)
|
|
590
|
+
_response_json = _response.json()
|
|
591
|
+
except JSONDecodeError:
|
|
592
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
593
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
594
|
+
|
|
595
|
+
def search(
|
|
596
|
+
self,
|
|
597
|
+
*,
|
|
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,
|
|
603
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
604
|
+
) -> None:
|
|
605
|
+
"""
|
|
606
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
607
|
+
|
|
608
|
+
Search deployed agents.
|
|
609
|
+
|
|
610
|
+
Parameters
|
|
611
|
+
----------
|
|
612
|
+
search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
|
|
613
|
+
|
|
614
|
+
project_id : typing.Optional[str]
|
|
615
|
+
|
|
616
|
+
combinator : typing.Optional[AgentsSearchRequestCombinator]
|
|
617
|
+
|
|
618
|
+
limit : typing.Optional[float]
|
|
619
|
+
|
|
620
|
+
offset : typing.Optional[float]
|
|
621
|
+
|
|
622
|
+
request_options : typing.Optional[RequestOptions]
|
|
623
|
+
Request-specific configuration.
|
|
624
|
+
|
|
625
|
+
Returns
|
|
626
|
+
-------
|
|
627
|
+
None
|
|
628
|
+
|
|
629
|
+
Examples
|
|
630
|
+
--------
|
|
631
|
+
from letta_client import Letta
|
|
632
|
+
|
|
633
|
+
client = Letta(
|
|
634
|
+
token="YOUR_TOKEN",
|
|
635
|
+
)
|
|
636
|
+
client.agents.search()
|
|
637
|
+
"""
|
|
638
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
639
|
+
"v1/agents/search",
|
|
640
|
+
method="POST",
|
|
641
|
+
json={
|
|
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,
|
|
647
|
+
"limit": limit,
|
|
648
|
+
"offset": offset,
|
|
649
|
+
},
|
|
650
|
+
headers={
|
|
651
|
+
"content-type": "application/json",
|
|
652
|
+
},
|
|
653
|
+
request_options=request_options,
|
|
654
|
+
omit=OMIT,
|
|
655
|
+
)
|
|
656
|
+
try:
|
|
657
|
+
if 200 <= _response.status_code < 300:
|
|
658
|
+
return
|
|
659
|
+
_response_json = _response.json()
|
|
660
|
+
except JSONDecodeError:
|
|
661
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
662
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
663
|
+
|
|
664
|
+
|
|
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)
|
|
677
|
+
|
|
678
|
+
async def list(
|
|
679
|
+
self,
|
|
680
|
+
*,
|
|
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,
|
|
686
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
687
|
+
) -> typing.List[AgentState]:
|
|
688
|
+
"""
|
|
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.
|
|
691
|
+
|
|
692
|
+
Parameters
|
|
693
|
+
----------
|
|
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
|
|
699
|
+
|
|
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.
|
|
702
|
+
|
|
703
|
+
cursor : typing.Optional[int]
|
|
704
|
+
Cursor for pagination
|
|
705
|
+
|
|
706
|
+
limit : typing.Optional[int]
|
|
707
|
+
Limit for pagination
|
|
708
|
+
|
|
709
|
+
request_options : typing.Optional[RequestOptions]
|
|
710
|
+
Request-specific configuration.
|
|
711
|
+
|
|
712
|
+
Returns
|
|
713
|
+
-------
|
|
714
|
+
typing.List[AgentState]
|
|
715
|
+
Successful Response
|
|
716
|
+
|
|
717
|
+
Examples
|
|
718
|
+
--------
|
|
719
|
+
import asyncio
|
|
720
|
+
|
|
721
|
+
from letta_client import AsyncLetta
|
|
722
|
+
|
|
723
|
+
client = AsyncLetta(
|
|
724
|
+
token="YOUR_TOKEN",
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
async def main() -> None:
|
|
729
|
+
await client.agents.list()
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
asyncio.run(main())
|
|
733
|
+
"""
|
|
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,
|
|
743
|
+
},
|
|
744
|
+
request_options=request_options,
|
|
745
|
+
)
|
|
746
|
+
try:
|
|
747
|
+
if 200 <= _response.status_code < 300:
|
|
748
|
+
return typing.cast(
|
|
749
|
+
typing.List[AgentState],
|
|
750
|
+
construct_type(
|
|
751
|
+
type_=typing.List[AgentState], # type: ignore
|
|
752
|
+
object_=_response.json(),
|
|
753
|
+
),
|
|
754
|
+
)
|
|
755
|
+
if _response.status_code == 422:
|
|
756
|
+
raise UnprocessableEntityError(
|
|
757
|
+
typing.cast(
|
|
758
|
+
HttpValidationError,
|
|
759
|
+
construct_type(
|
|
760
|
+
type_=HttpValidationError, # type: ignore
|
|
761
|
+
object_=_response.json(),
|
|
762
|
+
),
|
|
763
|
+
)
|
|
764
|
+
)
|
|
765
|
+
_response_json = _response.json()
|
|
766
|
+
except JSONDecodeError:
|
|
767
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
768
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
769
|
+
|
|
770
|
+
async def create(
|
|
771
|
+
self,
|
|
772
|
+
*,
|
|
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,
|
|
794
|
+
project_id: typing.Optional[str] = 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,
|
|
797
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
798
|
+
) -> AgentState:
|
|
799
|
+
"""
|
|
800
|
+
Create a new agent with the specified configuration.
|
|
801
|
+
|
|
802
|
+
Parameters
|
|
803
|
+
----------
|
|
804
|
+
memory_blocks : typing.Sequence[CreateBlock]
|
|
805
|
+
The blocks to create in the agent's in-context memory.
|
|
806
|
+
|
|
807
|
+
name : typing.Optional[str]
|
|
808
|
+
The name of the agent.
|
|
809
|
+
|
|
810
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
811
|
+
The tools used by the agent.
|
|
812
|
+
|
|
813
|
+
tool_ids : typing.Optional[typing.Sequence[str]]
|
|
814
|
+
The ids of the tools used by the agent.
|
|
815
|
+
|
|
816
|
+
source_ids : typing.Optional[typing.Sequence[str]]
|
|
817
|
+
The ids of the sources used by the agent.
|
|
818
|
+
|
|
819
|
+
block_ids : typing.Optional[typing.Sequence[str]]
|
|
820
|
+
The ids of the blocks used by the agent.
|
|
821
|
+
|
|
822
|
+
tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
|
|
823
|
+
The tool rules governing the agent.
|
|
824
|
+
|
|
825
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
826
|
+
The tags associated with the agent.
|
|
827
|
+
|
|
828
|
+
system : typing.Optional[str]
|
|
829
|
+
The system prompt used by the agent.
|
|
830
|
+
|
|
831
|
+
agent_type : typing.Optional[AgentType]
|
|
832
|
+
The type of agent.
|
|
833
|
+
|
|
834
|
+
llm_config : typing.Optional[LlmConfig]
|
|
835
|
+
The LLM configuration used by the agent.
|
|
836
|
+
|
|
837
|
+
embedding_config : typing.Optional[EmbeddingConfig]
|
|
838
|
+
The embedding configuration used by the agent.
|
|
839
|
+
|
|
840
|
+
initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
|
|
841
|
+
The initial set of messages to put in the agent's in-context memory.
|
|
842
|
+
|
|
843
|
+
include_base_tools : typing.Optional[bool]
|
|
844
|
+
The LLM configuration used by the agent.
|
|
845
|
+
|
|
846
|
+
description : typing.Optional[str]
|
|
847
|
+
The description of the agent.
|
|
848
|
+
|
|
849
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
850
|
+
The metadata of the agent.
|
|
851
|
+
|
|
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.
|
|
854
|
+
|
|
855
|
+
embedding : typing.Optional[str]
|
|
856
|
+
The embedding configuration handle used by the agent, specified in the format provider/model-name.
|
|
857
|
+
|
|
858
|
+
context_window_limit : typing.Optional[int]
|
|
859
|
+
The context window limit used by the agent.
|
|
860
|
+
|
|
861
|
+
embedding_chunk_size : typing.Optional[int]
|
|
862
|
+
The embedding chunk size used by the agent.
|
|
863
|
+
|
|
864
|
+
from_template : typing.Optional[str]
|
|
865
|
+
The template id used to configure the agent
|
|
866
|
+
|
|
867
|
+
project_id : typing.Optional[str]
|
|
868
|
+
The project id that the agent will be associated with.
|
|
869
|
+
|
|
870
|
+
tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
871
|
+
The environment variables for tool execution specific to this agent.
|
|
872
|
+
|
|
873
|
+
variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
|
874
|
+
The variables that should be set for the agent.
|
|
875
|
+
|
|
876
|
+
request_options : typing.Optional[RequestOptions]
|
|
877
|
+
Request-specific configuration.
|
|
878
|
+
|
|
879
|
+
Returns
|
|
880
|
+
-------
|
|
881
|
+
AgentState
|
|
882
|
+
Successful Response
|
|
883
|
+
|
|
884
|
+
Examples
|
|
885
|
+
--------
|
|
886
|
+
import asyncio
|
|
887
|
+
|
|
888
|
+
from letta_client import AsyncLetta, CreateBlock
|
|
889
|
+
|
|
890
|
+
client = AsyncLetta(
|
|
891
|
+
token="YOUR_TOKEN",
|
|
892
|
+
)
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
async def main() -> None:
|
|
896
|
+
await client.agents.create(
|
|
897
|
+
memory_blocks=[
|
|
898
|
+
CreateBlock(
|
|
899
|
+
value="value",
|
|
900
|
+
label="label",
|
|
901
|
+
)
|
|
902
|
+
],
|
|
903
|
+
)
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
asyncio.run(main())
|
|
907
|
+
"""
|
|
908
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
909
|
+
"v1/agents/",
|
|
910
|
+
method="POST",
|
|
911
|
+
json={
|
|
912
|
+
"name": name,
|
|
913
|
+
"memory_blocks": convert_and_respect_annotation_metadata(
|
|
914
|
+
object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
|
|
915
|
+
),
|
|
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"
|
|
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,
|
|
943
|
+
"project_id": project_id,
|
|
944
|
+
"tool_exec_environment_variables": tool_exec_environment_variables,
|
|
945
|
+
"variables": variables,
|
|
946
|
+
},
|
|
947
|
+
headers={
|
|
948
|
+
"content-type": "application/json",
|
|
949
|
+
},
|
|
950
|
+
request_options=request_options,
|
|
951
|
+
omit=OMIT,
|
|
952
|
+
)
|
|
953
|
+
try:
|
|
954
|
+
if 200 <= _response.status_code < 300:
|
|
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
|
+
)
|
|
972
|
+
_response_json = _response.json()
|
|
973
|
+
except JSONDecodeError:
|
|
974
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
975
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
976
|
+
|
|
977
|
+
async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
|
|
978
|
+
"""
|
|
979
|
+
Get the state of the agent.
|
|
980
|
+
|
|
981
|
+
Parameters
|
|
982
|
+
----------
|
|
983
|
+
agent_id : str
|
|
984
|
+
|
|
985
|
+
request_options : typing.Optional[RequestOptions]
|
|
986
|
+
Request-specific configuration.
|
|
987
|
+
|
|
988
|
+
Returns
|
|
989
|
+
-------
|
|
990
|
+
AgentState
|
|
991
|
+
Successful Response
|
|
992
|
+
|
|
993
|
+
Examples
|
|
994
|
+
--------
|
|
995
|
+
import asyncio
|
|
996
|
+
|
|
997
|
+
from letta_client import AsyncLetta
|
|
998
|
+
|
|
999
|
+
client = AsyncLetta(
|
|
1000
|
+
token="YOUR_TOKEN",
|
|
1001
|
+
)
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
async def main() -> None:
|
|
1005
|
+
await client.agents.get(
|
|
1006
|
+
agent_id="agent_id",
|
|
1007
|
+
)
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
asyncio.run(main())
|
|
1011
|
+
"""
|
|
1012
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1013
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1014
|
+
method="GET",
|
|
1015
|
+
request_options=request_options,
|
|
1016
|
+
)
|
|
1017
|
+
try:
|
|
1018
|
+
if 200 <= _response.status_code < 300:
|
|
1019
|
+
return typing.cast(
|
|
1020
|
+
AgentState,
|
|
1021
|
+
construct_type(
|
|
1022
|
+
type_=AgentState, # type: ignore
|
|
1023
|
+
object_=_response.json(),
|
|
1024
|
+
),
|
|
1025
|
+
)
|
|
1026
|
+
if _response.status_code == 422:
|
|
1027
|
+
raise UnprocessableEntityError(
|
|
1028
|
+
typing.cast(
|
|
1029
|
+
HttpValidationError,
|
|
1030
|
+
construct_type(
|
|
1031
|
+
type_=HttpValidationError, # type: ignore
|
|
1032
|
+
object_=_response.json(),
|
|
1033
|
+
),
|
|
1034
|
+
)
|
|
1035
|
+
)
|
|
1036
|
+
_response_json = _response.json()
|
|
1037
|
+
except JSONDecodeError:
|
|
1038
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1039
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1040
|
+
|
|
1041
|
+
async def delete(
|
|
1042
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1043
|
+
) -> typing.Optional[typing.Any]:
|
|
1044
|
+
"""
|
|
1045
|
+
Delete an agent.
|
|
1046
|
+
|
|
1047
|
+
Parameters
|
|
1048
|
+
----------
|
|
1049
|
+
agent_id : str
|
|
1050
|
+
|
|
1051
|
+
request_options : typing.Optional[RequestOptions]
|
|
1052
|
+
Request-specific configuration.
|
|
1053
|
+
|
|
1054
|
+
Returns
|
|
1055
|
+
-------
|
|
1056
|
+
typing.Optional[typing.Any]
|
|
1057
|
+
Successful Response
|
|
1058
|
+
|
|
1059
|
+
Examples
|
|
1060
|
+
--------
|
|
1061
|
+
import asyncio
|
|
1062
|
+
|
|
1063
|
+
from letta_client import AsyncLetta
|
|
1064
|
+
|
|
1065
|
+
client = AsyncLetta(
|
|
1066
|
+
token="YOUR_TOKEN",
|
|
1067
|
+
)
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
async def main() -> None:
|
|
1071
|
+
await client.agents.delete(
|
|
1072
|
+
agent_id="agent_id",
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
asyncio.run(main())
|
|
1077
|
+
"""
|
|
1078
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1079
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1080
|
+
method="DELETE",
|
|
1081
|
+
request_options=request_options,
|
|
1082
|
+
)
|
|
1083
|
+
try:
|
|
1084
|
+
if 200 <= _response.status_code < 300:
|
|
1085
|
+
return typing.cast(
|
|
1086
|
+
typing.Optional[typing.Any],
|
|
1087
|
+
construct_type(
|
|
1088
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1089
|
+
object_=_response.json(),
|
|
1090
|
+
),
|
|
1091
|
+
)
|
|
1092
|
+
if _response.status_code == 422:
|
|
1093
|
+
raise UnprocessableEntityError(
|
|
1094
|
+
typing.cast(
|
|
1095
|
+
HttpValidationError,
|
|
1096
|
+
construct_type(
|
|
1097
|
+
type_=HttpValidationError, # type: ignore
|
|
1098
|
+
object_=_response.json(),
|
|
1099
|
+
),
|
|
1100
|
+
)
|
|
1101
|
+
)
|
|
1102
|
+
_response_json = _response.json()
|
|
1103
|
+
except JSONDecodeError:
|
|
1104
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1105
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1106
|
+
|
|
1107
|
+
async def update(
|
|
1108
|
+
self,
|
|
1109
|
+
agent_id: str,
|
|
1110
|
+
*,
|
|
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,
|
|
1124
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1125
|
+
) -> AgentState:
|
|
1126
|
+
"""
|
|
1127
|
+
Update an exsiting agent
|
|
1128
|
+
|
|
1129
|
+
Parameters
|
|
1130
|
+
----------
|
|
1131
|
+
agent_id : str
|
|
1132
|
+
|
|
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.
|
|
1171
|
+
|
|
1172
|
+
request_options : typing.Optional[RequestOptions]
|
|
1173
|
+
Request-specific configuration.
|
|
1174
|
+
|
|
1175
|
+
Returns
|
|
1176
|
+
-------
|
|
1177
|
+
AgentState
|
|
1178
|
+
Successful Response
|
|
1179
|
+
|
|
1180
|
+
Examples
|
|
1181
|
+
--------
|
|
1182
|
+
import asyncio
|
|
1183
|
+
|
|
1184
|
+
from letta_client import AsyncLetta
|
|
1185
|
+
|
|
1186
|
+
client = AsyncLetta(
|
|
1187
|
+
token="YOUR_TOKEN",
|
|
1188
|
+
)
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
async def main() -> None:
|
|
1192
|
+
await client.agents.update(
|
|
1193
|
+
agent_id="agent_id",
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
asyncio.run(main())
|
|
1198
|
+
"""
|
|
1199
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1200
|
+
f"v1/agents/{jsonable_encoder(agent_id)}",
|
|
1201
|
+
method="PATCH",
|
|
1202
|
+
json={
|
|
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,
|
|
1222
|
+
},
|
|
1223
|
+
headers={
|
|
1224
|
+
"content-type": "application/json",
|
|
1225
|
+
},
|
|
1226
|
+
request_options=request_options,
|
|
1227
|
+
omit=OMIT,
|
|
1228
|
+
)
|
|
1229
|
+
try:
|
|
1230
|
+
if 200 <= _response.status_code < 300:
|
|
1231
|
+
return typing.cast(
|
|
1232
|
+
AgentState,
|
|
1233
|
+
construct_type(
|
|
1234
|
+
type_=AgentState, # type: ignore
|
|
1235
|
+
object_=_response.json(),
|
|
1236
|
+
),
|
|
1237
|
+
)
|
|
1238
|
+
if _response.status_code == 422:
|
|
1239
|
+
raise UnprocessableEntityError(
|
|
1240
|
+
typing.cast(
|
|
1241
|
+
HttpValidationError,
|
|
1242
|
+
construct_type(
|
|
1243
|
+
type_=HttpValidationError, # type: ignore
|
|
1244
|
+
object_=_response.json(),
|
|
1245
|
+
),
|
|
1246
|
+
)
|
|
1247
|
+
)
|
|
1248
|
+
_response_json = _response.json()
|
|
1249
|
+
except JSONDecodeError:
|
|
1250
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1251
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1252
|
+
|
|
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:
|
|
1263
|
+
"""
|
|
1264
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
1265
|
+
|
|
1266
|
+
Search deployed agents.
|
|
1267
|
+
|
|
1268
|
+
Parameters
|
|
1269
|
+
----------
|
|
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]
|
|
1279
|
+
|
|
1280
|
+
request_options : typing.Optional[RequestOptions]
|
|
1281
|
+
Request-specific configuration.
|
|
1282
|
+
|
|
1283
|
+
Returns
|
|
1284
|
+
-------
|
|
1285
|
+
None
|
|
1286
|
+
|
|
1287
|
+
Examples
|
|
1288
|
+
--------
|
|
1289
|
+
import asyncio
|
|
1290
|
+
|
|
1291
|
+
from letta_client import AsyncLetta
|
|
1292
|
+
|
|
1293
|
+
client = AsyncLetta(
|
|
1294
|
+
token="YOUR_TOKEN",
|
|
1295
|
+
)
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
async def main() -> None:
|
|
1299
|
+
await client.agents.search()
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
asyncio.run(main())
|
|
1303
|
+
"""
|
|
1304
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
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
|
+
},
|
|
1319
|
+
request_options=request_options,
|
|
1320
|
+
omit=OMIT,
|
|
1321
|
+
)
|
|
1322
|
+
try:
|
|
1323
|
+
if 200 <= _response.status_code < 300:
|
|
1324
|
+
return
|
|
1325
|
+
_response_json = _response.json()
|
|
1326
|
+
except JSONDecodeError:
|
|
1327
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1328
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|