Home / File/ tools.py — langchain Source File

tools.py — langchain Source File

Architecture documentation for tools.py, a python file in the langchain codebase. 7 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  42caa1a3_7eac_fb42_5120_f01c6f7d463b["tools.py"]
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> feec1ec4_6917_867b_d228_b134d0ff8099
  0344251d_a425_177d_d810_f45aa8de9600["exa_py"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> 0344251d_a425_177d_d810_f45aa8de9600
  5d33df87_33f9_172a_2864_dd2e31881c5b["exa_py.api"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> 5d33df87_33f9_172a_2864_dd2e31881c5b
  17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> 17a62cb3_fefd_6320_b757_b53bb4a1c661
  121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4
  dd5e7909_a646_84f1_497b_cae69735550e["pydantic"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> dd5e7909_a646_84f1_497b_cae69735550e
  ad09f074_c715_9e1c_1a2c_aaa919862b80["langchain_exa._utilities"]
  42caa1a3_7eac_fb42_5120_f01c6f7d463b --> ad09f074_c715_9e1c_1a2c_aaa919862b80
  style 42caa1a3_7eac_fb42_5120_f01c6f7d463b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Tool for the Exa Search API."""

from __future__ import annotations

from typing import Any, Literal

from exa_py import Exa  # type: ignore[untyped-import]
from exa_py.api import (
    HighlightsContentsOptions,  # type: ignore[untyped-import]
    TextContentsOptions,  # type: ignore[untyped-import]
)
from langchain_core.callbacks import (
    CallbackManagerForToolRun,
)
from langchain_core.tools import BaseTool
from pydantic import Field, SecretStr, model_validator

from langchain_exa._utilities import initialize_client


class ExaSearchResults(BaseTool):  # type: ignore[override]
    r"""Exa Search tool.

    Setup:
        Install `langchain-exa` and set environment variable `EXA_API_KEY`.

        ```bash
        pip install -U langchain-exa
        export EXA_API_KEY="your-api-key"
        ```

    Instantiation:
        ```python
        from langchain-exa import ExaSearchResults

        tool = ExaSearchResults()
        ```

    Invocation with args:
        ```python
        tool.invoke({"query": "what is the weather in SF", "num_results": 1})
        ```

        ```python
        SearchResponse(
            results=[
                Result(
                    url="https://www.wunderground.com/weather/37.8,-122.4",
                    id="https://www.wunderground.com/weather/37.8,-122.4",
                    title="San Francisco, CA Weather Conditionsstar_ratehome",
                    score=0.1843988299369812,
                    published_date="2023-02-23T01:17:06.594Z",
                    author=None,
                    text="The time period when the sun is no more than 6 degrees below the horizon at either sunrise or sunset. The horizon should be clearly defined and the brightest stars should be visible under good atmospheric conditions (i.e. no moonlight, or other lights). One still should be able to carry on ordinary outdoor activities. The time period when the sun is between 6 and 12 degrees below the horizon at either sunrise or sunset. The horizon is well defined and the outline of objects might be visible without artificial light. Ordinary outdoor activities are not possible at this time without extra illumination. The time period when the sun is between 12 and 18 degrees below the horizon at either sunrise or sunset. The sun does not contribute to the illumination of the sky before this time in the morning, or after this time in the evening. In the beginning of morning astronomical twilight and at the end of astronomical twilight in the evening, sky illumination is very faint, and might be undetectable. The time of Civil Sunset minus the time of Civil Sunrise. The time of Actual Sunset minus the time of Actual Sunrise. The change in length of daylight between today and tomorrow is also listed when available.",
                    highlights=None,
                    highlight_scores=None,
                    summary=None,
                )
            ],
            autoprompt_string=None,
// ... (183 more lines)

Domain

Subdomains

Dependencies

  • exa_py
  • exa_py.api
  • langchain_core.callbacks
  • langchain_core.tools
  • langchain_exa._utilities
  • pydantic
  • typing

Frequently Asked Questions

What does tools.py do?
tools.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What does tools.py depend on?
tools.py imports 7 module(s): exa_py, exa_py.api, langchain_core.callbacks, langchain_core.tools, langchain_exa._utilities, pydantic, typing.
Where is tools.py in the architecture?
tools.py is located at libs/partners/exa/langchain_exa/tools.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/partners/exa/langchain_exa).

Analyze Your Own Codebase

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

Try Supermodel Free