run isort on apps/core

This commit is contained in:
Caren Thomas
2024-12-26 19:27:09 -08:00
parent c5f6a19a4d
commit 905906d416
58 changed files with 383 additions and 383 deletions

View File

@@ -13,11 +13,11 @@ from letta.schemas.job import Job
from letta.schemas.letta_message import LettaMessage
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import (
ArchivalMemorySummary,
BasicBlockMemory,
ChatMemory,
Memory,
RecallMemorySummary,
ArchivalMemorySummary,
BasicBlockMemory,
ChatMemory,
Memory,
RecallMemorySummary,
)
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_response import UsageStatistics

View File

@@ -7,17 +7,17 @@ from abc import ABC, abstractmethod
from typing import List, Optional, Tuple, Union
from 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 ContextWindowExceededError
from letta.helpers import ToolRulesSolver
@@ -34,11 +34,11 @@ from letta.schemas.enums import MessageRole
from letta.schemas.memory import ContextWindowOverview, Memory
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_request import (
Tool as ChatCompletionRequestTool,
Tool as ChatCompletionRequestTool,
)
from letta.schemas.openai.chat_completion_response import ChatCompletionResponse
from letta.schemas.openai.chat_completion_response import (
Message as ChatCompletionMessage,
Message as ChatCompletionMessage,
)
from letta.schemas.openai.chat_completion_response import UsageStatistics
from letta.schemas.tool import Tool
@@ -47,30 +47,30 @@ from letta.schemas.usage import LettaUsageStatistics
from letta.services.agent_manager import AgentManager
from letta.services.block_manager import BlockManager
from letta.services.helpers.agent_manager_helper import (
check_supports_structured_output,
compile_memory_metadata_block,
check_supports_structured_output,
compile_memory_metadata_block,
)
from letta.services.message_manager import MessageManager
from letta.services.passage_manager import PassageManager
from letta.services.tool_execution_sandbox import ToolExecutionSandbox
from letta.streaming_interface import StreamingRefreshCLIInterface
from letta.system import (
get_heartbeat,
get_token_limit_warning,
package_function_response,
package_summarize_message,
package_user_message,
get_heartbeat,
get_token_limit_warning,
package_function_response,
package_summarize_message,
package_user_message,
)
from 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,
)

View File

@@ -10,10 +10,10 @@ from letta import create_client
from letta.agent import Agent, save_agent
from letta.config import LettaConfig
from letta.constants import (
CLI_WARNING_PREFIX,
CORE_MEMORY_BLOCK_CHAR_LIMIT,
LETTA_DIR,
MIN_CONTEXT_WINDOW,
CLI_WARNING_PREFIX,
CORE_MEMORY_BLOCK_CHAR_LIMIT,
LETTA_DIR,
MIN_CONTEXT_WINDOW,
)
from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL
from letta.log import get_logger
@@ -23,7 +23,7 @@ from 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
StreamingRefreshCLIInterface as interface, # for printing to terminal
)
from letta.utils import open_folder_in_explorer, printd

View File

@@ -5,12 +5,12 @@ from typing import Callable, Dict, Generator, List, Optional, Union
import letta.utils
import requests
from letta.constants import (
ADMIN_PREFIX,
BASE_MEMORY_TOOLS,
BASE_TOOLS,
DEFAULT_HUMAN,
DEFAULT_PERSONA,
FUNCTION_RETURN_CHAR_LIMIT,
ADMIN_PREFIX,
BASE_MEMORY_TOOLS,
BASE_TOOLS,
DEFAULT_HUMAN,
DEFAULT_PERSONA,
FUNCTION_RETURN_CHAR_LIMIT,
)
from letta.data_sources.connectors import DataConnector
from letta.functions.functions import parse_source_code
@@ -27,25 +27,25 @@ from letta.schemas.letta_request import LettaRequest, LettaStreamingRequest
from letta.schemas.letta_response import LettaResponse, LettaStreamingResponse
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import (
ArchivalMemorySummary,
ChatMemory,
CreateArchivalMemory,
Memory,
RecallMemorySummary,
ArchivalMemorySummary,
ChatMemory,
CreateArchivalMemory,
Memory,
RecallMemorySummary,
)
from letta.schemas.message import Message, MessageCreate, MessageUpdate
from letta.schemas.openai.chat_completions import ToolCall
from letta.schemas.organization import Organization
from letta.schemas.passage import Passage
from 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, SourceUpdate
from letta.schemas.tool import Tool, ToolCreate, ToolUpdate

