searx: implement async + helper tool providing json results (#2129)

- implemented `arun` and `aresults`. Reuses aiosession if available.
- helper tools `SearxSearchRun` and `SearxSearchResults`
- update doc

Co-authored-by: blob42 <spike@w530>
This commit is contained in:
blob42
2023-03-29 05:49:02 +00:00
committed by GitHub
parent ccee1aedd2
commit 031e32f331
5 changed files with 193 additions and 14 deletions

View File

@@ -47,12 +47,24 @@ s.run("what is a large language model?")
### Tool
You can also easily load this wrapper as a Tool (to use with an Agent).
You can also load this wrapper as a Tool (to use with an Agent).
You can do this with:
```python
from langchain.agents import load_tools
tools = load_tools(["searx-search"], searx_host="http://localhost:8888")
tools = load_tools(["searx-search"],
searx_host="http://localhost:8888",
engines=["github"])
```
Note that we could _optionally_ pass custom engines to use.
If you want to obtain results with metadata as *json* you can use:
```python
tools = load_tools(["searx-search-results-json"],
searx_host="http://localhost:8888",
num_results=5)
```
For more information on tools, see [this page](../modules/agents/tools/getting_started.md)