letta-client 0.1.6__py3-none-any.whl → 0.1.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of letta-client might be problematic. Click here for more details.
- {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,578 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ...core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ...core.request_options import RequestOptions
|
|
6
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
7
|
+
from ...errors.not_found_error import NotFoundError
|
|
8
|
+
from ...core.unchecked_base_model import construct_type
|
|
9
|
+
from ...errors.internal_server_error import InternalServerError
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ...core.api_error import ApiError
|
|
12
|
+
from .types.templates_migrate_response import TemplatesMigrateResponse
|
|
13
|
+
from ...errors.conflict_error import ConflictError
|
|
14
|
+
from ...types.conflict_error_body import ConflictErrorBody
|
|
15
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
16
|
+
|
|
17
|
+
# this is used as the default value for optional parameters
|
|
18
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TemplatesClient:
|
|
22
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
|
+
self._client_wrapper = client_wrapper
|
|
24
|
+
|
|
25
|
+
def create_version(
|
|
26
|
+
self,
|
|
27
|
+
agent_id: str,
|
|
28
|
+
*,
|
|
29
|
+
return_agent_state: typing.Optional[bool] = None,
|
|
30
|
+
migrate_deployed_agents: typing.Optional[bool] = OMIT,
|
|
31
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
"""
|
|
34
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
35
|
+
|
|
36
|
+
Creates a new version of the template version of the agent.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
agent_id : str
|
|
41
|
+
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
|
|
42
|
+
|
|
43
|
+
return_agent_state : typing.Optional[bool]
|
|
44
|
+
|
|
45
|
+
migrate_deployed_agents : typing.Optional[bool]
|
|
46
|
+
|
|
47
|
+
request_options : typing.Optional[RequestOptions]
|
|
48
|
+
Request-specific configuration.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
None
|
|
53
|
+
|
|
54
|
+
Examples
|
|
55
|
+
--------
|
|
56
|
+
from letta_client import Letta
|
|
57
|
+
|
|
58
|
+
client = Letta(
|
|
59
|
+
token="YOUR_TOKEN",
|
|
60
|
+
)
|
|
61
|
+
client.agents.templates.create_version(
|
|
62
|
+
agent_id="agent_id",
|
|
63
|
+
)
|
|
64
|
+
"""
|
|
65
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
66
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/version-template",
|
|
67
|
+
method="POST",
|
|
68
|
+
params={
|
|
69
|
+
"returnAgentState": return_agent_state,
|
|
70
|
+
},
|
|
71
|
+
json={
|
|
72
|
+
"migrate_deployed_agents": migrate_deployed_agents,
|
|
73
|
+
},
|
|
74
|
+
headers={
|
|
75
|
+
"content-type": "application/json",
|
|
76
|
+
},
|
|
77
|
+
request_options=request_options,
|
|
78
|
+
omit=OMIT,
|
|
79
|
+
)
|
|
80
|
+
try:
|
|
81
|
+
if 200 <= _response.status_code < 300:
|
|
82
|
+
return
|
|
83
|
+
if _response.status_code == 404:
|
|
84
|
+
raise NotFoundError(
|
|
85
|
+
typing.cast(
|
|
86
|
+
typing.Optional[typing.Any],
|
|
87
|
+
construct_type(
|
|
88
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
89
|
+
object_=_response.json(),
|
|
90
|
+
),
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
if _response.status_code == 500:
|
|
94
|
+
raise InternalServerError(
|
|
95
|
+
typing.cast(
|
|
96
|
+
typing.Optional[typing.Any],
|
|
97
|
+
construct_type(
|
|
98
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
99
|
+
object_=_response.json(),
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
_response_json = _response.json()
|
|
104
|
+
except JSONDecodeError:
|
|
105
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
106
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
107
|
+
|
|
108
|
+
def migrate(
|
|
109
|
+
self,
|
|
110
|
+
agent_id: str,
|
|
111
|
+
*,
|
|
112
|
+
to_template: str,
|
|
113
|
+
preserve_core_memories: bool,
|
|
114
|
+
variables: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
115
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
116
|
+
) -> TemplatesMigrateResponse:
|
|
117
|
+
"""
|
|
118
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
119
|
+
|
|
120
|
+
Migrate an agent to a new versioned agent template.
|
|
121
|
+
|
|
122
|
+
Parameters
|
|
123
|
+
----------
|
|
124
|
+
agent_id : str
|
|
125
|
+
|
|
126
|
+
to_template : str
|
|
127
|
+
|
|
128
|
+
preserve_core_memories : bool
|
|
129
|
+
|
|
130
|
+
variables : typing.Optional[typing.Dict[str, str]]
|
|
131
|
+
If you chose to not preserve core memories, you should provide the new variables for the core memories
|
|
132
|
+
|
|
133
|
+
request_options : typing.Optional[RequestOptions]
|
|
134
|
+
Request-specific configuration.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
TemplatesMigrateResponse
|
|
139
|
+
200
|
|
140
|
+
|
|
141
|
+
Examples
|
|
142
|
+
--------
|
|
143
|
+
from letta_client import Letta
|
|
144
|
+
|
|
145
|
+
client = Letta(
|
|
146
|
+
token="YOUR_TOKEN",
|
|
147
|
+
)
|
|
148
|
+
client.agents.templates.migrate(
|
|
149
|
+
agent_id="agent_id",
|
|
150
|
+
to_template="to_template",
|
|
151
|
+
preserve_core_memories=True,
|
|
152
|
+
)
|
|
153
|
+
"""
|
|
154
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
155
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/migrate",
|
|
156
|
+
method="POST",
|
|
157
|
+
json={
|
|
158
|
+
"to_template": to_template,
|
|
159
|
+
"variables": variables,
|
|
160
|
+
"preserve_core_memories": preserve_core_memories,
|
|
161
|
+
},
|
|
162
|
+
headers={
|
|
163
|
+
"content-type": "application/json",
|
|
164
|
+
},
|
|
165
|
+
request_options=request_options,
|
|
166
|
+
omit=OMIT,
|
|
167
|
+
)
|
|
168
|
+
try:
|
|
169
|
+
if 200 <= _response.status_code < 300:
|
|
170
|
+
return typing.cast(
|
|
171
|
+
TemplatesMigrateResponse,
|
|
172
|
+
construct_type(
|
|
173
|
+
type_=TemplatesMigrateResponse, # type: ignore
|
|
174
|
+
object_=_response.json(),
|
|
175
|
+
),
|
|
176
|
+
)
|
|
177
|
+
if _response.status_code == 404:
|
|
178
|
+
raise NotFoundError(
|
|
179
|
+
typing.cast(
|
|
180
|
+
typing.Optional[typing.Any],
|
|
181
|
+
construct_type(
|
|
182
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
183
|
+
object_=_response.json(),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
if _response.status_code == 409:
|
|
188
|
+
raise ConflictError(
|
|
189
|
+
typing.cast(
|
|
190
|
+
ConflictErrorBody,
|
|
191
|
+
construct_type(
|
|
192
|
+
type_=ConflictErrorBody, # type: ignore
|
|
193
|
+
object_=_response.json(),
|
|
194
|
+
),
|
|
195
|
+
)
|
|
196
|
+
)
|
|
197
|
+
if _response.status_code == 500:
|
|
198
|
+
raise InternalServerError(
|
|
199
|
+
typing.cast(
|
|
200
|
+
typing.Optional[typing.Any],
|
|
201
|
+
construct_type(
|
|
202
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
203
|
+
object_=_response.json(),
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
_response_json = _response.json()
|
|
208
|
+
except JSONDecodeError:
|
|
209
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
210
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
211
|
+
|
|
212
|
+
def create(
|
|
213
|
+
self,
|
|
214
|
+
agent_id: str,
|
|
215
|
+
*,
|
|
216
|
+
project_id: typing.Optional[str] = OMIT,
|
|
217
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
218
|
+
) -> None:
|
|
219
|
+
"""
|
|
220
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
221
|
+
|
|
222
|
+
Creates a template from an agent.
|
|
223
|
+
|
|
224
|
+
Parameters
|
|
225
|
+
----------
|
|
226
|
+
agent_id : str
|
|
227
|
+
|
|
228
|
+
project_id : typing.Optional[str]
|
|
229
|
+
|
|
230
|
+
request_options : typing.Optional[RequestOptions]
|
|
231
|
+
Request-specific configuration.
|
|
232
|
+
|
|
233
|
+
Returns
|
|
234
|
+
-------
|
|
235
|
+
None
|
|
236
|
+
|
|
237
|
+
Examples
|
|
238
|
+
--------
|
|
239
|
+
from letta_client import Letta
|
|
240
|
+
|
|
241
|
+
client = Letta(
|
|
242
|
+
token="YOUR_TOKEN",
|
|
243
|
+
)
|
|
244
|
+
client.agents.templates.create(
|
|
245
|
+
agent_id="agent_id",
|
|
246
|
+
)
|
|
247
|
+
"""
|
|
248
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
249
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/template",
|
|
250
|
+
method="POST",
|
|
251
|
+
json={
|
|
252
|
+
"project_id": project_id,
|
|
253
|
+
},
|
|
254
|
+
headers={
|
|
255
|
+
"content-type": "application/json",
|
|
256
|
+
},
|
|
257
|
+
request_options=request_options,
|
|
258
|
+
omit=OMIT,
|
|
259
|
+
)
|
|
260
|
+
try:
|
|
261
|
+
if 200 <= _response.status_code < 300:
|
|
262
|
+
return
|
|
263
|
+
if _response.status_code == 404:
|
|
264
|
+
raise NotFoundError(
|
|
265
|
+
typing.cast(
|
|
266
|
+
typing.Optional[typing.Any],
|
|
267
|
+
construct_type(
|
|
268
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
269
|
+
object_=_response.json(),
|
|
270
|
+
),
|
|
271
|
+
)
|
|
272
|
+
)
|
|
273
|
+
if _response.status_code == 500:
|
|
274
|
+
raise InternalServerError(
|
|
275
|
+
typing.cast(
|
|
276
|
+
typing.Optional[typing.Any],
|
|
277
|
+
construct_type(
|
|
278
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
279
|
+
object_=_response.json(),
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
)
|
|
283
|
+
_response_json = _response.json()
|
|
284
|
+
except JSONDecodeError:
|
|
285
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
286
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class AsyncTemplatesClient:
|
|
290
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
291
|
+
self._client_wrapper = client_wrapper
|
|
292
|
+
|
|
293
|
+
async def create_version(
|
|
294
|
+
self,
|
|
295
|
+
agent_id: str,
|
|
296
|
+
*,
|
|
297
|
+
return_agent_state: typing.Optional[bool] = None,
|
|
298
|
+
migrate_deployed_agents: typing.Optional[bool] = OMIT,
|
|
299
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
300
|
+
) -> None:
|
|
301
|
+
"""
|
|
302
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
303
|
+
|
|
304
|
+
Creates a new version of the template version of the agent.
|
|
305
|
+
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
agent_id : str
|
|
309
|
+
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
|
|
310
|
+
|
|
311
|
+
return_agent_state : typing.Optional[bool]
|
|
312
|
+
|
|
313
|
+
migrate_deployed_agents : typing.Optional[bool]
|
|
314
|
+
|
|
315
|
+
request_options : typing.Optional[RequestOptions]
|
|
316
|
+
Request-specific configuration.
|
|
317
|
+
|
|
318
|
+
Returns
|
|
319
|
+
-------
|
|
320
|
+
None
|
|
321
|
+
|
|
322
|
+
Examples
|
|
323
|
+
--------
|
|
324
|
+
import asyncio
|
|
325
|
+
|
|
326
|
+
from letta_client import AsyncLetta
|
|
327
|
+
|
|
328
|
+
client = AsyncLetta(
|
|
329
|
+
token="YOUR_TOKEN",
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
async def main() -> None:
|
|
334
|
+
await client.agents.templates.create_version(
|
|
335
|
+
agent_id="agent_id",
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
asyncio.run(main())
|
|
340
|
+
"""
|
|
341
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
342
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/version-template",
|
|
343
|
+
method="POST",
|
|
344
|
+
params={
|
|
345
|
+
"returnAgentState": return_agent_state,
|
|
346
|
+
},
|
|
347
|
+
json={
|
|
348
|
+
"migrate_deployed_agents": migrate_deployed_agents,
|
|
349
|
+
},
|
|
350
|
+
headers={
|
|
351
|
+
"content-type": "application/json",
|
|
352
|
+
},
|
|
353
|
+
request_options=request_options,
|
|
354
|
+
omit=OMIT,
|
|
355
|
+
)
|
|
356
|
+
try:
|
|
357
|
+
if 200 <= _response.status_code < 300:
|
|
358
|
+
return
|
|
359
|
+
if _response.status_code == 404:
|
|
360
|
+
raise NotFoundError(
|
|
361
|
+
typing.cast(
|
|
362
|
+
typing.Optional[typing.Any],
|
|
363
|
+
construct_type(
|
|
364
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
365
|
+
object_=_response.json(),
|
|
366
|
+
),
|
|
367
|
+
)
|
|
368
|
+
)
|
|
369
|
+
if _response.status_code == 500:
|
|
370
|
+
raise InternalServerError(
|
|
371
|
+
typing.cast(
|
|
372
|
+
typing.Optional[typing.Any],
|
|
373
|
+
construct_type(
|
|
374
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
375
|
+
object_=_response.json(),
|
|
376
|
+
),
|
|
377
|
+
)
|
|
378
|
+
)
|
|
379
|
+
_response_json = _response.json()
|
|
380
|
+
except JSONDecodeError:
|
|
381
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
382
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
383
|
+
|
|
384
|
+
async def migrate(
|
|
385
|
+
self,
|
|
386
|
+
agent_id: str,
|
|
387
|
+
*,
|
|
388
|
+
to_template: str,
|
|
389
|
+
preserve_core_memories: bool,
|
|
390
|
+
variables: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
391
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
392
|
+
) -> TemplatesMigrateResponse:
|
|
393
|
+
"""
|
|
394
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
395
|
+
|
|
396
|
+
Migrate an agent to a new versioned agent template.
|
|
397
|
+
|
|
398
|
+
Parameters
|
|
399
|
+
----------
|
|
400
|
+
agent_id : str
|
|
401
|
+
|
|
402
|
+
to_template : str
|
|
403
|
+
|
|
404
|
+
preserve_core_memories : bool
|
|
405
|
+
|
|
406
|
+
variables : typing.Optional[typing.Dict[str, str]]
|
|
407
|
+
If you chose to not preserve core memories, you should provide the new variables for the core memories
|
|
408
|
+
|
|
409
|
+
request_options : typing.Optional[RequestOptions]
|
|
410
|
+
Request-specific configuration.
|
|
411
|
+
|
|
412
|
+
Returns
|
|
413
|
+
-------
|
|
414
|
+
TemplatesMigrateResponse
|
|
415
|
+
200
|
|
416
|
+
|
|
417
|
+
Examples
|
|
418
|
+
--------
|
|
419
|
+
import asyncio
|
|
420
|
+
|
|
421
|
+
from letta_client import AsyncLetta
|
|
422
|
+
|
|
423
|
+
client = AsyncLetta(
|
|
424
|
+
token="YOUR_TOKEN",
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
async def main() -> None:
|
|
429
|
+
await client.agents.templates.migrate(
|
|
430
|
+
agent_id="agent_id",
|
|
431
|
+
to_template="to_template",
|
|
432
|
+
preserve_core_memories=True,
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
asyncio.run(main())
|
|
437
|
+
"""
|
|
438
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
439
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/migrate",
|
|
440
|
+
method="POST",
|
|
441
|
+
json={
|
|
442
|
+
"to_template": to_template,
|
|
443
|
+
"variables": variables,
|
|
444
|
+
"preserve_core_memories": preserve_core_memories,
|
|
445
|
+
},
|
|
446
|
+
headers={
|
|
447
|
+
"content-type": "application/json",
|
|
448
|
+
},
|
|
449
|
+
request_options=request_options,
|
|
450
|
+
omit=OMIT,
|
|
451
|
+
)
|
|
452
|
+
try:
|
|
453
|
+
if 200 <= _response.status_code < 300:
|
|
454
|
+
return typing.cast(
|
|
455
|
+
TemplatesMigrateResponse,
|
|
456
|
+
construct_type(
|
|
457
|
+
type_=TemplatesMigrateResponse, # type: ignore
|
|
458
|
+
object_=_response.json(),
|
|
459
|
+
),
|
|
460
|
+
)
|
|
461
|
+
if _response.status_code == 404:
|
|
462
|
+
raise NotFoundError(
|
|
463
|
+
typing.cast(
|
|
464
|
+
typing.Optional[typing.Any],
|
|
465
|
+
construct_type(
|
|
466
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
467
|
+
object_=_response.json(),
|
|
468
|
+
),
|
|
469
|
+
)
|
|
470
|
+
)
|
|
471
|
+
if _response.status_code == 409:
|
|
472
|
+
raise ConflictError(
|
|
473
|
+
typing.cast(
|
|
474
|
+
ConflictErrorBody,
|
|
475
|
+
construct_type(
|
|
476
|
+
type_=ConflictErrorBody, # type: ignore
|
|
477
|
+
object_=_response.json(),
|
|
478
|
+
),
|
|
479
|
+
)
|
|
480
|
+
)
|
|
481
|
+
if _response.status_code == 500:
|
|
482
|
+
raise InternalServerError(
|
|
483
|
+
typing.cast(
|
|
484
|
+
typing.Optional[typing.Any],
|
|
485
|
+
construct_type(
|
|
486
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
487
|
+
object_=_response.json(),
|
|
488
|
+
),
|
|
489
|
+
)
|
|
490
|
+
)
|
|
491
|
+
_response_json = _response.json()
|
|
492
|
+
except JSONDecodeError:
|
|
493
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
494
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
495
|
+
|
|
496
|
+
async def create(
|
|
497
|
+
self,
|
|
498
|
+
agent_id: str,
|
|
499
|
+
*,
|
|
500
|
+
project_id: typing.Optional[str] = OMIT,
|
|
501
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
502
|
+
) -> None:
|
|
503
|
+
"""
|
|
504
|
+
<Note>This endpoint is only available on Letta Cloud.</Note>
|
|
505
|
+
|
|
506
|
+
Creates a template from an agent.
|
|
507
|
+
|
|
508
|
+
Parameters
|
|
509
|
+
----------
|
|
510
|
+
agent_id : str
|
|
511
|
+
|
|
512
|
+
project_id : typing.Optional[str]
|
|
513
|
+
|
|
514
|
+
request_options : typing.Optional[RequestOptions]
|
|
515
|
+
Request-specific configuration.
|
|
516
|
+
|
|
517
|
+
Returns
|
|
518
|
+
-------
|
|
519
|
+
None
|
|
520
|
+
|
|
521
|
+
Examples
|
|
522
|
+
--------
|
|
523
|
+
import asyncio
|
|
524
|
+
|
|
525
|
+
from letta_client import AsyncLetta
|
|
526
|
+
|
|
527
|
+
client = AsyncLetta(
|
|
528
|
+
token="YOUR_TOKEN",
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
async def main() -> None:
|
|
533
|
+
await client.agents.templates.create(
|
|
534
|
+
agent_id="agent_id",
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
asyncio.run(main())
|
|
539
|
+
"""
|
|
540
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
541
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/template",
|
|
542
|
+
method="POST",
|
|
543
|
+
json={
|
|
544
|
+
"project_id": project_id,
|
|
545
|
+
},
|
|
546
|
+
headers={
|
|
547
|
+
"content-type": "application/json",
|
|
548
|
+
},
|
|
549
|
+
request_options=request_options,
|
|
550
|
+
omit=OMIT,
|
|
551
|
+
)
|
|
552
|
+
try:
|
|
553
|
+
if 200 <= _response.status_code < 300:
|
|
554
|
+
return
|
|
555
|
+
if _response.status_code == 404:
|
|
556
|
+
raise NotFoundError(
|
|
557
|
+
typing.cast(
|
|
558
|
+
typing.Optional[typing.Any],
|
|
559
|
+
construct_type(
|
|
560
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
561
|
+
object_=_response.json(),
|
|
562
|
+
),
|
|
563
|
+
)
|
|
564
|
+
)
|
|
565
|
+
if _response.status_code == 500:
|
|
566
|
+
raise InternalServerError(
|
|
567
|
+
typing.cast(
|
|
568
|
+
typing.Optional[typing.Any],
|
|
569
|
+
construct_type(
|
|
570
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
571
|
+
object_=_response.json(),
|
|
572
|
+
),
|
|
573
|
+
)
|
|
574
|
+
)
|
|
575
|
+
_response_json = _response.json()
|
|
576
|
+
except JSONDecodeError:
|
|
577
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
578
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
3
|
+
from ....core.unchecked_base_model import UncheckedBaseModel
|
|
4
|
+
from ....core.pydantic_utilities import IS_PYDANTIC_V2
|
|
5
5
|
import typing
|
|
6
6
|
import pydantic
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
class TemplatesMigrateResponse(UncheckedBaseModel):
|
|
10
10
|
success: bool
|
|
11
11
|
|
|
12
12
|
if IS_PYDANTIC_V2:
|