Home / Function/ grab_literal() — langchain Function Reference

grab_literal() — langchain Function Reference

Architecture documentation for the grab_literal() function in mustache.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5af91928_c2ae_f45b_c4c0_24e4090e4ba6["grab_literal()"]
  88ae0419_8f6b_8b31_dd8f_a3bc6bbcb7b6["mustache.py"]
  5af91928_c2ae_f45b_c4c0_24e4090e4ba6 -->|defined in| 88ae0419_8f6b_8b31_dd8f_a3bc6bbcb7b6
  ee317545_08fa_c1b5_d4bc_6d8f5e1e4e7c["tokenize()"]
  ee317545_08fa_c1b5_d4bc_6d8f5e1e4e7c -->|calls| 5af91928_c2ae_f45b_c4c0_24e4090e4ba6
  style 5af91928_c2ae_f45b_c4c0_24e4090e4ba6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/utils/mustache.py lines 41–63

def grab_literal(template: str, l_del: str) -> tuple[str, str]:
    """Parse a literal from the template.

    Args:
        template: The template to parse.
        l_del: The left delimiter.

    Returns:
        The literal and the template.
    """
    global _CURRENT_LINE

    try:
        # Look for the next tag and move the template to it
        literal, template = template.split(l_del, 1)
        _CURRENT_LINE += literal.count("\n")

    # There are no more tags in the template?
    except ValueError:
        # Then the rest of the template is a literal
        return (template, "")

    return (literal, template)

Domain

Subdomains

Called By

Frequently Asked Questions

What does grab_literal() do?
grab_literal() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/mustache.py.
Where is grab_literal() defined?
grab_literal() is defined in libs/core/langchain_core/utils/mustache.py at line 41.
What calls grab_literal()?
grab_literal() is called by 1 function(s): tokenize.

Analyze Your Own Codebase

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

Try Supermodel Free