letta-nightly 0.6.8.dev20250109190338__py3-none-any.whl → 0.6.8.dev20250110190527__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-nightly might be problematic. Click here for more details.
- letta/agent.py +1 -2
- letta/constants.py +0 -1
- letta/orm/enums.py +6 -0
- letta/schemas/agent.py +0 -1
- letta/schemas/tool.py +3 -6
- letta/server/rest_api/routers/v1/sandbox_configs.py +2 -1
- letta/server/rest_api/routers/v1/tools.py +1 -0
- letta/server/server.py +7 -14
- letta/services/helpers/agent_manager_helper.py +0 -2
- letta/services/sandbox_config_manager.py +6 -7
- letta/services/tool_execution_sandbox.py +16 -6
- {letta_nightly-0.6.8.dev20250109190338.dist-info → letta_nightly-0.6.8.dev20250110190527.dist-info}/METADATA +1 -1
- {letta_nightly-0.6.8.dev20250109190338.dist-info → letta_nightly-0.6.8.dev20250110190527.dist-info}/RECORD +16 -17
- letta/o1_agent.py +0 -86
- {letta_nightly-0.6.8.dev20250109190338.dist-info → letta_nightly-0.6.8.dev20250110190527.dist-info}/LICENSE +0 -0
- {letta_nightly-0.6.8.dev20250109190338.dist-info → letta_nightly-0.6.8.dev20250110190527.dist-info}/WHEEL +0 -0
- {letta_nightly-0.6.8.dev20250109190338.dist-info → letta_nightly-0.6.8.dev20250110190527.dist-info}/entry_points.txt +0 -0
letta/agent.py
CHANGED
|
@@ -16,7 +16,6 @@ from letta.constants import (
|
|
|
16
16
|
MESSAGE_SUMMARY_TRUNC_KEEP_N_LAST,
|
|
17
17
|
MESSAGE_SUMMARY_TRUNC_TOKEN_FRAC,
|
|
18
18
|
MESSAGE_SUMMARY_WARNING_FRAC,
|
|
19
|
-
O1_BASE_TOOLS,
|
|
20
19
|
REQ_HEARTBEAT_MESSAGE,
|
|
21
20
|
)
|
|
22
21
|
from letta.errors import ContextWindowExceededError
|
|
@@ -212,7 +211,7 @@ class Agent(BaseAgent):
|
|
|
212
211
|
# TODO: This is NO BUENO
|
|
213
212
|
# TODO: Matching purely by names is extremely problematic, users can create tools with these names and run them in the agent loop
|
|
214
213
|
# TODO: We will have probably have to match the function strings exactly for safety
|
|
215
|
-
if function_name in BASE_TOOLS
|
|
214
|
+
if function_name in BASE_TOOLS:
|
|
216
215
|
# base tools are allowed to access the `Agent` object and run on the database
|
|
217
216
|
function_args["self"] = self # need to attach self to arg since it's dynamically linked
|
|
218
217
|
function_response = callable_func(**function_args)
|
letta/constants.py
CHANGED
|
@@ -42,7 +42,6 @@ DEFAULT_PRESET = "memgpt_chat"
|
|
|
42
42
|
# Base tools that cannot be edited, as they access agent state directly
|
|
43
43
|
# Note that we don't include "conversation_search_date" for now
|
|
44
44
|
BASE_TOOLS = ["send_message", "conversation_search", "archival_memory_insert", "archival_memory_search"]
|
|
45
|
-
O1_BASE_TOOLS = ["send_thinking_message", "send_final_message"]
|
|
46
45
|
# Base memory tools CAN be edited, and are added by default by the server
|
|
47
46
|
BASE_MEMORY_TOOLS = ["core_memory_append", "core_memory_replace"]
|
|
48
47
|
|
letta/orm/enums.py
CHANGED
letta/schemas/agent.py
CHANGED
letta/schemas/tool.py
CHANGED
|
@@ -206,19 +206,16 @@ class ToolUpdate(LettaBase):
|
|
|
206
206
|
json_schema: Optional[Dict] = Field(
|
|
207
207
|
None, description="The JSON schema of the function (auto-generated from source_code if not provided)"
|
|
208
208
|
)
|
|
209
|
+
return_char_limit: Optional[int] = Field(None, description="The maximum number of characters in the response.")
|
|
209
210
|
|
|
210
211
|
class Config:
|
|
211
212
|
extra = "ignore" # Allows extra fields without validation errors
|
|
212
213
|
# TODO: Remove this, and clean usage of ToolUpdate everywhere else
|
|
213
214
|
|
|
214
215
|
|
|
215
|
-
class ToolRun(LettaBase):
|
|
216
|
-
id: str = Field(..., description="The ID of the tool to run.")
|
|
217
|
-
args: str = Field(..., description="The arguments to pass to the tool (as stringified JSON).")
|
|
218
|
-
|
|
219
|
-
|
|
220
216
|
class ToolRunFromSource(LettaBase):
|
|
221
217
|
source_code: str = Field(..., description="The source code of the function.")
|
|
222
|
-
args: str = Field(..., description="The arguments to pass to the tool
|
|
218
|
+
args: Dict[str, str] = Field(..., description="The arguments to pass to the tool.")
|
|
219
|
+
env_vars: Dict[str, str] = Field(None, description="The environment variables to pass to the tool.")
|
|
223
220
|
name: Optional[str] = Field(None, description="The name of the tool to run.")
|
|
224
221
|
source_type: Optional[str] = Field(None, description="The type of the source code.")
|
|
@@ -69,11 +69,12 @@ def delete_sandbox_config(
|
|
|
69
69
|
def list_sandbox_configs(
|
|
70
70
|
limit: int = Query(1000, description="Number of results to return"),
|
|
71
71
|
cursor: Optional[str] = Query(None, description="Pagination cursor to fetch the next set of results"),
|
|
72
|
+
sandbox_type: Optional[SandboxType] = Query(None, description="Filter for this specific sandbox type"),
|
|
72
73
|
server: SyncServer = Depends(get_letta_server),
|
|
73
74
|
user_id: str = Depends(get_user_id),
|
|
74
75
|
):
|
|
75
76
|
actor = server.user_manager.get_user_or_default(user_id=user_id)
|
|
76
|
-
return server.sandbox_config_manager.list_sandbox_configs(actor, limit=limit, cursor=cursor)
|
|
77
|
+
return server.sandbox_config_manager.list_sandbox_configs(actor, limit=limit, cursor=cursor, sandbox_type=sandbox_type)
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
### Sandbox Environment Variable Routes
|
letta/server/server.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# inspecting tools
|
|
2
|
-
import json
|
|
3
2
|
import os
|
|
4
3
|
import traceback
|
|
5
4
|
import warnings
|
|
6
5
|
from abc import abstractmethod
|
|
7
6
|
from datetime import datetime
|
|
8
|
-
from typing import Callable, List, Optional, Tuple, Union
|
|
7
|
+
from typing import Callable, Dict, List, Optional, Tuple, Union
|
|
9
8
|
|
|
10
9
|
from composio.client import Composio
|
|
11
10
|
from composio.client.collections import ActionModel, AppModel
|
|
@@ -23,7 +22,6 @@ from letta.data_sources.connectors import DataConnector, load_data
|
|
|
23
22
|
from letta.interface import AgentInterface # abstract
|
|
24
23
|
from letta.interface import CLIInterface # for printing to terminal
|
|
25
24
|
from letta.log import get_logger
|
|
26
|
-
from letta.o1_agent import O1Agent
|
|
27
25
|
from letta.offline_memory_agent import OfflineMemoryAgent
|
|
28
26
|
from letta.orm import Base
|
|
29
27
|
from letta.orm.errors import NoResultFound
|
|
@@ -391,8 +389,6 @@ class SyncServer(Server):
|
|
|
391
389
|
interface = interface or self.default_interface_factory()
|
|
392
390
|
if agent_state.agent_type == AgentType.memgpt_agent:
|
|
393
391
|
agent = Agent(agent_state=agent_state, interface=interface, user=actor)
|
|
394
|
-
elif agent_state.agent_type == AgentType.o1_agent:
|
|
395
|
-
agent = O1Agent(agent_state=agent_state, interface=interface, user=actor)
|
|
396
392
|
elif agent_state.agent_type == AgentType.offline_memory_agent:
|
|
397
393
|
agent = OfflineMemoryAgent(agent_state=agent_state, interface=interface, user=actor)
|
|
398
394
|
elif agent_state.agent_type == AgentType.chat_only_agent:
|
|
@@ -1117,22 +1113,17 @@ class SyncServer(Server):
|
|
|
1117
1113
|
def run_tool_from_source(
|
|
1118
1114
|
self,
|
|
1119
1115
|
actor: User,
|
|
1120
|
-
tool_args: str,
|
|
1116
|
+
tool_args: Dict[str, str],
|
|
1121
1117
|
tool_source: str,
|
|
1118
|
+
tool_env_vars: Optional[Dict[str, str]] = None,
|
|
1122
1119
|
tool_source_type: Optional[str] = None,
|
|
1123
1120
|
tool_name: Optional[str] = None,
|
|
1124
1121
|
) -> ToolReturnMessage:
|
|
1125
1122
|
"""Run a tool from source code"""
|
|
1126
|
-
|
|
1127
|
-
try:
|
|
1128
|
-
tool_args_dict = json.loads(tool_args)
|
|
1129
|
-
except json.JSONDecodeError:
|
|
1130
|
-
raise ValueError("Invalid JSON string for tool_args")
|
|
1131
|
-
|
|
1132
1123
|
if tool_source_type is not None and tool_source_type != "python":
|
|
1133
1124
|
raise ValueError("Only Python source code is supported at this time")
|
|
1134
1125
|
|
|
1135
|
-
# NOTE: we're creating a floating Tool object and NOT
|
|
1126
|
+
# NOTE: we're creating a floating Tool object and NOT persisting to DB
|
|
1136
1127
|
tool = Tool(
|
|
1137
1128
|
name=tool_name,
|
|
1138
1129
|
source_code=tool_source,
|
|
@@ -1144,7 +1135,9 @@ class SyncServer(Server):
|
|
|
1144
1135
|
|
|
1145
1136
|
# Next, attempt to run the tool with the sandbox
|
|
1146
1137
|
try:
|
|
1147
|
-
sandbox_run_result = ToolExecutionSandbox(tool.name,
|
|
1138
|
+
sandbox_run_result = ToolExecutionSandbox(tool.name, tool_args, actor, tool_object=tool).run(
|
|
1139
|
+
agent_state=agent_state, additional_env_vars=tool_env_vars
|
|
1140
|
+
)
|
|
1148
1141
|
return ToolReturnMessage(
|
|
1149
1142
|
id="null",
|
|
1150
1143
|
tool_call_id="null",
|
|
@@ -89,8 +89,6 @@ def derive_system_message(agent_type: AgentType, system: Optional[str] = None):
|
|
|
89
89
|
# TODO: don't hardcode
|
|
90
90
|
if agent_type == AgentType.memgpt_agent:
|
|
91
91
|
system = gpt_system.get_system_text("memgpt_chat")
|
|
92
|
-
elif agent_type == AgentType.o1_agent:
|
|
93
|
-
system = gpt_system.get_system_text("memgpt_modified_o1")
|
|
94
92
|
elif agent_type == AgentType.offline_memory_agent:
|
|
95
93
|
system = gpt_system.get_system_text("memgpt_offline_memory")
|
|
96
94
|
elif agent_type == AgentType.chat_only_agent:
|
|
@@ -111,16 +111,15 @@ class SandboxConfigManager:
|
|
|
111
111
|
|
|
112
112
|
@enforce_types
|
|
113
113
|
def list_sandbox_configs(
|
|
114
|
-
self, actor: PydanticUser, cursor: Optional[str] = None, limit: Optional[int] = 50
|
|
114
|
+
self, actor: PydanticUser, cursor: Optional[str] = None, limit: Optional[int] = 50, sandbox_type: Optional[SandboxType] = None
|
|
115
115
|
) -> List[PydanticSandboxConfig]:
|
|
116
116
|
"""List all sandbox configurations with optional pagination."""
|
|
117
|
+
kwargs = {"organization_id": actor.organization_id}
|
|
118
|
+
if sandbox_type:
|
|
119
|
+
kwargs.update({"type": sandbox_type})
|
|
120
|
+
|
|
117
121
|
with self.session_maker() as session:
|
|
118
|
-
sandboxes = SandboxConfigModel.list(
|
|
119
|
-
db_session=session,
|
|
120
|
-
cursor=cursor,
|
|
121
|
-
limit=limit,
|
|
122
|
-
organization_id=actor.organization_id,
|
|
123
|
-
)
|
|
122
|
+
sandboxes = SandboxConfigModel.list(db_session=session, cursor=cursor, limit=limit, **kwargs)
|
|
124
123
|
return [sandbox.to_pydantic() for sandbox in sandboxes]
|
|
125
124
|
|
|
126
125
|
@enforce_types
|
|
@@ -59,22 +59,23 @@ class ToolExecutionSandbox:
|
|
|
59
59
|
self.sandbox_config_manager = SandboxConfigManager(tool_settings)
|
|
60
60
|
self.force_recreate = force_recreate
|
|
61
61
|
|
|
62
|
-
def run(self, agent_state: Optional[AgentState] = None) -> SandboxRunResult:
|
|
62
|
+
def run(self, agent_state: Optional[AgentState] = None, additional_env_vars: Optional[Dict] = None) -> SandboxRunResult:
|
|
63
63
|
"""
|
|
64
64
|
Run the tool in a sandbox environment.
|
|
65
65
|
|
|
66
66
|
Args:
|
|
67
67
|
agent_state (Optional[AgentState]): The state of the agent invoking the tool
|
|
68
|
+
additional_env_vars (Optional[Dict]): Environment variables to inject into the sandbox
|
|
68
69
|
|
|
69
70
|
Returns:
|
|
70
71
|
Tuple[Any, Optional[AgentState]]: Tuple containing (tool_result, agent_state)
|
|
71
72
|
"""
|
|
72
73
|
if tool_settings.e2b_api_key:
|
|
73
74
|
logger.debug(f"Using e2b sandbox to execute {self.tool_name}")
|
|
74
|
-
result = self.run_e2b_sandbox(agent_state=agent_state)
|
|
75
|
+
result = self.run_e2b_sandbox(agent_state=agent_state, additional_env_vars=additional_env_vars)
|
|
75
76
|
else:
|
|
76
77
|
logger.debug(f"Using local sandbox to execute {self.tool_name}")
|
|
77
|
-
result = self.run_local_dir_sandbox(agent_state=agent_state)
|
|
78
|
+
result = self.run_local_dir_sandbox(agent_state=agent_state, additional_env_vars=additional_env_vars)
|
|
78
79
|
|
|
79
80
|
# Log out any stdout/stderr from the tool run
|
|
80
81
|
logger.debug(f"Executed tool '{self.tool_name}', logging output from tool run: \n")
|
|
@@ -98,19 +99,25 @@ class ToolExecutionSandbox:
|
|
|
98
99
|
os.environ.clear()
|
|
99
100
|
os.environ.update(original_env) # Restore original environment variables
|
|
100
101
|
|
|
101
|
-
def run_local_dir_sandbox(
|
|
102
|
+
def run_local_dir_sandbox(
|
|
103
|
+
self, agent_state: Optional[AgentState] = None, additional_env_vars: Optional[Dict] = None
|
|
104
|
+
) -> SandboxRunResult:
|
|
102
105
|
sbx_config = self.sandbox_config_manager.get_or_create_default_sandbox_config(sandbox_type=SandboxType.LOCAL, actor=self.user)
|
|
103
106
|
local_configs = sbx_config.get_local_config()
|
|
104
107
|
|
|
105
108
|
# Get environment variables for the sandbox
|
|
106
|
-
env_vars = self.sandbox_config_manager.get_sandbox_env_vars_as_dict(sandbox_config_id=sbx_config.id, actor=self.user, limit=100)
|
|
107
109
|
env = os.environ.copy()
|
|
110
|
+
env_vars = self.sandbox_config_manager.get_sandbox_env_vars_as_dict(sandbox_config_id=sbx_config.id, actor=self.user, limit=100)
|
|
108
111
|
env.update(env_vars)
|
|
109
112
|
|
|
110
113
|
# Get environment variables for this agent specifically
|
|
111
114
|
if agent_state:
|
|
112
115
|
env.update(agent_state.get_agent_env_vars_as_dict())
|
|
113
116
|
|
|
117
|
+
# Finally, get any that are passed explicitly into the `run` function call
|
|
118
|
+
if additional_env_vars:
|
|
119
|
+
env.update(additional_env_vars)
|
|
120
|
+
|
|
114
121
|
# Safety checks
|
|
115
122
|
if not os.path.isdir(local_configs.sandbox_dir):
|
|
116
123
|
raise FileNotFoundError(f"Sandbox directory does not exist: {local_configs.sandbox_dir}")
|
|
@@ -277,7 +284,7 @@ class ToolExecutionSandbox:
|
|
|
277
284
|
|
|
278
285
|
# e2b sandbox specific functions
|
|
279
286
|
|
|
280
|
-
def run_e2b_sandbox(self, agent_state: Optional[AgentState] = None) -> SandboxRunResult:
|
|
287
|
+
def run_e2b_sandbox(self, agent_state: Optional[AgentState] = None, additional_env_vars: Optional[Dict] = None) -> SandboxRunResult:
|
|
281
288
|
sbx_config = self.sandbox_config_manager.get_or_create_default_sandbox_config(sandbox_type=SandboxType.E2B, actor=self.user)
|
|
282
289
|
sbx = self.get_running_e2b_sandbox_with_same_state(sbx_config)
|
|
283
290
|
if not sbx or self.force_recreate:
|
|
@@ -300,6 +307,9 @@ class ToolExecutionSandbox:
|
|
|
300
307
|
if agent_state:
|
|
301
308
|
env_vars.update(agent_state.get_agent_env_vars_as_dict())
|
|
302
309
|
|
|
310
|
+
# Finally, get any that are passed explicitly into the `run` function call
|
|
311
|
+
if additional_env_vars:
|
|
312
|
+
env_vars.update(additional_env_vars)
|
|
303
313
|
code = self.generate_execution_script(agent_state=agent_state)
|
|
304
314
|
execution = sbx.run_code(code, envs=env_vars)
|
|
305
315
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
letta/__init__.py,sha256=-CRF0Bm3fnfx91Zwqgy6SjNRFRTorD37JtSJnVMpRGQ,991
|
|
2
2
|
letta/__main__.py,sha256=6Hs2PV7EYc5Tid4g4OtcLXhqVHiNYTGzSBdoOnW2HXA,29
|
|
3
|
-
letta/agent.py,sha256=
|
|
3
|
+
letta/agent.py,sha256=fvd_atYh1BDgjDWxP3pJjCQ7cJFRWQigfI8TtmXQ0Ng,54838
|
|
4
4
|
letta/benchmark/benchmark.py,sha256=ebvnwfp3yezaXOQyGXkYCDYpsmre-b9hvNtnyx4xkG0,3701
|
|
5
5
|
letta/benchmark/constants.py,sha256=aXc5gdpMGJT327VuxsT5FngbCK2J41PQYeICBO7g_RE,536
|
|
6
6
|
letta/chat_only_agent.py,sha256=ECqJS7KzXOsNkJc9mv7reKbcxBI_PKP_PQyk95tsT1Y,4761
|
|
@@ -12,7 +12,7 @@ letta/client/client.py,sha256=oOwifm06z0bVpHnv3yR4o-tMQxD0C7_p41luQ5r-C5E,127098
|
|
|
12
12
|
letta/client/streaming.py,sha256=Hz2j_hQZG2g7uhucjx2p3ybf2qjPT-vmIGCHGo87iCQ,4677
|
|
13
13
|
letta/client/utils.py,sha256=VCGV-op5ZSmurd4yw7Vhf93XDQ0BkyBT8qsuV7EqfiU,2859
|
|
14
14
|
letta/config.py,sha256=JFGY4TWW0Wm5fTbZamOwWqk5G8Nn-TXyhgByGoAqy2c,12375
|
|
15
|
-
letta/constants.py,sha256=
|
|
15
|
+
letta/constants.py,sha256=gl0uecmIZxO2si3gG9H-MRvHrH6jzFih3Uvfa02lewk,7071
|
|
16
16
|
letta/credentials.py,sha256=D9mlcPsdDWlIIXQQD8wSPE9M_QvsRrb0p3LB5i9OF5Q,5806
|
|
17
17
|
letta/data_sources/connectors.py,sha256=L-WL-znjaRstMwSunHf3xDywjvgnbjnUR9rUpL6Ypo0,7023
|
|
18
18
|
letta/data_sources/connectors_helper.py,sha256=2TQjCt74fCgT5sw1AP8PalDEk06jPBbhrPG4HVr-WLs,3371
|
|
@@ -80,7 +80,6 @@ letta/local_llm/webui/settings.py,sha256=gmLHfiOl1u4JmlAZU2d2O8YKF9lafdakyjwR_ft
|
|
|
80
80
|
letta/log.py,sha256=FxkAk2f8Bl-u9dfImSj1DYnjAsmV6PL3tjTSnEiNP48,2218
|
|
81
81
|
letta/main.py,sha256=_agyaYPJq70OL0goNwO34zENL2KupnTgqlg-HVcNaTY,15379
|
|
82
82
|
letta/memory.py,sha256=tt7xuknsId1c9LK0gNIfsMQgcrPXFa6aWHALlDeoHMc,3277
|
|
83
|
-
letta/o1_agent.py,sha256=lQ7nX61DFhICWLdh8KpJnAurpwnR1V7PnOVIoCHXdas,2950
|
|
84
83
|
letta/offline_memory_agent.py,sha256=Wc2_je3oXxXcaiPPNPxc78A3IXVsiK6Q7X3t_SrlHck,7651
|
|
85
84
|
letta/openai_backcompat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
85
|
letta/openai_backcompat/openai_object.py,sha256=Y1ZS1sATP60qxJiOsjOP3NbwSzuzvkNAvb3DeuhM5Uk,13490
|
|
@@ -92,7 +91,7 @@ letta/orm/base.py,sha256=47Pyo6iGPlJoT8oeXZWl3E7XHbPzcB81EueoFzeXbxE,2691
|
|
|
92
91
|
letta/orm/block.py,sha256=U2fOXdab9ynQscOqzUo3xv1a_GjqHLIgoNSZq-U0mYg,3308
|
|
93
92
|
letta/orm/blocks_agents.py,sha256=W0dykl9OchAofSuAYZD5zNmhyMabPr9LTJrz-I3A0m4,983
|
|
94
93
|
letta/orm/custom_columns.py,sha256=dBYJn3yc1BIy7ZntIFfq9oEdQav-u0r412C2HyDeUPU,5056
|
|
95
|
-
letta/orm/enums.py,sha256=
|
|
94
|
+
letta/orm/enums.py,sha256=a6Ka6EUcxjsw5bG9EvzsavWBAlb992BjWqgRkGWn184,270
|
|
96
95
|
letta/orm/errors.py,sha256=Se0Guz-gqi-D36NUWSh7AP9zTVCSph9KgZh_trwng4o,734
|
|
97
96
|
letta/orm/file.py,sha256=7_p7LxityP3NQZVURQYG0kgcZhEkVuMN0Fj4h9YOe1w,1780
|
|
98
97
|
letta/orm/job.py,sha256=If-qSTJW4t5h-6Jolw3tS3-xMZEaPIbXe3S0GMf_FXI,1102
|
|
@@ -137,7 +136,7 @@ letta/prompts/system/memgpt_offline_memory.txt,sha256=rWEJeF-6aiinjkJM9hgLUYCmlE
|
|
|
137
136
|
letta/prompts/system/memgpt_offline_memory_chat.txt,sha256=ituh7gDuio7nC2UKFB7GpBq6crxb8bYedQfJ0ADoPgg,3949
|
|
138
137
|
letta/providers.py,sha256=f-ZbMBmvX1rtVWuW-GS4mihFjWHg343keAzqVb9NgWY,27468
|
|
139
138
|
letta/pytest.ini,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
140
|
-
letta/schemas/agent.py,sha256=
|
|
139
|
+
letta/schemas/agent.py,sha256=mDaOHz1TOb4VgaXJisI6OZXNFfK38W9A6jVCyrD2NBQ,11482
|
|
141
140
|
letta/schemas/block.py,sha256=pVDH8jr5r-oxdX4cK9dX2wXyLBzgGKQOBWOzqZSeBog,5944
|
|
142
141
|
letta/schemas/embedding_config.py,sha256=8K2EGVQ26F3zjY1Wj3v_hsrA-1qICshVMGRlKPSATfg,3354
|
|
143
142
|
letta/schemas/enums.py,sha256=f8SVJqb0dzhlNCBN2SgeM4ZMHX5LMyhln1SCJAgXeow,1068
|
|
@@ -161,7 +160,7 @@ letta/schemas/organization.py,sha256=WWbUWVSp_VQRFwWN4fdHg1yObiV6x9rZnvIY8x5BPs0
|
|
|
161
160
|
letta/schemas/passage.py,sha256=t_bSI8hpEuh-mj8bV8qOiIA1tAgyjGKrZMVe9l5oIaY,3675
|
|
162
161
|
letta/schemas/sandbox_config.py,sha256=v32V5T73X-VxhDk0g_1RGniK985KMvg2xyLVi1dvMQY,4215
|
|
163
162
|
letta/schemas/source.py,sha256=B1VbaDJV-EGPv1nQXwCx_RAzeAJd50UqP_1m1cIRT8c,2854
|
|
164
|
-
letta/schemas/tool.py,sha256=
|
|
163
|
+
letta/schemas/tool.py,sha256=_2FaWTDdGtbKTh3-KHa57f5CKS_veWYtyS2Fk5ZwMFw,10349
|
|
165
164
|
letta/schemas/tool_rule.py,sha256=LJwi1T474-3zbFGiW7_fegyfduC3F2u7cdlBsV0U_IU,1679
|
|
166
165
|
letta/schemas/usage.py,sha256=8oYRH-JX0PfjIu2zkT5Uu3UWQ7Unnz_uHiO8hRGI4m0,912
|
|
167
166
|
letta/schemas/user.py,sha256=V32Tgl6oqB3KznkxUz12y7agkQicjzW7VocSpj78i6Q,1526
|
|
@@ -189,13 +188,13 @@ letta/server/rest_api/routers/v1/jobs.py,sha256=-tEyuIxlXZfPREeMks-sRzHwhKE2xxgz
|
|
|
189
188
|
letta/server/rest_api/routers/v1/llms.py,sha256=TcyvSx6MEM3je5F4DysL7ligmssL_pFlJaaO4uL95VY,877
|
|
190
189
|
letta/server/rest_api/routers/v1/organizations.py,sha256=tyqVzXTpMtk3sKxI3Iz4aS6RhbGEbXDzFBB_CpW18v4,2080
|
|
191
190
|
letta/server/rest_api/routers/v1/providers.py,sha256=7_921hS6AsvOG-9LeGsF61fM_8cP7Ez-AVUBX-G1iVs,2358
|
|
192
|
-
letta/server/rest_api/routers/v1/sandbox_configs.py,sha256=
|
|
191
|
+
letta/server/rest_api/routers/v1/sandbox_configs.py,sha256=DJ8mz7HsXCuGypNaxTgoMW8xR1kMOwdVnon00srRdCo,5266
|
|
193
192
|
letta/server/rest_api/routers/v1/sources.py,sha256=EJ-VCqiKtaiYuivZrWx1gYSNUKnWJuduSm-L_2ljhLc,9913
|
|
194
|
-
letta/server/rest_api/routers/v1/tools.py,sha256=
|
|
193
|
+
letta/server/rest_api/routers/v1/tools.py,sha256=rGw3hDUFYmY_kmJw5hsQWnBOWQqJFdfT3bfKiXwXikg,12764
|
|
195
194
|
letta/server/rest_api/routers/v1/users.py,sha256=EBQe9IfCG3kzHpKmotz4yVGZioXz3SCSRy5yEhJK8hU,2293
|
|
196
195
|
letta/server/rest_api/static_files.py,sha256=NG8sN4Z5EJ8JVQdj19tkFa9iQ1kBPTab9f_CUxd_u4Q,3143
|
|
197
196
|
letta/server/rest_api/utils.py,sha256=M4VE76TtC9qorvszq1x7MTBW9jSWgtUUCRahqpJNYNc,3953
|
|
198
|
-
letta/server/server.py,sha256=
|
|
197
|
+
letta/server/server.py,sha256=H_-51emg5gHQryjuL0cw5J7XV8mEtzs1JOun_GhYOYQ,50272
|
|
199
198
|
letta/server/startup.sh,sha256=722uKJWB2C4q3vjn39De2zzPacaZNw_1fN1SpLGjKIo,1569
|
|
200
199
|
letta/server/static_files/assets/index-048c9598.js,sha256=mR16XppvselwKCcNgONs4L7kZEVa4OEERm4lNZYtLSk,146819
|
|
201
200
|
letta/server/static_files/assets/index-0e31b727.css,sha256=SBbja96uiQVLDhDOroHgM6NSl7tS4lpJRCREgSS_hA8,7672
|
|
@@ -211,16 +210,16 @@ letta/server/ws_api/server.py,sha256=cBSzf-V4zT1bL_0i54OTI3cMXhTIIxqjSRF8pYjk7fg
|
|
|
211
210
|
letta/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
212
211
|
letta/services/agent_manager.py,sha256=r5HTYtCiSNE-hkloVGY0T2PflAvtmirQRBxVuPw03Zs,41912
|
|
213
212
|
letta/services/block_manager.py,sha256=HUj9HKW2LvAsENEsgCO3Pf3orvSy6XOimev38VKmRZ8,4929
|
|
214
|
-
letta/services/helpers/agent_manager_helper.py,sha256=
|
|
213
|
+
letta/services/helpers/agent_manager_helper.py,sha256=ytNViS18ubRbj90yZ2B3jf1on5pzxT9xaQOpCLFA-ss,10451
|
|
215
214
|
letta/services/job_manager.py,sha256=FrkSXloke48CZKuzlYdysxM5gKWoTu7FRigPrs_YW4A,3645
|
|
216
215
|
letta/services/message_manager.py,sha256=a7U0MfgaNAdjbls7ZtUdS7eJ6prJaMkE0NIHgtzh4us,8552
|
|
217
216
|
letta/services/organization_manager.py,sha256=hJI86_FErkRaW-VLBBmvmmciIXN59LN0mEMm78C36kQ,3331
|
|
218
217
|
letta/services/passage_manager.py,sha256=Lq1caspE1VGmT7vlsUOuJVRflJZ122qfG0dmNGm_6o8,7691
|
|
219
218
|
letta/services/per_agent_lock_manager.py,sha256=porM0cKKANQ1FvcGXOO_qM7ARk5Fgi1HVEAhXsAg9-4,546
|
|
220
219
|
letta/services/provider_manager.py,sha256=wCYgl2toWsuOHwFGkz0i94G0hyWtFNyRLUzB2ElTckw,2589
|
|
221
|
-
letta/services/sandbox_config_manager.py,sha256=
|
|
220
|
+
letta/services/sandbox_config_manager.py,sha256=RtJCiw43S80K_a8QgpQUH7P0jpi7UwoUV1fDjfyX1t4,13289
|
|
222
221
|
letta/services/source_manager.py,sha256=ZtLQikeJjwAq49f0d4WxUzyUN3LZBqWCZI4a-AzEMWQ,7643
|
|
223
|
-
letta/services/tool_execution_sandbox.py,sha256=
|
|
222
|
+
letta/services/tool_execution_sandbox.py,sha256=380xw7ptSdrAbfolZ0l4jnwpzCfbdUfIkOh2tg2vbmI,23019
|
|
224
223
|
letta/services/tool_manager.py,sha256=eKhvGYNBq8MOwfuk-GyqiTdEcxRn4srYvTJqj-HgTKA,7686
|
|
225
224
|
letta/services/tool_sandbox_env/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
226
225
|
letta/services/user_manager.py,sha256=oqLF9C4mGbN0TaGj7wMpb2RH2bUg6OJJcdyaWv370rQ,4272
|
|
@@ -229,8 +228,8 @@ letta/streaming_interface.py,sha256=lo2VAQRUJOdWTijwnXuKOC9uejqr2siUAEmZiQUXkj8,
|
|
|
229
228
|
letta/streaming_utils.py,sha256=329fsvj1ZN0r0LpQtmMPZ2vSxkDBIUUwvGHZFkjm2I8,11745
|
|
230
229
|
letta/system.py,sha256=buKYPqG5n2x41hVmWpu6JUpyd7vTWED9Km2_M7dLrvk,6960
|
|
231
230
|
letta/utils.py,sha256=1-HhTZEw7j5fXI2ukdto0y1cZ-I8wpHKf7rqtdwFnT4,33382
|
|
232
|
-
letta_nightly-0.6.8.
|
|
233
|
-
letta_nightly-0.6.8.
|
|
234
|
-
letta_nightly-0.6.8.
|
|
235
|
-
letta_nightly-0.6.8.
|
|
236
|
-
letta_nightly-0.6.8.
|
|
231
|
+
letta_nightly-0.6.8.dev20250110190527.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
|
|
232
|
+
letta_nightly-0.6.8.dev20250110190527.dist-info/METADATA,sha256=jVpu1w9e5acpFTZtETXxGlx0ZrQGdwn7jpVJXts6DCI,21694
|
|
233
|
+
letta_nightly-0.6.8.dev20250110190527.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
234
|
+
letta_nightly-0.6.8.dev20250110190527.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
|
|
235
|
+
letta_nightly-0.6.8.dev20250110190527.dist-info/RECORD,,
|
letta/o1_agent.py
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
from typing import List, Optional, Union
|
|
2
|
-
|
|
3
|
-
from letta.agent import Agent, save_agent
|
|
4
|
-
from letta.interface import AgentInterface
|
|
5
|
-
from letta.schemas.agent import AgentState
|
|
6
|
-
from letta.schemas.message import Message
|
|
7
|
-
from letta.schemas.openai.chat_completion_response import UsageStatistics
|
|
8
|
-
from letta.schemas.usage import LettaUsageStatistics
|
|
9
|
-
from letta.schemas.user import User
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def send_thinking_message(self: "Agent", message: str) -> Optional[str]:
|
|
13
|
-
"""
|
|
14
|
-
Sends a thinking message so that the model can reason out loud before responding.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
message (str): Message contents. All unicode (including emojis) are supported.
|
|
18
|
-
|
|
19
|
-
Returns:
|
|
20
|
-
Optional[str]: None is always returned as this function does not produce a response.
|
|
21
|
-
"""
|
|
22
|
-
self.interface.internal_monologue(message)
|
|
23
|
-
return None
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def send_final_message(self: "Agent", message: str) -> Optional[str]:
|
|
27
|
-
"""
|
|
28
|
-
Sends a final message to the human user after thinking for a while.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
message (str): Message contents. All unicode (including emojis) are supported.
|
|
32
|
-
|
|
33
|
-
Returns:
|
|
34
|
-
Optional[str]: None is always returned as this function does not produce a response.
|
|
35
|
-
"""
|
|
36
|
-
self.interface.internal_monologue(message)
|
|
37
|
-
return None
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class O1Agent(Agent):
|
|
41
|
-
def __init__(
|
|
42
|
-
self,
|
|
43
|
-
interface: AgentInterface,
|
|
44
|
-
agent_state: AgentState,
|
|
45
|
-
user: User,
|
|
46
|
-
max_thinking_steps: int = 10,
|
|
47
|
-
first_message_verify_mono: bool = False,
|
|
48
|
-
):
|
|
49
|
-
super().__init__(interface, agent_state, user)
|
|
50
|
-
self.max_thinking_steps = max_thinking_steps
|
|
51
|
-
self.first_message_verify_mono = first_message_verify_mono
|
|
52
|
-
|
|
53
|
-
def step(
|
|
54
|
-
self,
|
|
55
|
-
messages: Union[Message, List[Message]],
|
|
56
|
-
chaining: bool = True,
|
|
57
|
-
max_chaining_steps: Optional[int] = None,
|
|
58
|
-
**kwargs,
|
|
59
|
-
) -> LettaUsageStatistics:
|
|
60
|
-
"""Run Agent.inner_step in a loop, terminate when final thinking message is sent or max_thinking_steps is reached"""
|
|
61
|
-
# assert ms is not None, "MetadataStore is required"
|
|
62
|
-
next_input_message = messages if isinstance(messages, list) else [messages]
|
|
63
|
-
|
|
64
|
-
counter = 0
|
|
65
|
-
total_usage = UsageStatistics()
|
|
66
|
-
step_count = 0
|
|
67
|
-
while step_count < self.max_thinking_steps:
|
|
68
|
-
if counter > 0:
|
|
69
|
-
next_input_message = []
|
|
70
|
-
|
|
71
|
-
kwargs["first_message"] = False
|
|
72
|
-
step_response = self.inner_step(
|
|
73
|
-
messages=next_input_message,
|
|
74
|
-
**kwargs,
|
|
75
|
-
)
|
|
76
|
-
usage = step_response.usage
|
|
77
|
-
step_count += 1
|
|
78
|
-
total_usage += usage
|
|
79
|
-
counter += 1
|
|
80
|
-
self.interface.step_complete()
|
|
81
|
-
# check if it is final thinking message
|
|
82
|
-
if step_response.messages[-1].name == "send_final_message":
|
|
83
|
-
break
|
|
84
|
-
save_agent(self)
|
|
85
|
-
|
|
86
|
-
return LettaUsageStatistics(**total_usage.model_dump(), step_count=step_count)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|