Generative AI Toolkit for SAP HANA Cloud

_images/SAP_R_grad2.jpg

Welcome to Generative AI Toolkit for SAP HANA Cloud (hana.ai)!

This package enables the users to access SAP HANA data and build various machine learning models using the data directly in SAP HANA via natural language. This page provides an overview of hana.ai.

Generative AI Toolkit for SAP HANA Cloud consists of four main parts:

  • AI tools, which provides a set of tools to analyze data and build machine learning models.

  • HANA Vector Store and Knowledge Base API, which provides a way to store and retrieve vectors and knowledge bases.

  • Smart DataFrame, which is a HANA dataframe Agent to interact with HANA data.

  • Chatbot Agents, which provides a way to interact with the AI tools and HANA Vector Store and Knowledge Base API via natural language.

Prerequisites

Langchain Agent with HANAML Toolkit

HANAML Toolkit is a set of tools to analyze data and build machine learning models using the data directly in SAP HANA. It can be consumed by AI Agent. cc is a connection to a SAP HANA instance.

from hana_ai.agents.hanaml_rag_agent import HANAMLRAGAgent
from hana_ai.tools.toolkit import HANAMLToolkit

tools = HANAMLToolkit(connection_context=cc, used_tools='all').get_tools()
chatbot = HANAMLRAGAgent(llm=llm, tools=tools, verbose=True, vector_store_type="hanadb")
A chatbot with HANAML Toolkit.

HANA Vector Store and Knowledge Base API

Create Knowledge Base for hana-ml codes in HANA Vector Engine.

hana_vec = HANAMLinVectorEngine(connection_context=cc, table_name="hana_vec_hana_ml_knowledge")
hana_vec.create_knowledge()

Create Code Template Tool and Add Knowledge Bases to It

Create a code template tool and add knowledge bases to it.

from hana_ai.tools.code_template_tools import GetCodeTemplateFromVectorDB

code_tool = GetCodeTemplateFromVectorDB()
code_tool.set_vectordb(vectordb=self.vectordb)

Create HANA Dataframe Agent and Execute Task

Create a HANA dataframe agent and execute a task.

from hana_ai.agents.hana_dataframe_agent import create_hana_dataframe_agent

agent = create_hana_dataframe_agent(llm=llm, df=data, verbose=True)
agent.invoke("Create Automatic Regression model on this dataframe with max_eval_time_mins=10. Provide key is ID, background_size=100 and model_table_name='my_model' in the fit function and execute it. ")
A HANA dataframe agent to build model.

Build a dataset report.

agent.invoke("Build a dataset report")
A HANA dataframe agent to generate a dataset report.

Smart DataFrame

Smart DataFrame is a HANA dataframe Agent to interact with HANA data.

from hana_ai.smart_dataframe import SmartDataFrame

sdf = SmartDataFrame(dataframe=hana_df)
sdf.configure(llm=llm)
new_df = sdf.transform(question="Get first two rows", verbose=True)
new_df.collect()
A Smart DataFrame's transformed result.