Home / Function/ create_citation_fuzzy_match_chain() — langchain Function Reference

create_citation_fuzzy_match_chain() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py lines 128–169

def create_citation_fuzzy_match_chain(llm: BaseLanguageModel) -> LLMChain:
    """Create a citation fuzzy match chain.

    Args:
        llm: Language model to use for the chain.

    Returns:
        Chain (LLMChain) that can be used to answer questions with citations.
    """
    output_parser = PydanticOutputFunctionsParser(pydantic_schema=QuestionAnswer)
    schema = QuestionAnswer.model_json_schema()
    function = {
        "name": schema["title"],
        "description": schema["description"],
        "parameters": schema,
    }
    llm_kwargs = get_llm_kwargs(function)
    messages = [
        SystemMessage(
            content=(
                "You are a world class algorithm to answer "
                "questions with correct and exact citations."
            ),
        ),
        HumanMessage(content="Answer question using the following context"),
        HumanMessagePromptTemplate.from_template("{context}"),
        HumanMessagePromptTemplate.from_template("Question: {question}"),
        HumanMessage(
            content=(
                "Tips: Make sure to cite your sources, "
                "and use the exact words from the context."
            ),
        ),
    ]
    prompt = ChatPromptTemplate(messages=messages)  # type: ignore[arg-type]

    return LLMChain(
        llm=llm,
        prompt=prompt,
        llm_kwargs=llm_kwargs,
        output_parser=output_parser,
    )

Subdomains

Frequently Asked Questions

What does create_citation_fuzzy_match_chain() do?
create_citation_fuzzy_match_chain() 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_chain() defined?
create_citation_fuzzy_match_chain() is defined in libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py at line 128.

Analyze Your Own Codebase

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

Try Supermodel Free