Home / File/ test_standard.py — langchain Source File

test_standard.py — langchain Source File

Architecture documentation for test_standard.py, a python file in the langchain codebase. 5 imports, 0 dependents.

File python LangChainCore Runnables 5 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8["test_standard.py"]
  f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"]
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8 --> f69d6389_263d_68a4_7fbf_f14c0602a9ba
  e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"]
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8 --> e929cf21_6ab8_6ff3_3765_0d35a099a053
  3a16c96e_2b20_1092_e102_d9bfb77da65e["langchain_tests.unit_tests"]
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8 --> 3a16c96e_2b20_1092_e102_d9bfb77da65e
  4e10449f_1140_2e1d_c00d_fe1b4f649212["pytest_benchmark.fixture"]
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8 --> 4e10449f_1140_2e1d_c00d_fe1b4f649212
  a270c900_ac1e_6518_f720_875b8b52a3a0["langchain_anthropic"]
  57b52b3b_08ad_c744_35e6_97ebddb5fdb8 --> a270c900_ac1e_6518_f720_875b8b52a3a0
  style 57b52b3b_08ad_c744_35e6_97ebddb5fdb8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Standard LangChain interface tests."""

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_tests.unit_tests import ChatModelUnitTests
from pytest_benchmark.fixture import BenchmarkFixture  # type: ignore[import-untyped]

from langchain_anthropic import ChatAnthropic

_MODEL = "claude-3-haiku-20240307"


class TestAnthropicStandard(ChatModelUnitTests):
    """Use the standard chat model unit tests against the `ChatAnthropic` class."""

    @property
    def chat_model_class(self) -> type[BaseChatModel]:
        return ChatAnthropic

    @property
    def chat_model_params(self) -> dict:
        return {"model": _MODEL}

    @property
    def init_from_env_params(self) -> tuple[dict, dict, dict]:
        return (
            {"ANTHROPIC_API_KEY": "test"},
            {"model": _MODEL},
            {"anthropic_api_key": "test"},
        )


@pytest.mark.benchmark
def test_init_time_with_client(benchmark: BenchmarkFixture) -> None:
    """Test initialization time, accounting for lazy loading of client."""

    def _init_in_loop_with_clients() -> None:
        for _ in range(10):
            llm = ChatAnthropic(model="claude-3-5-haiku-20241022")
            _ = llm._client
            _ = llm._async_client

    benchmark(_init_in_loop_with_clients)

Domain

Subdomains

Dependencies

  • langchain_anthropic
  • langchain_core.language_models
  • langchain_tests.unit_tests
  • pytest
  • pytest_benchmark.fixture

Frequently Asked Questions

What does test_standard.py do?
test_standard.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in test_standard.py?
test_standard.py defines 1 function(s): test_init_time_with_client.
What does test_standard.py depend on?
test_standard.py imports 5 module(s): langchain_anthropic, langchain_core.language_models, langchain_tests.unit_tests, pytest, pytest_benchmark.fixture.
Where is test_standard.py in the architecture?
test_standard.py is located at libs/partners/anthropic/tests/unit_tests/test_standard.py (domain: LangChainCore, subdomain: Runnables, directory: libs/partners/anthropic/tests/unit_tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free