sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
langchain-ai/langchain:libs/core/tests/unit_tests/messages/block_translators/test_bedrock_converse.py
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage from langchain_core.messages import content as types def test_convert_to_v1_from_bedrock_converse() -> None: message = AIMessage( [ { "type": "reasoning_content", "reasoning_content": {"...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/messages/block_translators/test_bedrock_converse.py", "license": "MIT License", "lines": 367, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py
from langchain_core.messages import HumanMessage from langchain_core.messages import content as types from langchain_core.messages.block_translators.langchain_v0 import ( _convert_legacy_v0_content_block_to_v1, ) from tests.unit_tests.language_models.chat_models.test_base import ( _content_blocks_equal_ignore_i...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py", "license": "MIT License", "lines": 105, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/core/tests/unit_tests/messages/block_translators/test_openai.py
import pytest from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage from langchain_core.messages import content as types from langchain_core.messages.block_translators.openai import ( convert_to_openai_data_block, ) from tests.unit_tests.language_models.chat_models.test_base import ( _con...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/messages/block_translators/test_openai.py", "license": "MIT License", "lines": 570, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/core/tests/unit_tests/messages/block_translators/test_registration.py
import pkgutil from pathlib import Path import pytest from langchain_core.messages.block_translators import PROVIDER_TRANSLATORS def test_all_providers_registered() -> None: """Test that all block translators implemented in langchain-core are registered. If this test fails, it is likely that a block transl...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/messages/block_translators/test_registration.py", "license": "MIT License", "lines": 21, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/anthropic/langchain_anthropic/_compat.py
from __future__ import annotations import json from typing import Any, cast from langchain_core.messages import content as types def _convert_annotation_from_v1(annotation: types.Annotation) -> dict[str, Any]: """Convert LangChain annotation format to Anthropic's native citation format.""" if annotation["ty...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/anthropic/langchain_anthropic/_compat.py", "license": "MIT License", "lines": 168, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/partners/ollama/langchain_ollama/_compat.py
"""Go from v1 content blocks to Ollama SDK format.""" from typing import Any from langchain_core.messages import content as types def _convert_from_v1_to_ollama( content: list[types.ContentBlock], model_provider: str | None, # noqa: ARG001 ) -> list[dict[str, Any]]: """Convert v1 content blocks to Olla...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/ollama/langchain_ollama/_compat.py", "license": "MIT License", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langchain:libs/partners/ollama/tests/unit_tests/test_auth.py
"""Test URL authentication parsing functionality.""" import base64 from unittest.mock import MagicMock, patch from langchain_ollama._utils import parse_url_with_auth from langchain_ollama.chat_models import ChatOllama from langchain_ollama.embeddings import OllamaEmbeddings from langchain_ollama.llms import OllamaLLM...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/ollama/tests/unit_tests/test_auth.py", "license": "MIT License", "lines": 178, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/exa/tests/unit_tests/test_standard.py
"""Standard unit tests for ExaSearchRetriever.""" import pytest from pytest_benchmark.fixture import BenchmarkFixture # type: ignore[import-untyped] from langchain_exa import ExaSearchRetriever @pytest.mark.benchmark def test_exa_retriever_init_time(benchmark: BenchmarkFixture) -> None: """Test ExaSearchRetrie...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/exa/tests/unit_tests/test_standard.py", "license": "MIT License", "lines": 11, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/nomic/tests/unit_tests/test_standard.py
"""Unit tests for standard tests in Nomic partner integration.""" import pytest from pytest_benchmark.fixture import BenchmarkFixture # type: ignore[import] from langchain_nomic import NomicEmbeddings @pytest.mark.benchmark def test_nomic_embeddings_init_time(benchmark: BenchmarkFixture) -> None: """Test Nomic...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/nomic/tests/unit_tests/test_standard.py", "license": "MIT License", "lines": 11, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/qdrant/tests/unit_tests/test_standard.py
import pytest from langchain_core.embeddings import Embeddings from pytest_benchmark.fixture import BenchmarkFixture # type: ignore[import-untyped] from langchain_qdrant import QdrantVectorStore class MockEmbeddings(Embeddings): """Mock embeddings for testing.""" def embed_documents(self, texts: list[str])...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/qdrant/tests/unit_tests/test_standard.py", "license": "MIT License", "lines": 24, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain/tests/unit_tests/chains/test_flare.py
"""Tests for FlareChain.from_llm preserving supplied ChatOpenAI instance.""" from typing import cast import pytest from langchain_core.documents import Document from langchain_core.retrievers import BaseRetriever from langchain_core.runnables import RunnableSequence from langchain_classic.chains.flare.base import Fl...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain/tests/unit_tests/chains/test_flare.py", "license": "MIT License", "lines": 36, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py
"""Human in the loop middleware.""" from typing import Any, Literal, Protocol from langchain_core.messages import AIMessage, ToolCall, ToolMessage from langgraph.runtime import Runtime from langgraph.types import interrupt from typing_extensions import NotRequired, TypedDict from langchain.agents.middleware.types im...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py", "license": "MIT License", "lines": 299, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/langchain_v1/langchain/agents/middleware/summarization.py
"""Summarization middleware.""" import uuid import warnings from collections.abc import Callable, Iterable, Mapping from functools import partial from typing import Any, Literal, cast from langchain_core.messages import ( AIMessage, AnyMessage, MessageLikeRepresentation, RemoveMessage, ToolMessage...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/agents/middleware/summarization.py", "license": "MIT License", "lines": 534, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/langchain_v1/langchain/agents/middleware/types.py
"""Types for middleware and agents.""" from __future__ import annotations from collections.abc import Awaitable, Callable, Sequence from dataclasses import dataclass, field, replace from inspect import iscoroutinefunction from typing import ( TYPE_CHECKING, Annotated, Any, Generic, Literal, Pr...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/agents/middleware/types.py", "license": "MIT License", "lines": 1626, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langchain:libs/langchain_v1/langchain/agents/structured_output.py
"""Types for setting agent response formats.""" from __future__ import annotations import json import uuid from dataclasses import dataclass, is_dataclass from types import UnionType from typing import ( TYPE_CHECKING, Any, Generic, Literal, TypeVar, Union, get_args, get_origin, ) fro...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/agents/structured_output.py", "license": "MIT License", "lines": 362, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/any_str.py
import re class AnyStr(str): __slots__ = ("prefix",) def __init__(self, prefix: str | re.Pattern[str] = "") -> None: super().__init__() self.prefix = prefix def __eq__(self, other: object) -> bool: return isinstance(other, str) and ( other.startswith(self.prefix) ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/any_str.py", "license": "MIT License", "lines": 14, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/conftest_checkpointer.py
from collections.abc import AsyncIterator, Iterator from contextlib import asynccontextmanager, contextmanager from langgraph.checkpoint.base import BaseCheckpointSaver from tests.unit_tests.agents.memory_assert import MemorySaverAssertImmutable @contextmanager def _checkpointer_memory() -> Iterator[BaseCheckpointS...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/conftest_checkpointer.py", "license": "MIT License", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/conftest_store.py
from collections.abc import AsyncIterator, Iterator from contextlib import asynccontextmanager, contextmanager from langgraph.store.base import BaseStore from langgraph.store.memory import InMemoryStore @contextmanager def _store_memory() -> Iterator[BaseStore]: store = InMemoryStore() yield store @asyncco...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/conftest_store.py", "license": "MIT License", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/memory_assert.py
import os import tempfile import time from collections import defaultdict from typing import Any from langchain_core.runnables import RunnableConfig from langgraph.checkpoint.base import ( ChannelVersions, Checkpoint, CheckpointMetadata, ) from langgraph.checkpoint.memory import InMemorySaver, PersistentDi...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/memory_assert.py", "license": "MIT License", "lines": 56, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/messages.py
"""Redefined messages as a work-around for pydantic issue with AnyStr. The code below creates version of pydantic models that will work in unit tests with AnyStr as id field Please note that the `id` field is assigned AFTER the model is created to workaround an issue with pydantic ignoring the __eq__ method on subclas...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/messages.py", "license": "MIT License", "lines": 20, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/model.py
import json from collections.abc import Callable, Sequence from dataclasses import asdict, is_dataclass from typing import ( Any, Literal, ) from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import BaseChatModel, LanguageModelInput from langchain_core.messages im...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/model.py", "license": "MIT License", "lines": 100, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/test_react_agent.py
# import dataclasses # import inspect # from types import UnionType # from typing import ( # Annotated, # Union, # ) # import pytest # from langchain_core.language_models import BaseChatModel # from langchain_core.messages import ( # AIMessage, # HumanMessage, # MessageLikeRepresentation, # Rem...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/test_react_agent.py", "license": "MIT License", "lines": 824, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/test_response_format.py
"""Test suite for create_agent with structured output response_format permutations.""" import json from collections.abc import Callable, Sequence from dataclasses import dataclass from typing import Any from unittest.mock import patch import pytest from langchain_core.language_models import LanguageModelInput from la...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/test_response_format.py", "license": "MIT License", "lines": 776, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/test_responses.py
"""Unit tests for langchain.agents.structured_output module.""" import pytest from langchain_core.messages import AIMessage from pydantic import BaseModel from langchain.agents.structured_output import ( OutputToolBinding, ProviderStrategy, ProviderStrategyBinding, ToolStrategy, _SchemaSpec, ) c...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/test_responses.py", "license": "MIT License", "lines": 222, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py
from __future__ import annotations import os from typing import ( TYPE_CHECKING, Any, ) from unittest.mock import MagicMock import httpx import pytest from langchain_core.messages import HumanMessage from langchain_core.tools import tool from pydantic import BaseModel, create_model from langchain.agents impo...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py", "license": "MIT License", "lines": 127, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/test_return_direct_spec.py
from __future__ import annotations import os from typing import ( Any, ) from unittest.mock import MagicMock import pytest from langchain_core.messages import HumanMessage from langchain_core.tools import tool from langchain.agents import create_agent from langchain.agents.structured_output import ( ToolStra...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/test_return_direct_spec.py", "license": "MIT License", "lines": 94, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/agents/utils.py
import json from pathlib import Path from typing import TypeVar from pydantic import BaseModel, ConfigDict from pydantic.alias_generators import to_camel class BaseSchema(BaseModel): model_config = ConfigDict( alias_generator=to_camel, populate_by_name=True, from_attributes=True, ) ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/agents/utils.py", "license": "MIT License", "lines": 18, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/anthropic/tests/unit_tests/test_client_utils.py
"""Test client utility functions.""" from __future__ import annotations from langchain_anthropic._client_utils import ( _get_default_async_httpx_client, _get_default_httpx_client, ) def test_sync_client_without_proxy() -> None: """Test sync client creation without proxy.""" client = _get_default_htt...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/anthropic/tests/unit_tests/test_client_utils.py", "license": "MIT License", "lines": 44, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openai/langchain_openai/tools/custom_tool.py
"""Custom tool decorator for OpenAI custom tools.""" import inspect from collections.abc import Awaitable, Callable from typing import Any from langchain_core.tools import tool def _make_wrapped_func(func: Callable[..., str]) -> Callable[..., list[dict[str, Any]]]: def wrapped(x: str) -> list[dict[str, Any]]: ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/langchain_openai/tools/custom_tool.py", "license": "MIT License", "lines": 82, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langchain:libs/partners/openai/tests/unit_tests/test_tools.py
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage from langchain_core.tools import Tool from langchain_openai import ChatOpenAI, custom_tool def test_custom_tool() -> None: @custom_tool def my_tool(x: str) -> str: """Do thing.""" return "a" + x # Test decorator ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/tests/unit_tests/test_tools.py", "license": "MIT License", "lines": 110, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openai/tests/unit_tests/chat_models/test_prompt_cache_key.py
"""Unit tests for prompt_cache_key parameter.""" from langchain_core.messages import HumanMessage from langchain_openai import ChatOpenAI def test_prompt_cache_key_parameter_inclusion() -> None: """Test that prompt_cache_key parameter is properly included in request payload.""" chat = ChatOpenAI(model="gpt-...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/tests/unit_tests/chat_models/test_prompt_cache_key.py", "license": "MIT License", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/langchain/chat_models/base.py
"""Factory functions for chat models.""" from __future__ import annotations import functools import importlib import warnings from typing import ( TYPE_CHECKING, Any, Literal, TypeAlias, cast, overload, ) from langchain_core.language_models import BaseChatModel, LanguageModelInput from langch...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/chat_models/base.py", "license": "MIT License", "lines": 855, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/langchain_v1/langchain/embeddings/base.py
"""Factory functions for embeddings.""" import functools import importlib from collections.abc import Callable from typing import Any from langchain_core.embeddings import Embeddings def _call(cls: type[Embeddings], **kwargs: Any) -> Embeddings: return cls(**kwargs) _BUILTIN_PROVIDERS: dict[str, tuple[str, st...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/langchain/embeddings/base.py", "license": "MIT License", "lines": 212, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langchain:libs/langchain_v1/scripts/check_imports.py
"""Check imports script. Quickly verify that a list of Python files can be loaded by the Python interpreter without raising any errors. Ran before running more expensive tests. Useful in Makefiles. If loading a file fails, the script prints the problematic filename and the detailed error traceback. """ import random...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/scripts/check_imports.py", "license": "MIT License", "lines": 28, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langchain:libs/langchain_v1/tests/integration_tests/cache/fake_embeddings.py
"""Fake Embedding class for testing purposes.""" import math from langchain_core.embeddings import Embeddings from typing_extensions import override fake_texts = ["foo", "bar", "baz"] class FakeEmbeddings(Embeddings): """Fake embeddings functionality for testing.""" @override def embed_documents(self,...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/integration_tests/cache/fake_embeddings.py", "license": "MIT License", "lines": 68, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/integration_tests/chat_models/test_base.py
from typing import Any, cast import pytest from langchain_core.language_models import BaseChatModel from langchain_core.messages import AIMessage from langchain_core.prompts import ChatPromptTemplate from langchain_core.runnables import RunnableConfig from langchain_tests.integration_tests import ChatModelIntegrationT...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/integration_tests/chat_models/test_base.py", "license": "MIT License", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/integration_tests/embeddings/test_base.py
"""Test embeddings base module.""" import importlib import pytest from langchain_core.embeddings import Embeddings from langchain.embeddings.base import _BUILTIN_PROVIDERS, init_embeddings @pytest.mark.parametrize( ("provider", "model"), [ ("openai", "text-embedding-3-large"), ("google_vert...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/integration_tests/embeddings/test_base.py", "license": "MIT License", "lines": 34, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py
import os from typing import TYPE_CHECKING from unittest import mock import pytest from langchain_core.language_models.fake_chat_models import FakeChatModel from langchain_core.prompts import ChatPromptTemplate from langchain_core.runnables import RunnableConfig, RunnableSequence from pydantic import SecretStr from l...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py", "license": "MIT License", "lines": 302, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/embeddings/test_base.py
"""Test embeddings base module.""" import pytest from langchain.embeddings.base import ( _BUILTIN_PROVIDERS, _infer_model_and_provider, _parse_model_string, ) @pytest.mark.parametrize( ("model_string", "expected_provider", "expected_model"), [ ("openai:text-embedding-3-small", "openai", ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/embeddings/test_base.py", "license": "MIT License", "lines": 87, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/embeddings/test_imports.py
from langchain import embeddings EXPECTED_ALL = [ "Embeddings", "init_embeddings", ] def test_all_imports() -> None: assert set(embeddings.__all__) == set(EXPECTED_ALL)
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/embeddings/test_imports.py", "license": "MIT License", "lines": 7, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/test_dependencies.py
"""A unit test meant to catch accidental introduction of non-optional dependencies.""" from collections.abc import Mapping from pathlib import Path from typing import Any import pytest import toml from packaging.requirements import Requirement HERE = Path(__file__).parent PYPROJECT_TOML = HERE / "../../pyproject.to...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/test_dependencies.py", "license": "MIT License", "lines": 29, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/test_imports.py
import importlib import warnings from pathlib import Path # Attempt to recursively import all modules in langchain PKG_ROOT = Path(__file__).parent.parent.parent def test_import_all() -> None: """Generate the public API for this package.""" with warnings.catch_warnings(): warnings.filterwarnings(acti...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/test_imports.py", "license": "MIT License", "lines": 46, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/test_pytest_config.py
import pytest import pytest_socket import requests def test_socket_disabled() -> None: """This test should fail.""" with pytest.raises(pytest_socket.SocketBlockedError): requests.get("https://www.example.com", timeout=1)
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/test_pytest_config.py", "license": "MIT License", "lines": 7, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/langchain_v1/tests/unit_tests/tools/test_imports.py
from langchain import tools EXPECTED_ALL = { "BaseTool", "InjectedState", "InjectedStore", "InjectedToolArg", "InjectedToolCallId", "ToolException", "ToolRuntime", "tool", } def test_all_imports() -> None: assert set(tools.__all__) == EXPECTED_ALL
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/langchain_v1/tests/unit_tests/tools/test_imports.py", "license": "MIT License", "lines": 13, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/core/tests/unit_tests/utils/test_strings.py
"""Test string utilities.""" from langchain_core.utils.strings import ( comma_list, sanitize_for_postgres, stringify_dict, stringify_value, ) def test_sanitize_for_postgres() -> None: """Test sanitizing text for PostgreSQL compatibility.""" # Test with NUL bytes text_with_nul = "Hello\x00...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/utils/test_strings.py", "license": "MIT License", "lines": 80, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/ollama/langchain_ollama/_utils.py
"""Utility function to validate Ollama models.""" from __future__ import annotations import base64 from urllib.parse import unquote, urlparse from httpx import ConnectError from ollama import Client, ResponseError def validate_model(client: Client, model_name: str) -> None: """Validate that a model exists in t...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/ollama/langchain_ollama/_utils.py", "license": "MIT License", "lines": 91, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/text-splitters/tests/unit_tests/test_html_security.py
"""Security tests for HTML splitters to prevent XXE attacks.""" import pytest from langchain_text_splitters.html import HTMLSectionSplitter @pytest.mark.requires("lxml", "bs4") class TestHTMLSectionSplitterSecurity: """Security tests for HTMLSectionSplitter to ensure XXE prevention.""" def test_xxe_entity_...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/text-splitters/tests/unit_tests/test_html_security.py", "license": "MIT License", "lines": 101, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/anthropic/langchain_anthropic/_client_utils.py
"""Helpers for creating Anthropic API clients. This module allows for the caching of httpx clients to avoid creating new instances for each instance of ChatAnthropic. Logic is largely replicated from anthropic._base_client. """ from __future__ import annotations import asyncio import os from functools import lru_ca...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/anthropic/langchain_anthropic/_client_utils.py", "license": "MIT License", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/core/tests/unit_tests/vectorstores/test_utils.py
"""Tests for langchain_core.vectorstores.utils module.""" import math import pytest pytest.importorskip("numpy") import numpy as np from langchain_core.vectorstores.utils import _cosine_similarity class TestCosineSimilarity: """Tests for _cosine_similarity function.""" def test_basic_cosine_similarity(se...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/vectorstores/test_utils.py", "license": "MIT License", "lines": 141, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openai/langchain_openai/chat_models/_compat.py
"""Converts between AIMessage output formats, governed by `output_version`. `output_version` is an attribute on ChatOpenAI. Supported values are `None`, `'v0'`, and `'responses/v1'`. `'v0'` corresponds to the format as of `ChatOpenAI` v0.3. For the Responses API, it stores reasoning and tool outputs in `AIMessage.ad...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/langchain_openai/chat_models/_compat.py", "license": "MIT License", "lines": 398, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/partners/openai/tests/unit_tests/chat_models/test_responses_stream.py
from __future__ import annotations from typing import Any from unittest.mock import MagicMock, patch import pytest from langchain_core.messages import AIMessageChunk, BaseMessageChunk from openai.types.responses import ( ResponseCompletedEvent, ResponseContentPartAddedEvent, ResponseContentPartDoneEvent, ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/tests/unit_tests/chat_models/test_responses_stream.py", "license": "MIT License", "lines": 771, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openai/langchain_openai/chat_models/_client_utils.py
"""Helpers for creating OpenAI API clients. This module allows for the caching of httpx clients to avoid creating new instances for each instance of ChatOpenAI. Logic is largely replicated from openai._base_client. """ from __future__ import annotations import asyncio import inspect import os from collections.abc i...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openai/langchain_openai/chat_models/_client_utils.py", "license": "MIT License", "lines": 109, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/checkpoint/langgraph/checkpoint/serde/event_hooks.py
from __future__ import annotations import logging from collections.abc import Callable from threading import Lock from typing import TypedDict from typing_extensions import NotRequired logger = logging.getLogger(__name__) class SerdeEvent(TypedDict): kind: str module: str name: str method: NotRequi...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint/langgraph/checkpoint/serde/event_hooks.py", "license": "MIT License", "lines": 37, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langgraph:libs/checkpoint/langgraph/checkpoint/serde/_msgpack.py
import os from collections.abc import Iterable from typing import cast STRICT_MSGPACK_ENABLED = os.getenv("LANGGRAPH_STRICT_MSGPACK", "false").lower() in ( "1", "true", "yes", ) _SENTINEL = cast(None, object()) SAFE_MSGPACK_TYPES: frozenset[tuple[str, ...]] = frozenset( { # datetime types ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint/langgraph/checkpoint/serde/_msgpack.py", "license": "MIT License", "lines": 82, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langgraph:libs/checkpoint/tests/test_encrypted.py
"""Tests for EncryptedSerializer with msgpack allowlist functionality. These tests mirror the msgpack allowlist tests in test_jsonplus.py but run them through the EncryptedSerializer to ensure the allowlist behavior is preserved when encryption is enabled. """ from __future__ import annotations import logging import...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint/tests/test_encrypted.py", "license": "MIT License", "lines": 343, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/langgraph/bench/serde_allowlist.py
from __future__ import annotations from collections import deque from dataclasses import dataclass from enum import Enum from typing import Annotated from pydantic import BaseModel from typing_extensions import NotRequired, TypedDict from langgraph._internal._serde import collect_allowlist_from_schemas class Color...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/bench/serde_allowlist.py", "license": "MIT License", "lines": 55, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langgraph:libs/langgraph/langgraph/_internal/_serde.py
from __future__ import annotations import dataclasses import logging import sys import types from collections import deque from enum import Enum from typing import ( Annotated, Any, Literal, Union, get_args, get_origin, get_type_hints, ) from langchain_core import messages as lc_messages f...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/langgraph/_internal/_serde.py", "license": "MIT License", "lines": 211, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/langgraph/tests/test_serde_allowlist.py
from __future__ import annotations from collections import deque from dataclasses import dataclass from enum import Enum from typing import TYPE_CHECKING, Annotated, Any, Literal, NewType, Optional, Union import pytest from pydantic import BaseModel from typing_extensions import NotRequired, Required, TypedDict from...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/tests/test_serde_allowlist.py", "license": "MIT License", "lines": 110, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/langgraph/tests/test_subgraph_persistence.py
"""Tests for subgraph persistence behavior (sync). Covers three checkpointer settings for subgraph state: - checkpointer=False: no persistence, even when parent has a checkpointer - checkpointer=None (default): "stateless" — inherits parent checkpointer for interrupt support, but state resets each invocation. This i...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/tests/test_subgraph_persistence.py", "license": "MIT License", "lines": 540, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/langgraph/tests/test_subgraph_persistence_async.py
"""Tests for subgraph persistence behavior (async). Covers three checkpointer settings for subgraph state: - checkpointer=False: no persistence, even when parent has a checkpointer - checkpointer=None (default): "stateless" — inherits parent checkpointer for interrupt support, but state resets each invocation. This ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/tests/test_subgraph_persistence_async.py", "license": "MIT License", "lines": 559, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/langgraph/tests/test_parent_command.py
from __future__ import annotations from typing_extensions import TypedDict from langgraph.graph import END, START, StateGraph from langgraph.types import Command def test_parent_command_from_nested_subgraph() -> None: class ParentState(TypedDict): jump_from_idx: int class ChildState(TypedDict): ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/tests/test_parent_command.py", "license": "MIT License", "lines": 36, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/langgraph/tests/test_parent_command_async.py
from __future__ import annotations import pytest from langchain_core.runnables import RunnableConfig from typing_extensions import TypedDict from langgraph.graph import END, START, StateGraph from langgraph.types import Command pytestmark = pytest.mark.anyio async def test_parent_command_from_nested_subgraph() -> ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/langgraph/tests/test_parent_command_async.py", "license": "MIT License", "lines": 39, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:docs/generate_redirects.py
#!/usr/bin/env python3 """ Generate HTML redirect files from redirects.json. Usage: python generate_redirects.py This script reads redirects.json and generates individual HTML files for each redirect path. Each HTML file uses meta refresh (0 delay) which is SEO-friendly and treated similarly to 301 redirects by G...
{ "repo_id": "langchain-ai/langgraph", "file_path": "docs/generate_redirects.py", "license": "MIT License", "lines": 119, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/capabilities.py
"""Capability detection for checkpointer implementations.""" from __future__ import annotations from dataclasses import dataclass from enum import Enum from typing import TYPE_CHECKING from langgraph.checkpoint.base import BaseCheckpointSaver if TYPE_CHECKING: pass class Capability(str, Enum): """Capabili...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/capabilities.py", "license": "MIT License", "lines": 73, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/initializer.py
"""Checkpointer test registration and factory management.""" from __future__ import annotations from collections.abc import AsyncGenerator, Callable from contextlib import asynccontextmanager from dataclasses import dataclass, field from typing import Any from langgraph.checkpoint.base import BaseCheckpointSaver # ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/initializer.py", "license": "MIT License", "lines": 78, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/report.py
"""Capability report: results, progress callbacks, and pretty-printing.""" from __future__ import annotations from collections.abc import Callable from dataclasses import dataclass, field from typing import Any from langgraph.checkpoint.conformance.capabilities import ( BASE_CAPABILITIES, EXTENDED_CAPABILITI...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/report.py", "license": "MIT License", "lines": 165, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_copy_thread.py
"""COPY_THREAD capability tests — acopy_thread.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, generate...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_copy_thread.py", "license": "MIT License", "lines": 206, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_delete_for_runs.py
"""DELETE_FOR_RUNS capability tests — adelete_for_runs.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_delete_for_runs.py", "license": "MIT License", "lines": 176, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "temp...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_delete_thread.py
"""DELETE_THREAD capability tests — adelete_thread.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, gene...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_delete_thread.py", "license": "MIT License", "lines": 117, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "templa...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_get_tuple.py
"""GET_TUPLE capability tests — aget_tuple retrieval.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, ge...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_get_tuple.py", "license": "MIT License", "lines": 207, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template":...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_list.py
"""LIST capability tests — alist with various filters.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, g...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_list.py", "license": "MIT License", "lines": 328, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_prune.py
"""PRUNE capability tests — aprune(strategy).""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate_checkpoint, generate_c...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_prune.py", "license": "MIT License", "lines": 180, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" ...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_put.py
"""PUT capability tests — aput + aget_tuple round-trip.""" from __future__ import annotations import traceback from collections.abc import Callable from typing import Any from uuid import uuid4 from langgraph.checkpoint.base import ( BaseCheckpointSaver, ChannelVersions, ) from langgraph.checkpoint.conforma...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_put.py", "license": "MIT License", "lines": 340, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_put_writes.py
"""PUT_WRITES capability tests — aput_writes + pending_writes retrieval.""" from __future__ import annotations import traceback from collections.abc import Callable from uuid import uuid4 from langgraph.checkpoint.base import BaseCheckpointSaver from langgraph.checkpoint.conformance.test_utils import ( generate...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/spec/test_put_writes.py", "license": "MIT License", "lines": 250, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template"...
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/test_utils.py
"""Test utilities: checkpoint generators, assertion helpers, bulk operations.""" from __future__ import annotations from datetime import datetime, timezone from typing import Any from uuid import uuid4 from langchain_core.runnables import RunnableConfig from langgraph.checkpoint.base import ( ChannelVersions, ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/test_utils.py", "license": "MIT License", "lines": 185, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/checkpoint-conformance/langgraph/checkpoint/conformance/validate.py
"""Core conformance runner — detects capabilities, runs test suites, builds report.""" from __future__ import annotations from langgraph.checkpoint.conformance.capabilities import ( Capability, DetectedCapabilities, ) from langgraph.checkpoint.conformance.initializer import RegisteredCheckpointer from langgra...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/langgraph/checkpoint/conformance/validate.py", "license": "MIT License", "lines": 108, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/checkpoint-conformance/tests/test_validate_memory.py
"""Self-tests: run the conformance suite against InMemorySaver.""" from __future__ import annotations import pytest from langgraph.checkpoint.memory import InMemorySaver from langgraph.checkpoint.conformance import checkpointer_test, validate @checkpointer_test(name="InMemorySaver") async def memory_checkpointer()...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/checkpoint-conformance/tests/test_validate_memory.py", "license": "MIT License", "lines": 14, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/assistants.py
"""Async client for managing assistants in LangGraph.""" from __future__ import annotations from collections.abc import Mapping from typing import Any, Literal, cast, overload import httpx from langgraph_sdk._async.http import HttpClient from langgraph_sdk.schema import ( Assistant, AssistantSelectField, ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/assistants.py", "license": "MIT License", "lines": 647, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/client.py
"""Async LangGraph client.""" from __future__ import annotations import logging import os from collections.abc import Mapping from types import TracebackType import httpx from langgraph_sdk._async.assistants import AssistantsClient from langgraph_sdk._async.cron import CronClient from langgraph_sdk._async.http impo...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/client.py", "license": "MIT License", "lines": 147, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/cron.py
"""Async client for managing recurrent runs (cron jobs) in LangGraph.""" from __future__ import annotations import warnings from collections.abc import Mapping, Sequence from datetime import datetime from typing import Any from langgraph_sdk._async.http import HttpClient from langgraph_sdk.schema import ( All, ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/cron.py", "license": "MIT License", "lines": 462, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/http.py
"""HTTP client for async operations.""" from __future__ import annotations import asyncio import logging import sys import warnings from collections.abc import AsyncIterator, Callable, Mapping from typing import Any, cast import httpx import orjson from langgraph_sdk._shared.utilities import _orjson_default from la...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/http.py", "license": "MIT License", "lines": 277, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/runs.py
"""Async client for managing runs in LangGraph.""" from __future__ import annotations import builtins import warnings from collections.abc import AsyncIterator, Callable, Mapping, Sequence from typing import Any, overload import httpx from langgraph_sdk._async.http import HttpClient from langgraph_sdk._shared.utili...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/runs.py", "license": "MIT License", "lines": 983, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/store.py
"""Async Store client for LangGraph SDK.""" from __future__ import annotations from collections.abc import Mapping, Sequence from typing import Any, Literal from langgraph_sdk._async.http import HttpClient from langgraph_sdk._shared.utilities import _provided_vals from langgraph_sdk.schema import ( Item, Lis...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/store.py", "license": "MIT License", "lines": 272, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_async/threads.py
"""Async client for managing threads in LangGraph.""" from __future__ import annotations from collections.abc import AsyncIterator, Mapping, Sequence from typing import Any from langgraph_sdk._async.http import HttpClient from langgraph_sdk.schema import ( Checkpoint, Json, OnConflictBehavior, PruneS...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_async/threads.py", "license": "MIT License", "lines": 650, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_shared/types.py
"""Type aliases and constants.""" from __future__ import annotations TimeoutTypes = ( None | float | tuple[float | None, float | None] | tuple[float | None, float | None, float | None, float | None] )
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_shared/types.py", "license": "MIT License", "lines": 8, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_shared/utilities.py
"""Shared utility functions for async and sync clients.""" from __future__ import annotations import functools import os import re from collections.abc import Mapping from typing import Any, cast import httpx import langgraph_sdk from langgraph_sdk.schema import RunCreateMetadata RESERVED_HEADERS = ("x-api-key",) ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_shared/utilities.py", "license": "MIT License", "lines": 102, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/assistants.py
"""Synchronous client for managing assistants in LangGraph.""" from __future__ import annotations from collections.abc import Mapping from typing import Any, Literal, cast, overload import httpx from langgraph_sdk._sync.http import SyncHttpClient from langgraph_sdk.schema import ( Assistant, AssistantSelect...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/assistants.py", "license": "MIT License", "lines": 649, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/client.py
"""Sync LangGraph client.""" from __future__ import annotations from collections.abc import Mapping from types import TracebackType import httpx from langgraph_sdk._shared.types import TimeoutTypes from langgraph_sdk._shared.utilities import NOT_PROVIDED, _get_headers from langgraph_sdk._sync.assistants import Sync...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/client.py", "license": "MIT License", "lines": 102, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/cron.py
"""Synchronous cron client for LangGraph SDK.""" from __future__ import annotations import warnings from collections.abc import Mapping, Sequence from datetime import datetime from typing import Any from langgraph_sdk._sync.http import SyncHttpClient from langgraph_sdk.schema import ( All, Config, Contex...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/cron.py", "license": "MIT License", "lines": 452, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/http.py
"""Synchronous HTTP client for LangGraph API.""" from __future__ import annotations import logging import sys import warnings from collections.abc import Callable, Iterator, Mapping from typing import Any, cast import httpx import orjson from langgraph_sdk._shared.utilities import _orjson_default from langgraph_sdk...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/http.py", "license": "MIT License", "lines": 267, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/runs.py
"""Synchronous client for managing runs in LangGraph.""" from __future__ import annotations import builtins import warnings from collections.abc import Callable, Iterator, Mapping, Sequence from typing import Any, overload import httpx from langgraph_sdk._shared.utilities import _get_run_metadata_from_response from...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/runs.py", "license": "MIT License", "lines": 967, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/store.py
"""Synchronous store client for LangGraph SDK.""" from __future__ import annotations from collections.abc import Mapping, Sequence from typing import Any, Literal from langgraph_sdk._shared.utilities import _provided_vals from langgraph_sdk._sync.http import SyncHttpClient from langgraph_sdk.schema import ( Item...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/store.py", "license": "MIT License", "lines": 273, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/_sync/threads.py
"""Synchronous client for managing threads in LangGraph.""" from __future__ import annotations from collections.abc import Iterator, Mapping, Sequence from typing import Any from langgraph_sdk._sync.http import SyncHttpClient from langgraph_sdk.schema import ( Checkpoint, Json, OnConflictBehavior, Pr...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/_sync/threads.py", "license": "MIT License", "lines": 637, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/tests/test_client_exports.py
"""Test that all expected symbols are exported from langgraph_sdk.client. This test ensures backwards compatibility during refactoring. """ import httpx from langgraph_sdk import get_client as public_get_client from langgraph_sdk import get_sync_client as public_get_sync_client from langgraph_sdk.client import ( ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/tests/test_client_exports.py", "license": "MIT License", "lines": 74, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/runtime.py
from __future__ import annotations import sys from dataclasses import dataclass, field from typing import TYPE_CHECKING, Generic, Literal, TypeVar if sys.version_info >= (3, 13): ContextT = TypeVar("ContextT", default=None) else: ContextT = TypeVar("ContextT") if sys.version_info >= (3, 12): from typing ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/runtime.py", "license": "MIT License", "lines": 183, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/tests/test_crons_client.py
"""Tests for the crons client.""" from __future__ import annotations import json from datetime import datetime, timezone import httpx import pytest from langgraph_sdk.client import ( CronClient, HttpClient, SyncCronClient, SyncHttpClient, ) def _cron_payload() -> dict[str, object]: """Return a...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/tests/test_crons_client.py", "license": "MIT License", "lines": 381, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/sdk-py/langgraph_sdk/encryption/types.py
"""Encryption and decryption types for LangGraph. This module defines the core types used for custom at-rest encryption in LangGraph. It includes context types and typed dictionaries for encryption operations. """ from __future__ import annotations import typing from collections.abc import Awaitable, Callable Json ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/langgraph_sdk/encryption/types.py", "license": "MIT License", "lines": 106, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langchain-ai/langgraph:libs/sdk-py/tests/test_encryption.py
import pytest from langgraph_sdk.encryption import DuplicateHandlerError, Encryption class TestHandlerValidation: """Test duplicate handler and signature validation.""" def test_duplicate_handlers_raise_error(self): """Registering the same handler type twice raises DuplicateHandlerError.""" ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/tests/test_encryption.py", "license": "MIT License", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/sdk-py/tests/test_assistants_client.py
from __future__ import annotations import httpx import pytest from langgraph_sdk.client import ( AssistantsClient, HttpClient, SyncAssistantsClient, SyncHttpClient, ) def _assistant_payload() -> dict[str, object]: return { "assistant_id": "asst_123", "graph_id": "graph_123", ...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/tests/test_assistants_client.py", "license": "MIT License", "lines": 72, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langgraph:libs/sdk-py/tests/test_skip_auto_load_api_key.py
"""Tests for api_key parameter behavior.""" import pytest from langgraph_sdk import get_client, get_sync_client class TestSkipAutoLoadApiKey: """Test the api_key parameter's auto-loading behavior.""" @pytest.mark.asyncio async def test_get_client_loads_from_env_by_default(self, monkeypatch): ""...
{ "repo_id": "langchain-ai/langgraph", "file_path": "libs/sdk-py/tests/test_skip_auto_load_api_key.py", "license": "MIT License", "lines": 54, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test