Source code for langchain_community.tools.stackexchange.tool

"""Wikipedia API的工具。"""

from typing import Optional

from langchain_core.callbacks import CallbackManagerForToolRun
from langchain_core.tools import BaseTool

from langchain_community.utilities.stackexchange import StackExchangeAPIWrapper


[docs]class StackExchangeTool(BaseTool): """使用StackExchange的工具""" name: str = "stack_exchange" description: str = ( "A wrapper around StackExchange. " "Useful for when you need to answer specific programming questions" "code excerpts, code examples and solutions" "Input should be a fully formed question." ) api_wrapper: StackExchangeAPIWrapper def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """使用Stack Exchange工具。""" return self.api_wrapper.run(query)