create_hana_sql_agent
- hana_ai.agents.hana_sql_agent.create_hana_sql_agent(llm: any, connection_context: ConnectionContext, tools: BaseTool = None, agent_type: AgentType | Literal['openai-tools', 'tool-calling'] | None = AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager: BaseCallbackManager | None = None, prefix: str | None = None, suffix: str | None = None, format_instructions: str | None = None, input_variables: List[str] | None = None, top_k: int = 10, max_iterations: int | None = 15, max_execution_time: float | None = None, early_stopping_method: str = 'force', verbose: bool = False, agent_executor_kwargs: Dict[str, Any] | None = None, extra_tools: Sequence[BaseTool] = (), *, prompt: BasePromptTemplate | None = None, **kwargs: Any)
Create a HANA SQL agent.
- Parameters:
- llm: any
The language model to use.
- tools: BaseTool
The tools to use.
- agent_type: Union[AgentType, Literal["openai-tools", "tool-calling"]], optional
The type of agent to create.
- callback_manager: BaseCallbackManager, optional
The callback manager to use.
- prefix: str, optional
The prefix to use.
- suffix: str, optional
The suffix to use.
- format_instructions: str, optional
The format instructions to use.
- input_variables: List[str], optional
The input variables to use.
- top_k: int
The top k to use.
- max_iterations: int, optional
The max iterations to use.
- max_execution_time: float, optional
The max execution time to use.
- early_stopping_method: str
The early stopping method to use.
- verbose: bool
The verbose to use.
- agent_executor_kwargs: Dict[str, Any], optional
The agent executor kwargs to use.
- extra_tools: Sequence[BaseTool]
The extra tools to use.
- db: SQLDatabase, optional
The database to use.
- connection_context: ConnectionContext
The connection context to use.
- prompt: BasePromptTemplate, optional
The prompt to use.
- kwargs: Any
The kwargs to use.
Examples
Assume cc is a connection to a SAP HANA instance:
>>> from hana_ai.agents.hana_sql_agent import create_hana_sql_agent >>> from hana_ai.tools.code_template_tools import GetCodeTemplateFromVectorDB >>> from hana_ai.vectorstore.hana_vector_engine import HANAMLinVectorEngine
>>> hana_vec = HANAMLinVectorEngine(connection_context=cc, table_name="hana_vec_hana_ml_sql_knowledge") >>> hana_vec.create_knowledge(option='sql') >>> code_tool = GetCodeTemplateFromVectorDB() >>> code_tool.set_vectordb(vectordb=hana_vec) >>> agent_executor = create_hana_sql_agent(llm=llm, connection_context=cc, tools=[code_tool], verbose=True) >>> agent_executor.invoke("show me the min and max value of sepalwidthcm in the table iris_data_full_tbl?")