View File

@@ -7,9 +7,9 @@ from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
from letta.errors import LLMError
from letta.schemas.enums import MessageStreamStatus
from letta.schemas.letta_message import (
ReasoningMessage,
ToolCallMessage,
ToolReturnMessage,
ReasoningMessage,
ToolCallMessage,
ToolReturnMessage,
)
from letta.schemas.letta_response import LettaStreamingResponse
from letta.schemas.usage import LettaUsageStatistics

View File

@@ -4,8 +4,8 @@ from typing import Optional
from IPython.display import HTML, display
from letta.local_llm.constants import (
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
)
from sqlalchemy.testing.plugin.plugin_base import warnings

View File

@@ -5,12 +5,12 @@ from typing import Optional
import letta
from 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_logger
from letta.schemas.embedding_config import EmbeddingConfig

View File

@@ -2,9 +2,9 @@ from typing import Dict, Iterator, List, Tuple
import typer
from letta.data_sources.connectors_helper import (
assert_all_files_exist_locally,
extract_metadata_from_files,
get_filenames_in_dir,
assert_all_files_exist_locally,
extract_metadata_from_files,
get_filenames_in_dir,
)
from letta.embeddings import embedding_model
from letta.schemas.file import FileMetadata

View File

@@ -4,9 +4,9 @@ from typing import Any, List, Optional
import numpy as np
import tiktoken
from letta.constants import (
EMBEDDING_TO_TOKENIZER_DEFAULT,
EMBEDDING_TO_TOKENIZER_MAP,
MAX_EMBEDDING_DIM,
EMBEDDING_TO_TOKENIZER_DEFAULT,
EMBEDDING_TO_TOKENIZER_MAP,
MAX_EMBEDDING_DIM,
)
from letta.schemas.embedding_config import EmbeddingConfig
from letta.utils import is_valid_url, printd

View File

@@ -4,8 +4,8 @@ from typing import Optional
import requests
from letta.constants import (
MESSAGE_CHATGPT_FUNCTION_MODEL,
MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE,
MESSAGE_CHATGPT_FUNCTION_MODEL,
MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE,
)
from letta.llm_api.llm_api_tools import create
from letta.schemas.message import Message

View File

@@ -3,11 +3,11 @@ from typing import List, Optional, Union
from letta.schemas.enums import ToolRuleType
from letta.schemas.tool_rule import (
BaseToolRule,
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
BaseToolRule,
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
)
from pydantic import BaseModel, Field

View File

@@ -5,8 +5,8 @@ from typing import List, Optional
from 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,
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
)
from letta.schemas.message import Message
from letta.utils import json_loads, printd

View File

@@ -6,12 +6,12 @@ from letta.llm_api.helpers import make_post_request
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
FunctionCall,
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, UsageStatistics
from letta.utils import get_utc_time, smart_urljoin

View File

