Home / File/ test_base.py — langchain Source File

test_base.py — langchain Source File

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

File python CoreAbstractions Serialization 3 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  ac4e500c_e1cf_4a94_050b_0471dbbd95ad["test_base.py"]
  67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"]
  ac4e500c_e1cf_4a94_050b_0471dbbd95ad --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  ac4e500c_e1cf_4a94_050b_0471dbbd95ad --> 120e2591_3e15_b895_72b6_cb26195e40a6
  119305ac_1914_632e_73da_7975750314ee["langchain_classic.evaluation"]
  ac4e500c_e1cf_4a94_050b_0471dbbd95ad --> 119305ac_1914_632e_73da_7975750314ee
  style ac4e500c_e1cf_4a94_050b_0471dbbd95ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import re

import pytest

from langchain_classic.evaluation import RegexMatchStringEvaluator


@pytest.fixture
def regex_match_string_evaluator() -> RegexMatchStringEvaluator:
    """Create a RegexMatchStringEvaluator with default configuration."""
    return RegexMatchStringEvaluator()


@pytest.fixture
def regex_match_string_evaluator_ignore_case() -> RegexMatchStringEvaluator:
    """Create a RegexMatchStringEvaluator with IGNORECASE flag."""
    return RegexMatchStringEvaluator(flags=re.IGNORECASE)


def test_default_regex_matching(
    regex_match_string_evaluator: RegexMatchStringEvaluator,
) -> None:
    prediction = "Mindy is the CTO"
    reference = "^Mindy.*CTO$"
    result = regex_match_string_evaluator.evaluate_strings(
        prediction=prediction,
        reference=reference,
    )
    assert result["score"] == 1.0

    reference = "^Mike.*CEO$"
    result = regex_match_string_evaluator.evaluate_strings(
        prediction=prediction,
        reference=reference,
    )
    assert result["score"] == 0.0


def test_regex_matching_with_ignore_case(
    regex_match_string_evaluator_ignore_case: RegexMatchStringEvaluator,
) -> None:
    prediction = "Mindy is the CTO"
    reference = "^mindy.*cto$"
    result = regex_match_string_evaluator_ignore_case.evaluate_strings(
        prediction=prediction,
        reference=reference,
    )
    assert result["score"] == 1.0

Subdomains

Dependencies

  • langchain_classic.evaluation
  • pytest
  • re

Frequently Asked Questions

What does test_base.py do?
test_base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in test_base.py?
test_base.py defines 4 function(s): regex_match_string_evaluator, regex_match_string_evaluator_ignore_case, test_default_regex_matching, test_regex_matching_with_ignore_case.
What does test_base.py depend on?
test_base.py imports 3 module(s): langchain_classic.evaluation, pytest, re.
Where is test_base.py in the architecture?
test_base.py is located at libs/langchain/tests/unit_tests/evaluation/regex_match/test_base.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/tests/unit_tests/evaluation/regex_match).

Analyze Your Own Codebase

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

Try Supermodel Free