Home / Function/ create_citation_fuzzy_match_runnable() — langchain Function Reference

create_citation_fuzzy_match_runnable() — langchain Function Reference

Architecture documentation for the create_citation_fuzzy_match_runnable() function in citation_fuzzy_match.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b25ea880_9c6b_95de_8afa_8a9e6e89f2b4["create_citation_fuzzy_match_runnable()"]
  3fe204c3_507d_e239_ac89_e54bd9ed1a7b["citation_fuzzy_match.py"]
  b25ea880_9c6b_95de_8afa_8a9e6e89f2b4 -->|defined in| 3fe204c3_507d_e239_ac89_e54bd9ed1a7b
  style b25ea880_9c6b_95de_8afa_8a9e6e89f2b4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py lines 77–120

def create_citation_fuzzy_match_runnable(llm: BaseChatModel) -> Runnable:
    """Create a citation fuzzy match Runnable.

    Example usage:

        ```python
        from langchain_classic.chains import create_citation_fuzzy_match_runnable
        from langchain_openai import ChatOpenAI

        model = ChatOpenAI(model="gpt-4o-mini")

        context = "Alice has blue eyes. Bob has brown eyes. Charlie has green eyes."
        question = "What color are Bob's eyes?"

        chain = create_citation_fuzzy_match_runnable(model)
        chain.invoke({"question": question, "context": context})
        ```

    Args:
        llm: Language model to use for the chain. Must implement bind_tools.

    Returns:
        Runnable that can be used to answer questions with citations.

    """
    if type(llm).bind_tools is BaseChatModel.bind_tools:
        msg = "Language model must implement bind_tools to use this function."
        raise ValueError(msg)
    prompt = ChatPromptTemplate(
        [
            SystemMessage(
                "You are a world class algorithm to answer "
                "questions with correct and exact citations.",
            ),
            HumanMessagePromptTemplate.from_template(
                "Answer question using the following context."
                "\n\n{context}"
                "\n\nQuestion: {question}"
                "\n\nTips: Make sure to cite your sources, "
                "and use the exact words from the context.",
            ),
        ],
    )
    return prompt | llm.with_structured_output(QuestionAnswer)

Subdomains

Frequently Asked Questions

What does create_citation_fuzzy_match_runnable() do?
create_citation_fuzzy_match_runnable() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py.
Where is create_citation_fuzzy_match_runnable() defined?
create_citation_fuzzy_match_runnable() is defined in libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py at line 77.

Analyze Your Own Codebase

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

Try Supermodel Free