Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
run black, add isort config to pyproject.toml
Caren Thomas7144fd2867ba
diff --git a/alembic/env.py b/alembic/env.pyindex e7dfe71c6..767b7bbdb 100644--- a/alembic/env.py+++ b/alembic/env.py@@ -1,11 +1,12 @@import osfrom logging.config import fileConfig+from sqlalchemy import engine_from_config, pool+from alembic import contextfrom letta.config import LettaConfigfrom letta.orm import Basefrom letta.settings import settings-from sqlalchemy import engine_from_config, poolletta_config = LettaConfig.load()diff --git a/alembic/versions/08b2f8225812_adding_toolsagents_orm.py b/alembic/versions/08b2f8225812_adding_toolsagents_orm.pyindex d0e2cac86..0da80aae5 100644--- a/alembic/versions/08b2f8225812_adding_toolsagents_orm.py+++ b/alembic/versions/08b2f8225812_adding_toolsagents_orm.py@@ -9,6 +9,7 @@ Create Date: 2024-12-05 16:46:51.258831from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/1c8880d671ee_make_an_blocks_agents_mapping_table.py b/alembic/versions/1c8880d671ee_make_an_blocks_agents_mapping_table.pyindex 6890e0ed7..ffcb0b671 100644--- a/alembic/versions/1c8880d671ee_make_an_blocks_agents_mapping_table.py+++ b/alembic/versions/1c8880d671ee_make_an_blocks_agents_mapping_table.py@@ -9,6 +9,7 @@ Create Date: 2024-11-22 15:42:47.209229from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/3c683a662c82_migrate_jobs_to_the_orm.py b/alembic/versions/3c683a662c82_migrate_jobs_to_the_orm.pyindex 62b97e9d7..4f9b746d5 100644--- a/alembic/versions/3c683a662c82_migrate_jobs_to_the_orm.py+++ b/alembic/versions/3c683a662c82_migrate_jobs_to_the_orm.py@@ -9,9 +9,10 @@ Create Date: 2024-12-04 15:59:41.708396from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "3c683a662c82"down_revision: Union[str, None] = "5987401b40ae"diff --git a/alembic/versions/4e88e702f85e_drop_api_tokens_table_in_oss.py b/alembic/versions/4e88e702f85e_drop_api_tokens_table_in_oss.pyindex b692e8556..75a90445a 100644--- a/alembic/versions/4e88e702f85e_drop_api_tokens_table_in_oss.py+++ b/alembic/versions/4e88e702f85e_drop_api_tokens_table_in_oss.py@@ -9,6 +9,7 @@ Create Date: 2024-12-13 17:19:55.796210from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/54dec07619c4_divide_passage_table_into_.py b/alembic/versions/54dec07619c4_divide_passage_table_into_.pyindex ead70ec64..e164a997b 100644--- a/alembic/versions/54dec07619c4_divide_passage_table_into_.py+++ b/alembic/versions/54dec07619c4_divide_passage_table_into_.py@@ -9,11 +9,12 @@ Create Date: 2024-12-14 17:23:08.772554from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import op-from letta.orm.custom_columns import EmbeddingConfigColumnfrom pgvector.sqlalchemy import Vectorfrom sqlalchemy.dialects import postgresql+from alembic import op+from letta.orm.custom_columns import EmbeddingConfigColumn+# revision identifiers, used by Alembic.revision: str = "54dec07619c4"down_revision: Union[str, None] = "4e88e702f85e"diff --git a/alembic/versions/5987401b40ae_refactor_agent_memory.py b/alembic/versions/5987401b40ae_refactor_agent_memory.pyindex 84e4ebe2d..889e9425b 100644--- a/alembic/versions/5987401b40ae_refactor_agent_memory.py+++ b/alembic/versions/5987401b40ae_refactor_agent_memory.py@@ -9,9 +9,10 @@ Create Date: 2024-11-25 14:35:00.896507from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "5987401b40ae"down_revision: Union[str, None] = "1c8880d671ee"diff --git a/alembic/versions/95badb46fdf9_migrate_messages_to_the_orm.py b/alembic/versions/95badb46fdf9_migrate_messages_to_the_orm.pyindex f200e65e8..73254e39e 100644--- a/alembic/versions/95badb46fdf9_migrate_messages_to_the_orm.py+++ b/alembic/versions/95badb46fdf9_migrate_messages_to_the_orm.py@@ -9,9 +9,10 @@ Create Date: 2024-12-05 14:02:04.163150from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "95badb46fdf9"down_revision: Union[str, None] = "08b2f8225812"diff --git a/alembic/versions/9a505cc7eca9_create_a_baseline_migrations.py b/alembic/versions/9a505cc7eca9_create_a_baseline_migrations.pyindex 6ef44d476..21f6a3961 100644--- a/alembic/versions/9a505cc7eca9_create_a_baseline_migrations.py+++ b/alembic/versions/9a505cc7eca9_create_a_baseline_migrations.py@@ -8,12 +8,13 @@ Create Date: 2024-10-11 14:19:19.875656from typing import Sequence, Union-import letta.ormimport pgvectorimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+import letta.orm+from alembic import op+# revision identifiers, used by Alembic.revision: str = "9a505cc7eca9"down_revision: Union[str, None] = Nonediff --git a/alembic/versions/a91994b9752f_add_column_to_tools_table_to_contain_.py b/alembic/versions/a91994b9752f_add_column_to_tools_table_to_contain_.pyindex 157e87ef3..f8da3856b 100644--- a/alembic/versions/a91994b9752f_add_column_to_tools_table_to_contain_.py+++ b/alembic/versions/a91994b9752f_add_column_to_tools_table_to_contain_.py@@ -9,6 +9,7 @@ Create Date: 2024-12-09 18:27:25.650079from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import opfrom letta.constants import FUNCTION_RETURN_CHAR_LIMITdiff --git a/alembic/versions/b6d7ca024aa9_add_agents_tags_table.py b/alembic/versions/b6d7ca024aa9_add_agents_tags_table.pyindex 638bc5b5c..2aec8a09f 100644--- a/alembic/versions/b6d7ca024aa9_add_agents_tags_table.py+++ b/alembic/versions/b6d7ca024aa9_add_agents_tags_table.py@@ -9,6 +9,7 @@ Create Date: 2024-11-06 10:48:08.424108from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/c5d964280dff_add_passages_orm_drop_legacy_passages_.py b/alembic/versions/c5d964280dff_add_passages_orm_drop_legacy_passages_.pyindex fb0eafab6..b6d2e6ba8 100644--- a/alembic/versions/c5d964280dff_add_passages_orm_drop_legacy_passages_.py+++ b/alembic/versions/c5d964280dff_add_passages_orm_drop_legacy_passages_.py@@ -9,9 +9,10 @@ Create Date: 2024-12-10 15:05:32.335519from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "c5d964280dff"down_revision: Union[str, None] = "a91994b9752f"diff --git a/alembic/versions/c85a3d07c028_move_files_to_orm.py b/alembic/versions/c85a3d07c028_move_files_to_orm.pyindex 7d853e6a8..b05d79303 100644--- a/alembic/versions/c85a3d07c028_move_files_to_orm.py+++ b/alembic/versions/c85a3d07c028_move_files_to_orm.py@@ -9,6 +9,7 @@ Create Date: 2024-11-12 13:58:57.221081from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/cda66b6cb0d6_move_sources_to_orm.py b/alembic/versions/cda66b6cb0d6_move_sources_to_orm.pyindex ae10edbd0..f46bef6b4 100644--- a/alembic/versions/cda66b6cb0d6_move_sources_to_orm.py+++ b/alembic/versions/cda66b6cb0d6_move_sources_to_orm.py@@ -9,9 +9,10 @@ Create Date: 2024-11-07 13:29:57.186107from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "cda66b6cb0d6"down_revision: Union[str, None] = "b6d7ca024aa9"diff --git a/alembic/versions/d05669b60ebe_migrate_agents_to_orm.py b/alembic/versions/d05669b60ebe_migrate_agents_to_orm.pyindex 61b24f5ed..d03652c85 100644--- a/alembic/versions/d05669b60ebe_migrate_agents_to_orm.py+++ b/alembic/versions/d05669b60ebe_migrate_agents_to_orm.py@@ -9,9 +9,10 @@ Create Date: 2024-12-12 10:25:31.825635from typing import Sequence, Unionimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "d05669b60ebe"down_revision: Union[str, None] = "c5d964280dff"diff --git a/alembic/versions/d14ae606614c_move_organizations_users_tools_to_orm.py b/alembic/versions/d14ae606614c_move_organizations_users_tools_to_orm.pyindex 5c0dab194..e8733313f 100644--- a/alembic/versions/d14ae606614c_move_organizations_users_tools_to_orm.py+++ b/alembic/versions/d14ae606614c_move_organizations_users_tools_to_orm.py@@ -8,11 +8,12 @@ Create Date: 2024-11-05 15:03:12.350096from typing import Sequence, Union-import lettaimport sqlalchemy as sa-from alembic import opfrom sqlalchemy.dialects import postgresql+import letta+from alembic import op+# revision identifiers, used by Alembic.revision: str = "d14ae606614c"down_revision: Union[str, None] = "9a505cc7eca9"diff --git a/alembic/versions/e1a625072dbf_tweak_created_at_field_for_messages.py b/alembic/versions/e1a625072dbf_tweak_created_at_field_for_messages.pyindex 4fd8abd2d..fb425db31 100644--- a/alembic/versions/e1a625072dbf_tweak_created_at_field_for_messages.py+++ b/alembic/versions/e1a625072dbf_tweak_created_at_field_for_messages.py@@ -8,9 +8,10 @@ Create Date: 2024-12-07 14:28:27.643583from typing import Sequence, Union-from alembic import opfrom sqlalchemy.dialects import postgresql+from alembic import op+# revision identifiers, used by Alembic.revision: str = "e1a625072dbf"down_revision: Union[str, None] = "95badb46fdf9"diff --git a/alembic/versions/f7507eab4bb9_migrate_blocks_to_orm_model.py b/alembic/versions/f7507eab4bb9_migrate_blocks_to_orm_model.pyindex 37a67d88e..9e7fa270c 100644--- a/alembic/versions/f7507eab4bb9_migrate_blocks_to_orm_model.py+++ b/alembic/versions/f7507eab4bb9_migrate_blocks_to_orm_model.py@@ -9,6 +9,7 @@ Create Date: 2024-11-18 15:40:13.149438from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/alembic/versions/f81ceea2c08d_create_sandbox_config_and_sandbox_env_.py b/alembic/versions/f81ceea2c08d_create_sandbox_config_and_sandbox_env_.pyindex 32a1b6779..55332bfc1 100644--- a/alembic/versions/f81ceea2c08d_create_sandbox_config_and_sandbox_env_.py+++ b/alembic/versions/f81ceea2c08d_create_sandbox_config_and_sandbox_env_.py@@ -9,6 +9,7 @@ Create Date: 2024-11-14 17:51:27.263561from typing import Sequence, Unionimport sqlalchemy as sa+from alembic import op# revision identifiers, used by Alembic.diff --git a/examples/swarm/simple.py b/examples/swarm/simple.pyindex 7bedb0329..8e10c486d 100644--- a/examples/swarm/simple.py+++ b/examples/swarm/simple.py@@ -1,7 +1,8 @@import typer-from letta import EmbeddingConfig, LLMConfigfrom swarm import Swarm+from letta import EmbeddingConfig, LLMConfig+"""This is an example of how to implement the basic example provided by OpenAI for tranferring a conversation between two agents:https://github.com/openai/swarm/tree/main?tab=readme-ov-file#usagediff --git a/examples/swarm/swarm.py b/examples/swarm/swarm.pyindex 40552997b..ef080806d 100644--- a/examples/swarm/swarm.py+++ b/examples/swarm/swarm.py@@ -2,6 +2,7 @@ import jsonfrom typing import List, Optionalimport typer+from letta import AgentState, EmbeddingConfig, LLMConfig, create_clientfrom letta.schemas.agent import AgentTypefrom letta.schemas.memory import BasicBlockMemory, Blockdiff --git a/examples/tool_rule_usage.py b/examples/tool_rule_usage.pyindex 4e0193f8f..54e051e2d 100644--- a/examples/tool_rule_usage.py+++ b/examples/tool_rule_usage.py@@ -4,10 +4,7 @@ import uuidfrom letta import create_clientfrom letta.schemas.letta_message import ToolCallMessagefrom letta.schemas.tool_rule import ChildToolRule, InitToolRule, TerminalToolRule-from tests.helpers.endpoints_helper import (- assert_invoked_send_message_with_keyword,- setup_agent,-)+from tests.helpers.endpoints_helper import assert_invoked_send_message_with_keyword, setup_agentfrom tests.helpers.utils import cleanupfrom tests.test_model_letta_perfomance import llm_config_dirdiff --git a/letta/__init__.py b/letta/__init__.pyindex d7911ff5e..46390abe5 100644--- a/letta/__init__.py+++ b/letta/__init__.py@@ -12,13 +12,7 @@ from letta.schemas.file import FileMetadatafrom letta.schemas.job import Jobfrom letta.schemas.letta_message import LettaMessagefrom letta.schemas.llm_config import LLMConfig-from letta.schemas.memory import (- ArchivalMemorySummary,- BasicBlockMemory,- ChatMemory,- Memory,- RecallMemorySummary,-)+from letta.schemas.memory import ArchivalMemorySummary, BasicBlockMemory, ChatMemory, Memory, RecallMemorySummaryfrom letta.schemas.message import Messagefrom letta.schemas.openai.chat_completion_response import UsageStatisticsfrom letta.schemas.organization import Organizationdiff --git a/letta/agent.py b/letta/agent.pyindex 12515ebac..f61ace904 100644--- a/letta/agent.py+++ b/letta/agent.py@@ -7,17 +7,17 @@ from abc import ABC, abstractmethodfrom typing import List, Optional, Tuple, Unionfrom letta.constants import (- BASE_TOOLS,- CLI_WARNING_PREFIX,- ERROR_MESSAGE_PREFIX,- FIRST_MESSAGE_ATTEMPTS,- FUNC_FAILED_HEARTBEAT_MESSAGE,- LLM_MAX_TOKENS,- MESSAGE_SUMMARY_TRUNC_KEEP_N_LAST,- MESSAGE_SUMMARY_TRUNC_TOKEN_FRAC,- MESSAGE_SUMMARY_WARNING_FRAC,- O1_BASE_TOOLS,- REQ_HEARTBEAT_MESSAGE,+ BASE_TOOLS,+ CLI_WARNING_PREFIX,+ ERROR_MESSAGE_PREFIX,+ FIRST_MESSAGE_ATTEMPTS,+ FUNC_FAILED_HEARTBEAT_MESSAGE,+ LLM_MAX_TOKENS,+ MESSAGE_SUMMARY_TRUNC_KEEP_N_LAST,+ MESSAGE_SUMMARY_TRUNC_TOKEN_FRAC,+ MESSAGE_SUMMARY_WARNING_FRAC,+ O1_BASE_TOOLS,+ REQ_HEARTBEAT_MESSAGE,)from letta.errors import ContextWindowExceededErrorfrom letta.helpers import ToolRulesSolver@@ -33,44 +33,31 @@ from letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.enums import MessageRolefrom letta.schemas.memory import ContextWindowOverview, Memoryfrom letta.schemas.message import Message-from letta.schemas.openai.chat_completion_request import (- Tool as ChatCompletionRequestTool,-)+from letta.schemas.openai.chat_completion_request import Tool as ChatCompletionRequestToolfrom letta.schemas.openai.chat_completion_response import ChatCompletionResponse-from letta.schemas.openai.chat_completion_response import (- Message as ChatCompletionMessage,-)+from letta.schemas.openai.chat_completion_response import Message as ChatCompletionMessagefrom letta.schemas.openai.chat_completion_response import UsageStatisticsfrom letta.schemas.tool import Toolfrom letta.schemas.tool_rule import TerminalToolRulefrom letta.schemas.usage import LettaUsageStatisticsfrom letta.services.agent_manager import AgentManagerfrom letta.services.block_manager import BlockManager-from letta.services.helpers.agent_manager_helper import (- check_supports_structured_output,- compile_memory_metadata_block,-)+from letta.services.helpers.agent_manager_helper import check_supports_structured_output, compile_memory_metadata_blockfrom letta.services.message_manager import MessageManagerfrom letta.services.passage_manager import PassageManagerfrom letta.services.tool_execution_sandbox import ToolExecutionSandboxfrom letta.streaming_interface import StreamingRefreshCLIInterface-from letta.system import (- get_heartbeat,- get_token_limit_warning,- package_function_response,- package_summarize_message,- package_user_message,-)+from letta.system import get_heartbeat, get_token_limit_warning, package_function_response, package_summarize_message, package_user_messagefrom letta.utils import (- count_tokens,- get_friendly_error_msg,- get_tool_call_id,- get_utc_time,- json_dumps,- json_loads,- parse_json,- printd,- validate_function_response,+ count_tokens,+ get_friendly_error_msg,+ get_tool_call_id,+ get_utc_time,+ json_dumps,+ json_loads,+ parse_json,+ printd,+ validate_function_response,)diff --git a/letta/benchmark/benchmark.py b/letta/benchmark/benchmark.pyindex b7c01ab7e..7109210e9 100644--- a/letta/benchmark/benchmark.py+++ b/letta/benchmark/benchmark.py@@ -5,6 +5,7 @@ import uuidfrom typing import Annotated, Unionimport typer+from letta import LocalClient, RESTClient, create_clientfrom letta.benchmark.constants import HUMAN, PERSONA, PROMPTS, TRIESfrom letta.config import LettaConfigdiff --git a/letta/cli/cli.py b/letta/cli/cli.pyindex b385a01ca..4441190b2 100644--- a/letta/cli/cli.py+++ b/letta/cli/cli.py@@ -3,18 +3,14 @@ import sysfrom enum import Enumfrom typing import Annotated, Optional-import letta.utils as utilsimport questionaryimport typer++import letta.utils as utilsfrom letta import create_clientfrom letta.agent import Agent, save_agentfrom letta.config import LettaConfig-from letta.constants import (- CLI_WARNING_PREFIX,- CORE_MEMORY_BLOCK_CHAR_LIMIT,- LETTA_DIR,- MIN_CONTEXT_WINDOW,-)+from letta.constants import CLI_WARNING_PREFIX, CORE_MEMORY_BLOCK_CHAR_LIMIT, LETTA_DIR, MIN_CONTEXT_WINDOWfrom letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOLfrom letta.log import get_loggerfrom letta.schemas.enums import OptionState@@ -22,9 +18,7 @@ from letta.schemas.memory import ChatMemory, Memoryfrom letta.server.server import logger as server_logger# from letta.interface import CLIInterface as interface # for printing to terminal-from letta.streaming_interface import (- StreamingRefreshCLIInterface as interface, # for printing to terminal-)+from letta.streaming_interface import StreamingRefreshCLIInterface as interface # for printing to terminalfrom letta.utils import open_folder_in_explorer, printdlogger = get_logger(__name__)diff --git a/letta/cli/cli_config.py b/letta/cli/cli_config.pyindex f70b466b2..8278d5531 100644--- a/letta/cli/cli_config.py+++ b/letta/cli/cli_config.py@@ -5,10 +5,11 @@ from typing import Annotated, List, Optionalimport questionaryimport typer-from letta import utilsfrom prettytable.colortable import ColorTable, Themesfrom tqdm import tqdm+from letta import utils+app = typer.Typer()diff --git a/letta/cli/cli_load.py b/letta/cli/cli_load.pyindex e1d7b1b8c..b27da4d81 100644--- a/letta/cli/cli_load.py+++ b/letta/cli/cli_load.py@@ -13,6 +13,7 @@ from typing import Annotated, List, Optionalimport questionaryimport typer+from letta import create_clientfrom letta.data_sources.connectors import DirectoryConnectordiff --git a/letta/client/client.py b/letta/client/client.pyindex eb1b906f7..9931628cd 100644--- a/letta/client/client.py+++ b/letta/client/client.py@@ -2,16 +2,10 @@ import loggingimport timefrom typing import Callable, Dict, Generator, List, Optional, Union-import letta.utilsimport requests-from letta.constants import (- ADMIN_PREFIX,- BASE_MEMORY_TOOLS,- BASE_TOOLS,- DEFAULT_HUMAN,- DEFAULT_PERSONA,- FUNCTION_RETURN_CHAR_LIMIT,-)++import letta.utils+from letta.constants import ADMIN_PREFIX, BASE_MEMORY_TOOLS, BASE_TOOLS, DEFAULT_HUMAN, DEFAULT_PERSONA, FUNCTION_RETURN_CHAR_LIMITfrom letta.data_sources.connectors import DataConnectorfrom letta.functions.functions import parse_source_codefrom letta.orm.errors import NoResultFound@@ -26,26 +20,20 @@ from letta.schemas.job import Jobfrom letta.schemas.letta_request import LettaRequest, LettaStreamingRequestfrom letta.schemas.letta_response import LettaResponse, LettaStreamingResponsefrom letta.schemas.llm_config import LLMConfig-from letta.schemas.memory import (- ArchivalMemorySummary,- ChatMemory,- CreateArchivalMemory,- Memory,- RecallMemorySummary,-)+from letta.schemas.memory import ArchivalMemorySummary, ChatMemory, CreateArchivalMemory, Memory, RecallMemorySummaryfrom letta.schemas.message import Message, MessageCreate, MessageUpdatefrom letta.schemas.openai.chat_completions import ToolCallfrom letta.schemas.organization import Organizationfrom letta.schemas.passage import Passagefrom letta.schemas.sandbox_config import (- E2BSandboxConfig,- LocalSandboxConfig,- SandboxConfig,- SandboxConfigCreate,- SandboxConfigUpdate,- SandboxEnvironmentVariable,- SandboxEnvironmentVariableCreate,- SandboxEnvironmentVariableUpdate,+ E2BSandboxConfig,+ LocalSandboxConfig,+ SandboxConfig,+ SandboxConfigCreate,+ SandboxConfigUpdate,+ SandboxEnvironmentVariable,+ SandboxEnvironmentVariableCreate,+ SandboxEnvironmentVariableUpdate,)from letta.schemas.source import Source, SourceCreate, SourceUpdatefrom letta.schemas.tool import Tool, ToolCreate, ToolUpdatediff --git a/letta/client/streaming.py b/letta/client/streaming.pyindex 130e8ef2c..86be5c41a 100644--- a/letta/client/streaming.py+++ b/letta/client/streaming.py@@ -3,14 +3,11 @@ from typing import Generatorimport httpxfrom httpx_sse import SSEError, connect_sse+from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRINGfrom letta.errors import LLMErrorfrom letta.schemas.enums import MessageStreamStatus-from letta.schemas.letta_message import (- ReasoningMessage,- ToolCallMessage,- ToolReturnMessage,-)+from letta.schemas.letta_message import ReasoningMessage, ToolCallMessage, ToolReturnMessagefrom letta.schemas.letta_response import LettaStreamingResponsefrom letta.schemas.usage import LettaUsageStatisticsdiff --git a/letta/client/utils.py b/letta/client/utils.pyindex 1588f7d13..f823ee87f 100644--- a/letta/client/utils.py+++ b/letta/client/utils.py@@ -3,12 +3,10 @@ from datetime import datetimefrom typing import Optionalfrom IPython.display import HTML, display-from letta.local_llm.constants import (- ASSISTANT_MESSAGE_CLI_SYMBOL,- INNER_THOUGHTS_CLI_SYMBOL,-)from sqlalchemy.testing.plugin.plugin_base import warnings+from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL, INNER_THOUGHTS_CLI_SYMBOL+def pprint(messages):"""Utility function for pretty-printing the output of client.send_message in notebooks"""diff --git a/letta/config.py b/letta/config.pyindex a50154a60..ed9e8668e 100644--- a/letta/config.py+++ b/letta/config.py@@ -5,12 +5,12 @@ from typing import Optionalimport lettafrom letta.constants import (- CORE_MEMORY_HUMAN_CHAR_LIMIT,- CORE_MEMORY_PERSONA_CHAR_LIMIT,- DEFAULT_HUMAN,- DEFAULT_PERSONA,- DEFAULT_PRESET,- LETTA_DIR,+ CORE_MEMORY_HUMAN_CHAR_LIMIT,+ CORE_MEMORY_PERSONA_CHAR_LIMIT,+ DEFAULT_HUMAN,+ DEFAULT_PERSONA,+ DEFAULT_PRESET,+ LETTA_DIR,)from letta.log import get_loggerfrom letta.schemas.embedding_config import EmbeddingConfigdiff --git a/letta/data_sources/connectors.py b/letta/data_sources/connectors.pyindex 274e25242..8ae67f881 100644--- a/letta/data_sources/connectors.py+++ b/letta/data_sources/connectors.py@@ -1,11 +1,8 @@from typing import Dict, Iterator, List, Tupleimport typer-from letta.data_sources.connectors_helper import (- assert_all_files_exist_locally,- extract_metadata_from_files,- get_filenames_in_dir,-)++from letta.data_sources.connectors_helper import assert_all_files_exist_locally, extract_metadata_from_files, get_filenames_in_dirfrom letta.embeddings import embedding_modelfrom letta.schemas.file import FileMetadatafrom letta.schemas.passage import Passagediff --git a/letta/embeddings.py b/letta/embeddings.pyindex 56f016314..e588f17ab 100644--- a/letta/embeddings.py+++ b/letta/embeddings.py@@ -3,11 +3,8 @@ from typing import Any, List, Optionalimport numpy as npimport tiktoken-from letta.constants import (- EMBEDDING_TO_TOKENIZER_DEFAULT,- EMBEDDING_TO_TOKENIZER_MAP,- MAX_EMBEDDING_DIM,-)++from letta.constants import EMBEDDING_TO_TOKENIZER_DEFAULT, EMBEDDING_TO_TOKENIZER_MAP, MAX_EMBEDDING_DIMfrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.utils import is_valid_url, printddiff --git a/letta/functions/function_sets/extras.py b/letta/functions/function_sets/extras.pyindex c8edc93cb..d5d21644f 100644--- a/letta/functions/function_sets/extras.py+++ b/letta/functions/function_sets/extras.py@@ -3,10 +3,8 @@ import uuidfrom typing import Optionalimport requests-from letta.constants import (- MESSAGE_CHATGPT_FUNCTION_MODEL,- MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE,-)++from letta.constants import MESSAGE_CHATGPT_FUNCTION_MODEL, MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGEfrom letta.llm_api.llm_api_tools import createfrom letta.schemas.message import Messagefrom letta.utils import json_dumps, json_loadsdiff --git a/letta/helpers/tool_rule_solver.py b/letta/helpers/tool_rule_solver.pyindex b9370bf7f..cba8a0ca4 100644--- a/letta/helpers/tool_rule_solver.py+++ b/letta/helpers/tool_rule_solver.py@@ -1,16 +1,11 @@import jsonfrom typing import List, Optional, Union-from letta.schemas.enums import ToolRuleType-from letta.schemas.tool_rule import (- BaseToolRule,- ChildToolRule,- ConditionalToolRule,- InitToolRule,- TerminalToolRule,-)from pydantic import BaseModel, Field+from letta.schemas.enums import ToolRuleType+from letta.schemas.tool_rule import BaseToolRule, ChildToolRule, ConditionalToolRule, InitToolRule, TerminalToolRule+class ToolRuleValidationError(Exception):"""Custom exception for tool rule validation errors in ToolRulesSolver."""diff --git a/letta/interface.py b/letta/interface.pyindex 22e9678c5..28cb0264f 100644--- a/letta/interface.py+++ b/letta/interface.py@@ -3,11 +3,9 @@ from abc import ABC, abstractmethodfrom typing import List, Optionalfrom colorama import Fore, Style, init+from letta.constants import CLI_WARNING_PREFIX-from letta.local_llm.constants import (- ASSISTANT_MESSAGE_CLI_SYMBOL,- INNER_THOUGHTS_CLI_SYMBOL,-)+from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL, INNER_THOUGHTS_CLI_SYMBOLfrom letta.schemas.message import Messagefrom letta.utils import json_loads, printddiff --git a/letta/llm_api/anthropic.py b/letta/llm_api/anthropic.pyindex 059c08815..fb42e696e 100644--- a/letta/llm_api/anthropic.py+++ b/letta/llm_api/anthropic.py@@ -5,13 +5,9 @@ from typing import List, Optional, Unionfrom letta.llm_api.helpers import make_post_requestfrom letta.schemas.message import Messagefrom letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, FunctionCallfrom letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- FunctionCall,-)-from letta.schemas.openai.chat_completion_response import (- Message as ChoiceMessage, # NOTE: avoid conflict with our own Letta Message datatype+ Message as ChoiceMessage, # NOTE: avoid conflict with our own Letta Message datatype)from letta.schemas.openai.chat_completion_response import ToolCall, UsageStatisticsfrom letta.utils import get_utc_time, smart_urljoindiff --git a/letta/llm_api/azure_openai.py b/letta/llm_api/azure_openai.pyindex 047f2f86b..e60b547be 100644--- a/letta/llm_api/azure_openai.py+++ b/letta/llm_api/azure_openai.py@@ -1,6 +1,7 @@from collections import defaultdictimport requests+from letta.llm_api.helpers import make_post_requestfrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.openai.chat_completion_response import ChatCompletionResponsediff --git a/letta/llm_api/cohere.py b/letta/llm_api/cohere.pyindex 7ea633e08..0259f6feb 100644--- a/letta/llm_api/cohere.py+++ b/letta/llm_api/cohere.py@@ -3,16 +3,13 @@ import uuidfrom typing import List, Optional, Unionimport requests+from letta.local_llm.utils import count_tokensfrom letta.schemas.message import Messagefrom letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, FunctionCallfrom letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- FunctionCall,-)-from letta.schemas.openai.chat_completion_response import (- Message as ChoiceMessage, # NOTE: avoid conflict with our own Letta Message datatype+ Message as ChoiceMessage, # NOTE: avoid conflict with our own Letta Message datatype)from letta.schemas.openai.chat_completion_response import ToolCall, UsageStatisticsfrom letta.utils import get_tool_call_id, get_utc_time, json_dumps, smart_urljoin@@ -275,10 +272,7 @@ def convert_tools_to_cohere_format(tools: List[Tool], inner_thoughts_in_kwargs:if inner_thoughts_in_kwargs:# NOTE: since Cohere doesn't allow "text" in the response when a tool call happens, if we want# a simultaneous CoT + tool call we need to put it inside a kwarg- from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,- )+ from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfor cohere_tool in tools_dict_list:cohere_tool["parameter_definitions"][INNER_THOUGHTS_KWARG] = {diff --git a/letta/llm_api/google_ai.py b/letta/llm_api/google_ai.pyindex 483a319f1..1eec3eaae 100644--- a/letta/llm_api/google_ai.py+++ b/letta/llm_api/google_ai.py@@ -2,19 +2,13 @@ import uuidfrom typing import List, Optional, Tupleimport requests+from letta.constants import NON_USER_MSG_PREFIXfrom letta.llm_api.helpers import make_post_requestfrom letta.local_llm.json_parser import clean_json_string_extra_backslashfrom letta.local_llm.utils import count_tokensfrom letta.schemas.openai.chat_completion_request import Tool-from letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- FunctionCall,- Message,- ToolCall,- UsageStatistics,-)+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, FunctionCall, Message, ToolCall, UsageStatisticsfrom letta.utils import get_tool_call_id, get_utc_time, json_dumps@@ -229,10 +223,7 @@ def convert_tools_to_google_ai_format(tools: List[Tool], inner_thoughts_in_kwargparam_fields["type"] = param_fields["type"].upper()# Add inner thoughtsif inner_thoughts_in_kwargs:- from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,- )+ from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfunc["parameters"]["properties"][INNER_THOUGHTS_KWARG] = {"type": "STRING",diff --git a/letta/llm_api/helpers.py b/letta/llm_api/helpers.pyindex 25f77e244..1244b6ffe 100644--- a/letta/llm_api/helpers.py+++ b/letta/llm_api/helpers.py@@ -5,6 +5,7 @@ from collections import OrderedDictfrom typing import Any, List, Unionimport requests+from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRINGfrom letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choicefrom letta.utils import json_dumps, printddiff --git a/letta/llm_api/llm_api_tools.py b/letta/llm_api/llm_api_tools.pyindex 9acb1f017..030d7375c 100644--- a/letta/llm_api/llm_api_tools.py+++ b/letta/llm_api/llm_api_tools.py@@ -3,42 +3,27 @@ import timefrom typing import List, Optional, Unionimport requests+from letta.constants import CLI_WARNING_PREFIXfrom letta.errors import LettaConfigurationError, RateLimitExceededErrorfrom letta.llm_api.anthropic import anthropic_chat_completions_requestfrom letta.llm_api.azure_openai import azure_openai_chat_completions_request-from letta.llm_api.google_ai import (- convert_tools_to_google_ai_format,- google_ai_chat_completions_request,-)-from letta.llm_api.helpers import (- add_inner_thoughts_to_functions,- unpack_all_inner_thoughts_from_kwargs,-)+from letta.llm_api.google_ai import convert_tools_to_google_ai_format, google_ai_chat_completions_request+from letta.llm_api.helpers import add_inner_thoughts_to_functions, unpack_all_inner_thoughts_from_kwargsfrom letta.llm_api.openai import (- build_openai_chat_completions_request,- openai_chat_completions_process_stream,- openai_chat_completions_request,+ build_openai_chat_completions_request,+ openai_chat_completions_process_stream,+ openai_chat_completions_request,)from letta.local_llm.chat_completion_proxy import get_chat_completion-from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,-)+from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfrom letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messagesfrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.message import Message-from letta.schemas.openai.chat_completion_request import (- ChatCompletionRequest,- Tool,- cast_message_to_subtype,-)+from letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool, cast_message_to_subtypefrom letta.schemas.openai.chat_completion_response import ChatCompletionResponsefrom letta.settings import ModelSettings-from letta.streaming_interface import (- AgentChunkStreamingInterface,- AgentRefreshStreamingInterface,-)+from letta.streaming_interface import AgentChunkStreamingInterface, AgentRefreshStreamingInterfaceLLM_API_PROVIDER_OPTIONS = ["openai", "azure", "anthropic", "google_ai", "cohere", "local", "groq"]diff --git a/letta/llm_api/mistral.py b/letta/llm_api/mistral.pyindex b53d76edb..932cf8748 100644--- a/letta/llm_api/mistral.py+++ b/letta/llm_api/mistral.py@@ -1,4 +1,5 @@import requests+from letta.utils import printd, smart_urljoindiff --git a/letta/llm_api/openai.py b/letta/llm_api/openai.pyindex 3ad3cf2a3..bb3557568 100644--- a/letta/llm_api/openai.py+++ b/letta/llm_api/openai.py@@ -6,44 +6,29 @@ import httpximport requestsfrom httpx_sse import connect_ssefrom httpx_sse._exceptions import SSEError+from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRINGfrom letta.errors import LLMError-from letta.llm_api.helpers import (- add_inner_thoughts_to_functions,- convert_to_structured_output,- make_post_request,-)-from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,-)+from letta.llm_api.helpers import add_inner_thoughts_to_functions, convert_to_structured_output, make_post_request+from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfrom letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messagesfrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.message import Message as _Messagefrom letta.schemas.message import MessageRole as _MessageRolefrom letta.schemas.openai.chat_completion_request import ChatCompletionRequest-from letta.schemas.openai.chat_completion_request import (- FunctionCall as ToolFunctionChoiceFunctionCall,-)-from letta.schemas.openai.chat_completion_request import (- Tool,- ToolFunctionChoice,- cast_message_to_subtype,-)+from letta.schemas.openai.chat_completion_request import FunctionCall as ToolFunctionChoiceFunctionCall+from letta.schemas.openai.chat_completion_request import Tool, ToolFunctionChoice, cast_message_to_subtypefrom letta.schemas.openai.chat_completion_response import (- ChatCompletionChunkResponse,- ChatCompletionResponse,- Choice,- FunctionCall,- Message,- ToolCall,- UsageStatistics,+ ChatCompletionChunkResponse,+ ChatCompletionResponse,+ Choice,+ FunctionCall,+ Message,+ ToolCall,+ UsageStatistics,)from letta.schemas.openai.embedding_response import EmbeddingResponse-from letta.streaming_interface import (- AgentChunkStreamingInterface,- AgentRefreshStreamingInterface,-)+from letta.streaming_interface import AgentChunkStreamingInterface, AgentRefreshStreamingInterfacefrom letta.utils import get_tool_call_id, smart_urljoinOPENAI_SSE_DONE = "[DONE]"diff --git a/letta/local_llm/chat_completion_proxy.py b/letta/local_llm/chat_completion_proxy.pyindex aa1731819..184489c8d 100644--- a/letta/local_llm/chat_completion_proxy.py+++ b/letta/local_llm/chat_completion_proxy.py@@ -3,14 +3,12 @@import uuidimport requests+from letta.constants import CLI_WARNING_PREFIXfrom letta.errors import LocalLLMConnectionError, LocalLLMErrorfrom letta.local_llm.constants import DEFAULT_WRAPPERfrom letta.local_llm.function_parser import patch_function-from letta.local_llm.grammars.gbnf_grammar_generator import (- create_dynamic_model_from_function,- generate_gbnf_grammar_and_documentation,-)+from letta.local_llm.grammars.gbnf_grammar_generator import create_dynamic_model_from_function, generate_gbnf_grammar_and_documentationfrom letta.local_llm.koboldcpp.api import get_koboldcpp_completionfrom letta.local_llm.llamacpp.api import get_llamacpp_completionfrom letta.local_llm.llm_chat_completion_wrappers import simple_summary_wrapper@@ -19,17 +17,9 @@ from letta.local_llm.ollama.api import get_ollama_completionfrom letta.local_llm.utils import count_tokens, get_available_wrappersfrom letta.local_llm.vllm.api import get_vllm_completionfrom letta.local_llm.webui.api import get_webui_completion-from letta.local_llm.webui.legacy_api import (- get_webui_completion as get_webui_completion_legacy,-)+from letta.local_llm.webui.legacy_api import get_webui_completion as get_webui_completion_legacyfrom letta.prompts.gpt_summarize import SYSTEM as SUMMARIZE_SYSTEM_MESSAGE-from letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- Message,- ToolCall,- UsageStatistics,-)+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, Message, ToolCall, UsageStatisticsfrom letta.utils import get_tool_call_id, get_utc_time, json_dumpshas_shown_warning = Falsediff --git a/letta/local_llm/constants.py b/letta/local_llm/constants.pyindex 4552f1039..03abcc81d 100644--- a/letta/local_llm/constants.py+++ b/letta/local_llm/constants.py@@ -1,7 +1,5 @@# import letta.local_llm.llm_chat_completion_wrappers.airoboros as airoboros-from letta.local_llm.llm_chat_completion_wrappers.chatml import (- ChatMLInnerMonologueWrapper,-)+from letta.local_llm.llm_chat_completion_wrappers.chatml import ChatMLInnerMonologueWrapperDEFAULT_ENDPOINTS = {# Localdiff --git a/letta/local_llm/grammars/gbnf_grammar_generator.py b/letta/local_llm/grammars/gbnf_grammar_generator.pyindex ce3ace739..402b21bfd 100644--- a/letta/local_llm/grammars/gbnf_grammar_generator.py+++ b/letta/local_llm/grammars/gbnf_grammar_generator.py@@ -5,23 +5,13 @@ from copy import copyfrom enum import Enumfrom inspect import getdoc, isclassfrom types import NoneType-from typing import (- Any,- Callable,- List,- Optional,- Tuple,- Type,- Union,- _GenericAlias,- get_args,- get_origin,-)+from typing import Any, Callable, List, Optional, Tuple, Type, Union, _GenericAlias, get_args, get_originfrom docstring_parser import parse-from letta.utils import json_dumpsfrom pydantic import BaseModel, create_model+from letta.utils import json_dumps+class PydanticDataType(Enum):"""diff --git a/letta/local_llm/llm_chat_completion_wrappers/chatml.py b/letta/local_llm/llm_chat_completion_wrappers/chatml.pyindex 583b77b99..2c1ebaf7f 100644--- a/letta/local_llm/llm_chat_completion_wrappers/chatml.py+++ b/letta/local_llm/llm_chat_completion_wrappers/chatml.py@@ -1,8 +1,6 @@from letta.errors import LLMJSONParsingErrorfrom letta.local_llm.json_parser import clean_json-from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import (- LLMChatCompletionWrapper,-)+from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import LLMChatCompletionWrapperfrom letta.schemas.enums import MessageRolefrom letta.utils import json_dumps, json_loads@@ -75,10 +73,7 @@ class ChatMLInnerMonologueWrapper(LLMChatCompletionWrapper):func_str += f"\n description: {schema['description']}"func_str += f"\n params:"if add_inner_thoughts:- from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,- )+ from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfunc_str += f"\n {INNER_THOUGHTS_KWARG}: {INNER_THOUGHTS_KWARG_DESCRIPTION}"for param_k, param_v in schema["parameters"]["properties"].items():diff --git a/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py b/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.pyindex 4b41d7a57..19f256685 100644--- a/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py+++ b/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py@@ -1,4 +1,5 @@import yaml+from letta.utils import json_dumps, json_loadsfrom ...errors import LLMJSONParsingErrordiff --git a/letta/local_llm/llm_chat_completion_wrappers/llama3.py b/letta/local_llm/llm_chat_completion_wrappers/llama3.pyindex 43174dd54..804e90db7 100644--- a/letta/local_llm/llm_chat_completion_wrappers/llama3.py+++ b/letta/local_llm/llm_chat_completion_wrappers/llama3.py@@ -1,8 +1,6 @@from letta.errors import LLMJSONParsingErrorfrom letta.local_llm.json_parser import clean_json-from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import (- LLMChatCompletionWrapper,-)+from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import LLMChatCompletionWrapperfrom letta.utils import json_dumps, json_loadsPREFIX_HINT = """# Reminders:@@ -74,10 +72,7 @@ class LLaMA3InnerMonologueWrapper(LLMChatCompletionWrapper):func_str += f"\n description: {schema['description']}"func_str += "\n params:"if add_inner_thoughts:- from letta.local_llm.constants import (- INNER_THOUGHTS_KWARG,- INNER_THOUGHTS_KWARG_DESCRIPTION,- )+ from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTIONfunc_str += f"\n {INNER_THOUGHTS_KWARG}: {INNER_THOUGHTS_KWARG_DESCRIPTION}"for param_k, param_v in schema["parameters"]["properties"].items():diff --git a/letta/local_llm/settings/settings.py b/letta/local_llm/settings/settings.pyindex 8a3fcbe8d..9efbcf6ac 100644--- a/letta/local_llm/settings/settings.py+++ b/letta/local_llm/settings/settings.py@@ -2,9 +2,7 @@ import jsonimport osfrom letta.constants import LETTA_DIR-from letta.local_llm.settings.deterministic_mirostat import (- settings as det_miro_settings,-)+from letta.local_llm.settings.deterministic_mirostat import settings as det_miro_settingsfrom letta.local_llm.settings.simple import settings as simple_settingsDEFAULT = "simple"diff --git a/letta/local_llm/utils.py b/letta/local_llm/utils.pyindex 796b3c57a..b0529c358 100644--- a/letta/local_llm/utils.py+++ b/letta/local_llm/utils.py@@ -2,14 +2,15 @@ import osimport warningsfrom typing import List, Union+import requests+import tiktoken+import letta.local_llm.llm_chat_completion_wrappers.airoboros as airoborosimport letta.local_llm.llm_chat_completion_wrappers.chatml as chatmlimport letta.local_llm.llm_chat_completion_wrappers.configurable_wrapper as configurable_wrapperimport letta.local_llm.llm_chat_completion_wrappers.dolphin as dolphinimport letta.local_llm.llm_chat_completion_wrappers.llama3 as llama3import letta.local_llm.llm_chat_completion_wrappers.zephyr as zephyr-import requests-import tiktokenfrom letta.schemas.openai.chat_completion_request import Tool, ToolCalldiff --git a/letta/main.py b/letta/main.pyindex bbcd56e59..de1b4028a 100644--- a/letta/main.py+++ b/letta/main.py@@ -2,12 +2,14 @@ import osimport sysimport traceback-import letta.agent as agent-import letta.errors as errors-import letta.system as systemimport questionaryimport requestsimport typer+from rich.console import Console++import letta.agent as agent+import letta.errors as errors+import letta.system as system# import benchmarkfrom letta import create_client@@ -20,7 +22,6 @@ from letta.constants import FUNC_FAILED_HEARTBEAT_MESSAGE, REQ_HEARTBEAT_MESSAGE# from letta.interface import CLIInterface as interface # for printing to terminalfrom letta.streaming_interface import AgentRefreshStreamingInterface-from rich.console import Console# interface = interface()diff --git a/letta/orm/agent.py b/letta/orm/agent.pyindex b8c541e2d..353d4fe78 100644--- a/letta/orm/agent.py+++ b/letta/orm/agent.py@@ -1,12 +1,11 @@import uuidfrom typing import TYPE_CHECKING, List, Optional+from sqlalchemy import JSON, String, UniqueConstraint+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.block import Block-from letta.orm.custom_columns import (- EmbeddingConfigColumn,- LLMConfigColumn,- ToolRulesColumn,-)+from letta.orm.custom_columns import EmbeddingConfigColumn, LLMConfigColumn, ToolRulesColumnfrom letta.orm.message import Messagefrom letta.orm.mixins import OrganizationMixinfrom letta.orm.organization import Organization@@ -17,8 +16,6 @@ from letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.memory import Memoryfrom letta.schemas.tool_rule import ToolRule-from sqlalchemy import JSON, String, UniqueConstraint-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm.agents_tags import AgentsTagsdiff --git a/letta/orm/agents_tags.py b/letta/orm/agents_tags.pyindex 5041f629c..76ff90110 100644--- a/letta/orm/agents_tags.py+++ b/letta/orm/agents_tags.py@@ -1,7 +1,8 @@-from letta.orm.base import Basefrom sqlalchemy import ForeignKey, String, UniqueConstraintfrom sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.base import Base+class AgentsTags(Base):__tablename__ = "agents_tags"diff --git a/letta/orm/base.py b/letta/orm/base.pyindex f740ef45d..62951741f 100644--- a/letta/orm/base.py+++ b/letta/orm/base.py@@ -2,13 +2,7 @@ from datetime import datetimefrom typing import Optionalfrom sqlalchemy import Boolean, DateTime, String, func, text-from sqlalchemy.orm import (- DeclarativeBase,- Mapped,- declarative_mixin,- declared_attr,- mapped_column,-)+from sqlalchemy.orm import DeclarativeBase, Mapped, declarative_mixin, declared_attr, mapped_columnclass Base(DeclarativeBase):diff --git a/letta/orm/block.py b/letta/orm/block.pyindex 6759596da..99cfa29b2 100644--- a/letta/orm/block.py+++ b/letta/orm/block.py@@ -1,13 +1,14 @@from typing import TYPE_CHECKING, Optional, Type+from sqlalchemy import JSON, BigInteger, Integer, UniqueConstraint, event+from sqlalchemy.orm import Mapped, attributes, mapped_column, relationship+from letta.constants import CORE_MEMORY_BLOCK_CHAR_LIMITfrom letta.orm.blocks_agents import BlocksAgentsfrom letta.orm.mixins import OrganizationMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.block import Block as PydanticBlockfrom letta.schemas.block import Human, Persona-from sqlalchemy import JSON, BigInteger, Integer, UniqueConstraint, event-from sqlalchemy.orm import Mapped, attributes, mapped_column, relationshipif TYPE_CHECKING:from letta.orm import Organizationdiff --git a/letta/orm/blocks_agents.py b/letta/orm/blocks_agents.pyindex 86a75e9a1..4774783b5 100644--- a/letta/orm/blocks_agents.py+++ b/letta/orm/blocks_agents.py@@ -1,7 +1,8 @@-from letta.orm.base import Basefrom sqlalchemy import ForeignKey, ForeignKeyConstraint, String, UniqueConstraintfrom sqlalchemy.orm import Mapped, mapped_column+from letta.orm.base import Base+class BlocksAgents(Base):"""Agents must have one or many blocks to make up their core memory."""diff --git a/letta/orm/custom_columns.py b/letta/orm/custom_columns.pyindex 05113a6a5..f53169d93 100644--- a/letta/orm/custom_columns.py+++ b/letta/orm/custom_columns.py@@ -2,18 +2,14 @@ import base64from typing import List, Unionimport numpy as np+from sqlalchemy import JSON+from sqlalchemy.types import BINARY, TypeDecorator+from letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.enums import ToolRuleTypefrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.openai.chat_completions import ToolCall, ToolCallFunction-from letta.schemas.tool_rule import (- ChildToolRule,- ConditionalToolRule,- InitToolRule,- TerminalToolRule,-)-from sqlalchemy import JSON-from sqlalchemy.types import BINARY, TypeDecorator+from letta.schemas.tool_rule import ChildToolRule, ConditionalToolRule, InitToolRule, TerminalToolRuleclass EmbeddingConfigColumn(TypeDecorator):diff --git a/letta/orm/file.py b/letta/orm/file.pyindex 4216a01a4..88342700e 100644--- a/letta/orm/file.py+++ b/letta/orm/file.py@@ -1,10 +1,11 @@from typing import TYPE_CHECKING, List, Optional+from sqlalchemy import Integer, String+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.mixins import OrganizationMixin, SourceMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.file import FileMetadata as PydanticFileMetadata-from sqlalchemy import Integer, String-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm.organization import Organizationdiff --git a/letta/orm/job.py b/letta/orm/job.pyindex fabdb9188..d95abe443 100644--- a/letta/orm/job.py+++ b/letta/orm/job.py@@ -1,12 +1,13 @@from datetime import datetimefrom typing import TYPE_CHECKING, Optional+from sqlalchemy import JSON, String+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.mixins import UserMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.enums import JobStatusfrom letta.schemas.job import Job as PydanticJob-from sqlalchemy import JSON, String-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm.user import Userdiff --git a/letta/orm/message.py b/letta/orm/message.pyindex 6e2194f5c..a8bbb9001 100644--- a/letta/orm/message.py+++ b/letta/orm/message.py@@ -1,12 +1,13 @@from typing import Optional+from sqlalchemy import Index+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.custom_columns import ToolCallColumnfrom letta.orm.mixins import AgentMixin, OrganizationMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.message import Message as PydanticMessagefrom letta.schemas.openai.chat_completions import ToolCall-from sqlalchemy import Index-from sqlalchemy.orm import Mapped, mapped_column, relationshipclass Message(SqlalchemyBase, OrganizationMixin, AgentMixin):diff --git a/letta/orm/mixins.py b/letta/orm/mixins.pyindex 3e82f4d69..febf84de2 100644--- a/letta/orm/mixins.py+++ b/letta/orm/mixins.py@@ -1,10 +1,11 @@from typing import Optionalfrom uuid import UUID-from letta.orm.base import Basefrom sqlalchemy import ForeignKey, Stringfrom sqlalchemy.orm import Mapped, mapped_column+from letta.orm.base import Base+def is_valid_uuid4(uuid_string: str) -> bool:"""Check if a string is a valid UUID4."""diff --git a/letta/orm/organization.py b/letta/orm/organization.pyindex 9bcc09b2a..335a15d0f 100644--- a/letta/orm/organization.py+++ b/letta/orm/organization.py@@ -1,8 +1,9 @@from typing import TYPE_CHECKING, List, Union+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.organization import Organization as PydanticOrganization-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:diff --git a/letta/orm/passage.py b/letta/orm/passage.pyindex 8237ed612..492c60217 100644--- a/letta/orm/passage.py+++ b/letta/orm/passage.py@@ -1,5 +1,8 @@from typing import TYPE_CHECKING+from sqlalchemy import JSON, Column, Index+from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship+from letta.config import LettaConfigfrom letta.constants import MAX_EMBEDDING_DIMfrom letta.orm.custom_columns import CommonVector, EmbeddingConfigColumn@@ -7,8 +10,6 @@ from letta.orm.mixins import AgentMixin, FileMixin, OrganizationMixin, SourceMixfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.passage import Passage as PydanticPassagefrom letta.settings import settings-from sqlalchemy import JSON, Column, Index-from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationshipconfig = LettaConfig()diff --git a/letta/orm/sandbox_config.py b/letta/orm/sandbox_config.pyindex 600e0c8a8..9058657f6 100644--- a/letta/orm/sandbox_config.py+++ b/letta/orm/sandbox_config.py@@ -1,17 +1,16 @@from typing import TYPE_CHECKING, Dict, List, Optional-from letta.orm.mixins import OrganizationMixin, SandboxConfigMixin-from letta.orm.sqlalchemy_base import SqlalchemyBase-from letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfig-from letta.schemas.sandbox_config import (- SandboxEnvironmentVariable as PydanticSandboxEnvironmentVariable,-)-from letta.schemas.sandbox_config import SandboxTypefrom sqlalchemy import JSONfrom sqlalchemy import Enum as SqlEnumfrom sqlalchemy import String, UniqueConstraintfrom sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.mixins import OrganizationMixin, SandboxConfigMixin+from letta.orm.sqlalchemy_base import SqlalchemyBase+from letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfig+from letta.schemas.sandbox_config import SandboxEnvironmentVariable as PydanticSandboxEnvironmentVariable+from letta.schemas.sandbox_config import SandboxType+if TYPE_CHECKING:from letta.orm.organization import Organizationdiff --git a/letta/orm/source.py b/letta/orm/source.pyindex 838f4c78d..e7443ea67 100644--- a/letta/orm/source.py+++ b/letta/orm/source.py@@ -1,13 +1,14 @@from typing import TYPE_CHECKING, List, Optional+from sqlalchemy import JSON+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm import FileMetadatafrom letta.orm.custom_columns import EmbeddingConfigColumnfrom letta.orm.mixins import OrganizationMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.source import Source as PydanticSource-from sqlalchemy import JSON-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm.agent import Agentdiff --git a/letta/orm/sources_agents.py b/letta/orm/sources_agents.pyindex 2da5003f4..ffe8a9d0e 100644--- a/letta/orm/sources_agents.py+++ b/letta/orm/sources_agents.py@@ -1,7 +1,8 @@-from letta.orm.base import Basefrom sqlalchemy import ForeignKey, Stringfrom sqlalchemy.orm import Mapped, mapped_column+from letta.orm.base import Base+class SourcesAgents(Base):"""Agents can have zero to many sources"""diff --git a/letta/orm/sqlalchemy_base.py b/letta/orm/sqlalchemy_base.pyindex 3e307bc4a..c5240f3c1 100644--- a/letta/orm/sqlalchemy_base.py+++ b/letta/orm/sqlalchemy_base.py@@ -3,19 +3,15 @@ from enum import Enumfrom functools import wrapsfrom typing import TYPE_CHECKING, List, Literal, Optional-from letta.log import get_logger-from letta.orm.base import Base, CommonSqlalchemyMetaMixins-from letta.orm.errors import (- DatabaseTimeoutError,- ForeignKeyConstraintViolationError,- NoResultFound,- UniqueConstraintViolationError,-)-from letta.orm.sqlite_functions import adapt_arrayfrom sqlalchemy import String, desc, func, or_, selectfrom sqlalchemy.exc import DBAPIError, IntegrityError, TimeoutErrorfrom sqlalchemy.orm import Mapped, Session, mapped_column+from letta.log import get_logger+from letta.orm.base import Base, CommonSqlalchemyMetaMixins+from letta.orm.errors import DatabaseTimeoutError, ForeignKeyConstraintViolationError, NoResultFound, UniqueConstraintViolationError+from letta.orm.sqlite_functions import adapt_array+if TYPE_CHECKING:from pydantic import BaseModelfrom sqlalchemy.orm import Sessiondiff --git a/letta/orm/sqlite_functions.py b/letta/orm/sqlite_functions.pyindex 50c257a08..f5957cd6c 100644--- a/letta/orm/sqlite_functions.py+++ b/letta/orm/sqlite_functions.py@@ -3,10 +3,11 @@ import sqlite3from typing import Optional, Unionimport numpy as np-from letta.constants import MAX_EMBEDDING_DIMfrom sqlalchemy import eventfrom sqlalchemy.engine import Engine+from letta.constants import MAX_EMBEDDING_DIM+def adapt_array(arr):"""diff --git a/letta/orm/tool.py b/letta/orm/tool.pyindex 50d475062..a25c7ebb0 100644--- a/letta/orm/tool.py+++ b/letta/orm/tool.py@@ -1,12 +1,13 @@from typing import TYPE_CHECKING, List, Optional+from sqlalchemy import JSON, String, UniqueConstraint+from sqlalchemy.orm import Mapped, mapped_column, relationship+# TODO everything in functions should live in this modelfrom letta.orm.enums import ToolSourceTypefrom letta.orm.mixins import OrganizationMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.tool import Tool as PydanticTool-from sqlalchemy import JSON, String, UniqueConstraint-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm.organization import Organizationdiff --git a/letta/orm/tools_agents.py b/letta/orm/tools_agents.pyindex 50668d940..52c1e0a1e 100644--- a/letta/orm/tools_agents.py+++ b/letta/orm/tools_agents.py@@ -1,7 +1,8 @@-from letta.orm import Basefrom sqlalchemy import ForeignKey, String, UniqueConstraintfrom sqlalchemy.orm import Mapped, mapped_column+from letta.orm import Base+class ToolsAgents(Base):"""Agents can have one or many tools associated with them."""diff --git a/letta/orm/user.py b/letta/orm/user.pyindex 23c2b268a..9f626b104 100644--- a/letta/orm/user.py+++ b/letta/orm/user.py@@ -1,9 +1,10 @@from typing import TYPE_CHECKING, List+from sqlalchemy.orm import Mapped, mapped_column, relationship+from letta.orm.mixins import OrganizationMixinfrom letta.orm.sqlalchemy_base import SqlalchemyBasefrom letta.schemas.user import User as PydanticUser-from sqlalchemy.orm import Mapped, mapped_column, relationshipif TYPE_CHECKING:from letta.orm import Job, Organizationdiff --git a/letta/providers.py b/letta/providers.pyindex 23964c628..87a7557db 100644--- a/letta/providers.py+++ b/letta/providers.py@@ -1,14 +1,12 @@from typing import List, Optional+from pydantic import BaseModel, Field, model_validator+from letta.constants import LLM_MAX_TOKENS, MIN_CONTEXT_WINDOW-from letta.llm_api.azure_openai import (- get_azure_chat_completions_endpoint,- get_azure_embeddings_endpoint,-)+from letta.llm_api.azure_openai import get_azure_chat_completions_endpoint, get_azure_embeddings_endpointfrom letta.llm_api.azure_openai_constants import AZURE_MODEL_TO_CONTEXT_LENGTHfrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.llm_config import LLMConfig-from pydantic import BaseModel, Field, model_validatorclass Provider(BaseModel):@@ -567,9 +565,7 @@ class AzureProvider(Provider):return valuesdef list_llm_models(self) -> List[LLMConfig]:- from letta.llm_api.azure_openai import (- azure_openai_get_chat_completion_model_list,- )+ from letta.llm_api.azure_openai import azure_openai_get_chat_completion_model_listmodel_options = azure_openai_get_chat_completion_model_list(self.base_url, api_key=self.api_key, api_version=self.api_version)configs = []diff --git a/letta/schemas/agent.py b/letta/schemas/agent.pyindex 06fe58600..03d40350e 100644--- a/letta/schemas/agent.py+++ b/letta/schemas/agent.py@@ -1,6 +1,8 @@from enum import Enumfrom typing import Dict, List, Optional+from pydantic import BaseModel, Field, field_validator+from letta.constants import DEFAULT_EMBEDDING_CHUNK_SIZEfrom letta.schemas.block import CreateBlockfrom letta.schemas.embedding_config import EmbeddingConfig@@ -13,7 +15,6 @@ from letta.schemas.source import Sourcefrom letta.schemas.tool import Toolfrom letta.schemas.tool_rule import ToolRulefrom letta.utils import create_random_username-from pydantic import BaseModel, Field, field_validatorclass AgentType(str, Enum):diff --git a/letta/schemas/block.py b/letta/schemas/block.pyindex bd905bd2d..25e84b7da 100644--- a/letta/schemas/block.py+++ b/letta/schemas/block.py@@ -1,10 +1,11 @@from typing import Optional-from letta.constants import CORE_MEMORY_BLOCK_CHAR_LIMIT-from letta.schemas.letta_base import LettaBasefrom pydantic import BaseModel, Field, model_validatorfrom typing_extensions import Self+from letta.constants import CORE_MEMORY_BLOCK_CHAR_LIMIT+from letta.schemas.letta_base import LettaBase+# block of the LLM contextdiff --git a/letta/schemas/file.py b/letta/schemas/file.pyindex 0671bc3eb..b43eb64c3 100644--- a/letta/schemas/file.py+++ b/letta/schemas/file.py@@ -1,9 +1,10 @@from datetime import datetimefrom typing import Optional-from letta.schemas.letta_base import LettaBasefrom pydantic import Field+from letta.schemas.letta_base import LettaBase+class FileMetadataBase(LettaBase):"""Base class for FileMetadata schemas"""diff --git a/letta/schemas/job.py b/letta/schemas/job.pyindex b767b5671..17c2b98da 100644--- a/letta/schemas/job.py+++ b/letta/schemas/job.py@@ -1,9 +1,10 @@from datetime import datetimefrom typing import Optional+from pydantic import Field+from letta.schemas.enums import JobStatusfrom letta.schemas.letta_base import OrmMetadataBase-from pydantic import Fieldclass JobBase(OrmMetadataBase):diff --git a/letta/schemas/letta_request.py b/letta/schemas/letta_request.pyindex 73f956ff5..123d817cf 100644--- a/letta/schemas/letta_request.py+++ b/letta/schemas/letta_request.py@@ -1,8 +1,9 @@from typing import List+from pydantic import BaseModel, Field+from letta.constants import DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARGfrom letta.schemas.message import MessageCreate-from pydantic import BaseModel, Fieldclass LettaRequest(BaseModel):diff --git a/letta/schemas/letta_response.py b/letta/schemas/letta_response.pyindex 7084c3ba0..c6a1e8be5 100644--- a/letta/schemas/letta_response.py+++ b/letta/schemas/letta_response.py@@ -3,11 +3,12 @@ import jsonimport refrom typing import List, Union+from pydantic import BaseModel, Field+from letta.schemas.enums import MessageStreamStatusfrom letta.schemas.letta_message import LettaMessage, LettaMessageUnionfrom letta.schemas.usage import LettaUsageStatisticsfrom letta.utils import json_dumps-from pydantic import BaseModel, Field# TODO: consider moving into own filediff --git a/letta/schemas/message.py b/letta/schemas/message.pyindex 9697b550e..ea46f3f87 100644--- a/letta/schemas/message.py+++ b/letta/schemas/message.py@@ -4,25 +4,17 @@ import warningsfrom datetime import datetime, timezonefrom typing import List, Literal, Optional-from letta.constants import (- DEFAULT_MESSAGE_TOOL,- DEFAULT_MESSAGE_TOOL_KWARG,- TOOL_CALL_ID_MAX_LEN,-)+from pydantic import BaseModel, Field, field_validator++from letta.constants import DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARG, TOOL_CALL_ID_MAX_LENfrom letta.local_llm.constants import INNER_THOUGHTS_KWARGfrom letta.schemas.enums import MessageRolefrom letta.schemas.letta_base import OrmMetadataBase-from letta.schemas.letta_message import (- AssistantMessage,- LettaMessage,- ReasoningMessage,- SystemMessage,-)+from letta.schemas.letta_message import AssistantMessage, LettaMessage, ReasoningMessage, SystemMessagefrom letta.schemas.letta_message import ToolCall as LettaToolCallfrom letta.schemas.letta_message import ToolCallMessage, ToolReturnMessage, UserMessagefrom letta.schemas.openai.chat_completions import ToolCall, ToolCallFunctionfrom letta.utils import get_utc_time, is_utc_datetime, json_dumps-from pydantic import BaseModel, Field, field_validatordef add_inner_thoughts_to_tool_call(diff --git a/letta/schemas/organization.py b/letta/schemas/organization.pyindex 6220b987a..35784ad0d 100644--- a/letta/schemas/organization.py+++ b/letta/schemas/organization.py@@ -1,9 +1,10 @@from datetime import datetimefrom typing import Optional+from pydantic import Field+from letta.schemas.letta_base import LettaBasefrom letta.utils import create_random_username, get_utc_time-from pydantic import Fieldclass OrganizationBase(LettaBase):diff --git a/letta/schemas/passage.py b/letta/schemas/passage.pyindex c613c2e1b..c1ec13bec 100644--- a/letta/schemas/passage.py+++ b/letta/schemas/passage.py@@ -1,11 +1,12 @@from datetime import datetimefrom typing import Dict, List, Optional+from pydantic import Field, field_validator+from letta.constants import MAX_EMBEDDING_DIMfrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.letta_base import OrmMetadataBasefrom letta.utils import get_utc_time-from pydantic import Field, field_validatorclass PassageBase(OrmMetadataBase):diff --git a/letta/schemas/sandbox_config.py b/letta/schemas/sandbox_config.pyindex 993711cc5..f86233fae 100644--- a/letta/schemas/sandbox_config.py+++ b/letta/schemas/sandbox_config.py@@ -3,10 +3,11 @@ import jsonfrom enum import Enumfrom typing import Any, Dict, List, Literal, Optional, Union+from pydantic import BaseModel, Field, model_validator+from letta.schemas.agent import AgentStatefrom letta.schemas.letta_base import LettaBase, OrmMetadataBasefrom letta.settings import tool_settings-from pydantic import BaseModel, Field, model_validator# Sandbox Configdiff --git a/letta/schemas/source.py b/letta/schemas/source.pyindex d6a14d79f..0a458dfde 100644--- a/letta/schemas/source.py+++ b/letta/schemas/source.py@@ -1,9 +1,10 @@from datetime import datetimefrom typing import Optional+from pydantic import Field+from letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.letta_base import LettaBase-from pydantic import Fieldclass BaseSource(LettaBase):diff --git a/letta/schemas/tool.py b/letta/schemas/tool.pyindex cee04fefa..8066f9b2c 100644--- a/letta/schemas/tool.py+++ b/letta/schemas/tool.py@@ -1,15 +1,13 @@from typing import Dict, List, Optional+from pydantic import Field, model_validator+from letta.constants import FUNCTION_RETURN_CHAR_LIMITfrom letta.functions.functions import derive_openai_json_schema-from letta.functions.helpers import (- generate_composio_tool_wrapper,- generate_langchain_tool_wrapper,-)+from letta.functions.helpers import generate_composio_tool_wrapper, generate_langchain_tool_wrapperfrom letta.functions.schema_generator import generate_schema_from_args_schema_v2from letta.schemas.letta_base import LettaBasefrom letta.schemas.openai.chat_completions import ToolCall-from pydantic import Field, model_validatorclass BaseTool(LettaBase):diff --git a/letta/schemas/tool_rule.py b/letta/schemas/tool_rule.pyindex e88ff2904..1ab313a7e 100644--- a/letta/schemas/tool_rule.py+++ b/letta/schemas/tool_rule.py@@ -1,8 +1,9 @@from typing import Any, Dict, List, Optional, Union+from pydantic import Field+from letta.schemas.enums import ToolRuleTypefrom letta.schemas.letta_base import LettaBase-from pydantic import Fieldclass BaseToolRule(LettaBase):diff --git a/letta/schemas/user.py b/letta/schemas/user.pyindex b2bcb9337..59a4594e0 100644--- a/letta/schemas/user.py+++ b/letta/schemas/user.py@@ -1,9 +1,10 @@from datetime import datetimefrom typing import Optional+from pydantic import Field+from letta.schemas.letta_base import LettaBasefrom letta.services.organization_manager import OrganizationManager-from pydantic import Fieldclass UserBase(LettaBase):diff --git a/letta/server/rest_api/app.py b/letta/server/rest_api/app.pyindex bb1839359..8e2b7fb74 100644--- a/letta/server/rest_api/app.py+++ b/letta/server/rest_api/app.py@@ -8,44 +8,30 @@ from typing import Optionalimport uvicornfrom fastapi import FastAPI, Requestfrom fastapi.responses import JSONResponse+from starlette.middleware.base import BaseHTTPMiddleware+from starlette.middleware.cors import CORSMiddleware+from letta.__init__ import __version__from letta.constants import ADMIN_PREFIX, API_PREFIX, OPENAI_API_PREFIXfrom letta.errors import LettaAgentNotFoundError, LettaUserNotFoundErrorfrom letta.log import get_logger-from letta.orm.errors import (- DatabaseTimeoutError,- ForeignKeyConstraintViolationError,- NoResultFound,- UniqueConstraintViolationError,-)+from letta.orm.errors import DatabaseTimeoutError, ForeignKeyConstraintViolationError, NoResultFound, UniqueConstraintViolationErrorfrom letta.schemas.letta_response import LettaResponsefrom letta.server.constants import REST_DEFAULT_PORT# NOTE(charles): these are extra routes that are not part of v1 but we still need to mount to pass tests-from letta.server.rest_api.auth.index import (- setup_auth_router, # TODO: probably remove right?-)+from letta.server.rest_api.auth.index import setup_auth_router # TODO: probably remove right?from letta.server.rest_api.interface import StreamingServerInterface-from letta.server.rest_api.routers.openai.assistants.assistants import (- router as openai_assistants_router,-)-from letta.server.rest_api.routers.openai.chat_completions.chat_completions import (- router as openai_chat_completions_router,-)+from letta.server.rest_api.routers.openai.assistants.assistants import router as openai_assistants_router+from letta.server.rest_api.routers.openai.chat_completions.chat_completions import router as openai_chat_completions_router# from letta.orm.utilities import get_db_session # TODO(ethan) reenable once we merge ORMfrom letta.server.rest_api.routers.v1 import ROUTERS as v1_routes-from letta.server.rest_api.routers.v1.organizations import (- router as organizations_router,-)-from letta.server.rest_api.routers.v1.users import (- router as users_router, # TODO: decide on admin-)+from letta.server.rest_api.routers.v1.organizations import router as organizations_router+from letta.server.rest_api.routers.v1.users import router as users_router # TODO: decide on adminfrom letta.server.rest_api.static_files import mount_static_filesfrom letta.server.server import SyncServerfrom letta.settings import settings-from starlette.middleware.base import BaseHTTPMiddleware-from starlette.middleware.cors import CORSMiddleware# TODO(ethan)# NOTE(charles): @ethan I had to add this to get the global as the bottom to workdiff --git a/letta/server/rest_api/auth/index.py b/letta/server/rest_api/auth/index.pyindex 7a29f6b4e..28d22435b 100644--- a/letta/server/rest_api/auth/index.py+++ b/letta/server/rest_api/auth/index.py@@ -2,10 +2,11 @@ from typing import Optionalfrom uuid import UUIDfrom fastapi import APIRouter+from pydantic import BaseModel, Field+from letta.log import get_loggerfrom letta.server.rest_api.interface import QueuingInterfacefrom letta.server.server import SyncServer-from pydantic import BaseModel, Fieldlogger = get_logger(__name__)router = APIRouter()diff --git a/letta/server/rest_api/auth_token.py b/letta/server/rest_api/auth_token.pyindex 72387bbdb..40e26d805 100644--- a/letta/server/rest_api/auth_token.py+++ b/letta/server/rest_api/auth_token.py@@ -2,6 +2,7 @@ import uuidfrom fastapi import Depends, HTTPExceptionfrom fastapi.security import HTTPAuthorizationCredentials, HTTPBearer+from letta.server.server import SyncServersecurity = HTTPBearer()diff --git a/letta/server/rest_api/interface.py b/letta/server/rest_api/interface.pyindex ffc46edd3..9fd8fb1cd 100644--- a/letta/server/rest_api/interface.py+++ b/letta/server/rest_api/interface.py@@ -11,23 +11,20 @@ from letta.interface import AgentInterfacefrom letta.local_llm.constants import INNER_THOUGHTS_KWARGfrom letta.schemas.enums import MessageStreamStatusfrom letta.schemas.letta_message import (- AssistantMessage,- LegacyFunctionCallMessage,- LegacyLettaMessage,- LettaMessage,- ReasoningMessage,- ToolCall,- ToolCallDelta,- ToolCallMessage,- ToolReturnMessage,+ AssistantMessage,+ LegacyFunctionCallMessage,+ LegacyLettaMessage,+ LettaMessage,+ ReasoningMessage,+ ToolCall,+ ToolCallDelta,+ ToolCallMessage,+ ToolReturnMessage,)from letta.schemas.message import Messagefrom letta.schemas.openai.chat_completion_response import ChatCompletionChunkResponsefrom letta.streaming_interface import AgentChunkStreamingInterface-from letta.streaming_utils import (- FunctionArgumentsStreamHandler,- JSONInnerThoughtsExtractor,-)+from letta.streaming_utils import FunctionArgumentsStreamHandler, JSONInnerThoughtsExtractorfrom letta.utils import is_utc_datetimediff --git a/letta/server/rest_api/routers/openai/assistants/assistants.py b/letta/server/rest_api/routers/openai/assistants/assistants.pyindex 95f8f01e9..2b646f931 100644--- a/letta/server/rest_api/routers/openai/assistants/assistants.py+++ b/letta/server/rest_api/routers/openai/assistants/assistants.py@@ -1,13 +1,14 @@from typing import Listfrom fastapi import APIRouter, Body, HTTPException, Path, Query+from letta.constants import DEFAULT_PRESETfrom letta.schemas.openai.openai import AssistantFile, OpenAIAssistantfrom letta.server.rest_api.routers.openai.assistants.schemas import (- CreateAssistantFileRequest,- CreateAssistantRequest,- DeleteAssistantFileResponse,- DeleteAssistantResponse,+ CreateAssistantFileRequest,+ CreateAssistantRequest,+ DeleteAssistantFileResponse,+ DeleteAssistantResponse,)from letta.utils import get_utc_timediff --git a/letta/server/rest_api/routers/openai/assistants/schemas.py b/letta/server/rest_api/routers/openai/assistants/schemas.pyindex 069a4d97f..07263ff2d 100644--- a/letta/server/rest_api/routers/openai/assistants/schemas.py+++ b/letta/server/rest_api/routers/openai/assistants/schemas.py@@ -1,14 +1,9 @@from typing import List, Optional-from letta.schemas.openai.openai import (- MessageRoleType,- OpenAIMessage,- OpenAIThread,- ToolCall,- ToolCallOutput,-)from pydantic import BaseModel, Field+from letta.schemas.openai.openai import MessageRoleType, OpenAIMessage, OpenAIThread, ToolCall, ToolCallOutput+class CreateAssistantRequest(BaseModel):model: str = Field(..., description="The model to use for the assistant.")diff --git a/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py b/letta/server/rest_api/routers/openai/chat_completions/chat_completions.pyindex 9127787f9..4809fa19d 100644--- a/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py+++ b/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py@@ -2,15 +2,11 @@ import jsonfrom typing import TYPE_CHECKING, Optionalfrom fastapi import APIRouter, Body, Depends, Header, HTTPException+from letta.schemas.enums import MessageRolefrom letta.schemas.letta_message import LettaMessage, ToolCallfrom letta.schemas.openai.chat_completion_request import ChatCompletionRequest-from letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- Message,- UsageStatistics,-)+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, Message, UsageStatistics# TODO this belongs in a controller!from letta.server.rest_api.routers.v1.agents import send_message_to_agentdiff --git a/letta/server/rest_api/routers/v1/__init__.py b/letta/server/rest_api/routers/v1/__init__.pyindex bcebeb26c..0617f4a94 100644--- a/letta/server/rest_api/routers/v1/__init__.py+++ b/letta/server/rest_api/routers/v1/__init__.py@@ -3,9 +3,7 @@ from letta.server.rest_api.routers.v1.blocks import router as blocks_routerfrom letta.server.rest_api.routers.v1.health import router as health_routerfrom letta.server.rest_api.routers.v1.jobs import router as jobs_routerfrom letta.server.rest_api.routers.v1.llms import router as llm_router-from letta.server.rest_api.routers.v1.sandbox_configs import (- router as sandbox_configs_router,-)+from letta.server.rest_api.routers.v1.sandbox_configs import router as sandbox_configs_routerfrom letta.server.rest_api.routers.v1.sources import router as sources_routerfrom letta.server.rest_api.routers.v1.tools import router as tools_routerdiff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex a11626538..6f78fbfad 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -3,42 +3,21 @@ import warningsfrom datetime import datetimefrom typing import List, Optional, Union-from fastapi import (- APIRouter,- BackgroundTasks,- Body,- Depends,- Header,- HTTPException,- Query,- status,-)+from fastapi import APIRouter, BackgroundTasks, Body, Depends, Header, HTTPException, Query, statusfrom fastapi.responses import JSONResponse, StreamingResponse+from pydantic import Field+from letta.constants import DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARGfrom letta.log import get_loggerfrom letta.orm.errors import NoResultFoundfrom letta.schemas.agent import AgentState, CreateAgent, UpdateAgent-from letta.schemas.block import ( # , BlockLabelUpdate, BlockLimitUpdate- Block,- BlockUpdate,- CreateBlock,-)+from letta.schemas.block import Block, BlockUpdate, CreateBlock # , BlockLabelUpdate, BlockLimitUpdatefrom letta.schemas.enums import MessageStreamStatusfrom letta.schemas.job import Job, JobStatus, JobUpdate-from letta.schemas.letta_message import (- LegacyLettaMessage,- LettaMessage,- LettaMessageUnion,-)+from letta.schemas.letta_message import LegacyLettaMessage, LettaMessage, LettaMessageUnionfrom letta.schemas.letta_request import LettaRequest, LettaStreamingRequestfrom letta.schemas.letta_response import LettaResponse-from letta.schemas.memory import (- ArchivalMemorySummary,- ContextWindowOverview,- CreateArchivalMemory,- Memory,- RecallMemorySummary,-)+from letta.schemas.memory import ArchivalMemorySummary, ContextWindowOverview, CreateArchivalMemory, Memory, RecallMemorySummaryfrom letta.schemas.message import Message, MessageCreate, MessageUpdatefrom letta.schemas.passage import Passagefrom letta.schemas.source import Source@@ -47,7 +26,6 @@ from letta.schemas.user import Userfrom letta.server.rest_api.interface import StreamingServerInterfacefrom letta.server.rest_api.utils import get_letta_server, sse_async_generatorfrom letta.server.server import SyncServer-from pydantic import Field# These can be forward refs, but because Fastapi needs them at runtime the must be imported normallydiff --git a/letta/server/rest_api/routers/v1/blocks.py b/letta/server/rest_api/routers/v1/blocks.pyindex 9d2a937d1..d92132334 100644--- a/letta/server/rest_api/routers/v1/blocks.py+++ b/letta/server/rest_api/routers/v1/blocks.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKING, List, Optionalfrom fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response+from letta.orm.errors import NoResultFoundfrom letta.schemas.block import Block, BlockUpdate, CreateBlockfrom letta.server.rest_api.utils import get_letta_serverdiff --git a/letta/server/rest_api/routers/v1/health.py b/letta/server/rest_api/routers/v1/health.pyindex 81bb41e05..99fce66d4 100644--- a/letta/server/rest_api/routers/v1/health.py+++ b/letta/server/rest_api/routers/v1/health.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKINGfrom fastapi import APIRouter+from letta.cli.cli import versionfrom letta.schemas.health import Healthdiff --git a/letta/server/rest_api/routers/v1/jobs.py b/letta/server/rest_api/routers/v1/jobs.pyindex bec226251..4245d2f98 100644--- a/letta/server/rest_api/routers/v1/jobs.py+++ b/letta/server/rest_api/routers/v1/jobs.py@@ -1,6 +1,7 @@from typing import List, Optionalfrom fastapi import APIRouter, Depends, Header, HTTPException, Query+from letta.orm.errors import NoResultFoundfrom letta.schemas.enums import JobStatusfrom letta.schemas.job import Jobdiff --git a/letta/server/rest_api/routers/v1/llms.py b/letta/server/rest_api/routers/v1/llms.pyindex f0bf9f425..4536ae498 100644--- a/letta/server/rest_api/routers/v1/llms.py+++ b/letta/server/rest_api/routers/v1/llms.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKING, Listfrom fastapi import APIRouter, Depends+from letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.llm_config import LLMConfigfrom letta.server.rest_api.utils import get_letta_serverdiff --git a/letta/server/rest_api/routers/v1/organizations.py b/letta/server/rest_api/routers/v1/organizations.pyindex 8fbead6d9..2f4cdb1b5 100644--- a/letta/server/rest_api/routers/v1/organizations.py+++ b/letta/server/rest_api/routers/v1/organizations.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKING, List, Optionalfrom fastapi import APIRouter, Body, Depends, HTTPException, Query+from letta.schemas.organization import Organization, OrganizationCreatefrom letta.server.rest_api.utils import get_letta_serverdiff --git a/letta/server/rest_api/routers/v1/sandbox_configs.py b/letta/server/rest_api/routers/v1/sandbox_configs.pyindex 822ca4f5d..436d9b8e8 100644--- a/letta/server/rest_api/routers/v1/sandbox_configs.py+++ b/letta/server/rest_api/routers/v1/sandbox_configs.py@@ -1,14 +1,11 @@from typing import List, Optionalfrom fastapi import APIRouter, Depends, Query+from letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfigfrom letta.schemas.sandbox_config import SandboxConfigCreate, SandboxConfigUpdatefrom letta.schemas.sandbox_config import SandboxEnvironmentVariable as PydanticEnvVar-from letta.schemas.sandbox_config import (- SandboxEnvironmentVariableCreate,- SandboxEnvironmentVariableUpdate,- SandboxType,-)+from letta.schemas.sandbox_config import SandboxEnvironmentVariableCreate, SandboxEnvironmentVariableUpdate, SandboxTypefrom letta.server.rest_api.utils import get_letta_server, get_user_idfrom letta.server.server import SyncServerdiff --git a/letta/server/rest_api/routers/v1/sources.py b/letta/server/rest_api/routers/v1/sources.pyindex 399942da6..59b933cfc 100644--- a/letta/server/rest_api/routers/v1/sources.py+++ b/letta/server/rest_api/routers/v1/sources.py@@ -2,15 +2,8 @@ import osimport tempfilefrom typing import List, Optional-from fastapi import (- APIRouter,- BackgroundTasks,- Depends,- Header,- HTTPException,- Query,- UploadFile,-)+from fastapi import APIRouter, BackgroundTasks, Depends, Header, HTTPException, Query, UploadFile+from letta.schemas.file import FileMetadatafrom letta.schemas.job import Jobfrom letta.schemas.passage import Passagediff --git a/letta/server/rest_api/routers/v1/tools.py b/letta/server/rest_api/routers/v1/tools.pyindex bb297a36e..ffc2b2124 100644--- a/letta/server/rest_api/routers/v1/tools.py+++ b/letta/server/rest_api/routers/v1/tools.py@@ -6,6 +6,7 @@ from composio.client.enums.base import EnumStringNotFoundfrom composio.exceptions import ApiKeyNotProvidedError, ComposioSDKErrorfrom composio.tools.base.abs import InvalidClassDefinitionfrom fastapi import APIRouter, Body, Depends, Header, HTTPException+from letta.errors import LettaToolCreateErrorfrom letta.orm.errors import UniqueConstraintViolationErrorfrom letta.schemas.letta_message import ToolReturnMessagediff --git a/letta/server/rest_api/routers/v1/users.py b/letta/server/rest_api/routers/v1/users.pyindex 2dfeb06b1..27a2feeb0 100644--- a/letta/server/rest_api/routers/v1/users.py+++ b/letta/server/rest_api/routers/v1/users.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKING, List, Optionalfrom fastapi import APIRouter, Body, Depends, HTTPException, Query+from letta.schemas.user import User, UserCreate, UserUpdatefrom letta.server.rest_api.utils import get_letta_serverdiff --git a/letta/server/rest_api/utils.py b/letta/server/rest_api/utils.pyindex 650f0e3e4..bb5dc0340 100644--- a/letta/server/rest_api/utils.py+++ b/letta/server/rest_api/utils.py@@ -6,11 +6,12 @@ from enum import Enumfrom typing import AsyncGenerator, Optional, Unionfrom fastapi import Header+from pydantic import BaseModel+from letta.errors import ContextWindowExceededError, RateLimitExceededErrorfrom letta.schemas.usage import LettaUsageStatisticsfrom letta.server.rest_api.interface import StreamingServerInterfacefrom letta.server.server import SyncServer-from pydantic import BaseModel# from letta.orm.user import User# from letta.orm.utilities import get_db_sessiondiff --git a/letta/server/server.py b/letta/server/server.pyindex 226d8d84b..03604a89d 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -7,12 +7,13 @@ from abc import abstractmethodfrom datetime import datetimefrom typing import Callable, List, Optional, Tuple, Union-import letta.constants as constants-import letta.server.utils as server_utils-import letta.system as systemfrom composio.client import Composiofrom composio.client.collections import ActionModel, AppModelfrom fastapi import HTTPException++import letta.constants as constants+import letta.server.utils as server_utils+import letta.system as systemfrom letta.agent import Agent, save_agentfrom letta.chat_only_agent import ChatOnlyAgentfrom letta.credentials import LettaCredentials@@ -27,17 +28,17 @@ from letta.offline_memory_agent import OfflineMemoryAgentfrom letta.orm import Basefrom letta.orm.errors import NoResultFoundfrom letta.providers import (- AnthropicProvider,- AzureProvider,- GoogleAIProvider,- GroqProvider,- LettaProvider,- OllamaProvider,- OpenAIProvider,- Provider,- TogetherProvider,- VLLMChatCompletionsProvider,- VLLMCompletionsProvider,+ AnthropicProvider,+ AzureProvider,+ GoogleAIProvider,+ GroqProvider,+ LettaProvider,+ OllamaProvider,+ OpenAIProvider,+ Provider,+ TogetherProvider,+ VLLMChatCompletionsProvider,+ VLLMCompletionsProvider,)from letta.schemas.agent import AgentState, AgentType, CreateAgentfrom letta.schemas.block import BlockUpdate@@ -48,12 +49,7 @@ from letta.schemas.enums import JobStatusfrom letta.schemas.job import Job, JobUpdatefrom letta.schemas.letta_message import LettaMessage, ToolReturnMessagefrom letta.schemas.llm_config import LLMConfig-from letta.schemas.memory import (- ArchivalMemorySummary,- ContextWindowOverview,- Memory,- RecallMemorySummary,-)+from letta.schemas.memory import ArchivalMemorySummary, ContextWindowOverview, Memory, RecallMemorySummaryfrom letta.schemas.message import Message, MessageCreate, MessageRole, MessageUpdatefrom letta.schemas.organization import Organizationfrom letta.schemas.passage import Passage@@ -138,16 +134,17 @@ class Server(object):from contextlib import contextmanager-from letta.config import LettaConfig--# NOTE: hack to see if single session management works-from letta.settings import model_settings, settings, tool_settingsfrom rich.console import Consolefrom rich.panel import Panelfrom rich.text import Textfrom sqlalchemy import create_enginefrom sqlalchemy.orm import sessionmaker+from letta.config import LettaConfig++# NOTE: hack to see if single session management works+from letta.settings import model_settings, settings, tool_settings+config = LettaConfig.load()diff --git a/letta/server/ws_api/example_client.py b/letta/server/ws_api/example_client.pyindex fdfdd6605..a7fc57b52 100644--- a/letta/server/ws_api/example_client.py+++ b/letta/server/ws_api/example_client.py@@ -1,7 +1,8 @@import asyncio-import letta.server.ws_api.protocol as protocolimport websockets++import letta.server.ws_api.protocol as protocolfrom letta.server.constants import WS_CLIENT_TIMEOUT, WS_DEFAULT_PORTfrom letta.server.utils import condition_to_stop_receiving, print_server_responsediff --git a/letta/server/ws_api/server.py b/letta/server/ws_api/server.pyindex b3dcc2ba1..e2408ddaa 100644--- a/letta/server/ws_api/server.py+++ b/letta/server/ws_api/server.py@@ -3,8 +3,9 @@ import signalimport sysimport traceback-import letta.server.ws_api.protocol as protocolimport websockets++import letta.server.ws_api.protocol as protocolfrom letta.server.constants import WS_DEFAULT_PORTfrom letta.server.server import SyncServerfrom letta.server.ws_api.interface import SyncWebSocketInterfacediff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.pyindex 969733913..4e6b80ec5 100644--- a/letta/services/agent_manager.py+++ b/letta/services/agent_manager.py@@ -2,6 +2,8 @@ from datetime import datetimefrom typing import Dict, List, Optionalimport numpy as np+from sqlalchemy import Select, func, literal, select, union_all+from letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLS, MAX_EMBEDDING_DIMfrom letta.embeddings import embedding_modelfrom letta.log import get_logger@@ -25,20 +27,19 @@ from letta.schemas.tool_rule import ToolRule as PydanticToolRulefrom letta.schemas.user import User as PydanticUserfrom letta.services.block_manager import BlockManagerfrom letta.services.helpers.agent_manager_helper import (- _process_relationship,- _process_tags,- check_supports_structured_output,- compile_system_message,- derive_system_message,- initialize_message_sequence,- package_initial_message_sequence,+ _process_relationship,+ _process_tags,+ check_supports_structured_output,+ compile_system_message,+ derive_system_message,+ initialize_message_sequence,+ package_initial_message_sequence,)from letta.services.message_manager import MessageManagerfrom letta.services.source_manager import SourceManagerfrom letta.services.tool_manager import ToolManagerfrom letta.settings import settingsfrom letta.utils import enforce_types, get_utc_time, united_diff-from sqlalchemy import Select, func, literal, select, union_alllogger = get_logger(__name__)diff --git a/letta/services/sandbox_config_manager.py b/letta/services/sandbox_config_manager.pyindex 270b1761b..9e47612ee 100644--- a/letta/services/sandbox_config_manager.py+++ b/letta/services/sandbox_config_manager.py@@ -9,11 +9,7 @@ from letta.schemas.sandbox_config import LocalSandboxConfigfrom letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfigfrom letta.schemas.sandbox_config import SandboxConfigCreate, SandboxConfigUpdatefrom letta.schemas.sandbox_config import SandboxEnvironmentVariable as PydanticEnvVar-from letta.schemas.sandbox_config import (- SandboxEnvironmentVariableCreate,- SandboxEnvironmentVariableUpdate,- SandboxType,-)+from letta.schemas.sandbox_config import SandboxEnvironmentVariableCreate, SandboxEnvironmentVariableUpdate, SandboxTypefrom letta.schemas.user import User as PydanticUserfrom letta.utils import enforce_types, printddiff --git a/letta/settings.py b/letta/settings.pyindex 3b9af8018..1b6ba44bb 100644--- a/letta/settings.py+++ b/letta/settings.py@@ -1,10 +1,11 @@from pathlib import Pathfrom typing import Optional-from letta.local_llm.constants import DEFAULT_WRAPPER_NAMEfrom pydantic import Fieldfrom pydantic_settings import BaseSettings, SettingsConfigDict+from letta.local_llm.constants import DEFAULT_WRAPPER_NAME+class ToolSettings(BaseSettings):composio_api_key: Optional[str] = Nonediff --git a/letta/streaming_interface.py b/letta/streaming_interface.pyindex 9dfcfd461..2949b94e4 100644--- a/letta/streaming_interface.py+++ b/letta/streaming_interface.py@@ -3,22 +3,16 @@ from abc import ABC, abstractmethodfrom datetime import datetimefrom typing import List, Optional-from letta.interface import CLIInterface-from letta.local_llm.constants import (- ASSISTANT_MESSAGE_CLI_SYMBOL,- INNER_THOUGHTS_CLI_SYMBOL,-)-from letta.schemas.message import Message-from letta.schemas.openai.chat_completion_response import (- ChatCompletionChunkResponse,- ChatCompletionResponse,-)-# from colorama import Fore, Style, initfrom rich.console import Consolefrom rich.live import Livefrom rich.markup import escape+from letta.interface import CLIInterface+from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL, INNER_THOUGHTS_CLI_SYMBOL+from letta.schemas.message import Message+from letta.schemas.openai.chat_completion_response import ChatCompletionChunkResponse, ChatCompletionResponse+# init(autoreset=True)# DEBUG = True # puts full message outputs in the terminaldiff --git a/letta/system.py b/letta/system.pyindex 89755c318..d903bf1fe 100644--- a/letta/system.py+++ b/letta/system.py@@ -3,10 +3,10 @@ import uuidfrom typing import Optionalfrom .constants import (- INITIAL_BOOT_MESSAGE,- INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG,- INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,- MESSAGE_SUMMARY_WARNING_STR,+ INITIAL_BOOT_MESSAGE,+ INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG,+ INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,+ MESSAGE_SUMMARY_WARNING_STR,)from .utils import get_local_time, json_dumpsdiff --git a/letta/utils.py b/letta/utils.pyindex 4e7771c9c..5d2eb5139 100644--- a/letta/utils.py+++ b/letta/utils.py@@ -19,20 +19,21 @@ from typing import List, Union, _GenericAlias, get_args, get_origin, get_type_hifrom urllib.parse import urljoin, urlparseimport demjson3 as demjson-import lettaimport pytzimport tiktoken+from pathvalidate import sanitize_filename as pathvalidate_sanitize_filename++import lettafrom letta.constants import (- CLI_WARNING_PREFIX,- CORE_MEMORY_HUMAN_CHAR_LIMIT,- CORE_MEMORY_PERSONA_CHAR_LIMIT,- ERROR_MESSAGE_PREFIX,- LETTA_DIR,- MAX_FILENAME_LENGTH,- TOOL_CALL_ID_MAX_LEN,+ CLI_WARNING_PREFIX,+ CORE_MEMORY_HUMAN_CHAR_LIMIT,+ CORE_MEMORY_PERSONA_CHAR_LIMIT,+ ERROR_MESSAGE_PREFIX,+ LETTA_DIR,+ MAX_FILENAME_LENGTH,+ TOOL_CALL_ID_MAX_LEN,)from letta.schemas.openai.chat_completion_response import ChatCompletionResponse-from pathvalidate import sanitize_filename as pathvalidate_sanitize_filenameDEBUG = Falseif "LOG_LEVEL" in os.environ:diff --git a/locust_test.py b/locust_test.pyindex bf32fb489..570e6eef4 100644--- a/locust_test.py+++ b/locust_test.py@@ -1,6 +1,8 @@import randomimport string+from locust import HttpUser, between, task+from letta.constants import BASE_TOOLS, DEFAULT_HUMAN, DEFAULT_PERSONAfrom letta.schemas.agent import AgentState, CreateAgentfrom letta.schemas.letta_request import LettaRequest@@ -8,7 +10,6 @@ from letta.schemas.letta_response import LettaResponsefrom letta.schemas.memory import ChatMemoryfrom letta.schemas.message import MessageCreate, MessageRolefrom letta.utils import get_human_text, get_persona_text-from locust import HttpUser, between, taskclass LettaUser(HttpUser):diff --git a/paper_experiments/doc_qa_task/doc_qa.py b/paper_experiments/doc_qa_task/doc_qa.pyindex 205fa0d01..e07060d1a 100644--- a/paper_experiments/doc_qa_task/doc_qa.py+++ b/paper_experiments/doc_qa_task/doc_qa.py@@ -23,6 +23,9 @@ import uuidfrom typing import Listfrom icml_experiments.utils import get_experiment_config, load_gzipped_file+from openai import OpenAI+from tqdm import tqdm+from letta import utilsfrom letta.agent_store.storage import StorageConnector, TableTypefrom letta.cli.cli_config import delete@@ -30,8 +33,6 @@ from letta.config import LettaConfigfrom letta.credentials import LettaCredentialsfrom letta.embeddings import embedding_modelfrom letta.utils import count_tokens-from openai import OpenAI-from tqdm import tqdmDATA_SOURCE_NAME = "wikipedia"DOC_QA_PERSONA = "You are Letta DOC-QA bot. Your job is to answer questions about documents that are stored in your archival memory. The answer to the users question will ALWAYS be in your archival memory, so remember to keep searching if you can't find the answer. Answer the questions as if though the year is 2018." # TODO decide on a good persona/humandiff --git a/paper_experiments/doc_qa_task/llm_judge_doc_qa.py b/paper_experiments/doc_qa_task/llm_judge_doc_qa.pyindex 18d907a36..c6ff6cfee 100644--- a/paper_experiments/doc_qa_task/llm_judge_doc_qa.py+++ b/paper_experiments/doc_qa_task/llm_judge_doc_qa.py@@ -2,10 +2,11 @@ import argparseimport jsonimport re-from letta.credentials import LettaCredentialsfrom openai import OpenAIfrom tqdm import tqdm+from letta.credentials import LettaCredentials+# Note: did not end up using since no cases of cheating were observed# CHEATING_PROMPT = \# """diff --git a/paper_experiments/doc_qa_task/load_wikipedia_embeddings.py b/paper_experiments/doc_qa_task/load_wikipedia_embeddings.pyindex e80e7e9bc..94b981437 100644--- a/paper_experiments/doc_qa_task/load_wikipedia_embeddings.py+++ b/paper_experiments/doc_qa_task/load_wikipedia_embeddings.py@@ -8,10 +8,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completedfrom absl import app, flagsfrom icml_experiments.utils import get_experiment_config+from tqdm import tqdm+from letta.agent_store.storage import StorageConnector, TableTypefrom letta.cli.cli_config import deletefrom letta.data_types import Passage-from tqdm import tqdm# Create an empty list to store the JSON objectssource_name = "wikipedia"diff --git a/paper_experiments/nested_kv_task/nested_kv.py b/paper_experiments/nested_kv_task/nested_kv.pyindex 64fa06a26..04c95ac54 100644--- a/paper_experiments/nested_kv_task/nested_kv.py+++ b/paper_experiments/nested_kv_task/nested_kv.py@@ -29,10 +29,11 @@ from typing import Optionalimport openaifrom icml_experiments.utils import get_experiment_config, load_gzipped_file+from tqdm import tqdm+from letta import utilsfrom letta.cli.cli_config import deletefrom letta.config import LettaConfig-from tqdm import tqdm# TODO: update personasNESTED_PERSONA = "You are Letta DOC-QA bot. Your job is to answer questions about documents that are stored in your archival memory. The answer to the users question will ALWAYS be in your archival memory, so remember to keep searching if you can't find the answer. DO NOT STOP SEARCHING UNTIL YOU VERIFY THAT THE VALUE IS NOT A KEY. Do not stop making nested lookups until this condition is met." # TODO decide on a good persona/humandiff --git a/pyproject.toml b/pyproject.tomlindex 0a8c73325..5aa60a0f1 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -100,3 +100,11 @@ extend-exclude = "examples/*"[build-system]requires = ["poetry-core"]build-backend = "poetry.core.masonry.api"++[tool.isort]+profile = "black"+line_length = 140+multi_line_output = 3+include_trailing_comma = true+force_grid_wrap = 0+use_parentheses = true\ No newline at end of filediff --git a/scripts/migrate_tools.py b/scripts/migrate_tools.pyindex 91e16071e..53578c690 100644--- a/scripts/migrate_tools.py+++ b/scripts/migrate_tools.py@@ -1,7 +1,8 @@+from tqdm import tqdm+from letta.schemas.user import Userfrom letta.services.organization_manager import OrganizationManagerfrom letta.services.tool_manager import ToolManager-from tqdm import tqdmdef deprecated_tool():diff --git a/tests/helpers/endpoints_helper.py b/tests/helpers/endpoints_helper.pyindex 4ed801468..82b2ed1c7 100644--- a/tests/helpers/endpoints_helper.py+++ b/tests/helpers/endpoints_helper.py@@ -14,12 +14,7 @@ from letta.agent import Agentfrom letta.config import LettaConfigfrom letta.constants import DEFAULT_HUMAN, DEFAULT_PERSONAfrom letta.embeddings import embedding_model-from letta.errors import (- InvalidInnerMonologueError,- InvalidToolCallError,- MissingInnerMonologueError,- MissingToolCallError,-)+from letta.errors import InvalidInnerMonologueError, InvalidToolCallError, MissingInnerMonologueError, MissingToolCallErrorfrom letta.llm_api.llm_api_tools import createfrom letta.local_llm.constants import INNER_THOUGHTS_KWARGfrom letta.schemas.agent import AgentState@@ -28,12 +23,7 @@ from letta.schemas.letta_message import LettaMessage, ReasoningMessage, ToolCallfrom letta.schemas.letta_response import LettaResponsefrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.memory import ChatMemory-from letta.schemas.openai.chat_completion_response import (- ChatCompletionResponse,- Choice,- FunctionCall,- Message,-)+from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice, FunctionCall, Messagefrom letta.utils import get_human_text, get_persona_text, json_dumpsfrom tests.helpers.utils import cleanupdiff --git a/tests/integration_test_agent_tool_graph.py b/tests/integration_test_agent_tool_graph.pyindex 4144c3477..64486ad33 100644--- a/tests/integration_test_agent_tool_graph.py+++ b/tests/integration_test_agent_tool_graph.py@@ -2,19 +2,15 @@ import timeimport uuidimport pytest+from letta import create_clientfrom letta.schemas.letta_message import ToolCallMessage-from letta.schemas.tool_rule import (- ChildToolRule,- ConditionalToolRule,- InitToolRule,- TerminalToolRule,-)+from letta.schemas.tool_rule import ChildToolRule, ConditionalToolRule, InitToolRule, TerminalToolRulefrom tests.helpers.endpoints_helper import (- assert_invoked_function_call,- assert_invoked_send_message_with_keyword,- assert_sanity_checks,- setup_agent,+ assert_invoked_function_call,+ assert_invoked_send_message_with_keyword,+ assert_sanity_checks,+ setup_agent,)from tests.helpers.utils import cleanupdiff --git a/tests/integration_test_offline_memory_agent.py b/tests/integration_test_offline_memory_agent.pyindex 01b04693d..15d4161d5 100644--- a/tests/integration_test_offline_memory_agent.py+++ b/tests/integration_test_offline_memory_agent.py@@ -1,13 +1,14 @@import pytest+from letta import BasicBlockMemoryfrom letta.client.client import Block, create_clientfrom letta.constants import DEFAULT_HUMAN, DEFAULT_PERSONAfrom letta.offline_memory_agent import (- finish_rethinking_memory,- finish_rethinking_memory_convo,- rethink_memory,- rethink_memory_convo,- trigger_rethink_memory,+ finish_rethinking_memory,+ finish_rethinking_memory_convo,+ rethink_memory,+ rethink_memory_convo,+ trigger_rethink_memory,)from letta.prompts import gpt_systemfrom letta.schemas.agent import AgentTypediff --git a/tests/integration_test_summarizer.py b/tests/integration_test_summarizer.pyindex ce6c41b25..b4de0043b 100644--- a/tests/integration_test_summarizer.py+++ b/tests/integration_test_summarizer.py@@ -4,6 +4,7 @@ import uuidfrom typing import Listimport pytest+from letta import create_clientfrom letta.agent import Agentfrom letta.client.client import LocalClientdiff --git a/tests/integration_test_tool_execution_sandbox.py b/tests/integration_test_tool_execution_sandbox.pyindex 699185c9f..97346021b 100644--- a/tests/integration_test_tool_execution_sandbox.py+++ b/tests/integration_test_tool_execution_sandbox.py@@ -5,6 +5,8 @@ from pathlib import Pathfrom unittest.mock import patchimport pytest+from sqlalchemy import delete+from letta import create_clientfrom letta.functions.function_sets.base import core_memory_append, core_memory_replacefrom letta.orm import SandboxConfig, SandboxEnvironmentVariable@@ -14,12 +16,12 @@ from letta.schemas.llm_config import LLMConfigfrom letta.schemas.memory import ChatMemoryfrom letta.schemas.organization import Organizationfrom letta.schemas.sandbox_config import (- E2BSandboxConfig,- LocalSandboxConfig,- SandboxConfigCreate,- SandboxConfigUpdate,- SandboxEnvironmentVariableCreate,- SandboxType,+ E2BSandboxConfig,+ LocalSandboxConfig,+ SandboxConfigCreate,+ SandboxConfigUpdate,+ SandboxEnvironmentVariableCreate,+ SandboxType,)from letta.schemas.tool import Tool, ToolCreatefrom letta.schemas.user import User@@ -29,7 +31,6 @@ from letta.services.tool_execution_sandbox import ToolExecutionSandboxfrom letta.services.tool_manager import ToolManagerfrom letta.services.user_manager import UserManagerfrom letta.settings import tool_settings-from sqlalchemy import deletefrom tests.helpers.utils import create_tool_from_func# Constants@@ -211,9 +212,7 @@ def clear_core_memory_tool(test_user):@pytest.fixturedef external_codebase_tool(test_user):- from tests.test_tool_sandbox.restaurant_management_system.adjust_menu_prices import (- adjust_menu_prices,- )+ from tests.test_tool_sandbox.restaurant_management_system.adjust_menu_prices import adjust_menu_pricestool = create_tool_from_func(adjust_menu_prices)tool = ToolManager().create_or_update_tool(tool, test_user)diff --git a/tests/test_base_functions.py b/tests/test_base_functions.pyindex 007d2bf9c..5b5bec6f4 100644--- a/tests/test_base_functions.py+++ b/tests/test_base_functions.py@@ -1,5 +1,6 @@-import letta.functions.function_sets.base as base_functionsimport pytest++import letta.functions.function_sets.base as base_functionsfrom letta import LocalClient, create_clientfrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.llm_config import LLMConfigdiff --git a/tests/test_cli.py b/tests/test_cli.pyindex c5595a004..c6497f501 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -4,10 +4,8 @@ import sysimport pexpectimport pytest-from letta.local_llm.constants import (- ASSISTANT_MESSAGE_CLI_SYMBOL,- INNER_THOUGHTS_CLI_SYMBOL,-)++from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL, INNER_THOUGHTS_CLI_SYMBOLoriginal_letta_path = os.path.expanduser("~/.letta")backup_letta_path = os.path.expanduser("~/.letta_backup")diff --git a/tests/test_client.py b/tests/test_client.pyindex 71f7216c1..cc3912353 100644--- a/tests/test_client.py+++ b/tests/test_client.py@@ -8,6 +8,8 @@ from typing import List, Unionimport pytestfrom dotenv import load_dotenv+from sqlalchemy import delete+from letta import LocalClient, RESTClient, create_clientfrom letta.orm import SandboxConfig, SandboxEnvironmentVariablefrom letta.schemas.agent import AgentState@@ -18,7 +20,6 @@ from letta.schemas.letta_message import ToolReturnMessagefrom letta.schemas.llm_config import LLMConfigfrom letta.schemas.sandbox_config import LocalSandboxConfig, SandboxTypefrom letta.utils import create_random_username-from sqlalchemy import delete# ConstantsSERVER_PORT = 8283diff --git a/tests/test_client_legacy.py b/tests/test_client_legacy.pyindex b578d847e..3d907fa37 100644--- a/tests/test_client_legacy.py+++ b/tests/test_client_legacy.py@@ -7,6 +7,8 @@ from typing import List, Unionimport pytestfrom dotenv import load_dotenv+from sqlalchemy import delete+from letta import create_clientfrom letta.client.client import LocalClient, RESTClientfrom letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLS, DEFAULT_PRESET@@ -15,13 +17,13 @@ from letta.schemas.agent import AgentStatefrom letta.schemas.embedding_config import EmbeddingConfigfrom letta.schemas.enums import MessageRole, MessageStreamStatusfrom letta.schemas.letta_message import (- AssistantMessage,- LettaMessage,- ReasoningMessage,- SystemMessage,- ToolCallMessage,- ToolReturnMessage,- UserMessage,+ AssistantMessage,+ LettaMessage,+ ReasoningMessage,+ SystemMessage,+ ToolCallMessage,+ ToolReturnMessage,+ UserMessage,)from letta.schemas.letta_response import LettaResponse, LettaStreamingResponsefrom letta.schemas.llm_config import LLMConfig@@ -32,7 +34,6 @@ from letta.services.organization_manager import OrganizationManagerfrom letta.services.user_manager import UserManagerfrom letta.settings import model_settingsfrom letta.utils import get_utc_time-from sqlalchemy import deletefrom tests.helpers.client_helper import upload_file_using_client# from tests.utils import create_configdiff --git a/tests/test_local_client.py b/tests/test_local_client.pyindex 8b0c76178..da5e533c5 100644--- a/tests/test_local_client.py+++ b/tests/test_local_client.py@@ -1,6 +1,7 @@import uuidimport pytest+from letta import create_clientfrom letta.client.client import LocalClientfrom letta.schemas.agent import AgentStatediff --git a/tests/test_managers.py b/tests/test_managers.pyindex 052a1819e..388d477c6 100644--- a/tests/test_managers.py+++ b/tests/test_managers.py@@ -3,27 +3,30 @@ import timefrom datetime import datetime, timedeltaimport pytest+from sqlalchemy import delete+from sqlalchemy.exc import IntegrityError+from letta.config import LettaConfigfrom letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLSfrom letta.embeddings import embedding_modelfrom letta.functions.functions import derive_openai_json_schema, parse_source_codefrom letta.orm import (- Agent,- AgentPassage,- Block,- BlocksAgents,- FileMetadata,- Job,- Message,- Organization,- SandboxConfig,- SandboxEnvironmentVariable,- Source,- SourcePassage,- SourcesAgents,- Tool,- ToolsAgents,- User,+ Agent,+ AgentPassage,+ Block,+ BlocksAgents,+ FileMetadata,+ Job,+ Message,+ Organization,+ SandboxConfig,+ SandboxEnvironmentVariable,+ Source,+ SourcePassage,+ SourcesAgents,+ Tool,+ ToolsAgents,+ User,)from letta.orm.agents_tags import AgentsTagsfrom letta.orm.errors import NoResultFound, UniqueConstraintViolationError@@ -41,13 +44,13 @@ from letta.schemas.message import MessageCreate, MessageUpdatefrom letta.schemas.organization import Organization as PydanticOrganizationfrom letta.schemas.passage import Passage as PydanticPassagefrom letta.schemas.sandbox_config import (- E2BSandboxConfig,- LocalSandboxConfig,- SandboxConfigCreate,- SandboxConfigUpdate,- SandboxEnvironmentVariableCreate,- SandboxEnvironmentVariableUpdate,- SandboxType,+ E2BSandboxConfig,+ LocalSandboxConfig,+ SandboxConfigCreate,+ SandboxConfigUpdate,+ SandboxEnvironmentVariableCreate,+ SandboxEnvironmentVariableUpdate,+ SandboxType,)from letta.schemas.source import Source as PydanticSourcefrom letta.schemas.source import SourceUpdate@@ -60,8 +63,6 @@ from letta.server.server import SyncServerfrom letta.services.block_manager import BlockManagerfrom letta.services.organization_manager import OrganizationManagerfrom letta.settings import tool_settings-from sqlalchemy import delete-from sqlalchemy.exc import IntegrityErrorfrom tests.helpers.utils import comprehensive_agent_checksDEFAULT_EMBEDDING_CONFIG = EmbeddingConfig(diff --git a/tests/test_model_letta_perfomance.py b/tests/test_model_letta_perfomance.pyindex 59bc90af4..d45654eaa 100644--- a/tests/test_model_letta_perfomance.py+++ b/tests/test_model_letta_perfomance.py@@ -3,15 +3,15 @@ import osimport timefrom tests.helpers.endpoints_helper import (- check_agent_archival_memory_insert,- check_agent_archival_memory_retrieval,- check_agent_edit_core_memory,- check_agent_recall_chat_memory,- check_agent_summarize_memory_simple,- check_agent_uses_external_tool,- check_first_response_is_valid_for_llm_endpoint,- check_response_contains_keyword,- run_embedding_endpoint,+ check_agent_archival_memory_insert,+ check_agent_archival_memory_retrieval,+ check_agent_edit_core_memory,+ check_agent_recall_chat_memory,+ check_agent_summarize_memory_simple,+ check_agent_uses_external_tool,+ check_first_response_is_valid_for_llm_endpoint,+ check_response_contains_keyword,+ run_embedding_endpoint,)# directoriesdiff --git a/tests/test_providers.py b/tests/test_providers.pyindex 8e4ea5cc7..228e33525 100644--- a/tests/test_providers.py+++ b/tests/test_providers.py@@ -1,14 +1,14 @@import osfrom letta.providers import (- AnthropicProvider,- AzureProvider,- GoogleAIProvider,- GroqProvider,- MistralProvider,- OllamaProvider,- OpenAIProvider,- TogetherProvider,+ AnthropicProvider,+ AzureProvider,+ GoogleAIProvider,+ GroqProvider,+ MistralProvider,+ OllamaProvider,+ OpenAIProvider,+ TogetherProvider,)from letta.settings import model_settingsdiff --git a/tests/test_server.py b/tests/test_server.pyindex e0d51ffcb..2f205a7e7 100644--- a/tests/test_server.py+++ b/tests/test_server.py@@ -3,19 +3,13 @@ import uuidimport warningsfrom typing import List, Tuple-import letta.utils as utilsimport pytest++import letta.utils as utilsfrom letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLSfrom letta.schemas.block import CreateBlockfrom letta.schemas.enums import MessageRole-from letta.schemas.letta_message import (- LettaMessage,- ReasoningMessage,- SystemMessage,- ToolCallMessage,- ToolReturnMessage,- UserMessage,-)+from letta.schemas.letta_message import LettaMessage, ReasoningMessage, SystemMessage, ToolCallMessage, ToolReturnMessage, UserMessagefrom letta.schemas.user import Userutils.DEBUG = Truediff --git a/tests/test_stream_buffer_readers.py b/tests/test_stream_buffer_readers.pyindex 92335cc70..9a0bb5e85 100644--- a/tests/test_stream_buffer_readers.py+++ b/tests/test_stream_buffer_readers.py@@ -1,6 +1,7 @@import jsonimport pytest+from letta.streaming_utils import JSONInnerThoughtsExtractordiff --git a/tests/test_tool_rule_solver.py b/tests/test_tool_rule_solver.pyindex 8a9e93537..dcb66e1b1 100644--- a/tests/test_tool_rule_solver.py+++ b/tests/test_tool_rule_solver.py@@ -1,12 +1,8 @@import pytest+from letta.helpers import ToolRulesSolverfrom letta.helpers.tool_rule_solver import ToolRuleValidationError-from letta.schemas.tool_rule import (- ChildToolRule,- ConditionalToolRule,- InitToolRule,- TerminalToolRule,-)+from letta.schemas.tool_rule import ChildToolRule, ConditionalToolRule, InitToolRule, TerminalToolRule# Constants for tool names used in the testsSTART_TOOL = "start_tool"diff --git a/tests/test_tool_sandbox/restaurant_management_system/adjust_menu_prices.py b/tests/test_tool_sandbox/restaurant_management_system/adjust_menu_prices.pyindex 1e5c090e6..57adc1639 100644--- a/tests/test_tool_sandbox/restaurant_management_system/adjust_menu_prices.py+++ b/tests/test_tool_sandbox/restaurant_management_system/adjust_menu_prices.py@@ -8,6 +8,7 @@ def adjust_menu_prices(percentage: float) -> str:str: A formatted string summarizing the price adjustments."""import cowsay+from core.menu import Menu, MenuItem # Import a class from the codebasefrom core.utils import format_currency # Use a utility function to test importsdiff --git a/tests/test_tool_schema_parsing.py b/tests/test_tool_schema_parsing.pyindex 6eed18f19..f6738a06f 100644--- a/tests/test_tool_schema_parsing.py+++ b/tests/test_tool_schema_parsing.py@@ -2,6 +2,7 @@ import jsonimport osimport pytest+from letta.functions.functions import derive_openai_json_schemafrom letta.llm_api.helpers import convert_to_structured_output, make_post_requestdiff --git a/tests/test_utils.py b/tests/test_utils.pyindex f8fd42ddb..904e903e7 100644--- a/tests/test_utils.py+++ b/tests/test_utils.py@@ -1,4 +1,5 @@import pytest+from letta.constants import MAX_FILENAME_LENGTHfrom letta.utils import sanitize_filenamediff --git a/tests/test_v1_routes.py b/tests/test_v1_routes.pyindex 6877031c6..5093fe93b 100644--- a/tests/test_v1_routes.py+++ b/tests/test_v1_routes.py@@ -1,13 +1,9 @@from unittest.mock import MagicMock, Mock, patchimport pytest-from composio.client.collections import (- ActionModel,- ActionParametersModel,- ActionResponseModel,- AppModel,-)+from composio.client.collections import ActionModel, ActionParametersModel, ActionResponseModel, AppModelfrom fastapi.testclient import TestClient+from letta.schemas.tool import ToolCreate, ToolUpdatefrom letta.server.rest_api.app import appfrom letta.server.rest_api.utils import get_letta_serverdiff --git a/tests/test_vector_embeddings.py b/tests/test_vector_embeddings.pyindex 8640f628f..e65e6b9b1 100644--- a/tests/test_vector_embeddings.py+++ b/tests/test_vector_embeddings.py@@ -1,4 +1,5 @@import numpy as np+from letta.orm.sqlalchemy_base import adapt_arrayfrom letta.orm.sqlite_functions import convert_array, verify_embedding_dimensiondiff --git a/tests/utils.py b/tests/utils.pyindex 3ce1cb62b..19a05a090 100644--- a/tests/utils.py+++ b/tests/utils.py@@ -5,6 +5,7 @@ from importlib import utilfrom typing import Dict, Iterator, List, Tupleimport requests+from letta.config import LettaConfigfrom letta.data_sources.connectors import DataConnectorfrom letta.schemas.file import FileMetadata