codekingpro/portable-devtools
114k
1"""Tool for the Golden API."""2 3from typing import Optional4 5from langchain_core.callbacks import CallbackManagerForToolRun6from langchain_core.tools import BaseTool7 8from langchain_community.utilities.golden_query import GoldenQueryAPIWrapper9 10 11class GoldenQueryRun(BaseTool):12 """Tool that adds the capability to query using the Golden API and get back JSON."""13 14 name: str = "golden_query"15 description: str = (16 "A wrapper around Golden Query API."17 " Useful for getting entities that match"18 " a natural language query from Golden's Knowledge Base."19 "\nExample queries:"20 "\n- companies in nanotech"21 "\n- list of cloud providers starting in 2019"22 "\nInput should be the natural language query."23 "\nOutput is a paginated list of results or an error object"24 " in JSON format."25 )26 api_wrapper: GoldenQueryAPIWrapper27 28 def _run(29 self,30 query: str,31 run_manager: Optional[CallbackManagerForToolRun] = None,32 ) -> str:33 """Use the Golden tool."""34 return self.api_wrapper.run(query)35 