letta-nightly 0.6.34.dev20250303104329__py3-none-any.whl → 0.6.35.dev20250304104154__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/__init__.py +1 -1
- letta/agent.py +40 -15
- letta/agents/__init__.py +0 -0
- letta/agents/base_agent.py +51 -0
- letta/agents/ephemeral_agent.py +72 -0
- letta/agents/low_latency_agent.py +315 -0
- letta/constants.py +3 -1
- letta/functions/ast_parsers.py +50 -1
- letta/functions/helpers.py +79 -2
- letta/functions/schema_generator.py +3 -0
- letta/helpers/converters.py +3 -3
- letta/interfaces/__init__.py +0 -0
- letta/interfaces/openai_chat_completions_streaming_interface.py +109 -0
- letta/interfaces/utils.py +11 -0
- letta/llm_api/anthropic.py +9 -1
- letta/llm_api/azure_openai.py +3 -0
- letta/llm_api/google_ai.py +3 -0
- letta/llm_api/google_vertex.py +4 -0
- letta/llm_api/llm_api_tools.py +1 -1
- letta/llm_api/openai.py +6 -0
- letta/local_llm/chat_completion_proxy.py +6 -1
- letta/log.py +2 -2
- letta/orm/step.py +1 -0
- letta/orm/tool.py +1 -1
- letta/prompts/system/memgpt_convo_only.txt +3 -5
- letta/prompts/system/memgpt_memory_only.txt +29 -0
- letta/schemas/agent.py +0 -1
- letta/schemas/step.py +1 -1
- letta/schemas/tool.py +16 -2
- letta/server/rest_api/app.py +5 -1
- letta/server/rest_api/routers/v1/agents.py +32 -21
- letta/server/rest_api/routers/v1/identities.py +9 -1
- letta/server/rest_api/routers/v1/runs.py +49 -0
- letta/server/rest_api/routers/v1/tools.py +1 -0
- letta/server/rest_api/routers/v1/voice.py +19 -255
- letta/server/rest_api/utils.py +3 -2
- letta/server/server.py +15 -7
- letta/services/agent_manager.py +10 -6
- letta/services/helpers/agent_manager_helper.py +0 -2
- letta/services/helpers/tool_execution_helper.py +18 -0
- letta/services/job_manager.py +98 -0
- letta/services/step_manager.py +2 -0
- letta/services/summarizer/__init__.py +0 -0
- letta/services/summarizer/enums.py +9 -0
- letta/services/summarizer/summarizer.py +102 -0
- letta/services/tool_execution_sandbox.py +20 -3
- letta/services/tool_manager.py +1 -1
- letta/settings.py +2 -0
- letta/tracing.py +176 -156
- {letta_nightly-0.6.34.dev20250303104329.dist-info → letta_nightly-0.6.35.dev20250304104154.dist-info}/METADATA +6 -5
- {letta_nightly-0.6.34.dev20250303104329.dist-info → letta_nightly-0.6.35.dev20250304104154.dist-info}/RECORD +54 -44
- letta/chat_only_agent.py +0 -101
- {letta_nightly-0.6.34.dev20250303104329.dist-info → letta_nightly-0.6.35.dev20250304104154.dist-info}/LICENSE +0 -0
- {letta_nightly-0.6.34.dev20250303104329.dist-info → letta_nightly-0.6.35.dev20250304104154.dist-info}/WHEEL +0 -0
- {letta_nightly-0.6.34.dev20250303104329.dist-info → letta_nightly-0.6.35.dev20250304104154.dist-info}/entry_points.txt +0 -0
letta/chat_only_agent.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
from concurrent.futures import ThreadPoolExecutor
|
|
2
|
-
from typing import List, Optional, Union
|
|
3
|
-
|
|
4
|
-
from letta.agent import Agent
|
|
5
|
-
from letta.interface import AgentInterface
|
|
6
|
-
from letta.prompts import gpt_system
|
|
7
|
-
from letta.schemas.agent import AgentState, AgentType
|
|
8
|
-
from letta.schemas.embedding_config import EmbeddingConfig
|
|
9
|
-
from letta.schemas.llm_config import LLMConfig
|
|
10
|
-
from letta.schemas.memory import BasicBlockMemory, Block
|
|
11
|
-
from letta.schemas.message import Message
|
|
12
|
-
from letta.schemas.usage import LettaUsageStatistics
|
|
13
|
-
from letta.schemas.user import User
|
|
14
|
-
from letta.utils import get_persona_text
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ChatOnlyAgent(Agent):
|
|
18
|
-
def __init__(
|
|
19
|
-
self,
|
|
20
|
-
interface: AgentInterface,
|
|
21
|
-
agent_state: AgentState,
|
|
22
|
-
user: User,
|
|
23
|
-
first_message_verify_mono: bool = False,
|
|
24
|
-
always_rethink_memory: bool = True,
|
|
25
|
-
recent_convo_limit: int = 2000,
|
|
26
|
-
):
|
|
27
|
-
super().__init__(interface, agent_state, user)
|
|
28
|
-
self.first_message_verify_mono = first_message_verify_mono
|
|
29
|
-
self.always_rethink_memory = always_rethink_memory
|
|
30
|
-
self.offline_memory_agent = None
|
|
31
|
-
self.recent_convo_limit = recent_convo_limit
|
|
32
|
-
|
|
33
|
-
def step(
|
|
34
|
-
self,
|
|
35
|
-
messages: Union[Message, List[Message]],
|
|
36
|
-
chaining: bool = True,
|
|
37
|
-
max_chaining_steps: Optional[int] = None,
|
|
38
|
-
**kwargs,
|
|
39
|
-
) -> LettaUsageStatistics:
|
|
40
|
-
letta_statistics = super().step(messages=messages, chaining=chaining, max_chaining_steps=max_chaining_steps, **kwargs)
|
|
41
|
-
|
|
42
|
-
if self.always_rethink_memory:
|
|
43
|
-
|
|
44
|
-
def generate_offline_memory_agent():
|
|
45
|
-
from letta.client.client import create_client
|
|
46
|
-
|
|
47
|
-
client = create_client()
|
|
48
|
-
if self.offline_memory_agent:
|
|
49
|
-
client.delete_agent(agent_id=self.offline_memory_agent.id)
|
|
50
|
-
self.offline_memory_agent = None
|
|
51
|
-
|
|
52
|
-
conversation_human_block = self.agent_state.memory.get_block("chat_agent_human")
|
|
53
|
-
conversation_persona_block = self.agent_state.memory.get_block("chat_agent_persona")
|
|
54
|
-
offline_persona_block = Block(
|
|
55
|
-
name="offline_memory_persona",
|
|
56
|
-
label="offline_memory_persona",
|
|
57
|
-
value=get_persona_text("offline_memory_persona"),
|
|
58
|
-
limit=2000,
|
|
59
|
-
)
|
|
60
|
-
conversation_human_block_new = Block(
|
|
61
|
-
name="chat_agent_human_new", label="chat_agent_human_new", value=conversation_human_block.value, limit=2000
|
|
62
|
-
)
|
|
63
|
-
conversation_persona_block_new = Block(
|
|
64
|
-
name="chat_agent_persona_new", label="chat_agent_persona_new", value=conversation_persona_block.value, limit=2000
|
|
65
|
-
)
|
|
66
|
-
in_context_messages = self.agent_manager.get_in_context_messages(agent_id=self.agent_state.id, actor=self.user)
|
|
67
|
-
recent_convo = "".join([str(message) for message in in_context_messages[3:]])[-self.recent_convo_limit :]
|
|
68
|
-
conversation_messages_block = Block(
|
|
69
|
-
name="conversation_block", label="conversation_block", value=recent_convo, limit=self.recent_convo_limit
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
offline_memory = BasicBlockMemory(
|
|
73
|
-
blocks=[
|
|
74
|
-
offline_persona_block,
|
|
75
|
-
conversation_human_block,
|
|
76
|
-
conversation_persona_block,
|
|
77
|
-
conversation_human_block_new,
|
|
78
|
-
conversation_persona_block_new,
|
|
79
|
-
conversation_messages_block,
|
|
80
|
-
]
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
self.offline_memory_agent = client.create_agent(
|
|
84
|
-
name="offline_memory_agent",
|
|
85
|
-
agent_type=AgentType.offline_memory_agent,
|
|
86
|
-
system=gpt_system.get_system_text("memgpt_offline_memory_chat"),
|
|
87
|
-
memory=offline_memory,
|
|
88
|
-
llm_config=LLMConfig.default_config("gpt-4"),
|
|
89
|
-
embedding_config=EmbeddingConfig.default_config("text-embedding-ada-002"),
|
|
90
|
-
tool_ids=self.agent_state.metadata.get("offline_memory_tools", []),
|
|
91
|
-
include_base_tools=False,
|
|
92
|
-
)
|
|
93
|
-
self.offline_memory_agent.memory.update_block_value(label="conversation_block", value=recent_convo)
|
|
94
|
-
client.send_message(agent_id=self.offline_memory_agent.id, message="Reorganize the memory", role="user")
|
|
95
|
-
client.delete_agent(agent_id=self.offline_memory_agent.id)
|
|
96
|
-
self.offline_memory_agent = None
|
|
97
|
-
|
|
98
|
-
with ThreadPoolExecutor(max_workers=1) as executor:
|
|
99
|
-
executor.submit(generate_offline_memory_agent)
|
|
100
|
-
|
|
101
|
-
return letta_statistics
|
|
File without changes
|
|
File without changes
|