Source code for langchain_community.tools.dataherald.tool
"""Tool for the Dataherald Hosted API"""fromtypingimportOptional,Typefromlangchain_core.callbacksimportCallbackManagerForToolRunfromlangchain_core.toolsimportBaseToolfrompydanticimportBaseModel,Fieldfromlangchain_community.utilities.dataheraldimportDataheraldAPIWrapper
[docs]classDataheraldTextToSQLInput(BaseModel):prompt:str=Field(description="Natural language query to be translated to a SQL query.")
[docs]classDataheraldTextToSQL(BaseTool):# type: ignore[override, override]"""Tool that queries using the Dataherald SDK."""name:str="dataherald"description:str=("A wrapper around Dataherald. ""Text to SQL. ""Input should be a prompt and an existing db_connection_id")api_wrapper:DataheraldAPIWrapperargs_schema:Type[BaseModel]=DataheraldTextToSQLInputdef_run(self,prompt:str,run_manager:Optional[CallbackManagerForToolRun]=None,)->str:"""Use the Dataherald tool."""returnself.api_wrapper.run(prompt)