Home / File/ test_llm_summarization_checker.py — langchain Source File

test_llm_summarization_checker.py — langchain Source File

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

Entity Profile

Dependency Diagram

graph LR
  448d0970_96bc_cb04_405a_d4eaa7dd3110["test_llm_summarization_checker.py"]
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  448d0970_96bc_cb04_405a_d4eaa7dd3110 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  ff650ea8_b6fd_6503_302d_deca2d89d80c["langchain_classic.chains.llm_summarization_checker.base"]
  448d0970_96bc_cb04_405a_d4eaa7dd3110 --> ff650ea8_b6fd_6503_302d_deca2d89d80c
  7e88f5ce_ff41_7d87_8fb2_f355489a149e["tests.unit_tests.llms.fake_llm"]
  448d0970_96bc_cb04_405a_d4eaa7dd3110 --> 7e88f5ce_ff41_7d87_8fb2_f355489a149e
  style 448d0970_96bc_cb04_405a_d4eaa7dd3110 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test LLMSummarization functionality."""

import pytest

from langchain_classic.chains.llm_summarization_checker.base import (
    ARE_ALL_TRUE_PROMPT,
    CHECK_ASSERTIONS_PROMPT,
    CREATE_ASSERTIONS_PROMPT,
    REVISED_SUMMARY_PROMPT,
    LLMSummarizationCheckerChain,
)
from tests.unit_tests.llms.fake_llm import FakeLLM


def test_input_variables() -> None:
    assert CREATE_ASSERTIONS_PROMPT.input_variables == ["summary"]
    assert CHECK_ASSERTIONS_PROMPT.input_variables == ["assertions"]
    assert REVISED_SUMMARY_PROMPT.input_variables == ["checked_assertions", "summary"]
    assert ARE_ALL_TRUE_PROMPT.input_variables == ["checked_assertions"]


@pytest.fixture
def fake_llm_summarization_checker_chain() -> LLMSummarizationCheckerChain:
    """Fake LLMCheckerChain for testing."""
    queries = {
        CREATE_ASSERTIONS_PROMPT.format(
            summary="a",
        ): "b",
        CHECK_ASSERTIONS_PROMPT.format(
            assertions="b",
        ): "- b - True",
        REVISED_SUMMARY_PROMPT.format(
            checked_assertions="- b - True", summary="a"
        ): "b",
        ARE_ALL_TRUE_PROMPT.format(
            checked_assertions="- b - True",
        ): "True",
    }
    fake_llm = FakeLLM(queries=queries)
    return LLMSummarizationCheckerChain.from_llm(
        fake_llm, input_key="q", output_key="a"
    )


def test_simple_text(
    fake_llm_summarization_checker_chain: LLMSummarizationCheckerChain,
) -> None:
    """Test simple question that should not need python."""
    question = "a"
    output = fake_llm_summarization_checker_chain.run(question)
    assert output == "b"

Subdomains

Dependencies

  • langchain_classic.chains.llm_summarization_checker.base
  • pytest
  • tests.unit_tests.llms.fake_llm

Frequently Asked Questions

What does test_llm_summarization_checker.py do?
test_llm_summarization_checker.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_llm_summarization_checker.py?
test_llm_summarization_checker.py defines 3 function(s): fake_llm_summarization_checker_chain, test_input_variables, test_simple_text.
What does test_llm_summarization_checker.py depend on?
test_llm_summarization_checker.py imports 3 module(s): langchain_classic.chains.llm_summarization_checker.base, pytest, tests.unit_tests.llms.fake_llm.
Where is test_llm_summarization_checker.py in the architecture?
test_llm_summarization_checker.py is located at libs/langchain/tests/unit_tests/chains/test_llm_summarization_checker.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/tests/unit_tests/chains).

Analyze Your Own Codebase

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

Try Supermodel Free