Home / Class/ ExaSearchResults Class — langchain Architecture

ExaSearchResults Class — langchain Architecture

Architecture documentation for the ExaSearchResults class in tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d1cd17ae_5381_3dd6_4d26_fee4a361375b["ExaSearchResults"]
  18e85ff8_9a5d_f800_f722_027398dc89e7["BaseTool"]
  d1cd17ae_5381_3dd6_4d26_fee4a361375b -->|extends| 18e85ff8_9a5d_f800_f722_027398dc89e7
  42caa1a3_7eac_fb42_5120_f01c6f7d463b["tools.py"]
  d1cd17ae_5381_3dd6_4d26_fee4a361375b -->|defined in| 42caa1a3_7eac_fb42_5120_f01c6f7d463b
  7fb23801_7fde_e064_177e_417e4c41bef9["validate_environment()"]
  d1cd17ae_5381_3dd6_4d26_fee4a361375b -->|method| 7fb23801_7fde_e064_177e_417e4c41bef9
  2ca892f8_801d_f665_c823_eced16c2ea0d["_run()"]
  d1cd17ae_5381_3dd6_4d26_fee4a361375b -->|method| 2ca892f8_801d_f665_c823_eced16c2ea0d

Relationship Graph

Source Code

libs/partners/exa/langchain_exa/tools.py lines 21–161

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,
        )
        ```

    Invocation with ToolCall:

        ```python
        tool.invoke(
            {
                "args": {"query": "what is the weather in SF", "num_results": 1},
                "id": "1",
                "name": tool.name,
                "type": "tool_call",
            }
        )
        ```

        ```python
        ToolMessage(
            content="Title: San Francisco, CA Weather Conditionsstar_ratehome\nURL: https://www.wunderground.com/weather/37.8,-122.4\nID: https://www.wunderground.com/weather/37.8,-122.4\nScore: 0.1843988299369812\nPublished Date: 2023-02-23T01:17:06.594Z\nAuthor: None\nText: 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.\nHighlights: None\nHighlight Scores: None\nSummary: None\n",
            name="exa_search_results_json",
            tool_call_id="1",
        )
        ```
    """  # noqa: E501

    name: str = "exa_search_results_json"
    description: str = (
        "A wrapper around Exa Search. "
        "Input should be an Exa-optimized query. "
        "Output is a JSON array of the query results"
    )
    client: Exa = Field(default=None)  # type: ignore[assignment]
    exa_api_key: SecretStr = Field(default=SecretStr(""))

    @model_validator(mode="before")
    @classmethod
    def validate_environment(cls, values: dict) -> Any:
        """Validate the environment."""
        return initialize_client(values)

    def _run(

Extends

Frequently Asked Questions

What is the ExaSearchResults class?
ExaSearchResults is a class in the langchain codebase, defined in libs/partners/exa/langchain_exa/tools.py.
Where is ExaSearchResults defined?
ExaSearchResults is defined in libs/partners/exa/langchain_exa/tools.py at line 21.
What does ExaSearchResults extend?
ExaSearchResults extends BaseTool.

Analyze Your Own Codebase

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

Try Supermodel Free