Home / Function/ lookup() — langchain Function Reference

lookup() — langchain Function Reference

Architecture documentation for the lookup() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  9565a536_6f2d_1c62_4d0c_2f36f91ed655["lookup()"]
  8afabfb7_0c09_a238_4fcf_d1930995022d["DocstoreExplorer"]
  9565a536_6f2d_1c62_4d0c_2f36f91ed655 -->|defined in| 8afabfb7_0c09_a238_4fcf_d1930995022d
  style 9565a536_6f2d_1c62_4d0c_2f36f91ed655 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/react/base.py lines 108–124

    def lookup(self, term: str) -> str:
        """Lookup a term in document (if saved)."""
        if self.document is None:
            msg = "Cannot lookup without a successful search first"
            raise ValueError(msg)
        if term.lower() != self.lookup_str:
            self.lookup_str = term.lower()
            self.lookup_index = 0
        else:
            self.lookup_index += 1
        lookups = [p for p in self._paragraphs if self.lookup_str in p.lower()]
        if len(lookups) == 0:
            return "No Results"
        if self.lookup_index >= len(lookups):
            return "No More Results"
        result_prefix = f"(Result {self.lookup_index + 1}/{len(lookups)})"
        return f"{result_prefix} {lookups[self.lookup_index]}"

Subdomains

Frequently Asked Questions

What does lookup() do?
lookup() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/react/base.py.
Where is lookup() defined?
lookup() is defined in libs/langchain/langchain_classic/agents/react/base.py at line 108.

Analyze Your Own Codebase

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

Try Supermodel Free