@@ -7,12 +7,12 @@ from letta.local_llm.utils import count_tokens
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
FunctionCall,
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, UsageStatistics
from letta.utils import get_tool_call_id, get_utc_time, json_dumps, smart_urljoin
@@ -276,8 +276,8 @@ def convert_tools_to_cohere_format(tools: List[Tool], 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,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
for cohere_tool in tools_dict_list:

View File

@@ -8,12 +8,12 @@ from letta.local_llm.json_parser import clean_json_string_extra_backslash
from letta.local_llm.utils import count_tokens
from letta.schemas.openai.chat_completion_request import Tool
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
FunctionCall,
Message,
ToolCall,
UsageStatistics,
ChatCompletionResponse,
Choice,
FunctionCall,
Message,
ToolCall,
UsageStatistics,
)
from letta.utils import get_tool_call_id, get_utc_time, json_dumps
@@ -230,8 +230,8 @@ def convert_tools_to_google_ai_format(tools: List[Tool], inner_thoughts_in_kwarg
# Add inner thoughts
if inner_thoughts_in_kwargs:
from letta.local_llm.constants import (
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
func["parameters"]["properties"][INNER_THOUGHTS_KWARG] = {

View File

@@ -8,36 +8,36 @@ from letta.errors import LettaConfigurationError, RateLimitExceededError
from letta.llm_api.anthropic import anthropic_chat_completions_request
from 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,
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,
add_inner_thoughts_to_functions,
unpack_all_inner_thoughts_from_kwargs,
)
from 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,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
from letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messages
from letta.schemas.llm_config import LLMConfig
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_request import (
ChatCompletionRequest,
Tool,
cast_message_to_subtype,
ChatCompletionRequest,
Tool,
cast_message_to_subtype,
)
from letta.schemas.openai.chat_completion_response import ChatCompletionResponse
from letta.settings import ModelSettings
from letta.streaming_interface import (
AgentChunkStreamingInterface,
AgentRefreshStreamingInterface,
AgentChunkStreamingInterface,
AgentRefreshStreamingInterface,
)
LLM_API_PROVIDER_OPTIONS = ["openai", "azure", "anthropic", "google_ai", "cohere", "local", "groq"]

View File

@@ -9,13 +9,13 @@ from httpx_sse._exceptions import SSEError
from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
from letta.errors import LLMError
from letta.llm_api.helpers import (
add_inner_thoughts_to_functions,
convert_to_structured_output,
make_post_request,
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,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
from letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messages
from letta.schemas.llm_config import LLMConfig
@@ -23,26 +23,26 @@ from letta.schemas.message import Message as _Message
from letta.schemas.message import MessageRole as _MessageRole
from letta.schemas.openai.chat_completion_request import ChatCompletionRequest
from letta.schemas.openai.chat_completion_request import (
FunctionCall as ToolFunctionChoiceFunctionCall,
FunctionCall as ToolFunctionChoiceFunctionCall,
)
from letta.schemas.openai.chat_completion_request import (
Tool,
ToolFunctionChoice,
cast_message_to_subtype,
Tool,
ToolFunctionChoice,
cast_message_to_subtype,
)
from 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,
AgentChunkStreamingInterface,
AgentRefreshStreamingInterface,
)
from letta.utils import get_tool_call_id, smart_urljoin

View File

@@ -8,8 +8,8 @@ from letta.errors import LocalLLMConnectionError, LocalLLMError
from letta.local_llm.constants import DEFAULT_WRAPPER
from 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,
create_dynamic_model_from_function,
generate_gbnf_grammar_and_documentation,
)
from letta.local_llm.koboldcpp.api import get_koboldcpp_completion
from letta.local_llm.llamacpp.api import get_llamacpp_completion
@@ -20,15 +20,15 @@ from letta.local_llm.utils import count_tokens, get_available_wrappers
from letta.local_llm.vllm.api import get_vllm_completion
from 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,
get_webui_completion as get_webui_completion_legacy,
)
from letta.prompts.gpt_summarize import SYSTEM as SUMMARIZE_SYSTEM_MESSAGE
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
Message,
ToolCall,
UsageStatistics,
ChatCompletionResponse,
Choice,
Message,
ToolCall,
UsageStatistics,
)
from letta.utils import get_tool_call_id, get_utc_time, json_dumps

View File

@@ -1,6 +1,6 @@
# import letta.local_llm.llm_chat_completion_wrappers.airoboros as airoboros
from letta.local_llm.llm_chat_completion_wrappers.chatml import (
ChatMLInnerMonologueWrapper,
ChatMLInnerMonologueWrapper,
)
DEFAULT_ENDPOINTS = {

View File

@@ -6,16 +6,16 @@ from enum import Enum
from inspect import getdoc, isclass
from types import NoneType
from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Type,
Union,
_GenericAlias,
get_args,
get_origin,
Any,
Callable,
List,
Optional,
Tuple,
Type,
Union,
_GenericAlias,
get_args,
get_origin,
)
from docstring_parser import parse

