letta-client 0.1.0__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- letta/__init__.py +277 -0
- letta/agents/__init__.py +44 -0
- letta/agents/archival_memory/__init__.py +2 -0
- letta/agents/archival_memory/client.py +591 -0
- letta/agents/client.py +2604 -0
- letta/agents/context/__init__.py +2 -0
- letta/agents/context/client.py +145 -0
- letta/agents/memory/__init__.py +5 -0
- letta/agents/memory/client.py +149 -0
- letta/agents/memory/messages/__init__.py +2 -0
- letta/agents/memory/messages/client.py +147 -0
- letta/agents/memory_blocks/__init__.py +2 -0
- letta/agents/memory_blocks/client.py +364 -0
- letta/agents/messages/__init__.py +5 -0
- letta/agents/messages/client.py +787 -0
- letta/agents/messages/types/__init__.py +7 -0
- letta/agents/messages/types/letta_streaming_response.py +20 -0
- letta/agents/messages/types/messages_list_response.py +7 -0
- letta/agents/messages/types/messages_list_response_item.py +13 -0
- letta/agents/recall_memory/__init__.py +2 -0
- letta/agents/recall_memory/client.py +147 -0
- letta/agents/sources/__init__.py +2 -0
- letta/agents/sources/client.py +145 -0
- letta/agents/tools/__init__.py +2 -0
- letta/agents/tools/client.py +408 -0
- letta/agents/types/__init__.py +39 -0
- letta/agents/types/agents_get_agent_variables_response.py +19 -0
- letta/agents/types/agents_migrate_response.py +19 -0
- letta/agents/types/agents_search_deployed_agents_request_combinator.py +5 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item.py +16 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction.py +27 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_direction.py +5 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_value.py +7 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator.py +24 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator_operator.py +7 -0
- letta/agents/types/agents_search_deployed_agents_request_search_item_zero.py +20 -0
- letta/agents/types/create_agent_request_tool_rules_item.py +9 -0
- letta/agents/types/update_agent_tool_rules_item.py +9 -0
- letta/blocks/__init__.py +2 -0
- letta/blocks/client.py +1054 -0
- letta/client.py +164 -0
- letta/core/__init__.py +47 -0
- letta/core/api_error.py +15 -0
- letta/core/client_wrapper.py +76 -0
- letta/core/datetime_utils.py +28 -0
- letta/core/file.py +67 -0
- letta/core/http_client.py +499 -0
- letta/core/jsonable_encoder.py +101 -0
- letta/core/pydantic_utilities.py +296 -0
- letta/core/query_encoder.py +58 -0
- letta/core/remove_none_from_dict.py +11 -0
- letta/core/request_options.py +35 -0
- letta/core/serialization.py +272 -0
- letta/environment.py +8 -0
- letta/errors/__init__.py +8 -0
- letta/errors/conflict_error.py +9 -0
- letta/errors/internal_server_error.py +9 -0
- letta/errors/not_found_error.py +9 -0
- letta/errors/unprocessable_entity_error.py +9 -0
- letta/health/__init__.py +2 -0
- letta/health/client.py +108 -0
- letta/jobs/__init__.py +2 -0
- letta/jobs/client.py +503 -0
- letta/models/__init__.py +2 -0
- letta/models/client.py +201 -0
- letta/sources/__init__.py +5 -0
- letta/sources/client.py +1154 -0
- letta/sources/files/__init__.py +2 -0
- letta/sources/files/client.py +436 -0
- letta/sources/passages/__init__.py +2 -0
- letta/sources/passages/client.py +145 -0
- letta/tools/__init__.py +2 -0
- letta/tools/client.py +1823 -0
- letta/types/__init__.py +231 -0
- letta/types/action_model.py +36 -0
- letta/types/action_parameters_model.py +26 -0
- letta/types/action_response_model.py +26 -0
- letta/types/agent_state.py +139 -0
- letta/types/agent_state_tool_rules_item.py +9 -0
- letta/types/agent_type.py +8 -0
- letta/types/app_auth_scheme.py +34 -0
- letta/types/app_auth_scheme_auth_mode.py +7 -0
- letta/types/app_model.py +44 -0
- letta/types/archival_memory_summary.py +22 -0
- letta/types/assistant_file.py +33 -0
- letta/types/assistant_message_input.py +23 -0
- letta/types/assistant_message_output.py +23 -0
- letta/types/auth_request.py +22 -0
- letta/types/auth_response.py +29 -0
- letta/types/auth_scheme_field.py +30 -0
- letta/types/block.py +91 -0
- letta/types/block_update.py +60 -0
- letta/types/chat_completion_request.py +49 -0
- letta/types/chat_completion_request_function_call.py +6 -0
- letta/types/chat_completion_request_messages_item.py +11 -0
- letta/types/chat_completion_request_stop.py +5 -0
- letta/types/chat_completion_request_tool_choice.py +8 -0
- letta/types/chat_completion_response.py +32 -0
- letta/types/child_tool_rule.py +33 -0
- letta/types/choice.py +25 -0
- letta/types/conditional_tool_rule.py +43 -0
- letta/types/conflict_error_body.py +21 -0
- letta/types/context_window_overview.py +105 -0
- letta/types/create_assistant_file_request.py +22 -0
- letta/types/create_assistant_request.py +57 -0
- letta/types/create_block.py +56 -0
- letta/types/delete_assistant_file_response.py +28 -0
- letta/types/delete_assistant_response.py +28 -0
- letta/types/e_2_b_sandbox_config.py +32 -0
- letta/types/embedding_config.py +77 -0
- letta/types/embedding_config_embedding_endpoint_type.py +26 -0
- letta/types/file_metadata.py +82 -0
- letta/types/function_call_input.py +19 -0
- letta/types/function_call_output.py +20 -0
- letta/types/function_schema.py +21 -0
- letta/types/health.py +24 -0
- letta/types/http_validation_error.py +20 -0
- letta/types/init_tool_rule.py +29 -0
- letta/types/internal_server_error_body.py +19 -0
- letta/types/job.py +79 -0
- letta/types/job_status.py +5 -0
- letta/types/letta_request.py +33 -0
- letta/types/letta_response.py +37 -0
- letta/types/letta_schemas_letta_message_tool_call.py +21 -0
- letta/types/letta_schemas_message_message.py +103 -0
- letta/types/letta_schemas_openai_chat_completion_request_tool.py +21 -0
- letta/types/letta_schemas_openai_chat_completion_request_tool_call.py +24 -0
- letta/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +20 -0
- letta/types/letta_schemas_openai_chat_completion_response_message.py +24 -0
- letta/types/letta_schemas_openai_chat_completion_response_tool_call.py +22 -0
- letta/types/letta_schemas_openai_chat_completions_tool_call_function.py +27 -0
- letta/types/letta_schemas_openai_chat_completions_tool_call_input.py +29 -0
- letta/types/letta_schemas_openai_chat_completions_tool_call_output.py +29 -0
- letta/types/letta_schemas_tool_tool.py +88 -0
- letta/types/letta_usage_statistics.py +48 -0
- letta/types/llm_config.py +65 -0
- letta/types/llm_config_model_endpoint_type.py +26 -0
- letta/types/local_sandbox_config.py +32 -0
- letta/types/log_prob_token.py +21 -0
- letta/types/memory.py +32 -0
- letta/types/message_content_log_prob.py +23 -0
- letta/types/message_create.py +37 -0
- letta/types/message_create_role.py +5 -0
- letta/types/message_role.py +5 -0
- letta/types/not_found_error_body.py +19 -0
- letta/types/not_found_error_body_message.py +11 -0
- letta/types/open_ai_assistant.py +67 -0
- letta/types/organization.py +33 -0
- letta/types/organization_create.py +22 -0
- letta/types/passage.py +107 -0
- letta/types/reasoning_message.py +32 -0
- letta/types/recall_memory_summary.py +22 -0
- letta/types/response_format.py +19 -0
- letta/types/sandbox_config.py +59 -0
- letta/types/sandbox_config_create.py +23 -0
- letta/types/sandbox_config_create_config.py +7 -0
- letta/types/sandbox_config_update.py +27 -0
- letta/types/sandbox_config_update_config.py +7 -0
- letta/types/sandbox_environment_variable.py +68 -0
- letta/types/sandbox_environment_variable_create.py +32 -0
- letta/types/sandbox_environment_variable_update.py +36 -0
- letta/types/sandbox_type.py +5 -0
- letta/types/source.py +85 -0
- letta/types/system_message_input.py +21 -0
- letta/types/system_message_output.py +32 -0
- letta/types/terminal_tool_rule.py +29 -0
- letta/types/tool_call_delta.py +21 -0
- letta/types/tool_call_function_output.py +27 -0
- letta/types/tool_call_message.py +33 -0
- letta/types/tool_call_message_tool_call.py +7 -0
- letta/types/tool_create.py +57 -0
- letta/types/tool_function_choice.py +21 -0
- letta/types/tool_input.py +21 -0
- letta/types/tool_message.py +21 -0
- letta/types/tool_return_message.py +41 -0
- letta/types/tool_return_message_status.py +5 -0
- letta/types/tool_rule_type.py +10 -0
- letta/types/usage_statistics.py +21 -0
- letta/types/user.py +57 -0
- letta/types/user_create.py +27 -0
- letta/types/user_message_input.py +22 -0
- letta/types/user_message_input_content.py +5 -0
- letta/types/user_message_output.py +32 -0
- letta/types/user_update.py +32 -0
- letta/types/validation_error.py +22 -0
- letta/types/validation_error_loc_item.py +5 -0
- letta/version.py +3 -0
- letta_client-0.1.4.dist-info/METADATA +189 -0
- letta_client-0.1.4.dist-info/RECORD +191 -0
- {letta_client-0.1.0.dist-info → letta_client-0.1.4.dist-info}/WHEEL +1 -1
- letta_client-0.1.0.dist-info/METADATA +0 -15
- letta_client-0.1.0.dist-info/RECORD +0 -4
- /letta_client/__init__.py → /letta/py.typed +0 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.client_wrapper import SyncClientWrapper
|
|
4
|
+
import typing
|
|
5
|
+
from ...core.request_options import RequestOptions
|
|
6
|
+
from ...types.letta_schemas_tool_tool import LettaSchemasToolTool
|
|
7
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
8
|
+
from ...core.pydantic_utilities import parse_obj_as
|
|
9
|
+
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
10
|
+
from ...types.http_validation_error import HttpValidationError
|
|
11
|
+
from json.decoder import JSONDecodeError
|
|
12
|
+
from ...core.api_error import ApiError
|
|
13
|
+
from ...types.agent_state import AgentState
|
|
14
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ToolsClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._client_wrapper = client_wrapper
|
|
20
|
+
|
|
21
|
+
def list(
|
|
22
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
23
|
+
) -> typing.List[LettaSchemasToolTool]:
|
|
24
|
+
"""
|
|
25
|
+
Get tools from an existing agent
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
agent_id : str
|
|
30
|
+
|
|
31
|
+
request_options : typing.Optional[RequestOptions]
|
|
32
|
+
Request-specific configuration.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
typing.List[LettaSchemasToolTool]
|
|
37
|
+
Successful Response
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
from letta import Letta
|
|
42
|
+
|
|
43
|
+
client = Letta(
|
|
44
|
+
token="YOUR_TOKEN",
|
|
45
|
+
)
|
|
46
|
+
client.agents.tools.list(
|
|
47
|
+
agent_id="agent_id",
|
|
48
|
+
)
|
|
49
|
+
"""
|
|
50
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
51
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/tools",
|
|
52
|
+
method="GET",
|
|
53
|
+
request_options=request_options,
|
|
54
|
+
)
|
|
55
|
+
try:
|
|
56
|
+
if 200 <= _response.status_code < 300:
|
|
57
|
+
return typing.cast(
|
|
58
|
+
typing.List[LettaSchemasToolTool],
|
|
59
|
+
parse_obj_as(
|
|
60
|
+
type_=typing.List[LettaSchemasToolTool], # type: ignore
|
|
61
|
+
object_=_response.json(),
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
if _response.status_code == 422:
|
|
65
|
+
raise UnprocessableEntityError(
|
|
66
|
+
typing.cast(
|
|
67
|
+
HttpValidationError,
|
|
68
|
+
parse_obj_as(
|
|
69
|
+
type_=HttpValidationError, # type: ignore
|
|
70
|
+
object_=_response.json(),
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
_response_json = _response.json()
|
|
75
|
+
except JSONDecodeError:
|
|
76
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
77
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
78
|
+
|
|
79
|
+
def add(
|
|
80
|
+
self, agent_id: str, tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
81
|
+
) -> AgentState:
|
|
82
|
+
"""
|
|
83
|
+
Add tools to an existing agent
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
agent_id : str
|
|
88
|
+
|
|
89
|
+
tool_id : str
|
|
90
|
+
|
|
91
|
+
request_options : typing.Optional[RequestOptions]
|
|
92
|
+
Request-specific configuration.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
AgentState
|
|
97
|
+
Successful Response
|
|
98
|
+
|
|
99
|
+
Examples
|
|
100
|
+
--------
|
|
101
|
+
from letta import Letta
|
|
102
|
+
|
|
103
|
+
client = Letta(
|
|
104
|
+
token="YOUR_TOKEN",
|
|
105
|
+
)
|
|
106
|
+
client.agents.tools.add(
|
|
107
|
+
agent_id="agent_id",
|
|
108
|
+
tool_id="tool_id",
|
|
109
|
+
)
|
|
110
|
+
"""
|
|
111
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
112
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/add-tool/{jsonable_encoder(tool_id)}",
|
|
113
|
+
method="PATCH",
|
|
114
|
+
request_options=request_options,
|
|
115
|
+
)
|
|
116
|
+
try:
|
|
117
|
+
if 200 <= _response.status_code < 300:
|
|
118
|
+
return typing.cast(
|
|
119
|
+
AgentState,
|
|
120
|
+
parse_obj_as(
|
|
121
|
+
type_=AgentState, # type: ignore
|
|
122
|
+
object_=_response.json(),
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
if _response.status_code == 422:
|
|
126
|
+
raise UnprocessableEntityError(
|
|
127
|
+
typing.cast(
|
|
128
|
+
HttpValidationError,
|
|
129
|
+
parse_obj_as(
|
|
130
|
+
type_=HttpValidationError, # type: ignore
|
|
131
|
+
object_=_response.json(),
|
|
132
|
+
),
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
_response_json = _response.json()
|
|
136
|
+
except JSONDecodeError:
|
|
137
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
138
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
139
|
+
|
|
140
|
+
def remove(
|
|
141
|
+
self, agent_id: str, tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
142
|
+
) -> AgentState:
|
|
143
|
+
"""
|
|
144
|
+
Add tools to an existing agent
|
|
145
|
+
|
|
146
|
+
Parameters
|
|
147
|
+
----------
|
|
148
|
+
agent_id : str
|
|
149
|
+
|
|
150
|
+
tool_id : str
|
|
151
|
+
|
|
152
|
+
request_options : typing.Optional[RequestOptions]
|
|
153
|
+
Request-specific configuration.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
AgentState
|
|
158
|
+
Successful Response
|
|
159
|
+
|
|
160
|
+
Examples
|
|
161
|
+
--------
|
|
162
|
+
from letta import Letta
|
|
163
|
+
|
|
164
|
+
client = Letta(
|
|
165
|
+
token="YOUR_TOKEN",
|
|
166
|
+
)
|
|
167
|
+
client.agents.tools.remove(
|
|
168
|
+
agent_id="agent_id",
|
|
169
|
+
tool_id="tool_id",
|
|
170
|
+
)
|
|
171
|
+
"""
|
|
172
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
173
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/remove-tool/{jsonable_encoder(tool_id)}",
|
|
174
|
+
method="PATCH",
|
|
175
|
+
request_options=request_options,
|
|
176
|
+
)
|
|
177
|
+
try:
|
|
178
|
+
if 200 <= _response.status_code < 300:
|
|
179
|
+
return typing.cast(
|
|
180
|
+
AgentState,
|
|
181
|
+
parse_obj_as(
|
|
182
|
+
type_=AgentState, # type: ignore
|
|
183
|
+
object_=_response.json(),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
if _response.status_code == 422:
|
|
187
|
+
raise UnprocessableEntityError(
|
|
188
|
+
typing.cast(
|
|
189
|
+
HttpValidationError,
|
|
190
|
+
parse_obj_as(
|
|
191
|
+
type_=HttpValidationError, # type: ignore
|
|
192
|
+
object_=_response.json(),
|
|
193
|
+
),
|
|
194
|
+
)
|
|
195
|
+
)
|
|
196
|
+
_response_json = _response.json()
|
|
197
|
+
except JSONDecodeError:
|
|
198
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
199
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class AsyncToolsClient:
|
|
203
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
204
|
+
self._client_wrapper = client_wrapper
|
|
205
|
+
|
|
206
|
+
async def list(
|
|
207
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
208
|
+
) -> typing.List[LettaSchemasToolTool]:
|
|
209
|
+
"""
|
|
210
|
+
Get tools from an existing agent
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
agent_id : str
|
|
215
|
+
|
|
216
|
+
request_options : typing.Optional[RequestOptions]
|
|
217
|
+
Request-specific configuration.
|
|
218
|
+
|
|
219
|
+
Returns
|
|
220
|
+
-------
|
|
221
|
+
typing.List[LettaSchemasToolTool]
|
|
222
|
+
Successful Response
|
|
223
|
+
|
|
224
|
+
Examples
|
|
225
|
+
--------
|
|
226
|
+
import asyncio
|
|
227
|
+
|
|
228
|
+
from letta import AsyncLetta
|
|
229
|
+
|
|
230
|
+
client = AsyncLetta(
|
|
231
|
+
token="YOUR_TOKEN",
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
async def main() -> None:
|
|
236
|
+
await client.agents.tools.list(
|
|
237
|
+
agent_id="agent_id",
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
asyncio.run(main())
|
|
242
|
+
"""
|
|
243
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
244
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/tools",
|
|
245
|
+
method="GET",
|
|
246
|
+
request_options=request_options,
|
|
247
|
+
)
|
|
248
|
+
try:
|
|
249
|
+
if 200 <= _response.status_code < 300:
|
|
250
|
+
return typing.cast(
|
|
251
|
+
typing.List[LettaSchemasToolTool],
|
|
252
|
+
parse_obj_as(
|
|
253
|
+
type_=typing.List[LettaSchemasToolTool], # type: ignore
|
|
254
|
+
object_=_response.json(),
|
|
255
|
+
),
|
|
256
|
+
)
|
|
257
|
+
if _response.status_code == 422:
|
|
258
|
+
raise UnprocessableEntityError(
|
|
259
|
+
typing.cast(
|
|
260
|
+
HttpValidationError,
|
|
261
|
+
parse_obj_as(
|
|
262
|
+
type_=HttpValidationError, # type: ignore
|
|
263
|
+
object_=_response.json(),
|
|
264
|
+
),
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
_response_json = _response.json()
|
|
268
|
+
except JSONDecodeError:
|
|
269
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
270
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
271
|
+
|
|
272
|
+
async def add(
|
|
273
|
+
self, agent_id: str, tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
274
|
+
) -> AgentState:
|
|
275
|
+
"""
|
|
276
|
+
Add tools to an existing agent
|
|
277
|
+
|
|
278
|
+
Parameters
|
|
279
|
+
----------
|
|
280
|
+
agent_id : str
|
|
281
|
+
|
|
282
|
+
tool_id : str
|
|
283
|
+
|
|
284
|
+
request_options : typing.Optional[RequestOptions]
|
|
285
|
+
Request-specific configuration.
|
|
286
|
+
|
|
287
|
+
Returns
|
|
288
|
+
-------
|
|
289
|
+
AgentState
|
|
290
|
+
Successful Response
|
|
291
|
+
|
|
292
|
+
Examples
|
|
293
|
+
--------
|
|
294
|
+
import asyncio
|
|
295
|
+
|
|
296
|
+
from letta import AsyncLetta
|
|
297
|
+
|
|
298
|
+
client = AsyncLetta(
|
|
299
|
+
token="YOUR_TOKEN",
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
async def main() -> None:
|
|
304
|
+
await client.agents.tools.add(
|
|
305
|
+
agent_id="agent_id",
|
|
306
|
+
tool_id="tool_id",
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
asyncio.run(main())
|
|
311
|
+
"""
|
|
312
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
313
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/add-tool/{jsonable_encoder(tool_id)}",
|
|
314
|
+
method="PATCH",
|
|
315
|
+
request_options=request_options,
|
|
316
|
+
)
|
|
317
|
+
try:
|
|
318
|
+
if 200 <= _response.status_code < 300:
|
|
319
|
+
return typing.cast(
|
|
320
|
+
AgentState,
|
|
321
|
+
parse_obj_as(
|
|
322
|
+
type_=AgentState, # type: ignore
|
|
323
|
+
object_=_response.json(),
|
|
324
|
+
),
|
|
325
|
+
)
|
|
326
|
+
if _response.status_code == 422:
|
|
327
|
+
raise UnprocessableEntityError(
|
|
328
|
+
typing.cast(
|
|
329
|
+
HttpValidationError,
|
|
330
|
+
parse_obj_as(
|
|
331
|
+
type_=HttpValidationError, # type: ignore
|
|
332
|
+
object_=_response.json(),
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
_response_json = _response.json()
|
|
337
|
+
except JSONDecodeError:
|
|
338
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
339
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
340
|
+
|
|
341
|
+
async def remove(
|
|
342
|
+
self, agent_id: str, tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
343
|
+
) -> AgentState:
|
|
344
|
+
"""
|
|
345
|
+
Add tools to an existing agent
|
|
346
|
+
|
|
347
|
+
Parameters
|
|
348
|
+
----------
|
|
349
|
+
agent_id : str
|
|
350
|
+
|
|
351
|
+
tool_id : str
|
|
352
|
+
|
|
353
|
+
request_options : typing.Optional[RequestOptions]
|
|
354
|
+
Request-specific configuration.
|
|
355
|
+
|
|
356
|
+
Returns
|
|
357
|
+
-------
|
|
358
|
+
AgentState
|
|
359
|
+
Successful Response
|
|
360
|
+
|
|
361
|
+
Examples
|
|
362
|
+
--------
|
|
363
|
+
import asyncio
|
|
364
|
+
|
|
365
|
+
from letta import AsyncLetta
|
|
366
|
+
|
|
367
|
+
client = AsyncLetta(
|
|
368
|
+
token="YOUR_TOKEN",
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
async def main() -> None:
|
|
373
|
+
await client.agents.tools.remove(
|
|
374
|
+
agent_id="agent_id",
|
|
375
|
+
tool_id="tool_id",
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
asyncio.run(main())
|
|
380
|
+
"""
|
|
381
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
382
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/remove-tool/{jsonable_encoder(tool_id)}",
|
|
383
|
+
method="PATCH",
|
|
384
|
+
request_options=request_options,
|
|
385
|
+
)
|
|
386
|
+
try:
|
|
387
|
+
if 200 <= _response.status_code < 300:
|
|
388
|
+
return typing.cast(
|
|
389
|
+
AgentState,
|
|
390
|
+
parse_obj_as(
|
|
391
|
+
type_=AgentState, # type: ignore
|
|
392
|
+
object_=_response.json(),
|
|
393
|
+
),
|
|
394
|
+
)
|
|
395
|
+
if _response.status_code == 422:
|
|
396
|
+
raise UnprocessableEntityError(
|
|
397
|
+
typing.cast(
|
|
398
|
+
HttpValidationError,
|
|
399
|
+
parse_obj_as(
|
|
400
|
+
type_=HttpValidationError, # type: ignore
|
|
401
|
+
object_=_response.json(),
|
|
402
|
+
),
|
|
403
|
+
)
|
|
404
|
+
)
|
|
405
|
+
_response_json = _response.json()
|
|
406
|
+
except JSONDecodeError:
|
|
407
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
408
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from .agents_get_agent_variables_response import AgentsGetAgentVariablesResponse
|
|
4
|
+
from .agents_migrate_response import AgentsMigrateResponse
|
|
5
|
+
from .agents_search_deployed_agents_request_combinator import AgentsSearchDeployedAgentsRequestCombinator
|
|
6
|
+
from .agents_search_deployed_agents_request_search_item import AgentsSearchDeployedAgentsRequestSearchItem
|
|
7
|
+
from .agents_search_deployed_agents_request_search_item_direction import (
|
|
8
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirection,
|
|
9
|
+
)
|
|
10
|
+
from .agents_search_deployed_agents_request_search_item_direction_direction import (
|
|
11
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirectionDirection,
|
|
12
|
+
)
|
|
13
|
+
from .agents_search_deployed_agents_request_search_item_direction_value import (
|
|
14
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirectionValue,
|
|
15
|
+
)
|
|
16
|
+
from .agents_search_deployed_agents_request_search_item_operator import (
|
|
17
|
+
AgentsSearchDeployedAgentsRequestSearchItemOperator,
|
|
18
|
+
)
|
|
19
|
+
from .agents_search_deployed_agents_request_search_item_operator_operator import (
|
|
20
|
+
AgentsSearchDeployedAgentsRequestSearchItemOperatorOperator,
|
|
21
|
+
)
|
|
22
|
+
from .agents_search_deployed_agents_request_search_item_zero import AgentsSearchDeployedAgentsRequestSearchItemZero
|
|
23
|
+
from .create_agent_request_tool_rules_item import CreateAgentRequestToolRulesItem
|
|
24
|
+
from .update_agent_tool_rules_item import UpdateAgentToolRulesItem
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"AgentsGetAgentVariablesResponse",
|
|
28
|
+
"AgentsMigrateResponse",
|
|
29
|
+
"AgentsSearchDeployedAgentsRequestCombinator",
|
|
30
|
+
"AgentsSearchDeployedAgentsRequestSearchItem",
|
|
31
|
+
"AgentsSearchDeployedAgentsRequestSearchItemDirection",
|
|
32
|
+
"AgentsSearchDeployedAgentsRequestSearchItemDirectionDirection",
|
|
33
|
+
"AgentsSearchDeployedAgentsRequestSearchItemDirectionValue",
|
|
34
|
+
"AgentsSearchDeployedAgentsRequestSearchItemOperator",
|
|
35
|
+
"AgentsSearchDeployedAgentsRequestSearchItemOperatorOperator",
|
|
36
|
+
"AgentsSearchDeployedAgentsRequestSearchItemZero",
|
|
37
|
+
"CreateAgentRequestToolRulesItem",
|
|
38
|
+
"UpdateAgentToolRulesItem",
|
|
39
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
+
import typing
|
|
5
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentsGetAgentVariablesResponse(UniversalBaseModel):
|
|
10
|
+
variables: typing.Dict[str, str]
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
14
|
+
else:
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
frozen = True
|
|
18
|
+
smart_union = True
|
|
19
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
5
|
+
import typing
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentsMigrateResponse(UniversalBaseModel):
|
|
10
|
+
success: bool
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
14
|
+
else:
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
frozen = True
|
|
18
|
+
smart_union = True
|
|
19
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from .agents_search_deployed_agents_request_search_item_zero import AgentsSearchDeployedAgentsRequestSearchItemZero
|
|
5
|
+
from .agents_search_deployed_agents_request_search_item_operator import (
|
|
6
|
+
AgentsSearchDeployedAgentsRequestSearchItemOperator,
|
|
7
|
+
)
|
|
8
|
+
from .agents_search_deployed_agents_request_search_item_direction import (
|
|
9
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirection,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
AgentsSearchDeployedAgentsRequestSearchItem = typing.Union[
|
|
13
|
+
AgentsSearchDeployedAgentsRequestSearchItemZero,
|
|
14
|
+
AgentsSearchDeployedAgentsRequestSearchItemOperator,
|
|
15
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirection,
|
|
16
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
+
import typing
|
|
5
|
+
from .agents_search_deployed_agents_request_search_item_direction_value import (
|
|
6
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirectionValue,
|
|
7
|
+
)
|
|
8
|
+
from .agents_search_deployed_agents_request_search_item_direction_direction import (
|
|
9
|
+
AgentsSearchDeployedAgentsRequestSearchItemDirectionDirection,
|
|
10
|
+
)
|
|
11
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
12
|
+
import pydantic
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AgentsSearchDeployedAgentsRequestSearchItemDirection(UniversalBaseModel):
|
|
16
|
+
field: typing.Literal["order_by"] = "order_by"
|
|
17
|
+
value: AgentsSearchDeployedAgentsRequestSearchItemDirectionValue
|
|
18
|
+
direction: AgentsSearchDeployedAgentsRequestSearchItemDirectionDirection
|
|
19
|
+
|
|
20
|
+
if IS_PYDANTIC_V2:
|
|
21
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
22
|
+
else:
|
|
23
|
+
|
|
24
|
+
class Config:
|
|
25
|
+
frozen = True
|
|
26
|
+
smart_union = True
|
|
27
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
+
import typing
|
|
5
|
+
from .agents_search_deployed_agents_request_search_item_operator_operator import (
|
|
6
|
+
AgentsSearchDeployedAgentsRequestSearchItemOperatorOperator,
|
|
7
|
+
)
|
|
8
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
9
|
+
import pydantic
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AgentsSearchDeployedAgentsRequestSearchItemOperator(UniversalBaseModel):
|
|
13
|
+
field: typing.Literal["name"] = "name"
|
|
14
|
+
operator: AgentsSearchDeployedAgentsRequestSearchItemOperatorOperator
|
|
15
|
+
value: str
|
|
16
|
+
|
|
17
|
+
if IS_PYDANTIC_V2:
|
|
18
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class Config:
|
|
22
|
+
frozen = True
|
|
23
|
+
smart_union = True
|
|
24
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
+
import typing
|
|
5
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentsSearchDeployedAgentsRequestSearchItemZero(UniversalBaseModel):
|
|
10
|
+
field: typing.Literal["version"] = "version"
|
|
11
|
+
value: str
|
|
12
|
+
|
|
13
|
+
if IS_PYDANTIC_V2:
|
|
14
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
15
|
+
else:
|
|
16
|
+
|
|
17
|
+
class Config:
|
|
18
|
+
frozen = True
|
|
19
|
+
smart_union = True
|
|
20
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ...types.child_tool_rule import ChildToolRule
|
|
5
|
+
from ...types.init_tool_rule import InitToolRule
|
|
6
|
+
from ...types.terminal_tool_rule import TerminalToolRule
|
|
7
|
+
from ...types.conditional_tool_rule import ConditionalToolRule
|
|
8
|
+
|
|
9
|
+
CreateAgentRequestToolRulesItem = typing.Union[ChildToolRule, InitToolRule, TerminalToolRule, ConditionalToolRule]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ...types.child_tool_rule import ChildToolRule
|
|
5
|
+
from ...types.init_tool_rule import InitToolRule
|
|
6
|
+
from ...types.terminal_tool_rule import TerminalToolRule
|
|
7
|
+
from ...types.conditional_tool_rule import ConditionalToolRule
|
|
8
|
+
|
|
9
|
+
UpdateAgentToolRulesItem = typing.Union[ChildToolRule, InitToolRule, TerminalToolRule, ConditionalToolRule]
|
letta/blocks/__init__.py
ADDED