sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
letta-ai/letta:letta/schemas/providers/vllm.py | """
Note: this consolidates the vLLM provider for completions (deprecated by openai)
and chat completions. Support is provided primarily for the chat completions endpoint,
but to utilize the completions endpoint, set the proper `base_url` and
`default_prompt_formatter`.
"""
from typing import Literal
from pydantic im... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/providers/vllm.py",
"license": "Apache License 2.0",
"lines": 47,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/schemas/providers/xai.py | from typing import Literal
from letta.log import get_logger
logger = get_logger(__name__)
from pydantic import Field
from letta.schemas.enums import ProviderCategory, ProviderType
from letta.schemas.llm_config import LLMConfig
from letta.schemas.providers.openai import OpenAIProvider
MODEL_CONTEXT_WINDOWS = {
... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/providers/xai.py",
"license": "Apache License 2.0",
"lines": 57,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/schemas/secret.py | from typing import Any, Dict, Optional
from pydantic import BaseModel, ConfigDict, PrivateAttr
from pydantic_core import core_schema
from letta.helpers.crypto_utils import CryptoUtils
from letta.log import get_logger
from letta.utils import bounded_gather
logger = get_logger(__name__)
class Secret(BaseModel):
... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/secret.py",
"license": "Apache License 2.0",
"lines": 305,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/schemas/source_metadata.py | from typing import List, Optional
from pydantic import Field
from letta.schemas.letta_base import LettaBase
class FileStats(LettaBase):
"""File statistics for metadata endpoint"""
file_id: str = Field(..., description="Unique identifier of the file")
file_name: str = Field(..., description="Name of the... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/source_metadata.py",
"license": "Apache License 2.0",
"lines": 21,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/schemas/step_metrics.py | from typing import Optional
from pydantic import Field
from letta.schemas.enums import PrimitiveType
from letta.schemas.letta_base import LettaBase
class StepMetricsBase(LettaBase):
__id_prefix__ = PrimitiveType.STEP.value
class StepMetrics(StepMetricsBase):
id: str = Field(..., description="The id of the... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/step_metrics.py",
"license": "Apache License 2.0",
"lines": 20,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/server/rest_api/dependencies.py | from typing import TYPE_CHECKING, Optional
from fastapi import Header
from pydantic import BaseModel
from letta.errors import LettaInvalidArgumentError
from letta.otel.tracing import tracer
from letta.schemas.enums import PrimitiveType
from letta.schemas.provider_trace import BillingContext
from letta.validators impo... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/dependencies.py",
"license": "Apache License 2.0",
"lines": 75,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/server/rest_api/json_parser.py | import json
from abc import ABC, abstractmethod
from typing import Any
from pydantic_core import from_json
from letta.log import get_logger
logger = get_logger(__name__)
class JSONParser(ABC):
@abstractmethod
def parse(self, input_str: str) -> Any:
raise NotImplementedError()
class PydanticJSONPa... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/json_parser.py",
"license": "Apache License 2.0",
"lines": 223,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/server/rest_api/middleware/check_password.py | from starlette.middleware.base import BaseHTTPMiddleware
from starlette.responses import JSONResponse
class CheckPasswordMiddleware(BaseHTTPMiddleware):
def __init__(self, app, password: str):
super().__init__(app)
self.password = password
async def dispatch(self, request, call_next):
... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/middleware/check_password.py",
"license": "Apache License 2.0",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/server/rest_api/redis_stream_manager.py | """Redis stream manager for reading and writing SSE chunks with batching and TTL."""
import asyncio
import json
import time
from collections import defaultdict
from collections.abc import AsyncGenerator, AsyncIterator
from contextlib import aclosing
from typing import Dict, List, Optional
from letta.data_sources.redi... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/redis_stream_manager.py",
"license": "Apache License 2.0",
"lines": 387,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/server/rest_api/routers/v1/archives.py | from typing import Dict, List, Literal, Optional
from fastapi import APIRouter, Body, Depends, Query
from pydantic import BaseModel, Field
from letta import AgentState
from letta.schemas.agent import AgentRelationships
from letta.schemas.archive import Archive as PydanticArchive
from letta.schemas.embedding_config im... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/routers/v1/archives.py",
"license": "Apache License 2.0",
"lines": 236,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/server/rest_api/routers/v1/folders.py | import asyncio
import mimetypes
import os
import tempfile
from pathlib import Path as PathLibPath
from typing import List, Literal, Optional
from fastapi import APIRouter, Depends, HTTPException, Query, UploadFile
from starlette import status
from starlette.responses import Response
import letta.constants as constant... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/routers/v1/folders.py",
"license": "Apache License 2.0",
"lines": 545,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/server/rest_api/routers/v1/internal_templates.py | from typing import List, Optional
from fastapi import APIRouter, Body, Depends, Query
from pydantic import BaseModel
from letta.schemas.agent import AgentState, InternalTemplateAgentCreate
from letta.schemas.block import Block, InternalTemplateBlockCreate
from letta.schemas.group import Group, InternalTemplateGroupCr... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/routers/v1/internal_templates.py",
"license": "Apache License 2.0",
"lines": 241,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/server/rest_api/routers/v1/telemetry.py | from typing import Optional
from fastapi import APIRouter, Depends
from letta.schemas.provider_trace import ProviderTrace
from letta.server.rest_api.dependencies import HeaderParams, get_headers, get_letta_server
from letta.server.server import SyncServer
from letta.settings import settings
router = APIRouter(prefix... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/routers/v1/telemetry.py",
"license": "Apache License 2.0",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/server/rest_api/streaming_response.py | # Alternative implementation of StreamingResponse that allows for effectively
# stremaing HTTP trailers, as we cannot set codes after the initial response.
# Taken from: https://github.com/fastapi/fastapi/discussions/10138#discussioncomment-10377361
import asyncio
import json
import re
from collections.abc import Asyn... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/streaming_response.py",
"license": "Apache License 2.0",
"lines": 332,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/agent_serialization_manager.py | import uuid
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional
from letta.constants import MCP_TOOL_TAG_NAME_PREFIX
from letta.errors import (
AgentExportIdMappingError,
AgentExportProcessingError,
AgentFileExportError,
AgentFileImportError,
AgentNotFoundForExportE... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/agent_serialization_manager.py",
"license": "Apache License 2.0",
"lines": 905,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/archive_manager.py | from datetime import datetime
from typing import Dict, List, Optional
from sqlalchemy import delete, or_, select
from letta.helpers.tpuf_client import should_use_tpuf
from letta.log import get_logger
from letta.orm import ArchivalPassage, Archive as ArchiveModel, ArchivesAgents
from letta.otel.tracing import trace_me... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/archive_manager.py",
"license": "Apache License 2.0",
"lines": 621,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/context_window_calculator/context_window_calculator.py | import asyncio
from typing import Any, Dict, List, Optional, Tuple
from openai.types.beta.function_tool import FunctionTool as OpenAITool
from letta.log import get_logger
from letta.schemas.agent import AgentState
from letta.schemas.enums import MessageRole
from letta.schemas.letta_message_content import TextContent
... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/context_window_calculator/context_window_calculator.py",
"license": "Apache License 2.0",
"lines": 323,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/context_window_calculator/token_counter.py | import hashlib
import json
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from letta.helpers.decorators import async_redis_cache
from letta.llm_api.anthropic_client import AnthropicClient
from letta.llm_api.google_vertex_client import GoogleVertexClient
from letta.log i... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/context_window_calculator/token_counter.py",
"license": "Apache License 2.0",
"lines": 257,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_manager.py | import os
from datetime import datetime, timedelta, timezone
from typing import List, Optional
from sqlalchemy import func, select, update
from sqlalchemy.dialects.postgresql import insert as pg_insert
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import selectinload
from letta.constants import MAX_FI... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_manager.py",
"license": "Apache License 2.0",
"lines": 626,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/chunker/line_chunker.py | import re
from typing import List, Optional
from letta.log import get_logger
from letta.schemas.file import FileMetadata
from letta.services.file_processor.file_types import ChunkingStrategy, file_type_registry
logger = get_logger(__name__)
class LineChunker:
"""Content-aware line chunker that adapts chunking s... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/chunker/line_chunker.py",
"license": "Apache License 2.0",
"lines": 154,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/chunker/llama_index_chunker.py | from typing import List, Optional, Union
from mistralai import OCRPageObject
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.services.file_processor.file_types import ChunkingStrategy, file_type_registry
logger = get_logger(__name__)
class LlamaIndexChunker:
"""LlamaInde... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/chunker/llama_index_chunker.py",
"license": "Apache License 2.0",
"lines": 131,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/embedder/base_embedder.py | from abc import ABC, abstractmethod
from typing import List
from letta.log import get_logger
from letta.schemas.enums import VectorDBProvider
from letta.schemas.passage import Passage
from letta.schemas.user import User
logger = get_logger(__name__)
class BaseEmbedder(ABC):
"""Abstract base class for embedding ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/embedder/base_embedder.py",
"license": "Apache License 2.0",
"lines": 15,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/file_processor/embedder/openai_embedder.py | import asyncio
import time
from typing import List, Optional, Tuple, cast
from letta.llm_api.llm_client import LLMClient
from letta.llm_api.openai_client import OpenAIClient
from letta.log import get_logger
from letta.otel.tracing import log_event, trace_method
from letta.schemas.embedding_config import EmbeddingConfi... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/embedder/openai_embedder.py",
"license": "Apache License 2.0",
"lines": 194,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/embedder/pinecone_embedder.py | from typing import List, Optional
from letta.helpers.pinecone_utils import upsert_file_records_to_pinecone_index
from letta.log import get_logger
from letta.otel.tracing import log_event, trace_method
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.enums import VectorDBProvider
from letta... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/embedder/pinecone_embedder.py",
"license": "Apache License 2.0",
"lines": 90,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/embedder/turbopuffer_embedder.py | import time
from typing import List, Optional
from letta.helpers.tpuf_client import TurbopufferClient
from letta.log import get_logger
from letta.otel.tracing import log_event, trace_method
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.enums import VectorDBProvider
from letta.schemas.pa... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/embedder/turbopuffer_embedder.py",
"license": "Apache License 2.0",
"lines": 85,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/file_processor.py | import asyncio
import time
from typing import List
from mistralai import OCRPageObject, OCRResponse, OCRUsageInfo
from letta.log import get_logger
from letta.otel.context import get_ctx_attributes
from letta.otel.tracing import log_event, trace_method
from letta.schemas.agent import AgentState
from letta.schemas.enum... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/file_processor.py",
"license": "Apache License 2.0",
"lines": 350,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/file_types.py | """
Centralized file type configuration for supported file formats.
This module provides a single source of truth for file type definitions,
mime types, and file processing capabilities across the Letta codebase.
"""
import mimetypes
from dataclasses import dataclass
from enum import Enum
from typing import Dict, Set... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/file_types.py",
"license": "Apache License 2.0",
"lines": 242,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/file_processor/parser/base_parser.py | from abc import ABC, abstractmethod
class FileParser(ABC):
"""Abstract base class for file parser"""
@abstractmethod
async def extract_text(self, content: bytes, mime_type: str):
"""Extract text from PDF content"""
| {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/parser/base_parser.py",
"license": "Apache License 2.0",
"lines": 6,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/file_processor/parser/markitdown_parser.py | import logging
import os
import tempfile
from markitdown import MarkItDown
from mistralai import OCRPageObject, OCRResponse, OCRUsageInfo
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.services.file_processor.file_types import is_simple_text_mime_type
from letta.services.file_... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/parser/markitdown_parser.py",
"license": "Apache License 2.0",
"lines": 87,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/file_processor/parser/mistral_parser.py | import base64
from mistralai import Mistral, OCRPageObject, OCRResponse, OCRUsageInfo
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.services.file_processor.file_types import is_simple_text_mime_type
from letta.services.file_processor.parser.base_parser import FileParser
from ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/file_processor/parser/mistral_parser.py",
"license": "Apache License 2.0",
"lines": 46,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/files_agents_manager.py | from datetime import datetime, timezone
from typing import Dict, List, Optional, Union
from sqlalchemy import and_, delete, func, or_, select, update
from letta.log import get_logger
from letta.orm.errors import NoResultFound
from letta.orm.file import FileMetadata as FileMetadataModel
from letta.orm.files_agents imp... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/files_agents_manager.py",
"license": "Apache License 2.0",
"lines": 683,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/helpers/tool_parser_helper.py | import ast
import base64
import pickle
from typing import Any, Union
from letta.constants import REQUEST_HEARTBEAT_DESCRIPTION, REQUEST_HEARTBEAT_PARAM, SEND_MESSAGE_TOOL_NAME
from letta.schemas.agent import AgentState
from letta.schemas.response_format import ResponseFormatType, ResponseFormatUnion
from letta.types i... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/helpers/tool_parser_helper.py",
"license": "Apache License 2.0",
"lines": 92,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/mcp/oauth_utils.py | """OAuth utilities for MCP server authentication."""
import asyncio
import json
import secrets
import time
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Callable, Optional, Tuple
from mcp.client.auth import OAuthClientProvider, TokenStorage
from mcp.shared.auth import OAuthClientInformati... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/mcp/oauth_utils.py",
"license": "Apache License 2.0",
"lines": 259,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/mcp/streamable_http_client.py | from datetime import timedelta
from typing import Optional
from mcp import ClientSession
from mcp.client.auth import OAuthClientProvider
from mcp.client.streamable_http import streamablehttp_client
from letta.functions.mcp_client.types import BaseServerConfig, StreamableHTTPServerConfig
from letta.log import get_logg... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/mcp/streamable_http_client.py",
"license": "Apache License 2.0",
"lines": 70,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/mcp_manager.py | import asyncio
import json
import os
import secrets
import uuid
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Tuple, Union
from fastapi import HTTPException
from sqlalchemy import delete, desc, select
from starlette.requests import Request
import letta.constants as constants
f... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/mcp_manager.py",
"license": "Apache License 2.0",
"lines": 1064,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/telemetry_manager.py | import asyncio
import os
from letta.helpers.singleton import singleton
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.schemas.provider_trace import ProviderTrace
from letta.schemas.user import User as PydanticUser
from letta.services.provider_trace_backends import get_provider_... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/telemetry_manager.py",
"license": "Apache License 2.0",
"lines": 110,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/builtin_tool_executor.py | import asyncio
import json
from typing import Any, Dict, List, Literal, Optional
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.schemas.agent import AgentState
from letta.schemas.sandbox_config import SandboxConfig
from letta.schemas.tool import Tool
from letta.schemas.tool_exe... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/builtin_tool_executor.py",
"license": "Apache License 2.0",
"lines": 338,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/composio_tool_executor.py | from typing import Any, Dict, Optional
from letta.constants import COMPOSIO_ENTITY_ENV_VAR_KEY
from letta.functions.composio_helpers import execute_composio_action_async, generate_composio_action_from_func_name
from letta.helpers.composio_helpers import get_composio_api_key_async
from letta.otel.tracing import trace_m... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/composio_tool_executor.py",
"license": "Apache License 2.0",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/tool_executor/core_tool_executor.py | from datetime import datetime
from typing import Any, Dict, List, Literal, Optional
from zoneinfo import ZoneInfo
from letta.constants import (
CORE_MEMORY_LINE_NUMBER_WARNING,
MEMORY_TOOLS_LINE_NUMBER_PREFIX_REGEX,
READ_ONLY_BLOCK_EDIT_ERROR,
RETRIEVAL_QUERY_DEFAULT_PAGE_SIZE,
)
from letta.log import ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/core_tool_executor.py",
"license": "Apache License 2.0",
"lines": 906,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/files_tool_executor.py | import asyncio
import re
from typing import Any, Dict, List, Optional
from sqlalchemy.exc import NoResultFound
from letta.constants import PINECONE_TEXT_FIELD_NAME
from letta.functions.types import FileOpenRequest
from letta.helpers.pinecone_utils import search_pinecone_index, should_use_pinecone
from letta.helpers.t... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/files_tool_executor.py",
"license": "Apache License 2.0",
"lines": 694,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/mcp_tool_executor.py | from typing import Any, Dict, Optional
from letta.constants import MCP_TOOL_TAG_NAME_PREFIX
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.schemas.agent import AgentState
from letta.schemas.sandbox_config import SandboxConfig
from letta.schemas.tool import Tool
from letta.schem... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/mcp_tool_executor.py",
"license": "Apache License 2.0",
"lines": 76,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/multi_agent_tool_executor.py | from typing import Any, Dict, List, Optional
from letta.log import get_logger
from letta.schemas.agent import AgentState
from letta.schemas.enums import MessageRole
from letta.schemas.letta_message import AssistantMessage
from letta.schemas.letta_message_content import TextContent
from letta.schemas.message import Mes... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/multi_agent_tool_executor.py",
"license": "Apache License 2.0",
"lines": 126,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/sandbox_tool_executor.py | import traceback
from typing import Any, Dict, Optional
from letta.functions.ast_parsers import coerce_dict_args_by_annotations, get_function_annotations_from_source
from letta.log import get_logger
from letta.otel.tracing import trace_method
from letta.schemas.agent import AgentState
from letta.schemas.enums import S... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/sandbox_tool_executor.py",
"license": "Apache License 2.0",
"lines": 161,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_executor/tool_executor_base.py | from abc import ABC, abstractmethod
from typing import Any, Dict, Optional
from letta.schemas.agent import AgentState
from letta.schemas.sandbox_config import SandboxConfig
from letta.schemas.tool import Tool
from letta.schemas.tool_execution_result import ToolExecutionResult
from letta.schemas.user import User
from l... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_executor/tool_executor_base.py",
"license": "Apache License 2.0",
"lines": 41,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/tool_sandbox/modal_constants.py | """Shared constants for Modal sandbox implementations."""
# Deployment and versioning
DEFAULT_CONFIG_KEY = "default"
MODAL_DEPLOYMENTS_KEY = "modal_deployments"
VERSION_HASH_LENGTH = 12
# Cache settings
CACHE_TTL_SECONDS = 60
# Modal execution settings
DEFAULT_MODAL_TIMEOUT = 60
DEFAULT_MAX_CONCURRENT_INPUTS = 1
DEF... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/modal_constants.py",
"license": "Apache License 2.0",
"lines": 13,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/services/tool_sandbox/modal_deployment_manager.py | """
Modal Deployment Manager - Handles deployment orchestration with optional locking.
This module separates deployment logic from the main sandbox execution,
making it easier to understand and optionally disable locking/version tracking.
"""
import hashlib
from typing import Tuple
import modal
from letta.log impor... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/modal_deployment_manager.py",
"license": "Apache License 2.0",
"lines": 201,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_sandbox/modal_sandbox.py | """
Model sandbox implementation, which configures on Modal App per tool.
"""
from typing import TYPE_CHECKING, Any, Dict, Optional
from letta.constants import MODAL_DEFAULT_TOOL_NAME
from letta.log import get_logger
from letta.otel.tracing import log_event, trace_method
from letta.schemas.agent import AgentState
fro... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/modal_sandbox.py",
"license": "Apache License 2.0",
"lines": 166,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_sandbox/modal_sandbox_v2.py | """
This runs tool calls within an isolated modal sandbox. This does this by doing the following:
1. deploying modal functions that embed the original functions
2. dynamically executing tools with arguments passed in at runtime
3. tracking deployment versions to know when a deployment update is needed
"""
import async... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/modal_sandbox_v2.py",
"license": "Apache License 2.0",
"lines": 389,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_sandbox/modal_version_manager.py | """
This module tracks and manages deployed app versions. We currently use the tools.metadata field
to store the information detailing modal deployments and when we need to redeploy due to changes.
Modal Version Manager - Tracks and manages deployed Modal app versions.
"""
import asyncio
import time
from datetime impo... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/modal_version_manager.py",
"license": "Apache License 2.0",
"lines": 221,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/tool_sandbox/safe_pickle.py | """Safe pickle serialization wrapper for Modal sandbox.
This module provides defensive serialization utilities to prevent segmentation
faults and other crashes when passing complex objects to Modal containers.
"""
import pickle
import sys
from typing import Any, Optional, Tuple
from letta.log import get_logger
logg... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/tool_sandbox/safe_pickle.py",
"license": "Apache License 2.0",
"lines": 148,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:sandbox/modal_executor.py | """Modal function executor for tool sandbox v2.
This module contains the executor function that runs inside Modal containers
to execute tool functions with dynamically passed arguments.
"""
import faulthandler
import signal
from typing import Any, Dict
import modal
# List of safe modules that can be imported in sch... | {
"repo_id": "letta-ai/letta",
"file_path": "sandbox/modal_executor.py",
"license": "Apache License 2.0",
"lines": 226,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:sandbox/node_server.py | import modal
class NodeShimServer:
# This runs once startup
@modal.enter()
def start_server(self):
import subprocess
import time
server_root_dir = "/root/sandbox/resources/server"
# /app/server
# Comment this in to show the updated user-function.ts file
# ... | {
"repo_id": "letta-ai/letta",
"file_path": "sandbox/node_server.py",
"license": "Apache License 2.0",
"lines": 61,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:tests/helpers/plugins_helper.py | from letta.data_sources.redis_client import get_redis_client
from letta.services.agent_manager import AgentManager
async def is_experimental_okay(feature_name: str, **kwargs) -> bool:
print(feature_name, kwargs)
if feature_name == "test_pass_with_kwarg":
return isinstance(kwargs["agent_manager"], Agen... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/helpers/plugins_helper.py",
"license": "Apache License 2.0",
"lines": 18,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_builtin_tools.py | import json
import os
import threading
import time
import uuid
from unittest.mock import MagicMock, patch
import pytest
import requests
from dotenv import load_dotenv
from letta_client import Letta
from letta_client.types import AgentState, MessageCreateParam, ToolReturnMessage
from letta_client.types.agents import To... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_builtin_tools.py",
"license": "Apache License 2.0",
"lines": 400,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_human_in_the_loop.py | import logging
import uuid
from typing import Any, List
from unittest.mock import patch
import pytest
from letta_client import APIError, Letta
from letta_client.types import AgentState, MessageCreateParam, Tool
from letta.adapters.simple_llm_stream_adapter import SimpleLLMStreamAdapter
logger = logging.getLogger(__n... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_human_in_the_loop.py",
"license": "Apache License 2.0",
"lines": 1315,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_modal_sandbox_v2.py | """
Integration tests for Modal Sandbox V2.
These tests cover:
- Basic tool execution with Modal
- Error handling and edge cases
- Async tool execution
- Version tracking and redeployment
- Persistence of deployment metadata
- Concurrent execution handling
- Multiple sandbox configurations
- Service restart scenarios
... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_modal_sandbox_v2.py",
"license": "Apache License 2.0",
"lines": 682,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_turbopuffer.py | import asyncio
import uuid
from datetime import datetime, timezone
import pytest
from letta.config import LettaConfig
from letta.helpers.tpuf_client import TurbopufferClient, should_use_tpuf, should_use_tpuf_for_messages
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.enums import Messag... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_turbopuffer.py",
"license": "Apache License 2.0",
"lines": 2138,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/locust_test.py | import random
import string
from locust import HttpUser, between, task
from letta.constants import BASE_TOOLS, DEFAULT_HUMAN, DEFAULT_PERSONA
from letta.schemas.agent import AgentState, CreateAgent
from letta.schemas.letta_request import LettaRequest
from letta.schemas.letta_response import LettaResponse
from letta.s... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/locust_test.py",
"license": "Apache License 2.0",
"lines": 87,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/mcp_test.py | #!/usr/bin/env python3
"""
Simple MCP client example with OAuth authentication support.
This client connects to an MCP server using streamable HTTP transport with OAuth.
"""
import asyncio
import os
import threading
import time
import webbrowser
from datetime import timedelta
from http.server import BaseHTTPRequestH... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/mcp_test.py",
"license": "Apache License 2.0",
"lines": 290,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/mcp_tests/test_mcp.py | import json
import os
import shutil
import subprocess
import threading
import time
import uuid
import venv
from pathlib import Path
import pytest
from dotenv import load_dotenv
from letta_client import Letta
from letta_client.types import MessageCreateParam, Tool, ToolReturnMessage
from letta_client.types.agents impor... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/mcp_tests/test_mcp.py",
"license": "Apache License 2.0",
"lines": 318,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/mcp_tests/test_mcp_schema_validation.py | """
Test MCP tool schema validation integration.
"""
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from letta.functions.mcp_client.types import MCPTool, MCPToolHealth
from letta.functions.schema_generator import generate_tool_schema_for_mcp
from letta.functions.schema_validator import SchemaHea... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/mcp_tests/test_mcp_schema_validation.py",
"license": "Apache License 2.0",
"lines": 727,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/mcp_tests/test_schema_validator.py | """
Unit tests for the JSON Schema validator for OpenAI strict mode compliance.
"""
from letta.functions.schema_validator import SchemaHealth, validate_complete_json_schema
class TestSchemaValidator:
"""Test cases for the schema validator."""
def test_valid_strict_compliant_schema(self):
"""Test a f... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/mcp_tests/test_schema_validator.py",
"license": "Apache License 2.0",
"lines": 270,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/mcp_tests/weather/weather.py | from typing import Any
import httpx
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP server
mcp = FastMCP("weather")
# Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"
async def make_nws_request(url: str) -> dict[str, Any] | None:
"""Make a request to the NWS API wit... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/mcp_tests/weather/weather.py",
"license": "Apache License 2.0",
"lines": 74,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/performance_tests/test_agent_mass_creation.py | import logging
import os
import threading
import time
import uuid
from concurrent.futures import ThreadPoolExecutor, as_completed
import matplotlib.pyplot as plt
import pandas as pd
import pytest
from dotenv import load_dotenv
from letta_client import Letta
from tqdm import tqdm
from letta.schemas.block import Block
... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/performance_tests/test_agent_mass_creation.py",
"license": "Apache License 2.0",
"lines": 237,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/performance_tests/test_agent_mass_update.py | import logging
import os
import random
import threading
import time
import uuid
from concurrent.futures import ThreadPoolExecutor, as_completed
import matplotlib.pyplot as plt
import pandas as pd
import pytest
from dotenv import load_dotenv
from letta_client import Letta
from tqdm import tqdm
from letta.schemas.embed... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/performance_tests/test_agent_mass_update.py",
"license": "Apache License 2.0",
"lines": 172,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/performance_tests/test_insert_archival_memory.py | import asyncio
import logging
import os
import threading
import time
import uuid
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pytest
from dotenv import load_dotenv
from faker import Faker
from letta_client import AsyncLetta
from tqdm import tqdm
from letta.schemas.embedding_confi... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/performance_tests/test_insert_archival_memory.py",
"license": "Apache License 2.0",
"lines": 143,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_agent_serialization_v2.py | from typing import List, Optional
import pytest
from letta.agents.agent_loop import AgentLoop
from letta.config import LettaConfig
from letta.errors import AgentFileExportError, AgentFileImportError
from letta.orm import Base
from letta.schemas.agent import AgentType, CreateAgent
from letta.schemas.agent_file import ... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_agent_serialization_v2.py",
"license": "Apache License 2.0",
"lines": 1506,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_crypto_utils.py | import base64
import json
import pytest
from letta.helpers.crypto_utils import CryptoUtils
class TestCryptoUtils:
"""Test suite for CryptoUtils encryption/decryption functionality."""
# Mock master keys for testing
MOCK_KEY_1 = "test-master-key-1234567890abcdef"
MOCK_KEY_2 = "another-test-key-fedcb... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_crypto_utils.py",
"license": "Apache License 2.0",
"lines": 397,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_embeddings.py | import glob
import json
import os
from unittest.mock import AsyncMock, patch
import pytest
from letta.config import LettaConfig
from letta.llm_api.llm_client import LLMClient
from letta.llm_api.openai_client import OpenAIClient
from letta.schemas.embedding_config import EmbeddingConfig
from letta.server.server import... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_embeddings.py",
"license": "Apache License 2.0",
"lines": 157,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_file_processor.py | from unittest.mock import AsyncMock, Mock, patch
import openai
import pytest
from letta.errors import ErrorCode, LLMBadRequestError
from letta.schemas.embedding_config import EmbeddingConfig
from letta.services.file_processor.embedder.openai_embedder import OpenAIEmbedder
class TestOpenAIEmbedder:
"""Test suite... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_file_processor.py",
"license": "Apache License 2.0",
"lines": 235,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_letta_request_schema.py | """Tests for LettaRequest schema validation"""
import pytest
from pydantic import ValidationError
from letta.constants import DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARG
from letta.schemas.letta_request import CreateBatch, LettaBatchRequest, LettaRequest, LettaStreamingRequest
from letta.schemas.message import M... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_letta_request_schema.py",
"license": "Apache License 2.0",
"lines": 134,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_long_running_agents.py | import os
import threading
import time
import httpx
import pytest
import requests
from dotenv import load_dotenv
from letta_client import Letta, MessageCreate, TextContent
from tests.helpers.utils import upload_test_agentfile_from_disk
RESEARCH_INSTRUCTIONS = "\n Lead Name: Kian Jones\n Lead Title: Software En... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_long_running_agents.py",
"license": "Apache License 2.0",
"lines": 108,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_mcp_encryption.py | """
Integration tests for MCP server and OAuth session encryption.
Tests the end-to-end encryption functionality in the MCP manager.
"""
import json
from datetime import datetime, timezone
from unittest.mock import AsyncMock, patch
from uuid import uuid4
import pytest
from sqlalchemy import select
from letta.config ... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_mcp_encryption.py",
"license": "Apache License 2.0",
"lines": 418,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_modal_sandbox_v2.py | import json
import pickle
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from letta.schemas.pip_requirement import PipRequirement
from letta.schemas.sandbox_config import ModalSandboxConfig, SandboxConfig, SandboxType
from letta.schemas.tool import Tool
from letta.services.tool_sandbox.modal_sand... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_modal_sandbox_v2.py",
"license": "Apache License 2.0",
"lines": 478,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_plugins.py | import pytest
from letta.data_sources.redis_client import NoopAsyncRedisClient, get_redis_client
from letta.helpers.decorators import experimental
from letta.settings import settings
@pytest.mark.asyncio
async def test_default_experimental_decorator():
settings.plugin_register = "experimental_check=tests.helpers... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_plugins.py",
"license": "Apache License 2.0",
"lines": 71,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_provider_trace.py | """
Comprehensive tests for provider trace telemetry.
Tests verify that provider traces are correctly created with all telemetry context
(agent_id, agent_tags, run_id, step_id, call_type) across:
- Agent steps (non-streaming and streaming)
- Tool calls
- Summarization calls
- Different agent architectures (V2, V3)
"""... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_provider_trace.py",
"license": "Apache License 2.0",
"lines": 313,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_redis_client.py | import pytest
from letta.data_sources.redis_client import get_redis_client
@pytest.mark.asyncio
async def test_redis_client():
test_values = {"LETTA_TEST_0": [1, 2, 3], "LETTA_TEST_1": ["apple", "pear", "banana"], "LETTA_TEST_2": ["{}", 3.2, "cat"]}
redis_client = await get_redis_client()
# Clear out ke... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_redis_client.py",
"license": "Apache License 2.0",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_schema_validator.py | """
Test schema validation for OpenAI strict mode compliance.
"""
from letta.functions.schema_validator import SchemaHealth, validate_complete_json_schema
def test_user_example_schema_now_strict():
"""Test that schemas with optional fields are now considered STRICT_COMPLIANT (will be healed)."""
schema = {
... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_schema_validator.py",
"license": "Apache License 2.0",
"lines": 229,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_secret.py | from unittest.mock import patch
import pytest
from letta.helpers.crypto_utils import CryptoUtils
from letta.schemas.secret import Secret
class TestSecret:
"""Test suite for Secret wrapper class."""
MOCK_KEY = "test-secret-key-1234567890"
def test_from_plaintext_with_key(self):
"""Test creating... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_secret.py",
"license": "Apache License 2.0",
"lines": 233,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_sonnet_nonnative_reasoning_buffering.py | """Test to verify streaming behavior of Anthropic models with and without native reasoning.
This test confirms:
1. Sonnet 3.5 (20241022) with non-native reasoning exhibits batch streaming (API limitation)
- UPDATE: With fine-grained-tool-streaming beta header, this may improve
2. Sonnet 4 (20250514) with native rea... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_sonnet_nonnative_reasoning_buffering.py",
"license": "Apache License 2.0",
"lines": 251,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_sources.py | import asyncio
import os
import re
import tempfile
import threading
import time
from datetime import datetime, timedelta
from typing import Any
import pytest
from dotenv import load_dotenv
from letta_client import Letta as LettaSDKClient
from letta_client.types import CreateBlockParam
from letta_client.types.agent_sta... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_sources.py",
"license": "Apache License 2.0",
"lines": 1306,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_timezone_formatting.py | import json
from datetime import datetime
import pytest
import pytz
from letta.helpers.datetime_helpers import get_local_time, get_local_time_timezone
from letta.system import (
get_heartbeat,
get_login_event,
package_function_response,
package_summarize_message,
package_system_message,
packag... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_timezone_formatting.py",
"license": "Apache License 2.0",
"lines": 173,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_tool_schema_parsing_files/expected_base_tool_schemas.py | def get_rethink_user_memory_schema():
return {
"name": "rethink_user_memory",
"description": (
"Rewrite memory block for the main agent, new_memory should contain all current "
"information from the block that is not outdated or inconsistent, integrating any "
"ne... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_tool_schema_parsing_files/expected_base_tool_schemas.py",
"license": "Apache License 2.0",
"lines": 89,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
locustio/locust:examples/qdrant/locustfile.py | """
Minimal example demonstrating Qdrant load testing with Locust.
"""
from locust import between, task
from locust.contrib.qdrant import QdrantUser
import random
from qdrant_client.models import Distance, PointStruct, VectorParams
class SimpleQdrantUser(QdrantUser):
"""Minimal Qdrant user for load testing."""... | {
"repo_id": "locustio/locust",
"file_path": "examples/qdrant/locustfile.py",
"license": "MIT License",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/contrib/qdrant.py | from locust import User, events
import time
from typing import Any
from qdrant_client import QdrantClient
from qdrant_client.models import VectorParams
class QdrantLocustClient:
"""Qdrant Client Wrapper"""
def __init__(self, url, collection_name, api_key=None, timeout=60, **kwargs):
self.url = url
... | {
"repo_id": "locustio/locust",
"file_path": "locust/contrib/qdrant.py",
"license": "MIT License",
"lines": 210,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
locustio/locust:locust/opentelemetry.py | import logging
import os
from urllib.parse import urlparse
from ._version import __version__
logger = logging.getLogger(__name__)
def setup_opentelemetry() -> bool:
try:
from opentelemetry import metrics, trace
from opentelemetry.sdk.resources import Resource
except ImportError:
logg... | {
"repo_id": "locustio/locust",
"file_path": "locust/opentelemetry.py",
"license": "MIT License",
"lines": 132,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
locustio/locust:examples/dns_ex.py | from locust import run_single_user, task
from locust.contrib.dns import DNSUser
import time
import dns.message
import dns.rdatatype
class MyDNSUser(DNSUser):
@task
def t(self):
message = dns.message.make_query("example.com", dns.rdatatype.A)
# self.client wraps all dns.query methods https://... | {
"repo_id": "locustio/locust",
"file_path": "examples/dns_ex.py",
"license": "MIT License",
"lines": 21,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/contrib/dns.py | from locust import User
from locust.exception import LocustError
import time
from collections.abc import Callable
import dns.query
from dns.exception import DNSException
from dns.message import Message
class DNSClient:
def __init__(self, request_event):
self.request_event = request_event
def __geta... | {
"repo_id": "locustio/locust",
"file_path": "locust/contrib/dns.py",
"license": "MIT License",
"lines": 50,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:examples/mqtt/locustfile.py | from locust import task
from locust.contrib.mqtt import MqttUser
from locust.user.wait_time import between
import time
class MyUser(MqttUser):
host = "localhost"
port = 1883
# We could uncomment below to use the WebSockets transport
# transport = "websockets"
# ws_path = "/mqtt/custom/path"
... | {
"repo_id": "locustio/locust",
"file_path": "examples/mqtt/locustfile.py",
"license": "MIT License",
"lines": 25,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:examples/mqtt/locustfile_custom_mqtt_client.py | from locust import task
from locust.contrib.mqtt import MqttClient, MqttUser
from locust.user.wait_time import between
import time
# extend the MqttClient class with your own custom implementation
class MyMqttClient(MqttClient):
# you can override the event name with your custom implementation
def _generate_... | {
"repo_id": "locustio/locust",
"file_path": "examples/mqtt/locustfile_custom_mqtt_client.py",
"license": "MIT License",
"lines": 30,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/contrib/mqtt.py | from __future__ import annotations
from locust import User
from locust.env import Environment
import random
import selectors
import time
import typing
from contextlib import suppress
import paho.mqtt.client as mqtt
from paho.mqtt.enums import MQTTErrorCode
if typing.TYPE_CHECKING:
from paho.mqtt.client import M... | {
"repo_id": "locustio/locust",
"file_path": "locust/contrib/mqtt.py",
"license": "MIT License",
"lines": 482,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
locustio/locust:examples/test_pytest.py | from locust.clients import HttpSession # this import is just for type hints
import time
# pytest/locust will discover any functions prefixed with "test_" as test cases.
# session and fastsession are pytest fixtures provided by Locust's pytest plugin.
def test_stuff(session):
resp = session.get("https://www.locu... | {
"repo_id": "locustio/locust",
"file_path": "examples/test_pytest.py",
"license": "MIT License",
"lines": 29,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
locustio/locust:locust/test/test_pytest_locustfile.py | # pytest style locustfiles, can be run from both pytest and locust!
#
# Example use:
#
# locust -H https://locust.io -f test_pytest.py -u 2 test_regular test_host
# pytest -H https://locust.io test_pytest.py
from locust.clients import HttpSession
from locust.contrib.fasthttp import FastHttpSession
from locust.exceptio... | {
"repo_id": "locustio/locust",
"file_path": "locust/test/test_pytest_locustfile.py",
"license": "MIT License",
"lines": 46,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
locustio/locust:examples/socketio/echo_server.py | # Used by socketio_ex.py as a mock target. Requires installing gevent-websocket
import gevent.monkey
gevent.monkey.patch_all()
import time
import socketio
from flask import Flask
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
# Create a Socket.IO server
sio = socketio.Server(async_mod... | {
"repo_id": "locustio/locust",
"file_path": "examples/socketio/echo_server.py",
"license": "MIT License",
"lines": 50,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:examples/socketio/socketio_ex.py | from locust import HttpUser, task
from locust.contrib.socketio import SocketIOUser
from threading import Event
import gevent
from socketio import Client
class MySIOHttpUser(SocketIOUser, HttpUser):
options = {
# "logger": True,
# "engineio_logger": True,
}
event: Event
def on_start(... | {
"repo_id": "locustio/locust",
"file_path": "examples/socketio/socketio_ex.py",
"license": "MIT License",
"lines": 45,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/contrib/socketio.py | from locust import User
from locust.event import EventHook
from typing import Any
import gevent
import socketio
class SocketIOClient(socketio.Client):
def __init__(self, request_event: EventHook, *args, **kwargs):
super().__init__(*args, **kwargs)
self.request_event = request_event
def conn... | {
"repo_id": "locustio/locust",
"file_path": "locust/contrib/socketio.py",
"license": "MIT License",
"lines": 85,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/test/test_socketio.py | from locust.contrib.socketio import SocketIOUser
import time
from unittest.mock import patch
import socketio
from .testcases import LocustTestCase
class TestSocketIOUser(LocustTestCase):
def test_everything(self):
def connect(self, *args, **kwargs): ...
def emit(self, *args, **kwargs): ...
... | {
"repo_id": "locustio/locust",
"file_path": "locust/test/test_socketio.py",
"license": "MIT License",
"lines": 28,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
locustio/locust:examples/milvus/locustfile.py | """
Minimal example demonstrating Milvus load testing with Locust.
"""
from locust import between, task
from locust.contrib.milvus import MilvusUser
import random
from pymilvus import CollectionSchema, DataType, FieldSchema
from pymilvus.milvus_client import IndexParams
class SimpleMilvusUser(MilvusUser):
"""M... | {
"repo_id": "locustio/locust",
"file_path": "examples/milvus/locustfile.py",
"license": "MIT License",
"lines": 68,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
locustio/locust:locust/contrib/milvus.py | import gevent.monkey
gevent.monkey.patch_all()
import grpc.experimental.gevent as grpc_gevent
grpc_gevent.init_gevent()
from locust import User, events
import time
from abc import ABC, abstractmethod
from typing import Any
from pymilvus import CollectionSchema, MilvusClient
from pymilvus.milvus_client import Index... | {
"repo_id": "locustio/locust",
"file_path": "locust/contrib/milvus.py",
"license": "MIT License",
"lines": 348,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
locustio/locust:locust/test/subprocess_utils.py | import os
import shlex
import signal
import subprocess
import time
from typing import IO
import gevent
import pytest
from .util import IS_WINDOWS
class TestProcess:
"""
Wraps a subprocess for testing purposes.
"""
__test__ = False
def __init__(
self,
command: str,
*,
... | {
"repo_id": "locustio/locust",
"file_path": "locust/test/subprocess_utils.py",
"license": "MIT License",
"lines": 140,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.