View File

@@ -1,7 +1,7 @@
from letta.errors import LLMJSONParsingError
from letta.local_llm.json_parser import clean_json
from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import (
LLMChatCompletionWrapper,
LLMChatCompletionWrapper,
)
from letta.schemas.enums import MessageRole
from letta.utils import json_dumps, json_loads
@@ -76,8 +76,8 @@ class ChatMLInnerMonologueWrapper(LLMChatCompletionWrapper):
func_str += f"\n params:"
if add_inner_thoughts:
from letta.local_llm.constants import (
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
func_str += f"\n {INNER_THOUGHTS_KWARG}: {INNER_THOUGHTS_KWARG_DESCRIPTION}"

View File

@@ -1,7 +1,7 @@
from letta.errors import LLMJSONParsingError
from letta.local_llm.json_parser import clean_json
from letta.local_llm.llm_chat_completion_wrappers.wrapper_base import (
LLMChatCompletionWrapper,
LLMChatCompletionWrapper,
)
from letta.utils import json_dumps, json_loads
@@ -75,8 +75,8 @@ class LLaMA3InnerMonologueWrapper(LLMChatCompletionWrapper):
func_str += "\n params:"
if add_inner_thoughts:
from letta.local_llm.constants import (
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
INNER_THOUGHTS_KWARG,
INNER_THOUGHTS_KWARG_DESCRIPTION,
)
func_str += f"\n {INNER_THOUGHTS_KWARG}: {INNER_THOUGHTS_KWARG_DESCRIPTION}"

View File

@@ -3,7 +3,7 @@ import os
from letta.constants import LETTA_DIR
from letta.local_llm.settings.deterministic_mirostat import (
settings as det_miro_settings,
settings as det_miro_settings,
)
from letta.local_llm.settings.simple import settings as simple_settings

View File

@@ -3,9 +3,9 @@ from typing import TYPE_CHECKING, List, Optional
from letta.orm.block import Block
from letta.orm.custom_columns import (
EmbeddingConfigColumn,
LLMConfigColumn,
ToolRulesColumn,
EmbeddingConfigColumn,
LLMConfigColumn,
ToolRulesColumn,
)
from letta.orm.message import Message
from letta.orm.mixins import OrganizationMixin

View File

@@ -3,11 +3,11 @@ from typing import Optional
from sqlalchemy import Boolean, DateTime, String, func, text
from sqlalchemy.orm import (
DeclarativeBase,
Mapped,
declarative_mixin,
declared_attr,
mapped_column,
DeclarativeBase,
Mapped,
declarative_mixin,
declared_attr,
mapped_column,
)

View File

@@ -7,10 +7,10 @@ from letta.schemas.enums import ToolRuleType
from letta.schemas.llm_config import LLMConfig
from letta.schemas.openai.chat_completions import ToolCall, ToolCallFunction
from letta.schemas.tool_rule import (
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
)
from sqlalchemy import JSON
from sqlalchemy.types import BINARY, TypeDecorator

View File

@@ -4,7 +4,7 @@ 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,
SandboxEnvironmentVariable as PydanticSandboxEnvironmentVariable,
)
from letta.schemas.sandbox_config import SandboxType
from sqlalchemy import JSON

View File

@@ -6,10 +6,10 @@ from 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,
DatabaseTimeoutError,
ForeignKeyConstraintViolationError,
NoResultFound,
UniqueConstraintViolationError,
)
from letta.orm.sqlite_functions import adapt_array
from sqlalchemy import String, desc, func, or_, select

View File

@@ -2,8 +2,8 @@ from typing import List, Optional
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,
get_azure_chat_completions_endpoint,
get_azure_embeddings_endpoint,
)
from letta.llm_api.azure_openai_constants import AZURE_MODEL_TO_CONTEXT_LENGTH
from letta.schemas.embedding_config import EmbeddingConfig
@@ -568,7 +568,7 @@ class AzureProvider(Provider):
def list_llm_models(self) -> List[LLMConfig]:
from letta.llm_api.azure_openai import (
azure_openai_get_chat_completion_model_list,
azure_openai_get_chat_completion_model_list,
)
model_options = azure_openai_get_chat_completion_model_list(self.base_url, api_key=self.api_key, api_version=self.api_version)

