test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cd9d676b_9b03_dca2_ee62_ebe70d80dc57["test_base.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 120e2591_3e15_b895_72b6_cb26195e40a6 e8ec017e_6c91_4b34_675f_2a96c5aa9be6["langchain_core.callbacks.manager"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> e8ec017e_6c91_4b34_675f_2a96c5aa9be6 c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> c554676d_b731_47b2_a98f_c1c2d537c0aa df467e5f_e8f3_1115_76cf_5cb823192a54["langchain_core.structured_query"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> df467e5f_e8f3_1115_76cf_5cb823192a54 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 91721f45_4909_e489_8c1f_084f8bd87145 6edc7348_6166_ff58_d0ba_4ff196040908["langchain_classic.chains.query_constructor.schema"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 6edc7348_6166_ff58_d0ba_4ff196040908 c0f56003_5236_544a_87a7_b51b1dd44e68["langchain_classic.retrievers"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> c0f56003_5236_544a_87a7_b51b1dd44e68 74a1bb82_932f_5eb6_2729_8e5fde9663f3["tests.unit_tests.indexes.test_indexing"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 74a1bb82_932f_5eb6_2729_8e5fde9663f3 7e88f5ce_ff41_7d87_8fb2_f355489a149e["tests.unit_tests.llms.fake_llm"] cd9d676b_9b03_dca2_ee62_ebe70d80dc57 --> 7e88f5ce_ff41_7d87_8fb2_f355489a149e style cd9d676b_9b03_dca2_ee62_ebe70d80dc57 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Any
import pytest
from langchain_core.callbacks.manager import (
AsyncCallbackManagerForRetrieverRun,
CallbackManagerForRetrieverRun,
)
from langchain_core.documents import Document
from langchain_core.structured_query import (
Comparator,
Comparison,
Operation,
Operator,
StructuredQuery,
Visitor,
)
from typing_extensions import override
from langchain_classic.chains.query_constructor.schema import AttributeInfo
from langchain_classic.retrievers import SelfQueryRetriever
from tests.unit_tests.indexes.test_indexing import InMemoryVectorStore
from tests.unit_tests.llms.fake_llm import FakeLLM
class FakeTranslator(Visitor):
allowed_comparators = (
Comparator.EQ,
Comparator.NE,
Comparator.LT,
Comparator.LTE,
Comparator.GT,
Comparator.GTE,
Comparator.CONTAIN,
Comparator.LIKE,
)
allowed_operators = (Operator.AND, Operator.OR, Operator.NOT)
def _format_func(self, func: Operator | Comparator) -> str:
self._validate_func(func)
return f"${func.value}"
def visit_operation(self, operation: Operation) -> dict:
args = [arg.accept(self) for arg in operation.arguments]
return {self._format_func(operation.operator): args}
def visit_comparison(self, comparison: Comparison) -> dict:
return {
comparison.attribute: {
self._format_func(comparison.comparator): comparison.value,
},
}
def visit_structured_query(
self,
structured_query: StructuredQuery,
) -> tuple[str, dict]:
if structured_query.filter is None:
kwargs = {}
else:
kwargs = {"filter": structured_query.filter.accept(self)}
// ... (89 more lines)
Domain
Subdomains
Functions
Dependencies
- langchain_classic.chains.query_constructor.schema
- langchain_classic.retrievers
- langchain_core.callbacks.manager
- langchain_core.documents
- langchain_core.structured_query
- pytest
- tests.unit_tests.indexes.test_indexing
- tests.unit_tests.llms.fake_llm
- typing
- typing_extensions
Source
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, RunnableInterface subdomain.
What functions are defined in test_base.py?
test_base.py defines 5 function(s): fake_llm, fake_self_query_retriever, fake_vectorstore, test__aget_relevant_documents, test__get_relevant_documents.
What does test_base.py depend on?
test_base.py imports 10 module(s): langchain_classic.chains.query_constructor.schema, langchain_classic.retrievers, langchain_core.callbacks.manager, langchain_core.documents, langchain_core.structured_query, pytest, tests.unit_tests.indexes.test_indexing, tests.unit_tests.llms.fake_llm, and 2 more.
Where is test_base.py in the architecture?
test_base.py is located at libs/langchain/tests/unit_tests/retrievers/self_query/test_base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/tests/unit_tests/retrievers/self_query).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free