load_query_constructor_runnable() — langchain Function Reference
Architecture documentation for the load_query_constructor_runnable() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8be56ad0_9949_1505_8cd9_95bdbee1ff5d["load_query_constructor_runnable()"] 7225abf9_cc63_55f0_0ae9_9fa5685b39ff["base.py"] 8be56ad0_9949_1505_8cd9_95bdbee1ff5d -->|defined in| 7225abf9_cc63_55f0_0ae9_9fa5685b39ff 445d6da1_3574_d2ff_dd74_d9fd7b77b470["get_query_constructor_prompt()"] 8be56ad0_9949_1505_8cd9_95bdbee1ff5d -->|calls| 445d6da1_3574_d2ff_dd74_d9fd7b77b470 a1a96dfd_ae4c_e804_cc3c_fa1f0626d568["from_components()"] 8be56ad0_9949_1505_8cd9_95bdbee1ff5d -->|calls| a1a96dfd_ae4c_e804_cc3c_fa1f0626d568 style 8be56ad0_9949_1505_8cd9_95bdbee1ff5d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/query_constructor/base.py lines 326–381
def load_query_constructor_runnable(
llm: BaseLanguageModel,
document_contents: str,
attribute_info: Sequence[AttributeInfo | dict],
*,
examples: Sequence | None = None,
allowed_comparators: Sequence[Comparator] = tuple(Comparator),
allowed_operators: Sequence[Operator] = tuple(Operator),
enable_limit: bool = False,
schema_prompt: BasePromptTemplate | None = None,
fix_invalid: bool = False,
**kwargs: Any,
) -> Runnable:
"""Load a query constructor runnable chain.
Args:
llm: BaseLanguageModel to use for the chain.
document_contents: Description of the page contents of the document to be
queried.
attribute_info: Sequence of attributes in the document.
examples: Optional list of examples to use for the chain.
allowed_comparators: Sequence of allowed comparators. Defaults to all
`Comparator` objects.
allowed_operators: Sequence of allowed operators. Defaults to all `Operator`
objects.
enable_limit: Whether to enable the limit operator.
schema_prompt: Prompt for describing query schema. Should have string input
variables allowed_comparators and allowed_operators.
fix_invalid: Whether to fix invalid filter directives by ignoring invalid
operators, comparators and attributes.
kwargs: Additional named params to pass to FewShotPromptTemplate init.
Returns:
A Runnable that can be used to construct queries.
"""
prompt = get_query_constructor_prompt(
document_contents,
attribute_info,
examples=examples,
allowed_comparators=allowed_comparators,
allowed_operators=allowed_operators,
enable_limit=enable_limit,
schema_prompt=schema_prompt,
**kwargs,
)
allowed_attributes = [
ainfo.name if isinstance(ainfo, AttributeInfo) else ainfo["name"]
for ainfo in attribute_info
]
output_parser = StructuredQueryOutputParser.from_components(
allowed_comparators=allowed_comparators,
allowed_operators=allowed_operators,
allowed_attributes=allowed_attributes,
fix_invalid=fix_invalid,
)
return prompt | llm | output_parser
Domain
Subdomains
Source
Frequently Asked Questions
What does load_query_constructor_runnable() do?
load_query_constructor_runnable() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/query_constructor/base.py.
Where is load_query_constructor_runnable() defined?
load_query_constructor_runnable() is defined in libs/langchain/langchain_classic/chains/query_constructor/base.py at line 326.
What does load_query_constructor_runnable() call?
load_query_constructor_runnable() calls 2 function(s): from_components, get_query_constructor_prompt.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free