mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
a79345f199
#16396 Fixed 1. golden_query 2. google_lens 3. memorize 4. merriam_webster 5. open_weather_map 6. pub_med 7. stack_exchange 8. generate_image 9. wikipedia
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Tool for the Golden API."""
|
|
|
|
from typing import Optional
|
|
|
|
from langchain_core.callbacks import CallbackManagerForToolRun
|
|
from langchain_core.tools import BaseTool
|
|
|
|
from langchain_community.utilities.golden_query import GoldenQueryAPIWrapper
|
|
|
|
|
|
class GoldenQueryRun(BaseTool):
|
|
"""Tool that adds the capability to query using the Golden API and get back JSON."""
|
|
|
|
name: str = "golden_query"
|
|
description: str = (
|
|
"A wrapper around Golden Query API."
|
|
" Useful for getting entities that match"
|
|
" a natural language query from Golden's Knowledge Base."
|
|
"\nExample queries:"
|
|
"\n- companies in nanotech"
|
|
"\n- list of cloud providers starting in 2019"
|
|
"\nInput should be the natural language query."
|
|
"\nOutput is a paginated list of results or an error object"
|
|
" in JSON format."
|
|
)
|
|
api_wrapper: GoldenQueryAPIWrapper
|
|
|
|
def _run(
|
|
self,
|
|
query: str,
|
|
run_manager: Optional[CallbackManagerForToolRun] = None,
|
|
) -> str:
|
|
"""Use the Golden tool."""
|
|
return self.api_wrapper.run(query)
|