letta-nightly 0.11.7.dev20250915104130__py3-none-any.whl → 0.11.7.dev20250916104104__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/functions/function_sets/multi_agent.py +1 -1
- letta/functions/helpers.py +1 -1
- letta/prompts/gpt_system.py +13 -15
- letta/prompts/system_prompts/__init__.py +27 -0
- letta/prompts/{system/memgpt_chat.txt → system_prompts/memgpt_chat.py} +2 -0
- letta/prompts/{system/memgpt_generate_tool.txt → system_prompts/memgpt_generate_tool.py} +4 -2
- letta/prompts/{system/memgpt_v2_chat.txt → system_prompts/memgpt_v2_chat.py} +2 -0
- letta/prompts/{system/react.txt → system_prompts/react.py} +2 -0
- letta/prompts/{system/sleeptime_doc_ingest.txt → system_prompts/sleeptime_doc_ingest.py} +2 -0
- letta/prompts/{system/sleeptime_v2.txt → system_prompts/sleeptime_v2.py} +2 -0
- letta/prompts/{system/summary_system_prompt.txt → system_prompts/summary_system_prompt.py} +2 -0
- letta/prompts/{system/voice_chat.txt → system_prompts/voice_chat.py} +2 -0
- letta/prompts/{system/voice_sleeptime.txt → system_prompts/voice_sleeptime.py} +2 -0
- letta/prompts/{system/workflow.txt → system_prompts/workflow.py} +2 -0
- letta/server/rest_api/dependencies.py +37 -0
- letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +4 -3
- letta/server/rest_api/routers/v1/agents.py +106 -103
- letta/server/rest_api/routers/v1/blocks.py +44 -20
- letta/server/rest_api/routers/v1/embeddings.py +3 -3
- letta/server/rest_api/routers/v1/folders.py +107 -47
- letta/server/rest_api/routers/v1/groups.py +52 -32
- letta/server/rest_api/routers/v1/identities.py +110 -21
- letta/server/rest_api/routers/v1/internal_templates.py +28 -13
- letta/server/rest_api/routers/v1/jobs.py +12 -12
- letta/server/rest_api/routers/v1/llms.py +6 -8
- letta/server/rest_api/routers/v1/messages.py +14 -14
- letta/server/rest_api/routers/v1/organizations.py +1 -1
- letta/server/rest_api/routers/v1/providers.py +40 -16
- letta/server/rest_api/routers/v1/runs.py +19 -19
- letta/server/rest_api/routers/v1/sandbox_configs.py +25 -25
- letta/server/rest_api/routers/v1/sources.py +44 -45
- letta/server/rest_api/routers/v1/steps.py +27 -25
- letta/server/rest_api/routers/v1/tags.py +11 -7
- letta/server/rest_api/routers/v1/telemetry.py +11 -6
- letta/server/rest_api/routers/v1/tools.py +71 -54
- letta/server/rest_api/routers/v1/users.py +1 -1
- letta/server/rest_api/routers/v1/voice.py +6 -5
- letta/server/rest_api/utils.py +1 -18
- letta/services/file_manager.py +6 -0
- letta/services/group_manager.py +2 -1
- letta/services/identity_manager.py +67 -0
- letta/services/provider_manager.py +14 -1
- letta/services/source_manager.py +11 -1
- letta/services/tool_manager.py +46 -9
- letta/utils.py +4 -2
- {letta_nightly-0.11.7.dev20250915104130.dist-info → letta_nightly-0.11.7.dev20250916104104.dist-info}/METADATA +1 -1
- {letta_nightly-0.11.7.dev20250915104130.dist-info → letta_nightly-0.11.7.dev20250916104104.dist-info}/RECORD +50 -62
- letta/prompts/system/memgpt_base.txt +0 -54
- letta/prompts/system/memgpt_chat_compressed.txt +0 -13
- letta/prompts/system/memgpt_chat_fstring.txt +0 -51
- letta/prompts/system/memgpt_convo_only.txt +0 -12
- letta/prompts/system/memgpt_doc.txt +0 -50
- letta/prompts/system/memgpt_gpt35_extralong.txt +0 -53
- letta/prompts/system/memgpt_intuitive_knowledge.txt +0 -31
- letta/prompts/system/memgpt_memory_only.txt +0 -29
- letta/prompts/system/memgpt_modified_chat.txt +0 -23
- letta/prompts/system/memgpt_modified_o1.txt +0 -31
- letta/prompts/system/memgpt_offline_memory.txt +0 -23
- letta/prompts/system/memgpt_offline_memory_chat.txt +0 -35
- letta/prompts/system/memgpt_sleeptime_chat.txt +0 -52
- letta/prompts/system/sleeptime.txt +0 -37
- {letta_nightly-0.11.7.dev20250915104130.dist-info → letta_nightly-0.11.7.dev20250916104104.dist-info}/WHEEL +0 -0
- {letta_nightly-0.11.7.dev20250915104130.dist-info → letta_nightly-0.11.7.dev20250916104104.dist-info}/entry_points.txt +0 -0
- {letta_nightly-0.11.7.dev20250915104130.dist-info → letta_nightly-0.11.7.dev20250916104104.dist-info}/licenses/LICENSE +0 -0
@@ -11,7 +11,7 @@ from letta.functions.helpers import (
|
|
11
11
|
)
|
12
12
|
from letta.schemas.enums import MessageRole
|
13
13
|
from letta.schemas.message import MessageCreate
|
14
|
-
from letta.server.rest_api.
|
14
|
+
from letta.server.rest_api.dependencies import get_letta_server
|
15
15
|
from letta.settings import settings
|
16
16
|
|
17
17
|
if TYPE_CHECKING:
|
letta/functions/helpers.py
CHANGED
@@ -17,7 +17,7 @@ from letta.schemas.letta_response import LettaResponse
|
|
17
17
|
from letta.schemas.letta_stop_reason import LettaStopReason, StopReasonType
|
18
18
|
from letta.schemas.message import Message, MessageCreate
|
19
19
|
from letta.schemas.user import User
|
20
|
-
from letta.server.rest_api.
|
20
|
+
from letta.server.rest_api.dependencies import get_letta_server
|
21
21
|
from letta.settings import settings
|
22
22
|
from letta.utils import safe_create_task
|
23
23
|
|
letta/prompts/gpt_system.py
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
import os
|
2
2
|
|
3
3
|
from letta.constants import LETTA_DIR
|
4
|
+
from letta.prompts.system_prompts import SYSTEM_PROMPTS
|
4
5
|
|
5
6
|
|
6
7
|
def get_system_text(key):
|
7
|
-
|
8
|
-
|
8
|
+
# first try to get from python constants (no file I/O)
|
9
|
+
if key in SYSTEM_PROMPTS:
|
10
|
+
return SYSTEM_PROMPTS[key].strip()
|
9
11
|
|
10
|
-
#
|
12
|
+
# fallback to user custom prompts in ~/.letta/system_prompts/*.txt
|
13
|
+
filename = f"{key}.txt"
|
14
|
+
user_system_prompts_dir = os.path.join(LETTA_DIR, "system_prompts")
|
15
|
+
# create directory if it doesn't exist
|
16
|
+
if not os.path.exists(user_system_prompts_dir):
|
17
|
+
os.makedirs(user_system_prompts_dir)
|
18
|
+
# look inside for a matching system prompt
|
19
|
+
file_path = os.path.join(user_system_prompts_dir, filename)
|
11
20
|
if os.path.exists(file_path):
|
12
21
|
with open(file_path, "r", encoding="utf-8") as file:
|
13
22
|
return file.read().strip()
|
14
23
|
else:
|
15
|
-
|
16
|
-
user_system_prompts_dir = os.path.join(LETTA_DIR, "system_prompts")
|
17
|
-
# create directory if it doesn't exist
|
18
|
-
if not os.path.exists(user_system_prompts_dir):
|
19
|
-
os.makedirs(user_system_prompts_dir)
|
20
|
-
# look inside for a matching system prompt
|
21
|
-
file_path = os.path.join(user_system_prompts_dir, filename)
|
22
|
-
if os.path.exists(file_path):
|
23
|
-
with open(file_path, "r", encoding="utf-8") as file:
|
24
|
-
return file.read().strip()
|
25
|
-
else:
|
26
|
-
raise FileNotFoundError(f"No file found for key {key}, path={file_path}")
|
24
|
+
raise FileNotFoundError(f"No system prompt found for key '{key}'")
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from letta.prompts.system_prompts import (
|
2
|
+
memgpt_chat,
|
3
|
+
memgpt_generate_tool,
|
4
|
+
memgpt_v2_chat,
|
5
|
+
react,
|
6
|
+
sleeptime_doc_ingest,
|
7
|
+
sleeptime_v2,
|
8
|
+
summary_system_prompt,
|
9
|
+
voice_chat,
|
10
|
+
voice_sleeptime,
|
11
|
+
workflow,
|
12
|
+
)
|
13
|
+
|
14
|
+
SYSTEM_PROMPTS = {
|
15
|
+
"voice_chat": voice_chat.PROMPT,
|
16
|
+
"voice_sleeptime": voice_sleeptime.PROMPT,
|
17
|
+
"memgpt_v2_chat": memgpt_v2_chat.PROMPT,
|
18
|
+
"sleeptime_v2": sleeptime_v2.PROMPT,
|
19
|
+
"react": react.PROMPT,
|
20
|
+
"workflow": workflow.PROMPT,
|
21
|
+
"memgpt_chat": memgpt_chat.PROMPT,
|
22
|
+
"sleeptime_doc_ingest": sleeptime_doc_ingest.PROMPT,
|
23
|
+
"summary_system_prompt": summary_system_prompt.PROMPT,
|
24
|
+
"memgpt_generate_tool": memgpt_generate_tool.PROMPT,
|
25
|
+
}
|
26
|
+
|
27
|
+
__all__ = ["SYSTEM_PROMPTS"]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
You are Letta, the latest version of Limnal Corporation's digital companion, developed in 2023.
|
2
3
|
Your task is to converse with a user from the perspective of your persona.
|
3
4
|
|
@@ -56,3 +57,4 @@ There is no function to search your core memory because it is always visible in
|
|
56
57
|
|
57
58
|
Base instructions finished.
|
58
59
|
From now on, you are going to act as your persona.
|
60
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
<base_instructions>
|
2
3
|
You are Letta, the latest version of Limnal Corporation's digital companion, developed in 2025.
|
3
4
|
You are a memory-augmented agent with a memory system consisting of memory blocks. Your primary task is to generate tools for the user to use in their interactions with you.
|
@@ -64,7 +65,7 @@ A docstring must always be generated and formatted correctly as part of any gene
|
|
64
65
|
Example:
|
65
66
|
```python
|
66
67
|
def get_price(coin_ids: str, vs_currencies: str, reverse: bool) -> list:
|
67
|
-
"""
|
68
|
+
\"\"\"
|
68
69
|
Fetch prices from CoinGecko.
|
69
70
|
|
70
71
|
Args:
|
@@ -74,7 +75,7 @@ def get_price(coin_ids: str, vs_currencies: str, reverse: bool) -> list:
|
|
74
75
|
|
75
76
|
Returns:
|
76
77
|
list: the prices in the target currency, in the same order as the coin_ids if reverse is False, otherwise in the reverse order
|
77
|
-
"""
|
78
|
+
\"\"\"
|
78
79
|
...
|
79
80
|
```
|
80
81
|
</tool_docstring>
|
@@ -137,3 +138,4 @@ Example:
|
|
137
138
|
|
138
139
|
Base instructions finished.
|
139
140
|
</base_instructions>
|
141
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
<base_instructions>
|
2
3
|
You are Letta, the latest version of Limnal Corporation's digital companion, developed in 2025.
|
3
4
|
You are a memory-augmented agent with a memory system consisting of memory blocks.
|
@@ -70,3 +71,4 @@ Maintain only those files relevant to the user’s current interaction.
|
|
70
71
|
|
71
72
|
Base instructions finished.
|
72
73
|
</base_instructions>
|
74
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
<base_instructions>
|
2
3
|
You are Letta ReAct agent, the latest version of Limnal Corporation's digital AI agent, developed in 2025.
|
3
4
|
You are an AI agent that can be equipped with various tools which you can execute.
|
@@ -17,3 +18,4 @@ You should use your inner monologue to plan actions or think privately.
|
|
17
18
|
|
18
19
|
Base instructions finished.
|
19
20
|
</base_instructions>
|
21
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
You are Letta-Sleeptime-Doc-Ingest, the latest version of Limnal Corporation's memory management system, developed in 2025.
|
2
3
|
|
3
4
|
You run in the background, organizing and maintaining the memories of an agent assistant who chats with the user.
|
@@ -33,3 +34,4 @@ Line numbers:
|
|
33
34
|
Line numbers are shown to you when viewing the memory blocks to help you make precise edits when needed. The line numbers are for viewing only, do NOT under any circumstances actually include the line numbers when using your memory editing tools, or they will not work properly.
|
34
35
|
|
35
36
|
You will be sent external context about the interaction, and your goal is to summarize the context and store it in the right memory blocks.
|
37
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
<base_instructions>
|
2
3
|
You are Letta-Sleeptime-Memory, the latest version of Limnal Corporation's memory management system, developed in 2025.
|
3
4
|
|
@@ -26,3 +27,4 @@ Not every observation warrants a memory edit, be selective in your memory editin
|
|
26
27
|
Line numbers:
|
27
28
|
Line numbers are shown to you when viewing the memory blocks to help you make precise edits when needed. The line numbers are for viewing only, do NOT under any circumstances actually include the line numbers when using your memory editing tools, or they will not work properly.
|
28
29
|
</base_instructions>
|
30
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
You are a memory-recall assistant that preserves conversational context as messages exit the AI's context window.
|
2
3
|
|
3
4
|
<core_function>
|
@@ -60,3 +61,4 @@ Apply to: high-level discussions, philosophical topics, general preferences
|
|
60
61
|
<critical_reminder>
|
61
62
|
Your notes are the sole record of evicted messages. Every word should enable future continuity.
|
62
63
|
</critical_reminder>
|
64
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
You are the single LLM turn in a low-latency voice assistant pipeline (STT ➜ LLM ➜ TTS).
|
2
3
|
Your goals, in priority order, are:
|
3
4
|
|
@@ -27,3 +28,4 @@ Tone.
|
|
27
28
|
|
28
29
|
The memory of the conversation so far below contains enduring facts and user preferences produced by the system.
|
29
30
|
Treat it as reliable ground-truth context. If the user references information that should appear here but does not, follow guidelines and consider `search_memory`.
|
31
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
You are Letta-Sleeptime-Memory, the latest version of Limnal Corporation's memory management system (developed 2025). You operate asynchronously to maintain the memories of a chat agent interacting with a user.
|
2
3
|
|
3
4
|
Your current task involves a two-phase process executed sequentially:
|
@@ -71,3 +72,4 @@ After the `store_memories` tool call is processed, consider the current content
|
|
71
72
|
|
72
73
|
Output Requirements:
|
73
74
|
- You MUST ONLY output tool calls in the specified sequence: First `store_memories` (once), then one or more `rethink_user_memory` calls, and finally `finish_rethinking_memory` (once).
|
75
|
+
"""
|
@@ -1,3 +1,4 @@
|
|
1
|
+
PROMPT = r"""
|
1
2
|
<base_instructions>
|
2
3
|
You are Letta workflow agent, the latest version of Limnal Corporation's digital AI agent, developed in 2025.
|
3
4
|
You are an AI agent that is capable of running one or more tools in a sequence to accomplish a task.
|
@@ -13,3 +14,4 @@ You should use your inner monologue to plan actions or think privately.
|
|
13
14
|
|
14
15
|
Base instructions finished.
|
15
16
|
</base_instructions>
|
17
|
+
"""
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Optional
|
2
|
+
|
3
|
+
from fastapi import Header
|
4
|
+
from pydantic import BaseModel
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from letta.server.server import SyncServer
|
8
|
+
|
9
|
+
|
10
|
+
class HeaderParams(BaseModel):
|
11
|
+
"""Common header parameters used across REST API endpoints."""
|
12
|
+
|
13
|
+
actor_id: Optional[str] = None
|
14
|
+
user_agent: Optional[str] = None
|
15
|
+
project_id: Optional[str] = None
|
16
|
+
|
17
|
+
|
18
|
+
def get_headers(
|
19
|
+
actor_id: Optional[str] = Header(None, alias="user_id"),
|
20
|
+
user_agent: Optional[str] = Header(None, alias="User-Agent"),
|
21
|
+
project_id: Optional[str] = Header(None, alias="X-Project-Id"),
|
22
|
+
) -> HeaderParams:
|
23
|
+
"""Dependency injection function to extract common headers from requests."""
|
24
|
+
return HeaderParams(
|
25
|
+
actor_id=actor_id,
|
26
|
+
user_agent=user_agent,
|
27
|
+
project_id=project_id,
|
28
|
+
)
|
29
|
+
|
30
|
+
|
31
|
+
# TODO: why does this double up the interface?
|
32
|
+
async def get_letta_server() -> "SyncServer":
|
33
|
+
# Check if a global server is already instantiated
|
34
|
+
from letta.server.rest_api.app import server
|
35
|
+
|
36
|
+
# assert isinstance(server, SyncServer)
|
37
|
+
return server
|
@@ -11,9 +11,10 @@ from letta.log import get_logger
|
|
11
11
|
from letta.schemas.message import Message, MessageCreate
|
12
12
|
from letta.schemas.user import User
|
13
13
|
from letta.server.rest_api.chat_completions_interface import ChatCompletionsStreamingInterface
|
14
|
+
from letta.server.rest_api.dependencies import HeaderParams, get_headers, get_letta_server
|
14
15
|
|
15
16
|
# TODO this belongs in a controller!
|
16
|
-
from letta.server.rest_api.utils import
|
17
|
+
from letta.server.rest_api.utils import get_user_message_from_chat_completions_request, sse_async_generator
|
17
18
|
from letta.utils import safe_create_task
|
18
19
|
|
19
20
|
if TYPE_CHECKING:
|
@@ -39,13 +40,13 @@ async def create_chat_completions(
|
|
39
40
|
agent_id: str,
|
40
41
|
completion_request: CompletionCreateParams = Body(...),
|
41
42
|
server: "SyncServer" = Depends(get_letta_server),
|
42
|
-
|
43
|
+
headers: HeaderParams = Depends(get_headers),
|
43
44
|
):
|
44
45
|
# Validate and process fields
|
45
46
|
if not completion_request["stream"]:
|
46
47
|
raise HTTPException(status_code=400, detail="Must be streaming request: `stream` was set to `False` in the request.")
|
47
48
|
|
48
|
-
actor = server.user_manager.get_user_or_default(user_id=
|
49
|
+
actor = server.user_manager.get_user_or_default(user_id=headers.actor_id)
|
49
50
|
|
50
51
|
letta_agent = server.load_agent(agent_id=agent_id, actor=actor)
|
51
52
|
llm_config = letta_agent.agent_state.llm_config
|