Spaces:
Sleeping
Sleeping
Download tools/wiki_tool.py from olcapone/final_exam: direct link, hf CLI and curl.
- Browser
- Download file 864 Bytes
-
https://huggingface.co/spaces/olcapone/final_exam/resolve/main/tools/wiki_tool.py
- Command line
-
hf download hf://spaces/olcapone/final_exam/tools/wiki_tool.py
-
curl -L -o wiki_tool.py https://huggingface.co/spaces/olcapone/final_exam/resolve/main/tools/wiki_tool.py
864 Bytes
| from langchain.tools import BaseTool | |
| from langchain_community.utilities import WikipediaAPIWrapper | |
| from pydantic import PrivateAttr | |
| class WikiSearchTool(BaseTool): | |
| """ | |
| Инструмент для поиска в English Wikipedia. | |
| """ | |
| name: str = "wiki_search" | |
| 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." | |
| _wrapper: WikipediaAPIWrapper = PrivateAttr() | |
| def __init__(self) -> None: | |
| super().__init__() | |
| self._wrapper = WikipediaAPIWrapper(lang="en") | |
| def _run(self, query: str) -> str: | |
| return self._wrapper.run(query) | |
| async def _arun(self, query: str) -> str: | |
| raise NotImplementedError("Async not supported.") | |