Home / Function/ get_parser() — langchain Function Reference

get_parser() — langchain Function Reference

Architecture documentation for the get_parser() function in parser.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  db692476_8c7d_0ce9_dc64_3bd4ed4d869e["get_parser()"]
  1ae7993b_d5cf_8ebd_a7db_4833692784eb["parser.py"]
  db692476_8c7d_0ce9_dc64_3bd4ed4d869e -->|defined in| 1ae7993b_d5cf_8ebd_a7db_4833692784eb
  style db692476_8c7d_0ce9_dc64_3bd4ed4d869e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/query_constructor/parser.py lines 257–280

def get_parser(
    allowed_comparators: Sequence[Comparator] | None = None,
    allowed_operators: Sequence[Operator] | None = None,
    allowed_attributes: Sequence[str] | None = None,
) -> Lark:
    """Return a parser for the query language.

    Args:
        allowed_comparators: The allowed comparators.
        allowed_operators: The allowed operators.
        allowed_attributes: The allowed attributes.

    Returns:
        Lark parser for the query language.
    """
    if not _HAS_LARK:
        msg = "Cannot import lark, please install it with 'pip install lark'."
        raise ImportError(msg)
    transformer = QueryTransformer(
        allowed_comparators=allowed_comparators,
        allowed_operators=allowed_operators,
        allowed_attributes=allowed_attributes,
    )
    return Lark(GRAMMAR, parser="lalr", transformer=transformer, start="program")

Subdomains

Frequently Asked Questions

What does get_parser() do?
get_parser() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/query_constructor/parser.py.
Where is get_parser() defined?
get_parser() is defined in libs/langchain/langchain_classic/chains/query_constructor/parser.py at line 257.

Analyze Your Own Codebase

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

Try Supermodel Free