View File

@@ -5,18 +5,18 @@ from datetime import datetime, timezone
from typing import List, Literal, Optional
from letta.constants import (
DEFAULT_MESSAGE_TOOL,
DEFAULT_MESSAGE_TOOL_KWARG,
TOOL_CALL_ID_MAX_LEN,
DEFAULT_MESSAGE_TOOL,
DEFAULT_MESSAGE_TOOL_KWARG,
TOOL_CALL_ID_MAX_LEN,
)
from letta.local_llm.constants import INNER_THOUGHTS_KWARG
from letta.schemas.enums import MessageRole
from letta.schemas.letta_base import OrmMetadataBase
from letta.schemas.letta_message import (
AssistantMessage,
LettaMessage,
ReasoningMessage,
SystemMessage,
AssistantMessage,
LettaMessage,
ReasoningMessage,
SystemMessage,
)
from letta.schemas.letta_message import ToolCall as LettaToolCall
from letta.schemas.letta_message import ToolCallMessage, ToolReturnMessage, UserMessage

View File

@@ -3,8 +3,8 @@ from typing import Dict, List, Optional
from letta.constants import FUNCTION_RETURN_CHAR_LIMIT
from letta.functions.functions import derive_openai_json_schema
from letta.functions.helpers import (
generate_composio_tool_wrapper,
generate_langchain_tool_wrapper,
generate_composio_tool_wrapper,
generate_langchain_tool_wrapper,
)
from letta.functions.schema_generator import generate_schema_from_args_schema_v2
from letta.schemas.letta_base import LettaBase

View File

@@ -13,33 +13,33 @@ from letta.constants import ADMIN_PREFIX, API_PREFIX, OPENAI_API_PREFIX
from letta.errors import LettaAgentNotFoundError, LettaUserNotFoundError
from letta.log import get_logger
from letta.orm.errors import (
DatabaseTimeoutError,
ForeignKeyConstraintViolationError,
NoResultFound,
UniqueConstraintViolationError,
DatabaseTimeoutError,
ForeignKeyConstraintViolationError,
NoResultFound,
UniqueConstraintViolationError,
)
from letta.schemas.letta_response import LettaResponse
from 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?
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,
router as openai_assistants_router,
)
from letta.server.rest_api.routers.openai.chat_completions.chat_completions import (
router as openai_chat_completions_router,
router as openai_chat_completions_router,
)
# from letta.orm.utilities import get_db_session # TODO(ethan) reenable once we merge ORM
from letta.server.rest_api.routers.v1 import ROUTERS as v1_routes
from letta.server.rest_api.routers.v1.organizations import (
router as organizations_router,
router as organizations_router,
)
from letta.server.rest_api.routers.v1.users import (
router as users_router, # TODO: decide on admin
router as users_router, # TODO: decide on admin
)
from letta.server.rest_api.static_files import mount_static_files
from letta.server.server import SyncServer

View File

@@ -11,22 +11,22 @@ from letta.interface import AgentInterface
from letta.local_llm.constants import INNER_THOUGHTS_KWARG
from letta.schemas.enums import MessageStreamStatus
from 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 Message
from letta.schemas.openai.chat_completion_response import ChatCompletionChunkResponse
from letta.streaming_interface import AgentChunkStreamingInterface
from letta.streaming_utils import (
FunctionArgumentsStreamHandler,
JSONInnerThoughtsExtractor,
FunctionArgumentsStreamHandler,
JSONInnerThoughtsExtractor,
)
from letta.utils import is_utc_datetime

View File

