Source code for langchain_community.tools.jina_search.tool
from __future__ import annotations
from typing import Optional
from langchain_core.callbacks import CallbackManagerForToolRun
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from langchain_community.utilities.jina_search import JinaSearchAPIWrapper
[docs]class JinaSearch(BaseTool):
"""Tool that queries the JinaSearch.
..versionadded:: 0.2.16
"""
name: str = "jina_search"
description: str = (
"Jina Reader allows you to ground your LLM with the latest information from "
"the web. "
"Jina Reader will search the web and return the top five results with their "
"URLs and contents, "
"each in clean, LLM-friendly text. This way, you can always keep your LLM "
"up-to-date, improve its factuality, and reduce hallucinations."
)
search_wrapper: JinaSearchAPIWrapper = Field(default_factory=JinaSearchAPIWrapper)
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
return self.search_wrapper.run(query)