letta-nightly 0.12.1.dev20251024104217__py3-none-any.whl → 0.13.0.dev20251024223017__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 +2 -3
- letta/adapters/letta_llm_adapter.py +1 -0
- letta/adapters/simple_llm_request_adapter.py +8 -5
- letta/adapters/simple_llm_stream_adapter.py +22 -6
- letta/agents/agent_loop.py +10 -3
- letta/agents/base_agent.py +4 -1
- letta/agents/helpers.py +41 -9
- letta/agents/letta_agent.py +11 -10
- letta/agents/letta_agent_v2.py +47 -37
- letta/agents/letta_agent_v3.py +395 -300
- letta/agents/voice_agent.py +8 -6
- letta/agents/voice_sleeptime_agent.py +3 -3
- letta/constants.py +30 -7
- letta/errors.py +20 -0
- letta/functions/function_sets/base.py +55 -3
- letta/functions/mcp_client/types.py +33 -57
- letta/functions/schema_generator.py +135 -23
- letta/groups/sleeptime_multi_agent_v3.py +6 -11
- letta/groups/sleeptime_multi_agent_v4.py +227 -0
- letta/helpers/converters.py +78 -4
- letta/helpers/crypto_utils.py +6 -2
- letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py +9 -11
- letta/interfaces/anthropic_streaming_interface.py +3 -4
- letta/interfaces/gemini_streaming_interface.py +4 -6
- letta/interfaces/openai_streaming_interface.py +63 -28
- letta/llm_api/anthropic_client.py +7 -4
- letta/llm_api/deepseek_client.py +6 -4
- letta/llm_api/google_ai_client.py +3 -12
- letta/llm_api/google_vertex_client.py +1 -1
- letta/llm_api/helpers.py +90 -61
- letta/llm_api/llm_api_tools.py +4 -1
- letta/llm_api/openai.py +12 -12
- letta/llm_api/openai_client.py +53 -16
- letta/local_llm/constants.py +4 -3
- letta/local_llm/json_parser.py +5 -2
- letta/local_llm/utils.py +2 -3
- letta/log.py +171 -7
- letta/orm/agent.py +43 -9
- letta/orm/archive.py +4 -0
- letta/orm/custom_columns.py +15 -0
- letta/orm/identity.py +11 -11
- letta/orm/mcp_server.py +9 -0
- letta/orm/message.py +6 -1
- letta/orm/run_metrics.py +7 -2
- letta/orm/sqlalchemy_base.py +2 -2
- letta/orm/tool.py +3 -0
- letta/otel/tracing.py +2 -0
- letta/prompts/prompt_generator.py +7 -2
- letta/schemas/agent.py +41 -10
- letta/schemas/agent_file.py +3 -0
- letta/schemas/archive.py +4 -2
- letta/schemas/block.py +2 -1
- letta/schemas/enums.py +36 -3
- letta/schemas/file.py +3 -3
- letta/schemas/folder.py +2 -1
- letta/schemas/group.py +2 -1
- letta/schemas/identity.py +18 -9
- letta/schemas/job.py +3 -1
- letta/schemas/letta_message.py +71 -12
- letta/schemas/letta_request.py +7 -3
- letta/schemas/letta_stop_reason.py +0 -25
- letta/schemas/llm_config.py +8 -2
- letta/schemas/mcp.py +80 -83
- letta/schemas/mcp_server.py +349 -0
- letta/schemas/memory.py +20 -8
- letta/schemas/message.py +212 -67
- letta/schemas/providers/anthropic.py +13 -6
- letta/schemas/providers/azure.py +6 -4
- letta/schemas/providers/base.py +8 -4
- letta/schemas/providers/bedrock.py +6 -2
- letta/schemas/providers/cerebras.py +7 -3
- letta/schemas/providers/deepseek.py +2 -1
- letta/schemas/providers/google_gemini.py +15 -6
- letta/schemas/providers/groq.py +2 -1
- letta/schemas/providers/lmstudio.py +9 -6
- letta/schemas/providers/mistral.py +2 -1
- letta/schemas/providers/openai.py +7 -2
- letta/schemas/providers/together.py +9 -3
- letta/schemas/providers/xai.py +7 -3
- letta/schemas/run.py +7 -2
- letta/schemas/run_metrics.py +2 -1
- letta/schemas/sandbox_config.py +2 -2
- letta/schemas/secret.py +3 -158
- letta/schemas/source.py +2 -2
- letta/schemas/step.py +2 -2
- letta/schemas/tool.py +24 -1
- letta/schemas/usage.py +0 -1
- letta/server/rest_api/app.py +123 -7
- letta/server/rest_api/dependencies.py +3 -0
- letta/server/rest_api/interface.py +7 -4
- letta/server/rest_api/redis_stream_manager.py +16 -1
- letta/server/rest_api/routers/v1/__init__.py +7 -0
- letta/server/rest_api/routers/v1/agents.py +332 -322
- letta/server/rest_api/routers/v1/archives.py +127 -40
- letta/server/rest_api/routers/v1/blocks.py +54 -6
- letta/server/rest_api/routers/v1/chat_completions.py +146 -0
- letta/server/rest_api/routers/v1/folders.py +27 -35
- letta/server/rest_api/routers/v1/groups.py +23 -35
- letta/server/rest_api/routers/v1/identities.py +24 -10
- letta/server/rest_api/routers/v1/internal_runs.py +107 -0
- letta/server/rest_api/routers/v1/internal_templates.py +162 -179
- letta/server/rest_api/routers/v1/jobs.py +15 -27
- letta/server/rest_api/routers/v1/mcp_servers.py +309 -0
- letta/server/rest_api/routers/v1/messages.py +23 -34
- letta/server/rest_api/routers/v1/organizations.py +6 -27
- letta/server/rest_api/routers/v1/providers.py +35 -62
- letta/server/rest_api/routers/v1/runs.py +30 -43
- letta/server/rest_api/routers/v1/sandbox_configs.py +6 -4
- letta/server/rest_api/routers/v1/sources.py +26 -42
- letta/server/rest_api/routers/v1/steps.py +16 -29
- letta/server/rest_api/routers/v1/tools.py +17 -13
- letta/server/rest_api/routers/v1/users.py +5 -17
- letta/server/rest_api/routers/v1/voice.py +18 -27
- letta/server/rest_api/streaming_response.py +5 -2
- letta/server/rest_api/utils.py +187 -25
- letta/server/server.py +27 -22
- letta/server/ws_api/server.py +5 -4
- letta/services/agent_manager.py +148 -26
- letta/services/agent_serialization_manager.py +6 -1
- letta/services/archive_manager.py +168 -15
- letta/services/block_manager.py +14 -4
- letta/services/file_manager.py +33 -29
- letta/services/group_manager.py +10 -0
- letta/services/helpers/agent_manager_helper.py +65 -11
- letta/services/identity_manager.py +105 -4
- letta/services/job_manager.py +11 -1
- letta/services/mcp/base_client.py +2 -2
- letta/services/mcp/oauth_utils.py +33 -8
- letta/services/mcp_manager.py +174 -78
- letta/services/mcp_server_manager.py +1331 -0
- letta/services/message_manager.py +109 -4
- letta/services/organization_manager.py +4 -4
- letta/services/passage_manager.py +9 -25
- letta/services/provider_manager.py +91 -15
- letta/services/run_manager.py +72 -15
- letta/services/sandbox_config_manager.py +45 -3
- letta/services/source_manager.py +15 -8
- letta/services/step_manager.py +24 -1
- letta/services/streaming_service.py +581 -0
- letta/services/summarizer/summarizer.py +1 -1
- letta/services/tool_executor/core_tool_executor.py +111 -0
- letta/services/tool_executor/files_tool_executor.py +5 -3
- letta/services/tool_executor/sandbox_tool_executor.py +2 -2
- letta/services/tool_executor/tool_execution_manager.py +1 -1
- letta/services/tool_manager.py +10 -3
- letta/services/tool_sandbox/base.py +61 -1
- letta/services/tool_sandbox/local_sandbox.py +1 -3
- letta/services/user_manager.py +2 -2
- letta/settings.py +49 -5
- letta/system.py +14 -5
- letta/utils.py +73 -1
- letta/validators.py +105 -0
- {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/METADATA +4 -2
- {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/RECORD +157 -151
- letta/schemas/letta_ping.py +0 -28
- letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
- {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/WHEEL +0 -0
- {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/entry_points.txt +0 -0
- {letta_nightly-0.12.1.dev20251024104217.dist-info → letta_nightly-0.13.0.dev20251024223017.dist-info}/licenses/LICENSE +0 -0
letta/validators.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import re
|
|
3
|
+
from functools import wraps
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
from fastapi import Path
|
|
7
|
+
|
|
8
|
+
from letta.errors import LettaInvalidArgumentError
|
|
9
|
+
from letta.schemas.enums import PrimitiveType # PrimitiveType is now in schemas.enums
|
|
10
|
+
|
|
11
|
+
# Map from PrimitiveType to the actual prefix string (which is just the enum value)
|
|
12
|
+
PRIMITIVE_ID_PREFIXES = {primitive_type: primitive_type.value for primitive_type in PrimitiveType}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
PRIMITIVE_ID_PATTERNS = {
|
|
16
|
+
# f-string interpolation gets confused because of the regex's required curly braces {}
|
|
17
|
+
prefix: re.compile("^" + prefix + "-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
|
|
18
|
+
for prefix in PRIMITIVE_ID_PREFIXES.values()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _create_path_validator_factory(primitive: str):
|
|
23
|
+
"""
|
|
24
|
+
Creates a factory function that returns a fresh Path validator.
|
|
25
|
+
|
|
26
|
+
This avoids shared state issues when the same validator is used
|
|
27
|
+
across multiple endpoints with different parameter names.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def factory():
|
|
31
|
+
return Path(
|
|
32
|
+
description=f"The ID of the {primitive} in the format '{primitive}-<uuid4>'",
|
|
33
|
+
pattern=PRIMITIVE_ID_PATTERNS[primitive].pattern,
|
|
34
|
+
examples=[f"{primitive}-123e4567-e89b-42d3-8456-426614174000"],
|
|
35
|
+
min_length=len(primitive) + 1 + 36,
|
|
36
|
+
max_length=len(primitive) + 1 + 36,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return factory
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# PATH_VALIDATORS now contains factory functions, not Path objects
|
|
43
|
+
# Usage: folder_id: str = PATH_VALIDATORS[PrimitiveType.FOLDER.value]()
|
|
44
|
+
PATH_VALIDATORS = {primitive_type.value: _create_path_validator_factory(primitive_type.value) for primitive_type in PrimitiveType}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Type aliases for common ID types
|
|
48
|
+
# These can be used directly in route handler signatures for cleaner code
|
|
49
|
+
AgentId = Annotated[str, PATH_VALIDATORS[PrimitiveType.AGENT.value]()]
|
|
50
|
+
ToolId = Annotated[str, PATH_VALIDATORS[PrimitiveType.TOOL.value]()]
|
|
51
|
+
SourceId = Annotated[str, PATH_VALIDATORS[PrimitiveType.SOURCE.value]()]
|
|
52
|
+
BlockId = Annotated[str, PATH_VALIDATORS[PrimitiveType.BLOCK.value]()]
|
|
53
|
+
MessageId = Annotated[str, PATH_VALIDATORS[PrimitiveType.MESSAGE.value]()]
|
|
54
|
+
RunId = Annotated[str, PATH_VALIDATORS[PrimitiveType.RUN.value]()]
|
|
55
|
+
JobId = Annotated[str, PATH_VALIDATORS[PrimitiveType.JOB.value]()]
|
|
56
|
+
GroupId = Annotated[str, PATH_VALIDATORS[PrimitiveType.GROUP.value]()]
|
|
57
|
+
FileId = Annotated[str, PATH_VALIDATORS[PrimitiveType.FILE.value]()]
|
|
58
|
+
FolderId = Annotated[str, PATH_VALIDATORS[PrimitiveType.FOLDER.value]()]
|
|
59
|
+
ArchiveId = Annotated[str, PATH_VALIDATORS[PrimitiveType.ARCHIVE.value]()]
|
|
60
|
+
PassageId = Annotated[str, PATH_VALIDATORS[PrimitiveType.PASSAGE.value]()]
|
|
61
|
+
ProviderId = Annotated[str, PATH_VALIDATORS[PrimitiveType.PROVIDER.value]()]
|
|
62
|
+
SandboxConfigId = Annotated[str, PATH_VALIDATORS[PrimitiveType.SANDBOX_CONFIG.value]()]
|
|
63
|
+
StepId = Annotated[str, PATH_VALIDATORS[PrimitiveType.STEP.value]()]
|
|
64
|
+
IdentityId = Annotated[str, PATH_VALIDATORS[PrimitiveType.IDENTITY.value]()]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def raise_on_invalid_id(param_name: str, expected_prefix: PrimitiveType):
|
|
68
|
+
"""
|
|
69
|
+
Decorator that validates an ID parameter has the expected prefix format.
|
|
70
|
+
Can be stacked multiple times on the same function to validate different IDs.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
param_name: The name of the function parameter to validate (e.g., "agent_id")
|
|
74
|
+
expected_prefix: The expected primitive type (e.g., PrimitiveType.AGENT)
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
@raise_on_invalid_id(param_name="agent_id", expected_prefix=PrimitiveType.AGENT)
|
|
78
|
+
@raise_on_invalid_id(param_name="folder_id", expected_prefix=PrimitiveType.FOLDER)
|
|
79
|
+
def my_function(agent_id: str, folder_id: str):
|
|
80
|
+
pass
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
def decorator(function):
|
|
84
|
+
@wraps(function)
|
|
85
|
+
def wrapper(*args, **kwargs):
|
|
86
|
+
sig = inspect.signature(function)
|
|
87
|
+
bound_args = sig.bind(*args, **kwargs)
|
|
88
|
+
bound_args.apply_defaults()
|
|
89
|
+
|
|
90
|
+
if param_name in bound_args.arguments:
|
|
91
|
+
arg_value = bound_args.arguments[param_name]
|
|
92
|
+
|
|
93
|
+
if arg_value is not None:
|
|
94
|
+
prefix = PRIMITIVE_ID_PREFIXES[expected_prefix]
|
|
95
|
+
if PRIMITIVE_ID_PATTERNS[prefix].match(arg_value) is None:
|
|
96
|
+
raise LettaInvalidArgumentError(
|
|
97
|
+
message=f"Invalid {expected_prefix.value} ID format: {arg_value}. Expected format: '{prefix}-<uuid4>'",
|
|
98
|
+
argument_name=param_name,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return function(*args, **kwargs)
|
|
102
|
+
|
|
103
|
+
return wrapper
|
|
104
|
+
|
|
105
|
+
return decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: letta-nightly
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0.dev20251024223017
|
|
4
4
|
Summary: Create LLM agents with long-term memory and custom tools
|
|
5
5
|
Author-email: Letta Team <contact@letta.com>
|
|
6
6
|
License: Apache License
|
|
@@ -99,7 +99,6 @@ Requires-Dist: pytest-json-report>=1.5.0; extra == 'dev'
|
|
|
99
99
|
Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
|
|
100
100
|
Requires-Dist: pytest-order>=1.2.0; extra == 'dev'
|
|
101
101
|
Provides-Extra: experimental
|
|
102
|
-
Requires-Dist: google-cloud-profiler>=4.1.0; extra == 'experimental'
|
|
103
102
|
Requires-Dist: granian[reload,uvloop]>=2.3.2; extra == 'experimental'
|
|
104
103
|
Requires-Dist: uvloop>=0.21.0; extra == 'experimental'
|
|
105
104
|
Provides-Extra: external-tools
|
|
@@ -119,6 +118,9 @@ Requires-Dist: pg8000>=1.30.3; extra == 'postgres'
|
|
|
119
118
|
Requires-Dist: pgvector>=0.2.3; extra == 'postgres'
|
|
120
119
|
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'postgres'
|
|
121
120
|
Requires-Dist: psycopg2>=2.9.10; extra == 'postgres'
|
|
121
|
+
Provides-Extra: profiling
|
|
122
|
+
Requires-Dist: ddtrace>=2.18.2; extra == 'profiling'
|
|
123
|
+
Requires-Dist: google-cloud-profiler>=4.1.0; extra == 'profiling'
|
|
122
124
|
Provides-Extra: redis
|
|
123
125
|
Requires-Dist: redis>=6.2.0; extra == 'redis'
|
|
124
126
|
Provides-Extra: server
|