@@ -4,10 +4,10 @@ from fastapi import APIRouter, Body, HTTPException, Path, Query
from letta.constants import DEFAULT_PRESET
from letta.schemas.openai.openai import AssistantFile, OpenAIAssistant
from letta.server.rest_api.routers.openai.assistants.schemas import (
CreateAssistantFileRequest,
CreateAssistantRequest,
DeleteAssistantFileResponse,
DeleteAssistantResponse,
CreateAssistantFileRequest,
CreateAssistantRequest,
DeleteAssistantFileResponse,
DeleteAssistantResponse,
)
from letta.utils import get_utc_time

View File

@@ -1,11 +1,11 @@
from typing import List, Optional
from letta.schemas.openai.openai import (
MessageRoleType,
OpenAIMessage,
OpenAIThread,
ToolCall,
ToolCallOutput,
MessageRoleType,
OpenAIMessage,
OpenAIThread,
ToolCall,
ToolCallOutput,
)
from pydantic import BaseModel, Field

View File

@@ -6,10 +6,10 @@ from letta.schemas.enums import MessageRole
from letta.schemas.letta_message import LettaMessage, ToolCall
from letta.schemas.openai.chat_completion_request import ChatCompletionRequest
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
Message,
UsageStatistics,
ChatCompletionResponse,
Choice,
Message,
UsageStatistics,
)
# TODO this belongs in a controller!

View File

@@ -4,7 +4,7 @@ from letta.server.rest_api.routers.v1.health import router as health_router
from letta.server.rest_api.routers.v1.jobs import router as jobs_router
from 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,
router as sandbox_configs_router,
)
from letta.server.rest_api.routers.v1.sources import router as sources_router
from letta.server.rest_api.routers.v1.tools import router as tools_router

View File

@@ -4,14 +4,14 @@ from datetime import datetime
from typing import List, Optional, Union
from fastapi import (
APIRouter,
BackgroundTasks,
Body,
Depends,
Header,
HTTPException,
Query,
status,
APIRouter,
BackgroundTasks,
Body,
Depends,
Header,
HTTPException,
Query,
status,
)
from fastapi.responses import JSONResponse, StreamingResponse
from letta.constants import DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARG
@@ -19,25 +19,25 @@ from letta.log import get_logger
from letta.orm.errors import NoResultFound
from letta.schemas.agent import AgentState, CreateAgent, UpdateAgent
from letta.schemas.block import ( # , BlockLabelUpdate, BlockLimitUpdate
Block,
BlockUpdate,
CreateBlock,
Block,
BlockUpdate,
CreateBlock,
)
from letta.schemas.enums import MessageStreamStatus
from letta.schemas.job import Job, JobStatus, JobUpdate
from letta.schemas.letta_message import (
LegacyLettaMessage,
LettaMessage,
LettaMessageUnion,
LegacyLettaMessage,
LettaMessage,
LettaMessageUnion,
)
from letta.schemas.letta_request import LettaRequest, LettaStreamingRequest
from letta.schemas.letta_response import LettaResponse
from letta.schemas.memory import (
ArchivalMemorySummary,
ContextWindowOverview,
CreateArchivalMemory,
Memory,
RecallMemorySummary,
ArchivalMemorySummary,
ContextWindowOverview,
CreateArchivalMemory,
Memory,
RecallMemorySummary,
)
from letta.schemas.message import Message, MessageCreate, MessageUpdate
from letta.schemas.passage import Passage

View File

@@ -5,9 +5,9 @@ from letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfig
from letta.schemas.sandbox_config import SandboxConfigCreate, SandboxConfigUpdate
from letta.schemas.sandbox_config import SandboxEnvironmentVariable as PydanticEnvVar
from letta.schemas.sandbox_config import (
SandboxEnvironmentVariableCreate,
SandboxEnvironmentVariableUpdate,
SandboxType,
SandboxEnvironmentVariableCreate,
SandboxEnvironmentVariableUpdate,
SandboxType,
)
from letta.server.rest_api.utils import get_letta_server, get_user_id
from letta.server.server import SyncServer

View File

