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.")