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,876 @@
|
|
|
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.run import Run
|
|
7
|
+
from ..core.unchecked_base_model import construct_type
|
|
8
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
9
|
+
from ..types.http_validation_error import HttpValidationError
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ..core.api_error import ApiError
|
|
12
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
13
|
+
import datetime as dt
|
|
14
|
+
from ..types.message_role import MessageRole
|
|
15
|
+
from ..types.letta_schemas_message_message import LettaSchemasMessageMessage
|
|
16
|
+
from ..core.datetime_utils import serialize_datetime
|
|
17
|
+
from ..types.usage_statistics import UsageStatistics
|
|
18
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class RunsClient:
|
|
22
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
|
+
self._client_wrapper = client_wrapper
|
|
24
|
+
|
|
25
|
+
def list_runs(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Run]:
|
|
26
|
+
"""
|
|
27
|
+
List all runs.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
request_options : typing.Optional[RequestOptions]
|
|
32
|
+
Request-specific configuration.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
typing.List[Run]
|
|
37
|
+
Successful Response
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
from letta_client import Letta
|
|
42
|
+
|
|
43
|
+
client = Letta(
|
|
44
|
+
token="YOUR_TOKEN",
|
|
45
|
+
)
|
|
46
|
+
client.runs.list_runs()
|
|
47
|
+
"""
|
|
48
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
49
|
+
"v1/runs/",
|
|
50
|
+
method="GET",
|
|
51
|
+
request_options=request_options,
|
|
52
|
+
)
|
|
53
|
+
try:
|
|
54
|
+
if 200 <= _response.status_code < 300:
|
|
55
|
+
return typing.cast(
|
|
56
|
+
typing.List[Run],
|
|
57
|
+
construct_type(
|
|
58
|
+
type_=typing.List[Run], # type: ignore
|
|
59
|
+
object_=_response.json(),
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
if _response.status_code == 422:
|
|
63
|
+
raise UnprocessableEntityError(
|
|
64
|
+
typing.cast(
|
|
65
|
+
HttpValidationError,
|
|
66
|
+
construct_type(
|
|
67
|
+
type_=HttpValidationError, # type: ignore
|
|
68
|
+
object_=_response.json(),
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
_response_json = _response.json()
|
|
73
|
+
except JSONDecodeError:
|
|
74
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
75
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
76
|
+
|
|
77
|
+
def list_active_runs(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Run]:
|
|
78
|
+
"""
|
|
79
|
+
List all active runs.
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
request_options : typing.Optional[RequestOptions]
|
|
84
|
+
Request-specific configuration.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
typing.List[Run]
|
|
89
|
+
Successful Response
|
|
90
|
+
|
|
91
|
+
Examples
|
|
92
|
+
--------
|
|
93
|
+
from letta_client import Letta
|
|
94
|
+
|
|
95
|
+
client = Letta(
|
|
96
|
+
token="YOUR_TOKEN",
|
|
97
|
+
)
|
|
98
|
+
client.runs.list_active_runs()
|
|
99
|
+
"""
|
|
100
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
101
|
+
"v1/runs/active",
|
|
102
|
+
method="GET",
|
|
103
|
+
request_options=request_options,
|
|
104
|
+
)
|
|
105
|
+
try:
|
|
106
|
+
if 200 <= _response.status_code < 300:
|
|
107
|
+
return typing.cast(
|
|
108
|
+
typing.List[Run],
|
|
109
|
+
construct_type(
|
|
110
|
+
type_=typing.List[Run], # type: ignore
|
|
111
|
+
object_=_response.json(),
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
if _response.status_code == 422:
|
|
115
|
+
raise UnprocessableEntityError(
|
|
116
|
+
typing.cast(
|
|
117
|
+
HttpValidationError,
|
|
118
|
+
construct_type(
|
|
119
|
+
type_=HttpValidationError, # type: ignore
|
|
120
|
+
object_=_response.json(),
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
_response_json = _response.json()
|
|
125
|
+
except JSONDecodeError:
|
|
126
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
127
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
128
|
+
|
|
129
|
+
def get_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
130
|
+
"""
|
|
131
|
+
Get the status of a run.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
run_id : str
|
|
136
|
+
|
|
137
|
+
request_options : typing.Optional[RequestOptions]
|
|
138
|
+
Request-specific configuration.
|
|
139
|
+
|
|
140
|
+
Returns
|
|
141
|
+
-------
|
|
142
|
+
Run
|
|
143
|
+
Successful Response
|
|
144
|
+
|
|
145
|
+
Examples
|
|
146
|
+
--------
|
|
147
|
+
from letta_client import Letta
|
|
148
|
+
|
|
149
|
+
client = Letta(
|
|
150
|
+
token="YOUR_TOKEN",
|
|
151
|
+
)
|
|
152
|
+
client.runs.get_run(
|
|
153
|
+
run_id="run_id",
|
|
154
|
+
)
|
|
155
|
+
"""
|
|
156
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
157
|
+
f"v1/runs/{jsonable_encoder(run_id)}",
|
|
158
|
+
method="GET",
|
|
159
|
+
request_options=request_options,
|
|
160
|
+
)
|
|
161
|
+
try:
|
|
162
|
+
if 200 <= _response.status_code < 300:
|
|
163
|
+
return typing.cast(
|
|
164
|
+
Run,
|
|
165
|
+
construct_type(
|
|
166
|
+
type_=Run, # type: ignore
|
|
167
|
+
object_=_response.json(),
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
if _response.status_code == 422:
|
|
171
|
+
raise UnprocessableEntityError(
|
|
172
|
+
typing.cast(
|
|
173
|
+
HttpValidationError,
|
|
174
|
+
construct_type(
|
|
175
|
+
type_=HttpValidationError, # type: ignore
|
|
176
|
+
object_=_response.json(),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
_response_json = _response.json()
|
|
181
|
+
except JSONDecodeError:
|
|
182
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
183
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
184
|
+
|
|
185
|
+
def delete_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
186
|
+
"""
|
|
187
|
+
Delete a run by its run_id.
|
|
188
|
+
|
|
189
|
+
Parameters
|
|
190
|
+
----------
|
|
191
|
+
run_id : str
|
|
192
|
+
|
|
193
|
+
request_options : typing.Optional[RequestOptions]
|
|
194
|
+
Request-specific configuration.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
Run
|
|
199
|
+
Successful Response
|
|
200
|
+
|
|
201
|
+
Examples
|
|
202
|
+
--------
|
|
203
|
+
from letta_client import Letta
|
|
204
|
+
|
|
205
|
+
client = Letta(
|
|
206
|
+
token="YOUR_TOKEN",
|
|
207
|
+
)
|
|
208
|
+
client.runs.delete_run(
|
|
209
|
+
run_id="run_id",
|
|
210
|
+
)
|
|
211
|
+
"""
|
|
212
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
213
|
+
f"v1/runs/{jsonable_encoder(run_id)}",
|
|
214
|
+
method="DELETE",
|
|
215
|
+
request_options=request_options,
|
|
216
|
+
)
|
|
217
|
+
try:
|
|
218
|
+
if 200 <= _response.status_code < 300:
|
|
219
|
+
return typing.cast(
|
|
220
|
+
Run,
|
|
221
|
+
construct_type(
|
|
222
|
+
type_=Run, # type: ignore
|
|
223
|
+
object_=_response.json(),
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
if _response.status_code == 422:
|
|
227
|
+
raise UnprocessableEntityError(
|
|
228
|
+
typing.cast(
|
|
229
|
+
HttpValidationError,
|
|
230
|
+
construct_type(
|
|
231
|
+
type_=HttpValidationError, # type: ignore
|
|
232
|
+
object_=_response.json(),
|
|
233
|
+
),
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
_response_json = _response.json()
|
|
237
|
+
except JSONDecodeError:
|
|
238
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
239
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
240
|
+
|
|
241
|
+
def get_run_messages(
|
|
242
|
+
self,
|
|
243
|
+
run_id: str,
|
|
244
|
+
*,
|
|
245
|
+
cursor: typing.Optional[str] = None,
|
|
246
|
+
start_date: typing.Optional[dt.datetime] = None,
|
|
247
|
+
end_date: typing.Optional[dt.datetime] = None,
|
|
248
|
+
limit: typing.Optional[int] = None,
|
|
249
|
+
query_text: typing.Optional[str] = None,
|
|
250
|
+
ascending: typing.Optional[bool] = None,
|
|
251
|
+
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
252
|
+
match_all_tags: typing.Optional[bool] = None,
|
|
253
|
+
role: typing.Optional[MessageRole] = None,
|
|
254
|
+
tool_name: typing.Optional[str] = None,
|
|
255
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
256
|
+
) -> typing.List[LettaSchemasMessageMessage]:
|
|
257
|
+
"""
|
|
258
|
+
Get messages associated with a run with filtering options.
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
run_id: ID of the run
|
|
262
|
+
cursor: Cursor for pagination
|
|
263
|
+
start_date: Filter messages after this date
|
|
264
|
+
end_date: Filter messages before this date
|
|
265
|
+
limit: Maximum number of messages to return
|
|
266
|
+
query_text: Search text in message content
|
|
267
|
+
ascending: Sort order by creation time
|
|
268
|
+
tags: Filter by message tags
|
|
269
|
+
match_all_tags: If true, match all tags. If false, match any tag
|
|
270
|
+
role: Filter by message role (user/assistant/system/tool)
|
|
271
|
+
tool_name: Filter by tool call name
|
|
272
|
+
user_id: ID of the user making the request
|
|
273
|
+
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
run_id : str
|
|
277
|
+
|
|
278
|
+
cursor : typing.Optional[str]
|
|
279
|
+
Cursor for pagination
|
|
280
|
+
|
|
281
|
+
start_date : typing.Optional[dt.datetime]
|
|
282
|
+
Filter messages after this date
|
|
283
|
+
|
|
284
|
+
end_date : typing.Optional[dt.datetime]
|
|
285
|
+
Filter messages before this date
|
|
286
|
+
|
|
287
|
+
limit : typing.Optional[int]
|
|
288
|
+
Maximum number of messages to return
|
|
289
|
+
|
|
290
|
+
query_text : typing.Optional[str]
|
|
291
|
+
Search text in message content
|
|
292
|
+
|
|
293
|
+
ascending : typing.Optional[bool]
|
|
294
|
+
Sort order by creation time
|
|
295
|
+
|
|
296
|
+
tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
297
|
+
Filter by message tags
|
|
298
|
+
|
|
299
|
+
match_all_tags : typing.Optional[bool]
|
|
300
|
+
If true, match all tags. If false, match any tag
|
|
301
|
+
|
|
302
|
+
role : typing.Optional[MessageRole]
|
|
303
|
+
Filter by message role
|
|
304
|
+
|
|
305
|
+
tool_name : typing.Optional[str]
|
|
306
|
+
Filter by tool call name
|
|
307
|
+
|
|
308
|
+
request_options : typing.Optional[RequestOptions]
|
|
309
|
+
Request-specific configuration.
|
|
310
|
+
|
|
311
|
+
Returns
|
|
312
|
+
-------
|
|
313
|
+
typing.List[LettaSchemasMessageMessage]
|
|
314
|
+
Successful Response
|
|
315
|
+
|
|
316
|
+
Examples
|
|
317
|
+
--------
|
|
318
|
+
from letta_client import Letta
|
|
319
|
+
|
|
320
|
+
client = Letta(
|
|
321
|
+
token="YOUR_TOKEN",
|
|
322
|
+
)
|
|
323
|
+
client.runs.get_run_messages(
|
|
324
|
+
run_id="run_id",
|
|
325
|
+
)
|
|
326
|
+
"""
|
|
327
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
328
|
+
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
329
|
+
method="GET",
|
|
330
|
+
params={
|
|
331
|
+
"cursor": cursor,
|
|
332
|
+
"start_date": serialize_datetime(start_date) if start_date is not None else None,
|
|
333
|
+
"end_date": serialize_datetime(end_date) if end_date is not None else None,
|
|
334
|
+
"limit": limit,
|
|
335
|
+
"query_text": query_text,
|
|
336
|
+
"ascending": ascending,
|
|
337
|
+
"tags": tags,
|
|
338
|
+
"match_all_tags": match_all_tags,
|
|
339
|
+
"role": role,
|
|
340
|
+
"tool_name": tool_name,
|
|
341
|
+
},
|
|
342
|
+
request_options=request_options,
|
|
343
|
+
)
|
|
344
|
+
try:
|
|
345
|
+
if 200 <= _response.status_code < 300:
|
|
346
|
+
return typing.cast(
|
|
347
|
+
typing.List[LettaSchemasMessageMessage],
|
|
348
|
+
construct_type(
|
|
349
|
+
type_=typing.List[LettaSchemasMessageMessage], # type: ignore
|
|
350
|
+
object_=_response.json(),
|
|
351
|
+
),
|
|
352
|
+
)
|
|
353
|
+
if _response.status_code == 422:
|
|
354
|
+
raise UnprocessableEntityError(
|
|
355
|
+
typing.cast(
|
|
356
|
+
HttpValidationError,
|
|
357
|
+
construct_type(
|
|
358
|
+
type_=HttpValidationError, # type: ignore
|
|
359
|
+
object_=_response.json(),
|
|
360
|
+
),
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
_response_json = _response.json()
|
|
364
|
+
except JSONDecodeError:
|
|
365
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
366
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
367
|
+
|
|
368
|
+
def get_run_usage(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> UsageStatistics:
|
|
369
|
+
"""
|
|
370
|
+
Get usage statistics for a run.
|
|
371
|
+
|
|
372
|
+
Parameters
|
|
373
|
+
----------
|
|
374
|
+
run_id : str
|
|
375
|
+
|
|
376
|
+
request_options : typing.Optional[RequestOptions]
|
|
377
|
+
Request-specific configuration.
|
|
378
|
+
|
|
379
|
+
Returns
|
|
380
|
+
-------
|
|
381
|
+
UsageStatistics
|
|
382
|
+
Successful Response
|
|
383
|
+
|
|
384
|
+
Examples
|
|
385
|
+
--------
|
|
386
|
+
from letta_client import Letta
|
|
387
|
+
|
|
388
|
+
client = Letta(
|
|
389
|
+
token="YOUR_TOKEN",
|
|
390
|
+
)
|
|
391
|
+
client.runs.get_run_usage(
|
|
392
|
+
run_id="run_id",
|
|
393
|
+
)
|
|
394
|
+
"""
|
|
395
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
396
|
+
f"v1/runs/{jsonable_encoder(run_id)}/usage",
|
|
397
|
+
method="GET",
|
|
398
|
+
request_options=request_options,
|
|
399
|
+
)
|
|
400
|
+
try:
|
|
401
|
+
if 200 <= _response.status_code < 300:
|
|
402
|
+
return typing.cast(
|
|
403
|
+
UsageStatistics,
|
|
404
|
+
construct_type(
|
|
405
|
+
type_=UsageStatistics, # type: ignore
|
|
406
|
+
object_=_response.json(),
|
|
407
|
+
),
|
|
408
|
+
)
|
|
409
|
+
if _response.status_code == 422:
|
|
410
|
+
raise UnprocessableEntityError(
|
|
411
|
+
typing.cast(
|
|
412
|
+
HttpValidationError,
|
|
413
|
+
construct_type(
|
|
414
|
+
type_=HttpValidationError, # type: ignore
|
|
415
|
+
object_=_response.json(),
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
)
|
|
419
|
+
_response_json = _response.json()
|
|
420
|
+
except JSONDecodeError:
|
|
421
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
422
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
class AsyncRunsClient:
|
|
426
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
427
|
+
self._client_wrapper = client_wrapper
|
|
428
|
+
|
|
429
|
+
async def list_runs(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Run]:
|
|
430
|
+
"""
|
|
431
|
+
List all runs.
|
|
432
|
+
|
|
433
|
+
Parameters
|
|
434
|
+
----------
|
|
435
|
+
request_options : typing.Optional[RequestOptions]
|
|
436
|
+
Request-specific configuration.
|
|
437
|
+
|
|
438
|
+
Returns
|
|
439
|
+
-------
|
|
440
|
+
typing.List[Run]
|
|
441
|
+
Successful Response
|
|
442
|
+
|
|
443
|
+
Examples
|
|
444
|
+
--------
|
|
445
|
+
import asyncio
|
|
446
|
+
|
|
447
|
+
from letta_client import AsyncLetta
|
|
448
|
+
|
|
449
|
+
client = AsyncLetta(
|
|
450
|
+
token="YOUR_TOKEN",
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
async def main() -> None:
|
|
455
|
+
await client.runs.list_runs()
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
asyncio.run(main())
|
|
459
|
+
"""
|
|
460
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
461
|
+
"v1/runs/",
|
|
462
|
+
method="GET",
|
|
463
|
+
request_options=request_options,
|
|
464
|
+
)
|
|
465
|
+
try:
|
|
466
|
+
if 200 <= _response.status_code < 300:
|
|
467
|
+
return typing.cast(
|
|
468
|
+
typing.List[Run],
|
|
469
|
+
construct_type(
|
|
470
|
+
type_=typing.List[Run], # type: ignore
|
|
471
|
+
object_=_response.json(),
|
|
472
|
+
),
|
|
473
|
+
)
|
|
474
|
+
if _response.status_code == 422:
|
|
475
|
+
raise UnprocessableEntityError(
|
|
476
|
+
typing.cast(
|
|
477
|
+
HttpValidationError,
|
|
478
|
+
construct_type(
|
|
479
|
+
type_=HttpValidationError, # type: ignore
|
|
480
|
+
object_=_response.json(),
|
|
481
|
+
),
|
|
482
|
+
)
|
|
483
|
+
)
|
|
484
|
+
_response_json = _response.json()
|
|
485
|
+
except JSONDecodeError:
|
|
486
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
487
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
488
|
+
|
|
489
|
+
async def list_active_runs(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Run]:
|
|
490
|
+
"""
|
|
491
|
+
List all active runs.
|
|
492
|
+
|
|
493
|
+
Parameters
|
|
494
|
+
----------
|
|
495
|
+
request_options : typing.Optional[RequestOptions]
|
|
496
|
+
Request-specific configuration.
|
|
497
|
+
|
|
498
|
+
Returns
|
|
499
|
+
-------
|
|
500
|
+
typing.List[Run]
|
|
501
|
+
Successful Response
|
|
502
|
+
|
|
503
|
+
Examples
|
|
504
|
+
--------
|
|
505
|
+
import asyncio
|
|
506
|
+
|
|
507
|
+
from letta_client import AsyncLetta
|
|
508
|
+
|
|
509
|
+
client = AsyncLetta(
|
|
510
|
+
token="YOUR_TOKEN",
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
async def main() -> None:
|
|
515
|
+
await client.runs.list_active_runs()
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
asyncio.run(main())
|
|
519
|
+
"""
|
|
520
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
521
|
+
"v1/runs/active",
|
|
522
|
+
method="GET",
|
|
523
|
+
request_options=request_options,
|
|
524
|
+
)
|
|
525
|
+
try:
|
|
526
|
+
if 200 <= _response.status_code < 300:
|
|
527
|
+
return typing.cast(
|
|
528
|
+
typing.List[Run],
|
|
529
|
+
construct_type(
|
|
530
|
+
type_=typing.List[Run], # type: ignore
|
|
531
|
+
object_=_response.json(),
|
|
532
|
+
),
|
|
533
|
+
)
|
|
534
|
+
if _response.status_code == 422:
|
|
535
|
+
raise UnprocessableEntityError(
|
|
536
|
+
typing.cast(
|
|
537
|
+
HttpValidationError,
|
|
538
|
+
construct_type(
|
|
539
|
+
type_=HttpValidationError, # type: ignore
|
|
540
|
+
object_=_response.json(),
|
|
541
|
+
),
|
|
542
|
+
)
|
|
543
|
+
)
|
|
544
|
+
_response_json = _response.json()
|
|
545
|
+
except JSONDecodeError:
|
|
546
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
547
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
548
|
+
|
|
549
|
+
async def get_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
550
|
+
"""
|
|
551
|
+
Get the status of a run.
|
|
552
|
+
|
|
553
|
+
Parameters
|
|
554
|
+
----------
|
|
555
|
+
run_id : str
|
|
556
|
+
|
|
557
|
+
request_options : typing.Optional[RequestOptions]
|
|
558
|
+
Request-specific configuration.
|
|
559
|
+
|
|
560
|
+
Returns
|
|
561
|
+
-------
|
|
562
|
+
Run
|
|
563
|
+
Successful Response
|
|
564
|
+
|
|
565
|
+
Examples
|
|
566
|
+
--------
|
|
567
|
+
import asyncio
|
|
568
|
+
|
|
569
|
+
from letta_client import AsyncLetta
|
|
570
|
+
|
|
571
|
+
client = AsyncLetta(
|
|
572
|
+
token="YOUR_TOKEN",
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
async def main() -> None:
|
|
577
|
+
await client.runs.get_run(
|
|
578
|
+
run_id="run_id",
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
asyncio.run(main())
|
|
583
|
+
"""
|
|
584
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
585
|
+
f"v1/runs/{jsonable_encoder(run_id)}",
|
|
586
|
+
method="GET",
|
|
587
|
+
request_options=request_options,
|
|
588
|
+
)
|
|
589
|
+
try:
|
|
590
|
+
if 200 <= _response.status_code < 300:
|
|
591
|
+
return typing.cast(
|
|
592
|
+
Run,
|
|
593
|
+
construct_type(
|
|
594
|
+
type_=Run, # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
)
|
|
598
|
+
if _response.status_code == 422:
|
|
599
|
+
raise UnprocessableEntityError(
|
|
600
|
+
typing.cast(
|
|
601
|
+
HttpValidationError,
|
|
602
|
+
construct_type(
|
|
603
|
+
type_=HttpValidationError, # type: ignore
|
|
604
|
+
object_=_response.json(),
|
|
605
|
+
),
|
|
606
|
+
)
|
|
607
|
+
)
|
|
608
|
+
_response_json = _response.json()
|
|
609
|
+
except JSONDecodeError:
|
|
610
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
611
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
612
|
+
|
|
613
|
+
async def delete_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
614
|
+
"""
|
|
615
|
+
Delete a run by its run_id.
|
|
616
|
+
|
|
617
|
+
Parameters
|
|
618
|
+
----------
|
|
619
|
+
run_id : str
|
|
620
|
+
|
|
621
|
+
request_options : typing.Optional[RequestOptions]
|
|
622
|
+
Request-specific configuration.
|
|
623
|
+
|
|
624
|
+
Returns
|
|
625
|
+
-------
|
|
626
|
+
Run
|
|
627
|
+
Successful Response
|
|
628
|
+
|
|
629
|
+
Examples
|
|
630
|
+
--------
|
|
631
|
+
import asyncio
|
|
632
|
+
|
|
633
|
+
from letta_client import AsyncLetta
|
|
634
|
+
|
|
635
|
+
client = AsyncLetta(
|
|
636
|
+
token="YOUR_TOKEN",
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
async def main() -> None:
|
|
641
|
+
await client.runs.delete_run(
|
|
642
|
+
run_id="run_id",
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
asyncio.run(main())
|
|
647
|
+
"""
|
|
648
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
649
|
+
f"v1/runs/{jsonable_encoder(run_id)}",
|
|
650
|
+
method="DELETE",
|
|
651
|
+
request_options=request_options,
|
|
652
|
+
)
|
|
653
|
+
try:
|
|
654
|
+
if 200 <= _response.status_code < 300:
|
|
655
|
+
return typing.cast(
|
|
656
|
+
Run,
|
|
657
|
+
construct_type(
|
|
658
|
+
type_=Run, # type: ignore
|
|
659
|
+
object_=_response.json(),
|
|
660
|
+
),
|
|
661
|
+
)
|
|
662
|
+
if _response.status_code == 422:
|
|
663
|
+
raise UnprocessableEntityError(
|
|
664
|
+
typing.cast(
|
|
665
|
+
HttpValidationError,
|
|
666
|
+
construct_type(
|
|
667
|
+
type_=HttpValidationError, # type: ignore
|
|
668
|
+
object_=_response.json(),
|
|
669
|
+
),
|
|
670
|
+
)
|
|
671
|
+
)
|
|
672
|
+
_response_json = _response.json()
|
|
673
|
+
except JSONDecodeError:
|
|
674
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
675
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
676
|
+
|
|
677
|
+
async def get_run_messages(
|
|
678
|
+
self,
|
|
679
|
+
run_id: str,
|
|
680
|
+
*,
|
|
681
|
+
cursor: typing.Optional[str] = None,
|
|
682
|
+
start_date: typing.Optional[dt.datetime] = None,
|
|
683
|
+
end_date: typing.Optional[dt.datetime] = None,
|
|
684
|
+
limit: typing.Optional[int] = None,
|
|
685
|
+
query_text: typing.Optional[str] = None,
|
|
686
|
+
ascending: typing.Optional[bool] = None,
|
|
687
|
+
tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
688
|
+
match_all_tags: typing.Optional[bool] = None,
|
|
689
|
+
role: typing.Optional[MessageRole] = None,
|
|
690
|
+
tool_name: typing.Optional[str] = None,
|
|
691
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
692
|
+
) -> typing.List[LettaSchemasMessageMessage]:
|
|
693
|
+
"""
|
|
694
|
+
Get messages associated with a run with filtering options.
|
|
695
|
+
|
|
696
|
+
Args:
|
|
697
|
+
run_id: ID of the run
|
|
698
|
+
cursor: Cursor for pagination
|
|
699
|
+
start_date: Filter messages after this date
|
|
700
|
+
end_date: Filter messages before this date
|
|
701
|
+
limit: Maximum number of messages to return
|
|
702
|
+
query_text: Search text in message content
|
|
703
|
+
ascending: Sort order by creation time
|
|
704
|
+
tags: Filter by message tags
|
|
705
|
+
match_all_tags: If true, match all tags. If false, match any tag
|
|
706
|
+
role: Filter by message role (user/assistant/system/tool)
|
|
707
|
+
tool_name: Filter by tool call name
|
|
708
|
+
user_id: ID of the user making the request
|
|
709
|
+
|
|
710
|
+
Parameters
|
|
711
|
+
----------
|
|
712
|
+
run_id : str
|
|
713
|
+
|
|
714
|
+
cursor : typing.Optional[str]
|
|
715
|
+
Cursor for pagination
|
|
716
|
+
|
|
717
|
+
start_date : typing.Optional[dt.datetime]
|
|
718
|
+
Filter messages after this date
|
|
719
|
+
|
|
720
|
+
end_date : typing.Optional[dt.datetime]
|
|
721
|
+
Filter messages before this date
|
|
722
|
+
|
|
723
|
+
limit : typing.Optional[int]
|
|
724
|
+
Maximum number of messages to return
|
|
725
|
+
|
|
726
|
+
query_text : typing.Optional[str]
|
|
727
|
+
Search text in message content
|
|
728
|
+
|
|
729
|
+
ascending : typing.Optional[bool]
|
|
730
|
+
Sort order by creation time
|
|
731
|
+
|
|
732
|
+
tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
733
|
+
Filter by message tags
|
|
734
|
+
|
|
735
|
+
match_all_tags : typing.Optional[bool]
|
|
736
|
+
If true, match all tags. If false, match any tag
|
|
737
|
+
|
|
738
|
+
role : typing.Optional[MessageRole]
|
|
739
|
+
Filter by message role
|
|
740
|
+
|
|
741
|
+
tool_name : typing.Optional[str]
|
|
742
|
+
Filter by tool call name
|
|
743
|
+
|
|
744
|
+
request_options : typing.Optional[RequestOptions]
|
|
745
|
+
Request-specific configuration.
|
|
746
|
+
|
|
747
|
+
Returns
|
|
748
|
+
-------
|
|
749
|
+
typing.List[LettaSchemasMessageMessage]
|
|
750
|
+
Successful Response
|
|
751
|
+
|
|
752
|
+
Examples
|
|
753
|
+
--------
|
|
754
|
+
import asyncio
|
|
755
|
+
|
|
756
|
+
from letta_client import AsyncLetta
|
|
757
|
+
|
|
758
|
+
client = AsyncLetta(
|
|
759
|
+
token="YOUR_TOKEN",
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
async def main() -> None:
|
|
764
|
+
await client.runs.get_run_messages(
|
|
765
|
+
run_id="run_id",
|
|
766
|
+
)
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
asyncio.run(main())
|
|
770
|
+
"""
|
|
771
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
772
|
+
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
773
|
+
method="GET",
|
|
774
|
+
params={
|
|
775
|
+
"cursor": cursor,
|
|
776
|
+
"start_date": serialize_datetime(start_date) if start_date is not None else None,
|
|
777
|
+
"end_date": serialize_datetime(end_date) if end_date is not None else None,
|
|
778
|
+
"limit": limit,
|
|
779
|
+
"query_text": query_text,
|
|
780
|
+
"ascending": ascending,
|
|
781
|
+
"tags": tags,
|
|
782
|
+
"match_all_tags": match_all_tags,
|
|
783
|
+
"role": role,
|
|
784
|
+
"tool_name": tool_name,
|
|
785
|
+
},
|
|
786
|
+
request_options=request_options,
|
|
787
|
+
)
|
|
788
|
+
try:
|
|
789
|
+
if 200 <= _response.status_code < 300:
|
|
790
|
+
return typing.cast(
|
|
791
|
+
typing.List[LettaSchemasMessageMessage],
|
|
792
|
+
construct_type(
|
|
793
|
+
type_=typing.List[LettaSchemasMessageMessage], # type: ignore
|
|
794
|
+
object_=_response.json(),
|
|
795
|
+
),
|
|
796
|
+
)
|
|
797
|
+
if _response.status_code == 422:
|
|
798
|
+
raise UnprocessableEntityError(
|
|
799
|
+
typing.cast(
|
|
800
|
+
HttpValidationError,
|
|
801
|
+
construct_type(
|
|
802
|
+
type_=HttpValidationError, # type: ignore
|
|
803
|
+
object_=_response.json(),
|
|
804
|
+
),
|
|
805
|
+
)
|
|
806
|
+
)
|
|
807
|
+
_response_json = _response.json()
|
|
808
|
+
except JSONDecodeError:
|
|
809
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
810
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
811
|
+
|
|
812
|
+
async def get_run_usage(
|
|
813
|
+
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
814
|
+
) -> UsageStatistics:
|
|
815
|
+
"""
|
|
816
|
+
Get usage statistics for a run.
|
|
817
|
+
|
|
818
|
+
Parameters
|
|
819
|
+
----------
|
|
820
|
+
run_id : str
|
|
821
|
+
|
|
822
|
+
request_options : typing.Optional[RequestOptions]
|
|
823
|
+
Request-specific configuration.
|
|
824
|
+
|
|
825
|
+
Returns
|
|
826
|
+
-------
|
|
827
|
+
UsageStatistics
|
|
828
|
+
Successful Response
|
|
829
|
+
|
|
830
|
+
Examples
|
|
831
|
+
--------
|
|
832
|
+
import asyncio
|
|
833
|
+
|
|
834
|
+
from letta_client import AsyncLetta
|
|
835
|
+
|
|
836
|
+
client = AsyncLetta(
|
|
837
|
+
token="YOUR_TOKEN",
|
|
838
|
+
)
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
async def main() -> None:
|
|
842
|
+
await client.runs.get_run_usage(
|
|
843
|
+
run_id="run_id",
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
asyncio.run(main())
|
|
848
|
+
"""
|
|
849
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
850
|
+
f"v1/runs/{jsonable_encoder(run_id)}/usage",
|
|
851
|
+
method="GET",
|
|
852
|
+
request_options=request_options,
|
|
853
|
+
)
|
|
854
|
+
try:
|
|
855
|
+
if 200 <= _response.status_code < 300:
|
|
856
|
+
return typing.cast(
|
|
857
|
+
UsageStatistics,
|
|
858
|
+
construct_type(
|
|
859
|
+
type_=UsageStatistics, # type: ignore
|
|
860
|
+
object_=_response.json(),
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
if _response.status_code == 422:
|
|
864
|
+
raise UnprocessableEntityError(
|
|
865
|
+
typing.cast(
|
|
866
|
+
HttpValidationError,
|
|
867
|
+
construct_type(
|
|
868
|
+
type_=HttpValidationError, # type: ignore
|
|
869
|
+
object_=_response.json(),
|
|
870
|
+
),
|
|
871
|
+
)
|
|
872
|
+
)
|
|
873
|
+
_response_json = _response.json()
|
|
874
|
+
except JSONDecodeError:
|
|
875
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
876
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|