test_chain_filter.py — langchain Source File
Architecture documentation for test_chain_filter.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR a1d36149_2a50_a9a2_1962_42de634f7391["test_chain_filter.py"] c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] a1d36149_2a50_a9a2_1962_42de634f7391 --> c554676d_b731_47b2_a98f_c1c2d537c0aa ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] a1d36149_2a50_a9a2_1962_42de634f7391 --> ba43b74d_3099_7e1c_aac3_cf594720469e 277d2e28_0cff_6729_d22a_ec3e8c454e81["langchain_classic.retrievers.document_compressors"] a1d36149_2a50_a9a2_1962_42de634f7391 --> 277d2e28_0cff_6729_d22a_ec3e8c454e81 style a1d36149_2a50_a9a2_1962_42de634f7391 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.documents import Document
from langchain_core.language_models import FakeListChatModel
from langchain_classic.retrievers.document_compressors import LLMChainFilter
def test_llm_chain_filter() -> None:
documents = [
Document(
page_content="Candlepin bowling is popular in New England.",
metadata={"a": 1},
),
Document(
page_content="Candlepin bowling balls are smaller.",
metadata={"b": 2},
),
Document(page_content="The moon is round.", metadata={"c": 3}),
]
llm = FakeListChatModel(responses=["YES", "YES", "NO"])
doc_compressor = LLMChainFilter.from_llm(llm)
output = doc_compressor.compress_documents(
documents,
"Tell me about Candlepin bowling.",
)
expected = documents[:2]
assert output == expected
async def test_llm_chain_extractor_async() -> None:
documents = [
Document(
page_content="Candlepin bowling is popular in New England.",
metadata={"a": 1},
),
Document(
page_content="Candlepin bowling balls are smaller.",
metadata={"b": 2},
),
Document(page_content="The moon is round.", metadata={"c": 3}),
]
llm = FakeListChatModel(responses=["YES", "YES", "NO"])
doc_compressor = LLMChainFilter.from_llm(llm)
output = await doc_compressor.acompress_documents(
documents,
"Tell me about Candlepin bowling.",
)
expected = documents[:2]
assert output == expected
Domain
Subdomains
Dependencies
- langchain_classic.retrievers.document_compressors
- langchain_core.documents
- langchain_core.language_models
Source
Frequently Asked Questions
What does test_chain_filter.py do?
test_chain_filter.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_chain_filter.py?
test_chain_filter.py defines 2 function(s): test_llm_chain_extractor_async, test_llm_chain_filter.
What does test_chain_filter.py depend on?
test_chain_filter.py imports 3 module(s): langchain_classic.retrievers.document_compressors, langchain_core.documents, langchain_core.language_models.
Where is test_chain_filter.py in the architecture?
test_chain_filter.py is located at libs/langchain/tests/unit_tests/retrievers/document_compressors/test_chain_filter.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/tests/unit_tests/retrievers/document_compressors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free