@@ -3,13 +3,13 @@ import tempfile
from typing import List, Optional
from fastapi import (
APIRouter,
BackgroundTasks,
Depends,
Header,
HTTPException,
Query,
UploadFile,
APIRouter,
BackgroundTasks,
Depends,
Header,
HTTPException,
Query,
UploadFile,
)
from letta.schemas.file import FileMetadata
from letta.schemas.job import Job

View File

@@ -27,17 +27,17 @@ from letta.offline_memory_agent import OfflineMemoryAgent
from letta.orm import Base
from letta.orm.errors import NoResultFound
from 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, CreateAgent
from letta.schemas.block import BlockUpdate
@@ -49,10 +49,10 @@ from letta.schemas.job import Job, JobUpdate
from letta.schemas.letta_message import LettaMessage, ToolReturnMessage
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import (
ArchivalMemorySummary,
ContextWindowOverview,
Memory,
RecallMemorySummary,
ArchivalMemorySummary,
ContextWindowOverview,
Memory,
RecallMemorySummary,
)
from letta.schemas.message import Message, MessageCreate, MessageRole, MessageUpdate
from letta.schemas.organization import Organization

View File

@@ -25,13 +25,13 @@ from letta.schemas.tool_rule import ToolRule as PydanticToolRule
from letta.schemas.user import User as PydanticUser
from letta.services.block_manager import BlockManager
from 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 MessageManager
from letta.services.source_manager import SourceManager

View File

@@ -10,9 +10,9 @@ from letta.schemas.sandbox_config import SandboxConfig as PydanticSandboxConfig
from letta.schemas.sandbox_config import SandboxConfigCreate, SandboxConfigUpdate
from letta.schemas.sandbox_config import SandboxEnvironmentVariable as PydanticEnvVar
from letta.schemas.sandbox_config import (
SandboxEnvironmentVariableCreate,
SandboxEnvironmentVariableUpdate,
SandboxType,
SandboxEnvironmentVariableCreate,
SandboxEnvironmentVariableUpdate,
SandboxType,
)
from letta.schemas.user import User as PydanticUser
from letta.utils import enforce_types, printd

View File

@@ -5,13 +5,13 @@ from typing import List, Optional
from letta.interface import CLIInterface
from letta.local_llm.constants import (
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
)
from letta.schemas.message import Message
from letta.schemas.openai.chat_completion_response import (
ChatCompletionChunkResponse,
ChatCompletionResponse,
ChatCompletionChunkResponse,
ChatCompletionResponse,
)
# from colorama import Fore, Style, init

View File

@@ -3,10 +3,10 @@ import uuid
from typing import Optional
from .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_dumps

View File

@@ -23,13 +23,13 @@ import letta
import pytz
import tiktoken
from 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_filename

View File

@@ -15,10 +15,10 @@ from letta.config import LettaConfig
from letta.constants import DEFAULT_HUMAN, DEFAULT_PERSONA
from letta.embeddings import embedding_model
from letta.errors import (
InvalidInnerMonologueError,
InvalidToolCallError,
MissingInnerMonologueError,
MissingToolCallError,
InvalidInnerMonologueError,
InvalidToolCallError,
MissingInnerMonologueError,
MissingToolCallError,
)
from letta.llm_api.llm_api_tools import create
from letta.local_llm.constants import INNER_THOUGHTS_KWARG
@@ -29,10 +29,10 @@ from letta.schemas.letta_response import LettaResponse
from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import ChatMemory
from letta.schemas.openai.chat_completion_response import (
ChatCompletionResponse,
Choice,
FunctionCall,
Message,
ChatCompletionResponse,
Choice,
FunctionCall,
Message,
)
from letta.utils import get_human_text, get_persona_text, json_dumps
from tests.helpers.utils import cleanup

View File

@@ -5,16 +5,16 @@ import pytest
from letta import create_client
from letta.schemas.letta_message import ToolCallMessage
from letta.schemas.tool_rule import (
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
)
from 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 cleanup

View File

@@ -3,11 +3,11 @@ from letta import BasicBlockMemory
from letta.client.client import Block, create_client
from letta.constants import DEFAULT_HUMAN, DEFAULT_PERSONA
from 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_system
from letta.schemas.agent import AgentType

