sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
langflow-ai/langflow:src/lfx/tests/unit/cli/test_run_real_flows.py | """Integration tests for the run command with real flows."""
import json
from pathlib import Path
import pytest
from lfx.__main__ import app
from typer.testing import CliRunner
runner = CliRunner()
class TestExecuteRealFlows:
"""Test run command with real flow files."""
@pytest.fixture
def test_data_d... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_run_real_flows.py",
"license": "MIT License",
"lines": 359,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_script_loader.py | """Unit tests for LFX CLI script loader."""
import sys
import tempfile
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from lfx.cli.script_loader import (
_load_module_from_script,
_validate_graph_instance,
extract_message_from_result,
extract_structured_result,
e... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_script_loader.py",
"license": "MIT License",
"lines": 468,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_serve.py | """Tests for LFX serve command."""
import json
import os
import tempfile
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from fastapi.testclient import TestClient
from lfx.cli.common import (
flow_id_from_path,
get_api_key,
get_best_access_host,
get_free_po... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_serve.py",
"license": "MIT License",
"lines": 224,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_serve_app.py | """Unit tests for LFX CLI FastAPI serve app."""
import json
import os
from pathlib import Path
from unittest.mock import MagicMock, Mock, patch
import pytest
from fastapi import HTTPException
from fastapi.testclient import TestClient
from lfx.cli.serve_app import (
FlowMeta,
create_multi_serve_app,
verify... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_serve_app.py",
"license": "MIT License",
"lines": 396,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_serve_app_streaming.py | """Unit tests for streaming functionality in multi-serve app."""
import asyncio
import tempfile
from pathlib import Path
from unittest.mock import patch
import pytest
from asgi_lifespan import LifespanManager
from httpx import ASGITransport, AsyncClient
from lfx.cli.serve_app import FlowMeta, StreamRequest, create_mu... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_serve_app_streaming.py",
"license": "MIT License",
"lines": 327,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_serve_components.py | """Unit tests for serve components without CLI runner dependencies."""
import json
import tempfile
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
import typer
from fastapi.testclient import TestClient
from lfx.cli.common import flow_id_from_path, load_graph_from_path, validate_script_pat... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_serve_components.py",
"license": "MIT License",
"lines": 375,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_serve_simple.py | """Simple tests for LFX serve command focusing on CLI functionality."""
import json
import os
import tempfile
from pathlib import Path
from unittest.mock import patch
from typer.testing import CliRunner
def test_cli_imports():
"""Test that we can import the CLI components."""
# These imports should work wit... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_serve_simple.py",
"license": "MIT License",
"lines": 89,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/cli/test_validation.py | """Tests for CLI validation utilities."""
from unittest.mock import MagicMock, patch
from lfx.cli.validation import is_valid_env_var_name, validate_global_variables_for_env
from lfx.graph.graph.base import Graph
from lfx.graph.vertex.base import Vertex
class TestIsValidEnvVarName:
"""Test cases for is_valid_env... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/cli/test_validation.py",
"license": "MIT License",
"lines": 221,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/events/test_event_manager.py | """Unit tests for lfx.events.event_manager module."""
import asyncio
import json
from unittest.mock import MagicMock
import pytest
from lfx.events.event_manager import (
EventManager,
create_default_event_manager,
create_stream_tokens_event_manager,
)
class TestEventManager:
"""Test cases for the Ev... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/events/test_event_manager.py",
"license": "MIT License",
"lines": 284,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/memory/test_memory.py | """Unit tests for lfx.memory module."""
import asyncio
import pytest
from lfx.memory import (
aadd_messages,
aadd_messagetables,
add_messages,
astore_message,
get_messages,
store_message,
)
# Import the appropriate Message class based on what's available
try:
from langflow.schema.message ... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/memory/test_memory.py",
"license": "MIT License",
"lines": 346,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/lfx/tests/unit/schema/test_dotdict.py | from lfx.schema.dotdict import dotdict
def test_create_dotdict():
"""Test creating a dotdict from a regular dict."""
sample_dict = {"name": "test", "value": 123, "nested": {"key": "value"}}
dd = dotdict(sample_dict)
# Test dot notation access
assert dd.name == "test"
assert dd.value == 123
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/lfx/tests/unit/schema/test_dotdict.py",
"license": "MIT License",
"lines": 52,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/api/v1/openai_responses.py | import asyncio
import json
import time
import uuid
from collections.abc import AsyncGenerator
from typing import Annotated, Any
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Request
from fastapi.responses import StreamingResponse
from lfx.log.logger import logger
from lfx.schema.openai_respon... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v1/openai_responses.py",
"license": "MIT License",
"lines": 616,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/integration/test_openai_responses_extended.py | import asyncio
import json
import pathlib
import pytest
from dotenv import load_dotenv
from httpx import AsyncClient
from lfx.log.logger import logger
# Load environment variables from .env file
def load_env_vars():
"""Load environment variables from .env files."""
# Try to find .env file in various location... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/integration/test_openai_responses_extended.py",
"license": "MIT License",
"lines": 460,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/integration/test_openai_responses_integration.py | import asyncio
import json
import pathlib
import pytest
from dotenv import find_dotenv, load_dotenv
from httpx import AsyncClient
from lfx.log.logger import logger
load_dotenv(find_dotenv())
async def create_global_variable(client: AsyncClient, headers, name, value, variable_type="credential"):
"""Create a glob... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/integration/test_openai_responses_integration.py",
"license": "MIT License",
"lines": 175,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/0882f9657f22_encrypt_existing_mcp_auth_settings_.py | """Encrypt existing MCP auth_settings credentials
Revision ID: 0882f9657f22
Revises: 1cb603706752
Create Date: 2025-08-21 20:11:26.504681
"""
import json
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
from sqlalchemy.engine.reflection import Inspector
from langflow.... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/alembic/versions/0882f9657f22_encrypt_existing_mcp_auth_settings_.py",
"license": "MIT License",
"lines": 97,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"te... | function_complex |
langflow-ai/langflow:src/backend/base/langflow/services/auth/mcp_encryption.py | """MCP Authentication encryption utilities for secure credential storage."""
from typing import Any
from cryptography.fernet import InvalidToken
from lfx.log.logger import logger
from langflow.services.auth import utils as auth_utils
# Fields that should be encrypted when stored
SENSITIVE_FIELDS = [
"oauth_clie... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/services/auth/mcp_encryption.py",
"license": "MIT License",
"lines": 88,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/services/auth/test_mcp_encryption.py | """Test MCP authentication encryption functionality."""
from types import SimpleNamespace
from unittest.mock import patch
import pytest
from cryptography.fernet import Fernet
from langflow.services.auth.mcp_encryption import (
decrypt_auth_settings,
encrypt_auth_settings,
is_encrypted,
)
from langflow.ser... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/services/auth/test_mcp_encryption.py",
"license": "MIT License",
"lines": 129,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/services/tracing/traceloop.py | from __future__ import annotations
import json
import math
import os
import types
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse
from lfx.log.logger import logger
from opentelemetry import trace
from opentelemetry.trace import Span, use_span
from opente... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/services/tracing/traceloop.py",
"license": "MIT License",
"lines": 197,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/1cb603706752_modify_uniqueness_constraint_on_file_.py | """Modify uniqueness constraint on file names
Revision ID: 1cb603706752
Revises: 3162e83e485f
Create Date: 2025-07-24 07:02:14.896583
"""
from __future__ import annotations
import logging
import re
import time
from typing import Sequence, Union, Iterable, Optional, Set, Tuple
from alembic import op
import sqlalchem... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/alembic/versions/1cb603706752_modify_uniqueness_constraint_on_file_.py",
"license": "MIT License",
"lines": 223,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
... | function_complex |
langflow-ai/langflow:src/backend/tests/integration/test_exception_telemetry.py | """Integration tests for exception telemetry."""
import asyncio
from unittest.mock import AsyncMock, MagicMock
import pytest
from langflow.services.telemetry.schema import (
ComponentPayload,
ExceptionPayload,
PlaygroundPayload,
RunPayload,
ShutdownPayload,
VersionPayload,
)
from langflow.serv... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/integration/test_exception_telemetry.py",
"license": "MIT License",
"lines": 528,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/test_exception_telemetry.py | """Unit tests for exception telemetry."""
import hashlib
import traceback
from unittest.mock import AsyncMock, MagicMock
import pytest
from langflow.services.telemetry.schema import ExceptionPayload
from langflow.services.telemetry.service import TelemetryService
class TestExceptionTelemetry:
"""Unit test suite... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/test_exception_telemetry.py",
"license": "MIT License",
"lines": 266,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/interface/initialize/test_loading.py | import os
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from lfx.interface.initialize.loading import (
update_params_with_load_from_db_fields,
update_table_params_with_load_from_db_fields,
)
@pytest.mark.asyncio
async def test_update_params_fallback_to_env_when_variable_not_found():
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/interface/initialize/test_loading.py",
"license": "MIT License",
"lines": 403,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/api/v1/knowledge_bases.py | import asyncio
import gc
import json
import shutil
import uuid
from datetime import datetime, timezone
from http import HTTPStatus
from pathlib import Path
from typing import Annotated, Any
import chromadb.errors
from fastapi import APIRouter, Depends, File, Form, HTTPException, Query, UploadFile
from langchain_chroma... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v1/knowledge_bases.py",
"license": "MIT License",
"lines": 628,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/base/data/test_kb_utils.py | import pytest
from langflow.base.knowledge_bases.knowledge_base_utils import compute_bm25, compute_tfidf
class TestKBUtils:
"""Test suite for knowledge base utility functions."""
# Test data for TF-IDF and BM25 tests
@pytest.fixture
def sample_documents(self):
"""Sample documents for testing.... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/base/data/test_kb_utils.py",
"license": "MIT License",
"lines": 349,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/integration/components/mcp/test_mcp_memory_leak.py | """Integration tests for MCP memory leak fix.
These tests verify that the MCP session manager properly handles session reuse
and cleanup to prevent subprocess leaks.
"""
import asyncio
import contextlib
import os
import platform
import shutil
import time
import psutil
import pytest
from lfx.base.mcp.util import MCPS... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/integration/components/mcp/test_mcp_memory_leak.py",
"license": "MIT License",
"lines": 329,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/base/mcp/test_mcp_util.py | """Unit tests for MCP utility functions.
This test suite validates the MCP utility functions including:
- Session management
- Header validation and processing
- Utility functions for name sanitization and schema conversion
"""
import re
import shutil
import sys
from unittest.mock import AsyncMock, MagicMock, patch
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/base/mcp/test_mcp_util.py",
"license": "MIT License",
"lines": 1540,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/integration/test_dynamic_import_integration.py | """Integration tests for dynamic import refactor.
Tests the dynamic import system in realistic usage scenarios to ensure
the refactor doesn't break existing functionality.
"""
import sys
import time
import pytest
from langflow.components.data import APIRequestComponent
from langflow.components.models_and_agents impo... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/integration/test_dynamic_import_integration.py",
"license": "MIT License",
"lines": 231,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/components/test_all_modules_importable.py | """Test to ensure all component modules are importable after dynamic import refactor.
This test validates that every component module can be imported successfully
and that all components listed in __all__ can be accessed.
This test suite includes:
1. Dynamic import system tests (lazy loading, caching, error handling)... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/test_all_modules_importable.py",
"license": "MIT License",
"lines": 474,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:scripts/generate_coverage_config.py | #!/usr/bin/env python3
"""Script to generate a custom .coveragerc file for backend testing.
This script:
1. Reads SIDEBAR_BUNDLES from frontend styleUtils.ts to get bundled component names
2. Scans backend components for files containing 'legacy = True'
3. Generates a .coveragerc file that omits these paths from cover... | {
"repo_id": "langflow-ai/langflow",
"file_path": "scripts/generate_coverage_config.py",
"license": "MIT License",
"lines": 125,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/custom/component/test_component_loading_fix.py | """Tests for the component loading fix that filters out BASE_COMPONENTS_PATH from custom components.
- BASE_COMPONENTS_PATH is properly filtered out from custom components paths
- Lazy loading mode works correctly
- Custom components are loaded only from valid custom paths
- No regression in existing functionality
"""... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/custom/component/test_component_loading_fix.py",
"license": "MIT License",
"lines": 362,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/utils/template_validation.py | """Template validation utilities for Langflow starter projects.
This module provides validation functions to ensure template integrity and prevent
unexpected breakage in starter project templates.
"""
import asyncio
import json
import uuid
from typing import Any
from lfx.custom.validate import validate_code
from lfx... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/utils/template_validation.py",
"license": "MIT License",
"lines": 217,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/template/test_starter_projects.py | """Comprehensive tests for starter project templates.
Tests all JSON templates in the starter_projects folder to ensure they:
1. Are valid JSON
2. Have required structure (nodes, edges)
3. Don't have basic security issues
4. Can be built into working flows
Validates that templates work correctly and prevent unexpecte... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/template/test_starter_projects.py",
"license": "MIT License",
"lines": 187,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/utils/test_template_validation.py | """Unit tests for template validation utilities."""
import asyncio
from unittest.mock import AsyncMock, Mock, patch
import pytest
from langflow.utils.template_validation import (
_validate_event_stream,
validate_flow_can_build,
validate_flow_code,
validate_flow_execution,
validate_template_structu... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/utils/test_template_validation.py",
"license": "MIT License",
"lines": 602,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/utils/test_validate.py | """Unit tests for validate.py utilities."""
import ast
import warnings
from unittest.mock import Mock, patch
import pytest
from lfx.custom.validate import (
_create_langflow_execution_context,
add_type_ignores,
build_class_constructor,
compile_class_code,
create_class,
create_function,
cre... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/utils/test_validate.py",
"license": "MIT License",
"lines": 540,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/3162e83e485f_add_auth_settings_to_folder_and_merge.py | """Add auth_settings column to folder table and merge migration branches.
Revision ID: 3162e83e485f
Revises: 0ae3a2674f32, d9a6ea21edcd
Create Date: 2025-01-16 13:00:00.000000
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: ... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/alembic/versions/3162e83e485f_add_auth_settings_to_folder_and_merge.py",
"license": "MIT License",
"lines": 43,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"... | function_simple |
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_rename_flow_to_save.py | import pytest
from fastapi import status
from httpx import AsyncClient
@pytest.mark.asyncio
async def test_duplicate_flow_name_basic(client: AsyncClient, logged_in_headers):
"""Test that duplicate flow names get numbered correctly."""
base_flow = {
"name": "Test Flow",
"description": "Test flo... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/api/v1/test_rename_flow_to_save.py",
"license": "MIT License",
"lines": 132,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/test_code_hash.py | """Test code hash and module metadata functionality."""
import pytest
from langflow.interface.components import import_langflow_components
@pytest.mark.asyncio
async def test_component_metadata_has_code_hash():
"""Test that built-in components have valid module and code_hash metadata."""
result = await impor... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/test_code_hash.py",
"license": "MIT License",
"lines": 50,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/api/v1/mcp_utils.py | """Common MCP handler functions shared between mcp.py and mcp_projects.py.
This module serves as the single source of truth for MCP functionality.
"""
import asyncio
import base64
from collections.abc import Awaitable, Callable
from contextvars import ContextVar
from functools import wraps
from pathlib import Path
fr... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v1/mcp_utils.py",
"license": "MIT License",
"lines": 336,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/base/langflow/services/database/session.py | class NoopSession:
class NoopBind:
class NoopConnect:
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc, tb):
pass
async def run_sync(self, fn, *args, **kwargs): # noqa: ARG002
return None
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/services/database/session.py",
"license": "MIT License",
"lines": 45,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
langflow-ai/langflow:src/backend/tests/unit/test_async_helpers.py | """Tests for async_helpers.py functions."""
import asyncio
import threading
import time
from unittest.mock import patch
import pytest
from lfx.utils.async_helpers import run_until_complete
class TestRunUntilComplete:
"""Test the run_until_complete function."""
def test_run_until_complete_no_running_loop(se... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/test_async_helpers.py",
"license": "MIT License",
"lines": 140,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/components/bundles/langwatch/test_langwatch_component.py | import json
import os
from unittest.mock import Mock, patch
import httpx
import pytest
import respx
from httpx import Response
from lfx.base.langwatch.utils import get_cached_evaluators
from lfx.components.langwatch.langwatch import LangWatchComponent
from lfx.schema.data import Data
from lfx.schema.dotdict import dot... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/bundles/langwatch/test_langwatch_component.py",
"license": "MIT License",
"lines": 328,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/langflow_launcher.py | import os
import platform
import sys
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
pass
from langflow.helpers.windows_postgres_helper import configure_windows_postgres_event_loop
configure_windows_postgres_event_loop(source="launcher")
import typer # noqa: E402
def main():
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/langflow_launcher.py",
"license": "MIT License",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
langflow-ai/langflow:src/backend/tests/unit/api/v2/test_mcp_servers_file.py | import io
import uuid
from types import SimpleNamespace
from typing import TYPE_CHECKING
import pytest
from fastapi import UploadFile
# Module under test
from langflow.api.v2.files import upload_user_file
from langflow.api.v2.mcp import get_mcp_file
if TYPE_CHECKING:
from langflow.services.database.models.file.m... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/api/v2/test_mcp_servers_file.py",
"license": "MIT License",
"lines": 186,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/d9a6ea21edcd_rename_default_folder.py | """Rename default folder
Revision ID: d9a6ea21edcd
Revises: 66f72f04a1de
Create Date: 2025-07-02 09:42:46.891585
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "d9a6ea21edcd"
down_revision: str | None = "66f72f04a1de"... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/alembic/versions/d9a6ea21edcd_rename_default_folder.py",
"license": "MIT License",
"lines": 55,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
langflow-ai/langflow:src/backend/tests/unit/components/languagemodels/test_openai_model.py | from unittest.mock import MagicMock, patch
import pytest
from langchain_openai import ChatOpenAI
from lfx.components.openai.openai_chat_model import OpenAIModelComponent
from tests.api_keys import get_openai_api_key, has_api_key
from tests.base import ComponentTestBaseWithoutClient
class TestOpenAIModelComponent(Co... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/languagemodels/test_openai_model.py",
"license": "MIT License",
"lines": 174,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/cli/progress.py | import platform
import sys
import threading
import time
from collections.abc import Generator
from contextlib import contextmanager
from typing import Any
import click
MIN_DURATION_THRESHOLD = 0.1 # Minimum duration to show in seconds (100ms)
class ProgressIndicator:
"""A CLI progress indicator that shows user... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/cli/progress.py",
"license": "MIT License",
"lines": 184,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/test_session_endpoint.py | from uuid import uuid4
import pytest
from httpx import AsyncClient
from langflow.memory import aadd_messagetables
from langflow.services.database.models.message.model import MessageTable
from langflow.services.deps import session_scope
@pytest.fixture
async def messages_with_flow_ids(session): # noqa: ARG001
""... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/test_session_endpoint.py",
"license": "MIT License",
"lines": 110,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/utils/test_interface_utils.py | import pytest
from langflow.interface.utils import extract_input_variables_from_prompt
@pytest.mark.parametrize(
("prompt", "expected"),
[
# Basic variable extraction
("Hello {name}!", ["name"]),
("Hi {name}, you are {age} years old", ["name", "age"]),
# Empty prompt
("... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/utils/test_interface_utils.py",
"license": "MIT License",
"lines": 56,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/test_load_components.py | # ruff: noqa: T201
import asyncio
import time
import warnings
import pytest
from lfx.constants import BASE_COMPONENTS_PATH
from lfx.interface.components import aget_all_types_dict, import_langflow_components
class TestComponentLoading:
"""Test suite for comparing component loading methods performance and functio... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/test_load_components.py",
"license": "MIT License",
"lines": 528,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/api/v2/mcp.py | import asyncio
import json
from collections import defaultdict
from io import BytesIO
from typing import Annotated
from fastapi import APIRouter, Body, Depends, HTTPException, UploadFile
from lfx.base.agents.utils import safe_cache_get, safe_cache_set
from lfx.base.mcp.util import update_tools
from langflow.api.utils... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v2/mcp.py",
"license": "MIT License",
"lines": 334,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/base/langflow/components/processing/converter.py | # Forward import for converter utilities
# We intentionally keep this file, as the redirect to lfx in components/__init__.py
# only supports direct imports from lfx.components, not sub-modules.
#
# This allows imports from langflow.components.processing.converter. to still function.
from lfx.components.processing.conve... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/components/processing/converter.py",
"license": "MIT License",
"lines": 7,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
langflow-ai/langflow:src/backend/tests/unit/components/processing/test_type_converter_component.py | import json
from io import StringIO
import pandas as pd
import pytest
from lfx.components.processing.converter import TypeConverterComponent
from lfx.schema.data import Data
from lfx.schema.dataframe import DataFrame
from lfx.schema.message import Message
from tests.base import ComponentTestBaseWithoutClient
class ... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/processing/test_type_converter_component.py",
"license": "MIT License",
"lines": 188,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/components/processing/test_data_operations_component.py | import pytest
from lfx.components.processing.data_operations import DataOperationsComponent
from lfx.schema import Data
from tests.base import ComponentTestBaseWithoutClient
class TestDataOperationsComponent(ComponentTestBaseWithoutClient):
@pytest.fixture
def component_class(self):
"""Return the com... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/processing/test_data_operations_component.py",
"license": "MIT License",
"lines": 189,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/components/bundles/google/test_google_bq_sql_executor_component.py | """Tests for BigQueryExecutorComponent."""
from __future__ import annotations
import json
import re
from unittest.mock import MagicMock, mock_open, patch
import pytest
from google.auth.exceptions import RefreshError
from google.oauth2.service_account import Credentials
from lfx.components.google.google_bq_sql_execut... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/components/bundles/google/test_google_bq_sql_executor_component.py",
"license": "MIT License",
"lines": 471,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"templa... | test |
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/66f72f04a1de_add_mcp_support_with_project_settings_.py | """Add MCP support with project settings in flows
Revision ID: 66f72f04a1de
Revises: e56d87f8994a
Create Date: 2025-04-24 18:42:15.828332
"""
from collections.abc import Sequence
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "66f72f04a1de"
d... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/alembic/versions/66f72f04a1de_add_mcp_support_with_project_settings_.py",
"license": "MIT License",
"lines": 40,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
... | function_simple |
langflow-ai/langflow:src/backend/base/langflow/api/v1/mcp_projects.py | import asyncio
import json
import os
import platform
from asyncio.subprocess import create_subprocess_exec
from collections.abc import Awaitable, Callable, Sequence
from contextvars import ContextVar
from datetime import datetime, timezone
from ipaddress import ip_address
from pathlib import Path
from subprocess import... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v1/mcp_projects.py",
"license": "MIT License",
"lines": 1285,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/base/langflow/api/v1/projects.py | import io
import json
import zipfile
from datetime import datetime, timezone
from typing import Annotated, cast
from urllib.parse import quote
from uuid import UUID
import orjson
from fastapi import APIRouter, BackgroundTasks, Depends, File, HTTPException, Query, Response, UploadFile, status
from fastapi.encoders impo... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/api/v1/projects.py",
"license": "MIT License",
"lines": 593,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_mcp.py | import asyncio
from unittest.mock import AsyncMock, MagicMock, patch
from uuid import uuid4
import pytest
from fastapi import HTTPException, status
from httpx import AsyncClient
from langflow.services.auth.utils import get_password_hash
from langflow.services.database.models.user import User
# Mark all tests in this ... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/api/v1/test_mcp.py",
"license": "MIT License",
"lines": 326,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_mcp_projects.py | import asyncio
import json
from contextlib import asynccontextmanager
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch
from uuid import uuid4
import pytest
from fastapi import HTTPException, status
from httpx import AsyncClient
from langflow.api.v1.mcp_projects import (
Proje... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/api/v1/test_mcp_projects.py",
"license": "MIT License",
"lines": 802,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_projects.py | import io
import json
import zipfile
from unittest.mock import MagicMock, patch
from uuid import uuid4
import pytest
from fastapi import status
from httpx import AsyncClient
from langflow.initial_setup.constants import STARTER_FOLDER_NAME
from langflow.services.database.models.flow.model import Flow, FlowCreate
from l... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/api/v1/test_projects.py",
"license": "MIT License",
"lines": 1453,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
langflow-ai/langflow:src/backend/base/langflow/services/flow/flow_runner.py | import json
import os
from pathlib import Path
from uuid import UUID, uuid4
from aiofile import async_open
from lfx.graph import Graph
from lfx.graph.vertex.param_handler import ParameterHandler
from lfx.log.logger import configure, logger
from lfx.utils.util import update_settings
from sqlmodel import delete, select,... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/base/langflow/services/flow/flow_runner.py",
"license": "MIT License",
"lines": 240,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
langflow-ai/langflow:src/backend/tests/unit/services/flow/test_flow_runner.py | from uuid import uuid4
import pytest
from langflow.services.flow.flow_runner import LangflowRunnerExperimental
@pytest.fixture
def sample_flow_dict():
return {
"id": str(uuid4()), # Add required ID field
"name": "test_flow", # Add name field
"data": {
"nodes": [],
... | {
"repo_id": "langflow-ai/langflow",
"file_path": "src/backend/tests/unit/services/flow/test_flow_runner.py",
"license": "MIT License",
"lines": 67,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:letta/services/memory_repo/path_mapping.py | """Helpers for mapping memory-repo markdown paths to block labels.
Special handling for skills:
- sync `skills/{skill_name}/SKILL.md` as block label `skills/{skill_name}`
- ignore all other markdown files under `skills/`
"""
from __future__ import annotations
def memory_block_label_from_markdown_path(path: str) -> ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/path_mapping.py",
"license": "Apache License 2.0",
"lines": 22,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
letta-ai/letta:alembic/versions/3e54e2fa2f7e_add_usage_columns_to_steps.py | """add_usage_columns_to_steps
Revision ID: 3e54e2fa2f7e
Revises: a1b2c3d4e5f8
Create Date: 2026-02-03 16:35:51.327031
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "3e54e2fa2f7e"
down_revision: Union[str, None] = "a1b... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/3e54e2fa2f7e_add_usage_columns_to_steps.py",
"license": "Apache License 2.0",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:alembic/versions/b2c3d4e5f6a8_add_llm_config_to_conversations.py | """Add model and model_settings columns to conversations table for model overrides
Revision ID: b2c3d4e5f6a8
Revises: 3e54e2fa2f7e
Create Date: 2026-02-23 02:50:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = ... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/b2c3d4e5f6a8_add_llm_config_to_conversations.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/adapters/sglang_native_adapter.py | """
SGLang Native Adapter for multi-turn RL training.
This adapter uses SGLang's native /generate endpoint instead of the OpenAI-compatible
endpoint to get token IDs and per-token logprobs, which are essential for proper
multi-turn RL training with loss masking.
Uses HuggingFace tokenizer's apply_chat_template() for ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/adapters/sglang_native_adapter.py",
"license": "Apache License 2.0",
"lines": 437,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/config_file.py | """
Letta Configuration File Support
Loads hierarchical YAML config and maps it to environment variables.
Supported top-level keys and their env var prefixes:
letta: -> LETTA_*
model: -> * (provider-prefixed: OPENAI_*, ANTHROPIC_*, etc.)
tool: -> * (prefix-based: E2B_*, MCP_*, TOOL_*, etc.... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/config_file.py",
"license": "Apache License 2.0",
"lines": 188,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
letta-ai/letta:letta/llm_api/sglang_native_client.py | """
SGLang Native Client for Letta.
This client uses SGLang's native /generate endpoint instead of the OpenAI-compatible
/v1/chat/completions endpoint. The native endpoint returns token IDs and per-token
logprobs, which are essential for multi-turn RL training.
The OpenAI-compatible endpoint only returns token string... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/llm_api/sglang_native_client.py",
"license": "Apache License 2.0",
"lines": 89,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
letta-ai/letta:letta/schemas/llm_trace.py | """Schema for LLM request/response traces stored in ClickHouse for analytics."""
from __future__ import annotations
from datetime import datetime
from typing import Optional
from pydantic import Field
from letta.helpers.datetime_helpers import get_utc_time
from letta.schemas.letta_base import LettaBase
class LLMT... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/llm_trace.py",
"license": "Apache License 2.0",
"lines": 150,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/schemas/memory_repo.py | """Pydantic schemas for git-based memory repositories.
These are used internally by the git-backed block/memory repository services.
Note: REST "sync" request/response schemas were removed when we switched to
clients interacting with repositories directly via git smart HTTP.
"""
from __future__ import annotations
f... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/memory_repo.py",
"license": "Apache License 2.0",
"lines": 28,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/server/rest_api/routers/v1/git_http.py | """Git HTTP Smart Protocol endpoints (proxied to memfs service).
This module proxies `/v1/git/*` requests to the external memfs service, which
handles git smart HTTP protocol (clone, push, pull).
Example:
git clone http://localhost:8283/v1/git/{agent_id}/state.git
Routes (smart HTTP):
GET /v1/git/{agent_id... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/server/rest_api/routers/v1/git_http.py",
"license": "Apache License 2.0",
"lines": 274,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/agent_generate_completion_manager.py | """Manager for handling direct LLM completions using agent configuration."""
from typing import TYPE_CHECKING, Any, Dict, Optional
from letta.errors import LLMError
from letta.llm_api.llm_client import LLMClient
from letta.log import get_logger
from letta.schemas.enums import AgentType, MessageRole
from letta.schemas... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/agent_generate_completion_manager.py",
"license": "Apache License 2.0",
"lines": 185,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/block_manager_git.py | """Git-enabled block manager that uses object storage as source of truth.
When an agent has the GIT_MEMORY_ENABLED_TAG tag, block operations:
1. Write to git (GCS) first - source of truth
2. Update PostgreSQL as cache
This provides full version history while maintaining fast reads from PostgreSQL.
"""
import time
fr... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/block_manager_git.py",
"license": "Apache License 2.0",
"lines": 514,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/credit_verification_service.py | import logging
import os
import httpx
from letta.errors import InsufficientCreditsError
logger = logging.getLogger(__name__)
class CreditVerificationService:
"""Service for verifying organization credit balance before agent execution."""
def __init__(self):
self.endpoint = os.getenv("STEP_ORCHESTR... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/credit_verification_service.py",
"license": "Apache License 2.0",
"lines": 57,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/llm_trace_reader.py | """ClickHouse reader for LLM analytics traces.
Reads LLM traces from ClickHouse for debugging, analytics, and auditing.
"""
from __future__ import annotations
import asyncio
from dataclasses import dataclass
from datetime import datetime
from typing import Any, List, Optional
from urllib.parse import urlparse
from ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/llm_trace_reader.py",
"license": "Apache License 2.0",
"lines": 393,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/llm_trace_writer.py | """ClickHouse writer for LLM analytics traces.
Writes LLM traces to ClickHouse with denormalized columns for cost analytics.
Uses ClickHouse's async_insert feature for server-side batching.
"""
from __future__ import annotations
import asyncio
import atexit
from typing import TYPE_CHECKING, Optional
from urllib.pars... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/llm_trace_writer.py",
"license": "Apache License 2.0",
"lines": 160,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/memory_repo/block_markdown.py | """Serialize and parse block data as Markdown with YAML frontmatter.
File format:
---
description: "Who I am and how I approach work"
---
My name is Memo. I'm a stateful coding assistant...
- Frontmatter fields are only rendered when they differ from defaults.
- ``limit`` is intentionally excluded fro... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/block_markdown.py",
"license": "Apache License 2.0",
"lines": 152,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/memory_repo/git_operations.py | """Git operations for memory repositories using git CLI.
This module provides high-level operations for working with git repos
stored in object storage (GCS/S3), using the git command-line tool
instead of dulwich for better compatibility and maintenance.
"""
import asyncio
import os
import shutil
import subprocess
im... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/git_operations.py",
"license": "Apache License 2.0",
"lines": 529,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/memory_repo/memfs_client_base.py | """Local filesystem-based client for git memory operations.
This is the open-source implementation that stores git repositories
on the local filesystem (~/.letta/memfs/ by default). This enables
git-backed memory for self-hosted deployments without external dependencies.
The cloud/enterprise version (memfs_client.py)... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/memfs_client_base.py",
"license": "Apache License 2.0",
"lines": 328,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/memory_repo/storage/base.py | """Abstract base class for storage backends."""
from abc import ABC, abstractmethod
from typing import List
class StorageBackend(ABC):
"""Abstract storage backend for memory repositories.
Provides a unified interface for storing git repository objects
in various object storage systems (GCS, S3, local fi... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/storage/base.py",
"license": "Apache License 2.0",
"lines": 96,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
letta-ai/letta:letta/services/memory_repo/storage/local.py | """Local filesystem storage backend for memory repositories.
This backend stores git repository data on the local filesystem,
making git-backed memory available without external dependencies.
Ideal for self-hosted OSS deployments.
"""
import os
import shutil
from pathlib import Path
from typing import List, Optional
... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/memory_repo/storage/local.py",
"license": "Apache License 2.0",
"lines": 113,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/services/summarizer/compact.py | """Standalone compaction functions for message summarization."""
from dataclasses import dataclass
from typing import List, Optional
from letta.helpers.message_helper import convert_message_creates_to_messages
from letta.llm_api.llm_client import LLMClient
from letta.log import get_logger
from letta.otel.tracing impo... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/services/summarizer/compact.py",
"license": "Apache License 2.0",
"lines": 393,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/test_gemini.py | from letta_client import Letta
def create_agent() -> None:
client = Letta(base_url="http://localhost:8283")
agent_state = client.agents.create(
name="test-gemini-3-pro-agent",
model="google_ai/gemini-3.1-pro-preview",
embedding="openai/text-embedding-3-small",
context_window_l... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/test_gemini.py",
"license": "Apache License 2.0",
"lines": 14,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_clickhouse_llm_traces.py | """
Integration tests for ClickHouse-backed LLM raw traces.
Validates that:
1) Agent message requests are stored in ClickHouse (request_json contains the message)
2) Summarization traces are stored and retrievable by step_id
3) Error traces are stored with is_error, error_type, and error_message
4) llm_config_json is ... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_clickhouse_llm_traces.py",
"license": "Apache License 2.0",
"lines": 287,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/integration_test_system_prompt_prefix_caching.py | """
Integration tests for system prompt prefix caching optimization.
These tests verify that the system prompt is NOT rebuilt on every step,
only after compaction or message reset. This helps preserve prefix caching
for LLM providers.
"""
import pytest
from letta_client import Letta
@pytest.fixture(scope="module")
... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_system_prompt_prefix_caching.py",
"license": "Apache License 2.0",
"lines": 153,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_context_window_calculator.py | from unittest.mock import AsyncMock, MagicMock
import pytest
from letta.services.context_window_calculator.context_window_calculator import ContextWindowCalculator
class TestExtractTagContent:
"""Tests for the _extract_tag_content helper method"""
def test_extracts_simple_tag(self):
text = "prefix ... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_context_window_calculator.py",
"license": "Apache License 2.0",
"lines": 551,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_google_schema_refs.py | """Unit tests for GoogleVertexClient._resolve_json_schema_refs and $ref safety net."""
import pytest
from letta.llm_api.google_vertex_client import GoogleVertexClient
@pytest.fixture
def client():
return GoogleVertexClient()
class TestResolveJsonSchemaRefs:
def test_single_def_with_ref(self, client):
... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_google_schema_refs.py",
"license": "Apache License 2.0",
"lines": 161,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_openai_prompt_cache_request_fields.py | from letta.llm_api.openai_client import OpenAIClient
from letta.schemas.enums import AgentType, MessageRole
from letta.schemas.letta_message_content import TextContent
from letta.schemas.llm_config import LLMConfig
from letta.schemas.message import Message
def _message(text: str = "hello") -> Message:
return Mess... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_openai_prompt_cache_request_fields.py",
"license": "Apache License 2.0",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:alembic/versions/297e8217e952_nullable_embedding_for_archives_and_.py | """nullable embedding for archives and passages
Revision ID: 297e8217e952
Revises: 308a180244fc
Create Date: 2026-01-20 14:11:21.137232
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from alembic import op
# revision identifiers, used by Alembic.
revision... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/297e8217e952_nullable_embedding_for_archives_and_.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:alembic/versions/308a180244fc_last_synced_column_for_providers.py | """last_synced column for providers
Revision ID: 308a180244fc
Revises: 82feb220a9b8
Create Date: 2026-01-05 18:54:15.996786
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "308a180244fc"
down_revision: Union[str, None] ... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/308a180244fc_last_synced_column_for_providers.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:alembic/versions/9275f62ad282_add_v2_protocol_fields_to_provider_traces.py | """Add v2 protocol fields to provider_traces
Revision ID: 9275f62ad282
Revises: 297e8217e952
Create Date: 2026-01-22
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "9275f62ad282"
down_revision: Union[str, None] = "297e8217e952"
branch_labels: Union[str, Seque... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/9275f62ad282_add_v2_protocol_fields_to_provider_traces.py",
"license": "Apache License 2.0",
"lines": 22,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:alembic/versions/a1b2c3d4e5f8_create_provider_trace_metadata_table.py | """create provider_trace_metadata table
Revision ID: a1b2c3d4e5f8
Revises: 9275f62ad282
Create Date: 2026-01-28
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from letta.settings import settings
revision: str = "a1b2c3d4e5f8"
down_revision: Union[str, None] = "9275f62ad282"
... | {
"repo_id": "letta-ai/letta",
"file_path": "alembic/versions/a1b2c3d4e5f8_create_provider_trace_metadata_table.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/llm_api/minimax_client.py | from typing import List, Optional, Union
import anthropic
from anthropic import AsyncStream
from anthropic.types.beta import BetaMessage, BetaRawMessageStreamEvent
from letta.helpers.json_helpers import sanitize_unicode_surrogates
from letta.llm_api.anthropic_client import AnthropicClient
from letta.log import get_lo... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/llm_api/minimax_client.py",
"license": "Apache License 2.0",
"lines": 144,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/model_specs/litellm_model_specs.py | """
Utility functions for working with litellm model specifications.
This module provides access to model specifications from the litellm model_prices_and_context_window.json file.
The data is synced from: https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json
"""
import json
import os
from... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/model_specs/litellm_model_specs.py",
"license": "Apache License 2.0",
"lines": 85,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
letta-ai/letta:letta/orm/provider_trace_metadata.py | import uuid
from datetime import datetime
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from letta.orm.organization import Organization
from sqlalchemy import JSON, DateTime, Index, String, UniqueConstraint, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from letta.orm.mixins ... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/orm/provider_trace_metadata.py",
"license": "Apache License 2.0",
"lines": 38,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
letta-ai/letta:letta/schemas/providers/minimax.py | from typing import Literal
import anthropic
from pydantic import Field
from letta.errors import ErrorCode, LLMAuthenticationError, LLMError
from letta.log import get_logger
from letta.schemas.enums import ProviderCategory, ProviderType
from letta.schemas.llm_config import LLMConfig
from letta.schemas.providers.base i... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/providers/minimax.py",
"license": "Apache License 2.0",
"lines": 98,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
letta-ai/letta:letta/schemas/providers/sglang.py | """
SGLang provider for Letta.
SGLang is a high-performance inference engine that exposes OpenAI-compatible API endpoints.
"""
from typing import Literal
from pydantic import Field
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.enums import ProviderCategory, ProviderType
from letta.sc... | {
"repo_id": "letta-ai/letta",
"file_path": "letta/schemas/providers/sglang.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:tests/integration_test_multi_modal_tool_returns.py | """
Integration tests for multi-modal tool returns (images in tool responses).
These tests verify that:
1. Models supporting images in tool returns can see and describe image content
2. Models NOT supporting images (e.g., Chat Completions API) receive placeholder text
3. The image data is properly passed through the a... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/integration_test_multi_modal_tool_returns.py",
"license": "Apache License 2.0",
"lines": 337,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_embedding_optional.py | """
Tests for embedding-optional archival memory feature.
This file tests that agents can be created without an embedding model
and that archival memory operations (insert, list, search) work correctly
using text-based search when no embeddings are available.
"""
import os
import threading
import warnings
import pyt... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_embedding_optional.py",
"license": "Apache License 2.0",
"lines": 359,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
letta-ai/letta:tests/test_minimax_client.py | """Unit tests for MiniMax client."""
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from letta.llm_api.minimax_client import MiniMaxClient
from letta.schemas.enums import AgentType
from letta.schemas.llm_config import LLMConfig
# MiniMax API base URL
MINIMAX_BASE_URL = "https://api.minimax.io/a... | {
"repo_id": "letta-ai/letta",
"file_path": "tests/test_minimax_client.py",
"license": "Apache License 2.0",
"lines": 218,
"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.