citation_fuzzy_match.py — langchain Source File
Architecture documentation for citation_fuzzy_match.py, a python file in the langchain codebase. 11 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3fe204c3_507d_e239_ac89_e54bd9ed1a7b["citation_fuzzy_match.py"] 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 2bf6d401_816d_d011_3b05_a6114f55ff58 2485b66a_3839_d0b6_ad9c_a4ff40457dc6["langchain_core._api"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 2485b66a_3839_d0b6_ad9c_a4ff40457dc6 e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> e929cf21_6ab8_6ff3_3765_0d35a099a053 9444498b_8066_55c7_b3a2_1d90c4162a32["langchain_core.messages"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 9444498b_8066_55c7_b3a2_1d90c4162a32 2b2663e7_3c78_e2fb_75f2_99a68ca124a7["langchain_core.output_parsers.openai_functions"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 2b2663e7_3c78_e2fb_75f2_99a68ca124a7 16c7d167_e2e4_cd42_2bc2_d182459cd93c["langchain_core.prompts.chat"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 16c7d167_e2e4_cd42_2bc2_d182459cd93c 31eab4ab_7281_1e6c_b17d_12e6ad9de07a["langchain_core.runnables"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 31eab4ab_7281_1e6c_b17d_12e6ad9de07a dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> dd5e7909_a646_84f1_497b_cae69735550e 4044d59c_c0a5_a371_f49b_bea3da4e20ac["langchain_classic.chains.llm"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 4044d59c_c0a5_a371_f49b_bea3da4e20ac 0c185122_d3ba_0c43_f0ed_a34e98a95301["langchain_classic.chains.openai_functions.utils"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> 0c185122_d3ba_0c43_f0ed_a34e98a95301 ed175c43_8914_9c84_fa26_62b3db653cc2["regex"] 3fe204c3_507d_e239_ac89_e54bd9ed1a7b --> ed175c43_8914_9c84_fa26_62b3db653cc2 style 3fe204c3_507d_e239_ac89_e54bd9ed1a7b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from collections.abc import Iterator
from langchain_core._api import deprecated
from langchain_core.language_models import BaseChatModel, BaseLanguageModel
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_core.output_parsers.openai_functions import PydanticOutputFunctionsParser
from langchain_core.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain_core.runnables import Runnable
from pydantic import BaseModel, Field
from langchain_classic.chains.llm import LLMChain
from langchain_classic.chains.openai_functions.utils import get_llm_kwargs
class FactWithEvidence(BaseModel):
"""Class representing a single statement.
Each fact has a body and a list of sources.
If there are multiple facts make sure to break them apart
such that each one only uses a set of sources that are relevant to it.
"""
fact: str = Field(..., description="Body of the sentence, as part of a response")
substring_quote: list[str] = Field(
...,
description=(
"Each source should be a direct quote from the context, "
"as a substring of the original content"
),
)
def _get_span(self, quote: str, context: str, errs: int = 100) -> Iterator[str]:
import regex
minor = quote
major = context
errs_ = 0
s = regex.search(f"({minor}){{e<={errs_}}}", major)
while s is None and errs_ <= errs:
errs_ += 1
s = regex.search(f"({minor}){{e<={errs_}}}", major)
if s is not None:
yield from s.spans()
def get_spans(self, context: str) -> Iterator[str]:
"""Get spans of the substring quote in the context.
Args:
context: The context in which to find the spans of the substring quote.
Returns:
An iterator over the spans of the substring quote in the context.
"""
for quote in self.substring_quote:
yield from self._get_span(quote, context)
class QuestionAnswer(BaseModel):
// ... (110 more lines)
Domain
Subdomains
Classes
Dependencies
- collections.abc
- langchain_classic.chains.llm
- langchain_classic.chains.openai_functions.utils
- langchain_core._api
- langchain_core.language_models
- langchain_core.messages
- langchain_core.output_parsers.openai_functions
- langchain_core.prompts.chat
- langchain_core.runnables
- pydantic
- regex
Source
Frequently Asked Questions
What does citation_fuzzy_match.py do?
citation_fuzzy_match.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ClassicChains subdomain.
What functions are defined in citation_fuzzy_match.py?
citation_fuzzy_match.py defines 2 function(s): create_citation_fuzzy_match_chain, create_citation_fuzzy_match_runnable.
What does citation_fuzzy_match.py depend on?
citation_fuzzy_match.py imports 11 module(s): collections.abc, langchain_classic.chains.llm, langchain_classic.chains.openai_functions.utils, langchain_core._api, langchain_core.language_models, langchain_core.messages, langchain_core.output_parsers.openai_functions, langchain_core.prompts.chat, and 3 more.
Where is citation_fuzzy_match.py in the architecture?
citation_fuzzy_match.py is located at libs/langchain/langchain_classic/chains/openai_functions/citation_fuzzy_match.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/chains/openai_functions).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free