LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicchainsquery_constructorbase
    Module●Since v1.0

    base

    LLM Chain for turning a user text query into a structured query.

    Attributes

    attribute
    DEFAULT_EXAMPLES: list
    attribute
    DEFAULT_PREFIX: str
    attribute
    DEFAULT_SCHEMA_PROMPT
    attribute
    DEFAULT_SUFFIX: str
    attribute
    EXAMPLE_PROMPT
    attribute
    EXAMPLES_WITH_LIMIT: list
    attribute
    PREFIX_WITH_DATA_SOURCE
    attribute
    SCHEMA_WITH_LIMIT_PROMPT
    attribute
    SUFFIX_WITHOUT_DATA_SOURCE: str
    attribute
    USER_SPECIFIED_EXAMPLE_PROMPT

    Functions

    function
    get_parser

    Return a parser for the query language.

    function
    fix_filter_directive

    Fix invalid filter directive.

    function
    construct_examples

    Construct examples from input-output pairs.

    function
    get_query_constructor_prompt

    Create query construction prompt.

    function
    load_query_constructor_runnable

    Load a query constructor runnable chain.

    deprecatedfunction
    load_query_constructor_chain

    Load a query constructor chain.

    Classes

    class
    AttributeInfo

    Information about a data source attribute.

    class
    StructuredQueryOutputParser

    Output parser that parses a structured query.

    deprecatedclass
    LLMChain

    Chain to run queries against LLMs.

    This class is deprecated. See below for an example implementation using LangChain runnables:

    from langchain_core.output_parsers import StrOutputParser
    from langchain_core.prompts import PromptTemplate
    from langchain_openai import OpenAI
    
    prompt_template = "Tell me a {adjective} joke"
    prompt = PromptTemplate(input_variables=["adjective"], template=prompt_template)
    model = OpenAI()
    chain = prompt | model | StrOutputParser()
    
    chain.invoke("your adjective here")
    View source on GitHub