View File

@@ -14,12 +14,12 @@ from letta.schemas.llm_config import LLMConfig
from letta.schemas.memory import ChatMemory
from letta.schemas.organization import Organization
from letta.schemas.sandbox_config import (
E2BSandboxConfig,
LocalSandboxConfig,
SandboxConfigCreate,
SandboxConfigUpdate,
SandboxEnvironmentVariableCreate,
SandboxType,
E2BSandboxConfig,
LocalSandboxConfig,
SandboxConfigCreate,
SandboxConfigUpdate,
SandboxEnvironmentVariableCreate,
SandboxType,
)
from letta.schemas.tool import Tool, ToolCreate
from letta.schemas.user import User
@@ -212,7 +212,7 @@ def clear_core_memory_tool(test_user):
@pytest.fixture
def external_codebase_tool(test_user):
from tests.test_tool_sandbox.restaurant_management_system.adjust_menu_prices import (
adjust_menu_prices,
adjust_menu_prices,
)
tool = create_tool_from_func(adjust_menu_prices)

View File

@@ -5,8 +5,8 @@ import sys
import pexpect
import pytest
from letta.local_llm.constants import (
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
ASSISTANT_MESSAGE_CLI_SYMBOL,
INNER_THOUGHTS_CLI_SYMBOL,
)
original_letta_path = os.path.expanduser("~/.letta")

View File

@@ -15,13 +15,13 @@ from letta.schemas.agent import AgentState
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.enums import MessageRole, MessageStreamStatus
from 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, LettaStreamingResponse
from letta.schemas.llm_config import LLMConfig

View File

@@ -8,22 +8,22 @@ from letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLS
from letta.embeddings import embedding_model
from letta.functions.functions import derive_openai_json_schema, parse_source_code
from 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 AgentsTags
from letta.orm.errors import NoResultFound, UniqueConstraintViolationError
@@ -41,13 +41,13 @@ from letta.schemas.message import MessageCreate, MessageUpdate
from letta.schemas.organization import Organization as PydanticOrganization
from letta.schemas.passage import Passage as PydanticPassage
from 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 PydanticSource
from letta.schemas.source import SourceUpdate

View File

@@ -3,15 +3,15 @@ import os
import time
from 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,
)
# directories

View File

@@ -1,14 +1,14 @@
import os
from letta.providers import (
AnthropicProvider,
AzureProvider,
GoogleAIProvider,
GroqProvider,
MistralProvider,
OllamaProvider,
OpenAIProvider,
TogetherProvider,
AnthropicProvider,
AzureProvider,
GoogleAIProvider,
GroqProvider,
MistralProvider,
OllamaProvider,
OpenAIProvider,
TogetherProvider,
)
from letta.settings import model_settings

View File

@@ -9,12 +9,12 @@ from letta.constants import BASE_MEMORY_TOOLS, BASE_TOOLS
from letta.schemas.block import CreateBlock
from letta.schemas.enums import MessageRole
from letta.schemas.letta_message import (
LettaMessage,
ReasoningMessage,
SystemMessage,
ToolCallMessage,
ToolReturnMessage,
UserMessage,
LettaMessage,
ReasoningMessage,
SystemMessage,
ToolCallMessage,
ToolReturnMessage,
UserMessage,
)
from letta.schemas.user import User

View File

@@ -2,10 +2,10 @@ import pytest
from letta.helpers import ToolRulesSolver
from letta.helpers.tool_rule_solver import ToolRuleValidationError
from letta.schemas.tool_rule import (
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
ChildToolRule,
ConditionalToolRule,
InitToolRule,
TerminalToolRule,
)
# Constants for tool names used in the tests

View File

@@ -2,10 +2,10 @@ from unittest.mock import MagicMock, Mock, patch
import pytest
from composio.client.collections import (
ActionModel,
ActionParametersModel,
ActionResponseModel,
AppModel,
ActionModel,
ActionParametersModel,
ActionResponseModel,
AppModel,
)
from fastapi.testclient import TestClient
from letta.schemas.tool import ToolCreate, ToolUpdate