letta-client 0.1.4__py3-none-any.whl → 0.1.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- letta/__init__.py +44 -21
- letta/agents/__init__.py +71 -24
- letta/agents/archival_memory/client.py +17 -17
- letta/agents/client.py +424 -1700
- letta/agents/context/client.py +5 -5
- letta/agents/core_memory/client.py +1080 -0
- letta/agents/memory_variables/__init__.py +5 -0
- letta/agents/{memory → memory_variables}/client.py +41 -40
- letta/agents/memory_variables/types/__init__.py +5 -0
- letta/agents/{types/agents_get_agent_variables_response.py → memory_variables/types/memory_variables_get_response.py} +3 -3
- letta/agents/messages/__init__.py +36 -2
- letta/agents/messages/client.py +278 -17
- letta/agents/messages/types/__init__.py +37 -3
- letta/agents/messages/types/letta_streaming_response.py +139 -16
- letta/agents/messages/types/messages_list_response_item.py +121 -9
- letta/agents/recall_memory/client.py +5 -5
- letta/agents/sources/client.py +5 -5
- letta/agents/templates/__init__.py +5 -0
- letta/agents/templates/client.py +578 -0
- letta/agents/templates/types/__init__.py +5 -0
- letta/agents/templates/types/templates_migrate_response.py +19 -0
- letta/agents/tools/client.py +13 -13
- letta/agents/types/__init__.py +23 -29
- letta/agents/types/agents_search_request_combinator.py +5 -0
- letta/agents/types/agents_search_request_search_item.py +64 -0
- letta/agents/types/{agents_search_deployed_agents_request_search_item_zero.py → agents_search_request_search_item_name.py} +5 -4
- letta/agents/types/agents_search_request_search_item_name_operator.py +5 -0
- letta/agents/types/agents_search_request_search_item_order_by.py +22 -0
- letta/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
- letta/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
- letta/agents/types/{agents_migrate_response.py → agents_search_request_search_item_version.py} +3 -3
- letta/blocks/client.py +25 -25
- letta/client.py +8 -4
- letta/core/__init__.py +4 -0
- letta/core/client_wrapper.py +7 -18
- letta/core/unchecked_base_model.py +305 -0
- letta/health/client.py +3 -3
- letta/jobs/client.py +17 -17
- letta/models/client.py +5 -5
- letta/providers/client.py +597 -0
- letta/sources/client.py +33 -33
- letta/sources/files/client.py +11 -11
- letta/sources/passages/client.py +5 -5
- letta/tools/client.py +77 -57
- letta/types/__init__.py +22 -0
- letta/types/action_model.py +2 -2
- letta/types/action_parameters_model.py +2 -2
- letta/types/action_response_model.py +2 -2
- letta/types/agent_environment_variable.py +63 -0
- letta/types/agent_state.py +19 -16
- letta/types/agent_type.py +1 -2
- letta/types/app_auth_scheme.py +2 -2
- letta/types/app_model.py +2 -2
- letta/types/archival_memory_summary.py +2 -2
- letta/types/assistant_file.py +2 -2
- letta/types/assistant_message_input.py +2 -2
- letta/types/assistant_message_output.py +3 -4
- letta/types/auth_request.py +2 -2
- letta/types/auth_response.py +2 -2
- letta/types/auth_scheme_field.py +2 -2
- letta/types/block.py +11 -16
- letta/types/block_update.py +2 -2
- letta/types/chat_completion_request.py +2 -2
- letta/types/chat_completion_response.py +2 -2
- letta/types/child_tool_rule.py +2 -2
- letta/types/choice.py +2 -2
- letta/types/conditional_tool_rule.py +2 -2
- letta/types/conflict_error_body.py +2 -2
- letta/types/context_window_overview.py +7 -2
- letta/types/create_assistant_file_request.py +2 -2
- letta/types/create_assistant_request.py +2 -2
- letta/types/create_block.py +2 -2
- letta/types/delete_assistant_file_response.py +2 -2
- letta/types/delete_assistant_response.py +2 -2
- letta/types/e_2_b_sandbox_config.py +2 -2
- letta/types/embedding_config.py +10 -10
- letta/types/file_metadata.py +2 -7
- letta/types/function_call_input.py +2 -2
- letta/types/function_call_output.py +2 -2
- letta/types/function_schema.py +2 -2
- letta/types/health.py +2 -2
- letta/types/http_validation_error.py +2 -2
- letta/types/init_tool_rule.py +2 -2
- letta/types/internal_server_error_body.py +2 -2
- letta/types/job.py +7 -12
- letta/types/letta_request.py +7 -2
- letta/types/letta_response.py +6 -5
- letta/types/letta_response_messages_item.py +125 -0
- letta/types/letta_schemas_letta_message_tool_call.py +2 -2
- letta/types/letta_schemas_message_message.py +12 -17
- letta/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
- letta/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
- letta/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
- letta/types/letta_schemas_tool_tool.py +14 -13
- letta/types/letta_usage_statistics.py +6 -7
- letta/types/llm_config.py +9 -9
- letta/types/local_sandbox_config.py +2 -2
- letta/types/log_prob_token.py +2 -2
- letta/types/memory.py +2 -2
- letta/types/message_content_log_prob.py +2 -2
- letta/types/message_create.py +2 -2
- letta/types/not_found_error_body.py +2 -2
- letta/types/open_ai_assistant.py +2 -2
- letta/types/organization.py +2 -2
- letta/types/organization_create.py +2 -2
- letta/types/passage.py +10 -15
- letta/types/provider.py +38 -0
- letta/types/reasoning_message.py +6 -7
- letta/types/recall_memory_summary.py +2 -2
- letta/types/response_format.py +2 -2
- letta/types/sandbox_config.py +2 -7
- letta/types/sandbox_config_create.py +2 -2
- letta/types/sandbox_config_update.py +2 -2
- letta/types/sandbox_environment_variable.py +2 -7
- letta/types/sandbox_environment_variable_create.py +2 -2
- letta/types/sandbox_environment_variable_update.py +2 -6
- letta/types/source.py +8 -13
- letta/types/system_message_input.py +2 -2
- letta/types/system_message_output.py +6 -7
- letta/types/terminal_tool_rule.py +2 -2
- letta/types/tool_call_delta.py +2 -2
- letta/types/tool_call_function_output.py +2 -2
- letta/types/tool_call_message.py +6 -7
- letta/types/tool_create.py +2 -2
- letta/types/tool_function_choice.py +2 -2
- letta/types/tool_input.py +2 -2
- letta/types/tool_message.py +2 -2
- letta/types/tool_return_message.py +10 -11
- letta/types/tool_type.py +5 -0
- letta/types/usage_statistics.py +2 -2
- letta/types/user.py +5 -10
- letta/types/user_create.py +2 -7
- letta/types/user_message_input.py +2 -2
- letta/types/user_message_output.py +6 -7
- letta/types/user_update.py +2 -7
- letta/types/validation_error.py +2 -2
- {letta_client-0.1.4.dist-info → letta_client-0.1.9.dist-info}/METADATA +1 -1
- letta_client-0.1.9.dist-info/RECORD +200 -0
- letta/agents/memory/__init__.py +0 -5
- letta/agents/memory/messages/client.py +0 -147
- letta/agents/memory_blocks/client.py +0 -364
- letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item.py +0 -16
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction.py +0 -27
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_direction.py +0 -5
- letta/agents/types/agents_search_deployed_agents_request_search_item_direction_value.py +0 -7
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator.py +0 -24
- letta/agents/types/agents_search_deployed_agents_request_search_item_operator_operator.py +0 -7
- letta_client-0.1.4.dist-info/RECORD +0 -191
- /letta/agents/{memory/messages → core_memory}/__init__.py +0 -0
- /letta/{agents/memory_blocks → providers}/__init__.py +0 -0
- {letta_client-0.1.4.dist-info → letta_client-0.1.9.dist-info}/WHEEL +0 -0
|
@@ -1,147 +0,0 @@
|
|
|
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_message_message import LettaSchemasMessageMessage
|
|
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 ....core.client_wrapper import AsyncClientWrapper
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class MessagesClient:
|
|
17
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
18
|
-
self._client_wrapper = client_wrapper
|
|
19
|
-
|
|
20
|
-
def list_in_context(
|
|
21
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
22
|
-
) -> typing.List[LettaSchemasMessageMessage]:
|
|
23
|
-
"""
|
|
24
|
-
Retrieve the messages in the context of a specific agent.
|
|
25
|
-
|
|
26
|
-
Parameters
|
|
27
|
-
----------
|
|
28
|
-
agent_id : str
|
|
29
|
-
|
|
30
|
-
request_options : typing.Optional[RequestOptions]
|
|
31
|
-
Request-specific configuration.
|
|
32
|
-
|
|
33
|
-
Returns
|
|
34
|
-
-------
|
|
35
|
-
typing.List[LettaSchemasMessageMessage]
|
|
36
|
-
Successful Response
|
|
37
|
-
|
|
38
|
-
Examples
|
|
39
|
-
--------
|
|
40
|
-
from letta import Letta
|
|
41
|
-
|
|
42
|
-
client = Letta(
|
|
43
|
-
token="YOUR_TOKEN",
|
|
44
|
-
)
|
|
45
|
-
client.agents.memory.messages.list_in_context(
|
|
46
|
-
agent_id="agent_id",
|
|
47
|
-
)
|
|
48
|
-
"""
|
|
49
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
50
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/messages",
|
|
51
|
-
method="GET",
|
|
52
|
-
request_options=request_options,
|
|
53
|
-
)
|
|
54
|
-
try:
|
|
55
|
-
if 200 <= _response.status_code < 300:
|
|
56
|
-
return typing.cast(
|
|
57
|
-
typing.List[LettaSchemasMessageMessage],
|
|
58
|
-
parse_obj_as(
|
|
59
|
-
type_=typing.List[LettaSchemasMessageMessage], # type: ignore
|
|
60
|
-
object_=_response.json(),
|
|
61
|
-
),
|
|
62
|
-
)
|
|
63
|
-
if _response.status_code == 422:
|
|
64
|
-
raise UnprocessableEntityError(
|
|
65
|
-
typing.cast(
|
|
66
|
-
HttpValidationError,
|
|
67
|
-
parse_obj_as(
|
|
68
|
-
type_=HttpValidationError, # type: ignore
|
|
69
|
-
object_=_response.json(),
|
|
70
|
-
),
|
|
71
|
-
)
|
|
72
|
-
)
|
|
73
|
-
_response_json = _response.json()
|
|
74
|
-
except JSONDecodeError:
|
|
75
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
76
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
class AsyncMessagesClient:
|
|
80
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
81
|
-
self._client_wrapper = client_wrapper
|
|
82
|
-
|
|
83
|
-
async def list_in_context(
|
|
84
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
85
|
-
) -> typing.List[LettaSchemasMessageMessage]:
|
|
86
|
-
"""
|
|
87
|
-
Retrieve the messages in the context of a specific agent.
|
|
88
|
-
|
|
89
|
-
Parameters
|
|
90
|
-
----------
|
|
91
|
-
agent_id : str
|
|
92
|
-
|
|
93
|
-
request_options : typing.Optional[RequestOptions]
|
|
94
|
-
Request-specific configuration.
|
|
95
|
-
|
|
96
|
-
Returns
|
|
97
|
-
-------
|
|
98
|
-
typing.List[LettaSchemasMessageMessage]
|
|
99
|
-
Successful Response
|
|
100
|
-
|
|
101
|
-
Examples
|
|
102
|
-
--------
|
|
103
|
-
import asyncio
|
|
104
|
-
|
|
105
|
-
from letta import AsyncLetta
|
|
106
|
-
|
|
107
|
-
client = AsyncLetta(
|
|
108
|
-
token="YOUR_TOKEN",
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
async def main() -> None:
|
|
113
|
-
await client.agents.memory.messages.list_in_context(
|
|
114
|
-
agent_id="agent_id",
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
asyncio.run(main())
|
|
119
|
-
"""
|
|
120
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
121
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/messages",
|
|
122
|
-
method="GET",
|
|
123
|
-
request_options=request_options,
|
|
124
|
-
)
|
|
125
|
-
try:
|
|
126
|
-
if 200 <= _response.status_code < 300:
|
|
127
|
-
return typing.cast(
|
|
128
|
-
typing.List[LettaSchemasMessageMessage],
|
|
129
|
-
parse_obj_as(
|
|
130
|
-
type_=typing.List[LettaSchemasMessageMessage], # type: ignore
|
|
131
|
-
object_=_response.json(),
|
|
132
|
-
),
|
|
133
|
-
)
|
|
134
|
-
if _response.status_code == 422:
|
|
135
|
-
raise UnprocessableEntityError(
|
|
136
|
-
typing.cast(
|
|
137
|
-
HttpValidationError,
|
|
138
|
-
parse_obj_as(
|
|
139
|
-
type_=HttpValidationError, # type: ignore
|
|
140
|
-
object_=_response.json(),
|
|
141
|
-
),
|
|
142
|
-
)
|
|
143
|
-
)
|
|
144
|
-
_response_json = _response.json()
|
|
145
|
-
except JSONDecodeError:
|
|
146
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
147
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -1,364 +0,0 @@
|
|
|
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 ...types.memory import Memory
|
|
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 ...core.client_wrapper import AsyncClientWrapper
|
|
14
|
-
|
|
15
|
-
# this is used as the default value for optional parameters
|
|
16
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class MemoryBlocksClient:
|
|
20
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
-
self._client_wrapper = client_wrapper
|
|
22
|
-
|
|
23
|
-
def remove(
|
|
24
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
25
|
-
) -> Memory:
|
|
26
|
-
"""
|
|
27
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
28
|
-
|
|
29
|
-
Parameters
|
|
30
|
-
----------
|
|
31
|
-
agent_id : str
|
|
32
|
-
|
|
33
|
-
block_label : str
|
|
34
|
-
|
|
35
|
-
request_options : typing.Optional[RequestOptions]
|
|
36
|
-
Request-specific configuration.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
Memory
|
|
41
|
-
Successful Response
|
|
42
|
-
|
|
43
|
-
Examples
|
|
44
|
-
--------
|
|
45
|
-
from letta import Letta
|
|
46
|
-
|
|
47
|
-
client = Letta(
|
|
48
|
-
token="YOUR_TOKEN",
|
|
49
|
-
)
|
|
50
|
-
client.agents.memory_blocks.remove(
|
|
51
|
-
agent_id="agent_id",
|
|
52
|
-
block_label="block_label",
|
|
53
|
-
)
|
|
54
|
-
"""
|
|
55
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
56
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
|
|
57
|
-
method="DELETE",
|
|
58
|
-
request_options=request_options,
|
|
59
|
-
)
|
|
60
|
-
try:
|
|
61
|
-
if 200 <= _response.status_code < 300:
|
|
62
|
-
return typing.cast(
|
|
63
|
-
Memory,
|
|
64
|
-
parse_obj_as(
|
|
65
|
-
type_=Memory, # type: ignore
|
|
66
|
-
object_=_response.json(),
|
|
67
|
-
),
|
|
68
|
-
)
|
|
69
|
-
if _response.status_code == 422:
|
|
70
|
-
raise UnprocessableEntityError(
|
|
71
|
-
typing.cast(
|
|
72
|
-
HttpValidationError,
|
|
73
|
-
parse_obj_as(
|
|
74
|
-
type_=HttpValidationError, # type: ignore
|
|
75
|
-
object_=_response.json(),
|
|
76
|
-
),
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
_response_json = _response.json()
|
|
80
|
-
except JSONDecodeError:
|
|
81
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
82
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
83
|
-
|
|
84
|
-
def add(
|
|
85
|
-
self,
|
|
86
|
-
agent_id: str,
|
|
87
|
-
*,
|
|
88
|
-
value: str,
|
|
89
|
-
label: str,
|
|
90
|
-
limit: typing.Optional[int] = OMIT,
|
|
91
|
-
name: typing.Optional[str] = OMIT,
|
|
92
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
93
|
-
description: typing.Optional[str] = OMIT,
|
|
94
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
95
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
96
|
-
) -> Memory:
|
|
97
|
-
"""
|
|
98
|
-
Creates a memory block and links it to the agent.
|
|
99
|
-
|
|
100
|
-
Parameters
|
|
101
|
-
----------
|
|
102
|
-
agent_id : str
|
|
103
|
-
|
|
104
|
-
value : str
|
|
105
|
-
Value of the block.
|
|
106
|
-
|
|
107
|
-
label : str
|
|
108
|
-
Label of the block.
|
|
109
|
-
|
|
110
|
-
limit : typing.Optional[int]
|
|
111
|
-
Character limit of the block.
|
|
112
|
-
|
|
113
|
-
name : typing.Optional[str]
|
|
114
|
-
Name of the block if it is a template.
|
|
115
|
-
|
|
116
|
-
is_template : typing.Optional[bool]
|
|
117
|
-
|
|
118
|
-
description : typing.Optional[str]
|
|
119
|
-
Description of the block.
|
|
120
|
-
|
|
121
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
122
|
-
Metadata of the block.
|
|
123
|
-
|
|
124
|
-
request_options : typing.Optional[RequestOptions]
|
|
125
|
-
Request-specific configuration.
|
|
126
|
-
|
|
127
|
-
Returns
|
|
128
|
-
-------
|
|
129
|
-
Memory
|
|
130
|
-
Successful Response
|
|
131
|
-
|
|
132
|
-
Examples
|
|
133
|
-
--------
|
|
134
|
-
from letta import Letta
|
|
135
|
-
|
|
136
|
-
client = Letta(
|
|
137
|
-
token="YOUR_TOKEN",
|
|
138
|
-
)
|
|
139
|
-
client.agents.memory_blocks.add(
|
|
140
|
-
agent_id="agent_id",
|
|
141
|
-
value="value",
|
|
142
|
-
label="label",
|
|
143
|
-
)
|
|
144
|
-
"""
|
|
145
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
146
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
|
|
147
|
-
method="POST",
|
|
148
|
-
json={
|
|
149
|
-
"value": value,
|
|
150
|
-
"limit": limit,
|
|
151
|
-
"name": name,
|
|
152
|
-
"is_template": is_template,
|
|
153
|
-
"label": label,
|
|
154
|
-
"description": description,
|
|
155
|
-
"metadata_": metadata,
|
|
156
|
-
},
|
|
157
|
-
request_options=request_options,
|
|
158
|
-
omit=OMIT,
|
|
159
|
-
)
|
|
160
|
-
try:
|
|
161
|
-
if 200 <= _response.status_code < 300:
|
|
162
|
-
return typing.cast(
|
|
163
|
-
Memory,
|
|
164
|
-
parse_obj_as(
|
|
165
|
-
type_=Memory, # type: ignore
|
|
166
|
-
object_=_response.json(),
|
|
167
|
-
),
|
|
168
|
-
)
|
|
169
|
-
if _response.status_code == 422:
|
|
170
|
-
raise UnprocessableEntityError(
|
|
171
|
-
typing.cast(
|
|
172
|
-
HttpValidationError,
|
|
173
|
-
parse_obj_as(
|
|
174
|
-
type_=HttpValidationError, # type: ignore
|
|
175
|
-
object_=_response.json(),
|
|
176
|
-
),
|
|
177
|
-
)
|
|
178
|
-
)
|
|
179
|
-
_response_json = _response.json()
|
|
180
|
-
except JSONDecodeError:
|
|
181
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
182
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
class AsyncMemoryBlocksClient:
|
|
186
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
187
|
-
self._client_wrapper = client_wrapper
|
|
188
|
-
|
|
189
|
-
async def remove(
|
|
190
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
191
|
-
) -> Memory:
|
|
192
|
-
"""
|
|
193
|
-
Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
|
|
194
|
-
|
|
195
|
-
Parameters
|
|
196
|
-
----------
|
|
197
|
-
agent_id : str
|
|
198
|
-
|
|
199
|
-
block_label : str
|
|
200
|
-
|
|
201
|
-
request_options : typing.Optional[RequestOptions]
|
|
202
|
-
Request-specific configuration.
|
|
203
|
-
|
|
204
|
-
Returns
|
|
205
|
-
-------
|
|
206
|
-
Memory
|
|
207
|
-
Successful Response
|
|
208
|
-
|
|
209
|
-
Examples
|
|
210
|
-
--------
|
|
211
|
-
import asyncio
|
|
212
|
-
|
|
213
|
-
from letta import AsyncLetta
|
|
214
|
-
|
|
215
|
-
client = AsyncLetta(
|
|
216
|
-
token="YOUR_TOKEN",
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
async def main() -> None:
|
|
221
|
-
await client.agents.memory_blocks.remove(
|
|
222
|
-
agent_id="agent_id",
|
|
223
|
-
block_label="block_label",
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
asyncio.run(main())
|
|
228
|
-
"""
|
|
229
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
230
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
|
|
231
|
-
method="DELETE",
|
|
232
|
-
request_options=request_options,
|
|
233
|
-
)
|
|
234
|
-
try:
|
|
235
|
-
if 200 <= _response.status_code < 300:
|
|
236
|
-
return typing.cast(
|
|
237
|
-
Memory,
|
|
238
|
-
parse_obj_as(
|
|
239
|
-
type_=Memory, # type: ignore
|
|
240
|
-
object_=_response.json(),
|
|
241
|
-
),
|
|
242
|
-
)
|
|
243
|
-
if _response.status_code == 422:
|
|
244
|
-
raise UnprocessableEntityError(
|
|
245
|
-
typing.cast(
|
|
246
|
-
HttpValidationError,
|
|
247
|
-
parse_obj_as(
|
|
248
|
-
type_=HttpValidationError, # type: ignore
|
|
249
|
-
object_=_response.json(),
|
|
250
|
-
),
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
_response_json = _response.json()
|
|
254
|
-
except JSONDecodeError:
|
|
255
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
256
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
257
|
-
|
|
258
|
-
async def add(
|
|
259
|
-
self,
|
|
260
|
-
agent_id: str,
|
|
261
|
-
*,
|
|
262
|
-
value: str,
|
|
263
|
-
label: str,
|
|
264
|
-
limit: typing.Optional[int] = OMIT,
|
|
265
|
-
name: typing.Optional[str] = OMIT,
|
|
266
|
-
is_template: typing.Optional[bool] = OMIT,
|
|
267
|
-
description: typing.Optional[str] = OMIT,
|
|
268
|
-
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
269
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
270
|
-
) -> Memory:
|
|
271
|
-
"""
|
|
272
|
-
Creates a memory block and links it to the agent.
|
|
273
|
-
|
|
274
|
-
Parameters
|
|
275
|
-
----------
|
|
276
|
-
agent_id : str
|
|
277
|
-
|
|
278
|
-
value : str
|
|
279
|
-
Value of the block.
|
|
280
|
-
|
|
281
|
-
label : str
|
|
282
|
-
Label of the block.
|
|
283
|
-
|
|
284
|
-
limit : typing.Optional[int]
|
|
285
|
-
Character limit of the block.
|
|
286
|
-
|
|
287
|
-
name : typing.Optional[str]
|
|
288
|
-
Name of the block if it is a template.
|
|
289
|
-
|
|
290
|
-
is_template : typing.Optional[bool]
|
|
291
|
-
|
|
292
|
-
description : typing.Optional[str]
|
|
293
|
-
Description of the block.
|
|
294
|
-
|
|
295
|
-
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
296
|
-
Metadata of the block.
|
|
297
|
-
|
|
298
|
-
request_options : typing.Optional[RequestOptions]
|
|
299
|
-
Request-specific configuration.
|
|
300
|
-
|
|
301
|
-
Returns
|
|
302
|
-
-------
|
|
303
|
-
Memory
|
|
304
|
-
Successful Response
|
|
305
|
-
|
|
306
|
-
Examples
|
|
307
|
-
--------
|
|
308
|
-
import asyncio
|
|
309
|
-
|
|
310
|
-
from letta import AsyncLetta
|
|
311
|
-
|
|
312
|
-
client = AsyncLetta(
|
|
313
|
-
token="YOUR_TOKEN",
|
|
314
|
-
)
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
async def main() -> None:
|
|
318
|
-
await client.agents.memory_blocks.add(
|
|
319
|
-
agent_id="agent_id",
|
|
320
|
-
value="value",
|
|
321
|
-
label="label",
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
asyncio.run(main())
|
|
326
|
-
"""
|
|
327
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
328
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
|
|
329
|
-
method="POST",
|
|
330
|
-
json={
|
|
331
|
-
"value": value,
|
|
332
|
-
"limit": limit,
|
|
333
|
-
"name": name,
|
|
334
|
-
"is_template": is_template,
|
|
335
|
-
"label": label,
|
|
336
|
-
"description": description,
|
|
337
|
-
"metadata_": metadata,
|
|
338
|
-
},
|
|
339
|
-
request_options=request_options,
|
|
340
|
-
omit=OMIT,
|
|
341
|
-
)
|
|
342
|
-
try:
|
|
343
|
-
if 200 <= _response.status_code < 300:
|
|
344
|
-
return typing.cast(
|
|
345
|
-
Memory,
|
|
346
|
-
parse_obj_as(
|
|
347
|
-
type_=Memory, # type: ignore
|
|
348
|
-
object_=_response.json(),
|
|
349
|
-
),
|
|
350
|
-
)
|
|
351
|
-
if _response.status_code == 422:
|
|
352
|
-
raise UnprocessableEntityError(
|
|
353
|
-
typing.cast(
|
|
354
|
-
HttpValidationError,
|
|
355
|
-
parse_obj_as(
|
|
356
|
-
type_=HttpValidationError, # type: ignore
|
|
357
|
-
object_=_response.json(),
|
|
358
|
-
),
|
|
359
|
-
)
|
|
360
|
-
)
|
|
361
|
-
_response_json = _response.json()
|
|
362
|
-
except JSONDecodeError:
|
|
363
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
364
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
]
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|