diff --git a/docs/extras/ecosystem/integrations/searx.mdx b/docs/extras/ecosystem/integrations/searx.mdx index e562a9a6..6d5d3c17 100644 --- a/docs/extras/ecosystem/integrations/searx.mdx +++ b/docs/extras/ecosystem/integrations/searx.mdx @@ -67,4 +67,24 @@ tools = load_tools(["searx-search-results-json"], num_results=5) ``` -For more information on tools, see [this page](/docs/modules/agents/tools/getting_started.md) +#### Quickly creating tools + +This examples showcases a quick way to create multiple tools from the same +wrapper. + +```python +from langchain.tools.searx_search.tool import SearxSearchResults + +wrapper = SearxSearchWrapper(searx_host="**") +github_tool = SearxSearchResults(name="Github", wrapper=wrapper, + kwargs = { + "engines": ["github"], + }) + +arxiv_tool = SearxSearchResults(name="Arxiv", wrapper=wrapper, + kwargs = { + "engines": ["arxiv"] + }) +``` + +For more information on tools, see [this page](../modules/agents/tools/getting_started.md) diff --git a/langchain/tools/searx_search/tool.py b/langchain/tools/searx_search/tool.py index bbec029f..9088d265 100644 --- a/langchain/tools/searx_search/tool.py +++ b/langchain/tools/searx_search/tool.py @@ -1,5 +1,5 @@ """Tool for the SearxNG search API.""" -from typing import Optional, Any +from typing import Optional from pydantic import Extra @@ -21,7 +21,7 @@ class SearxSearchRun(BaseTool): "Input should be a search query." ) wrapper: SearxSearchWrapper - kwargs: dict[Any, Any] = Field(default_factory=dict) + kwargs: dict = Field(default_factory=dict) def _run( self, @@ -51,7 +51,7 @@ class SearxSearchResults(BaseTool): ) wrapper: SearxSearchWrapper num_results: int = 4 - kwargs: dict[Any, Any] = Field(default_factory=dict) + kwargs: dict = Field(default_factory=dict) class Config: """Pydantic config.""" @@ -72,4 +72,6 @@ class SearxSearchResults(BaseTool): run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the tool asynchronously.""" - return (await self.wrapper.aresults(query, self.num_results, **self.kwargs)).__str__() + return ( + await self.wrapper.aresults(query, self.num_results, **self.kwargs) + ).__str__() diff --git a/langchain/utilities/searx_search.py b/langchain/utilities/searx_search.py index 8feb6c76..eb5c0102 100644 --- a/langchain/utilities/searx_search.py +++ b/langchain/utilities/searx_search.py @@ -120,7 +120,8 @@ Public searxNG instances often use a rate limiter for API usage, so you might wa use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your -own network as described `here `_. +own network as described +`here `_. For a list of public SearxNG instances see https://searx.space/