Update tools/wiki_tool.py
Browse files- tools/wiki_tool.py +25 -25
tools/wiki_tool.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
-
from langchain.tools import BaseTool
|
| 2 |
-
from langchain_community.utilities import WikipediaAPIWrapper
|
| 3 |
-
from pydantic import PrivateAttr
|
| 4 |
-
|
| 5 |
-
class WikiSearchTool(BaseTool):
|
| 6 |
-
"""
|
| 7 |
-
Инструмент для поиска в English Wikipedia.
|
| 8 |
-
"""
|
| 9 |
-
name: str = "wiki_search"
|
| 10 |
-
description: str =
|
| 11 |
-
_wrapper: WikipediaAPIWrapper = PrivateAttr()
|
| 12 |
-
|
| 13 |
-
def __init__(self) -> None:
|
| 14 |
-
super().__init__()
|
| 15 |
-
self._wrapper = WikipediaAPIWrapper(lang="en")
|
| 16 |
-
|
| 17 |
-
def _run(self, query: str) -> str:
|
| 18 |
-
return self._wrapper.run(query)
|
| 19 |
-
|
| 20 |
-
async def _arun(self, query: str) -> str:
|
| 21 |
-
raise NotImplementedError("Async not supported.")
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 1 |
+
from langchain.tools import BaseTool
|
| 2 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
| 3 |
+
from pydantic import PrivateAttr
|
| 4 |
+
|
| 5 |
+
class WikiSearchTool(BaseTool):
|
| 6 |
+
"""
|
| 7 |
+
Инструмент для поиска в English Wikipedia.
|
| 8 |
+
"""
|
| 9 |
+
name: str = "wiki_search"
|
| 10 |
+
description: str = “Search English Wikipedia articles by keyword/title and return summaries. Use for biographical details, dates, Featured Article look-ups, discographies, or any question answerable from an encyclopedia entry.”
|
| 11 |
+
_wrapper: WikipediaAPIWrapper = PrivateAttr()
|
| 12 |
+
|
| 13 |
+
def __init__(self) -> None:
|
| 14 |
+
super().__init__()
|
| 15 |
+
self._wrapper = WikipediaAPIWrapper(lang="en")
|
| 16 |
+
|
| 17 |
+
def _run(self, query: str) -> str:
|
| 18 |
+
return self._wrapper.run(query)
|
| 19 |
+
|
| 20 |
+
async def _arun(self, query: str) -> str:
|
| 21 |
+
raise NotImplementedError("Async not supported.")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|