This lesson demonstrates how to use the SDK to interact with the Orchestration Service, enabling the creation of AI-driven workflows by seamlessly integrating various modules, such as templating, large language models (LLMs), data masking and content filtering. By leveraging these modules, you can build complex, automated workflows that enhance the capabilities of your AI solutions. For more details on configuring and using these modules, please refer to the Orchestration Service Documentation.
Jupyter Notebook Extension in Business Application Studio
This exercise uses the Jupyter Notebooks extension in SAP Business Application Studio (BAS).
Click here to open the Business Application Studio.
Log in with your user () and provided credentials.
In the landing page for BAS, click on Create Dev Space to create a virtual environment in which to start a project.
For the Dev Space name, use _GenAIHub and select SAP HANA Native Application as the application type. On the right hand side, under the list of Additional SAP Extensions, choose Python Tools and then select Create Dev Space to start the process. This will create a dedicated development environment with all the tools required to run the notebook.

It will take a few minutes for the Dev Space to start up. The status can be seen beside the name.

Once the status changes to Running, click on the name (_VectorDB) to open it.

The Welcome to SAP HANA page will appear. Follow the sequence to login to Cloud Foundry.

The Cloud Foundry Sign In panel will appear with the following options selected:
| Login Option | Selection |
|---|---|
| Cloud Foundry Endpoint | {placeholder|cfapi_coreai} |
| Authentication method | SSO Passcode |
Select the Open a new browser page to generate your SSO passcode

Choose the identity provider when prompted and enter the academy-platform provider then select the Sign in with alternative provider option.

Copy the newly generate passcode.

Paste the copied passcode in the Enter your SSO passcode field.

Sign into the Cloud Foundry Target by clicking the Sign In button.

Proceed by selecting the desired Cloud Foundry Target and Space as seen below.
| Cloud Foundry Target | Selection |
|---|---|
| Cloud Foundry Organization | {placeholder|cforg_coreai} |
| Space | dev |
Select Apply

Notice the all the services associated with the target

The following steps are to setup the required notebook.
On the Get Started page in Business Application Studio, select the option Clone from Git to import a repository from Github.

A prompt will appear on top asking for a URL to the repository. Copy and paste in the following URL and then press Enter.
1https://github.com/SAP-samples/sap-genai-hub-with-sap-hana-cloud-vector-engine.git
The following message will appear. Select Open to see the imported files in the Explorer window.

The files should now be visible in the Explorer pane on the left hand side. Select the Jupyter Notebook genAI_orchestration.ipynb to open it.


Open a new terminal in BAS by following the numbered sequence of steps.

Change to the bin folder where the cf_create_bas_sso.py script is located.
To change folder use the following shell command as seen below:
1cd bin
Create the SAP AI Core service key by executing the following command from the bin folder.
1python3 cf_create_bas_sso.py --service "default_aicore" --service_key {placeholder|userid}_key
The script will indicate if the creation was successful or not.

The notebook, with executable code cells, will be displayed on the screen.

In the next section the python environment will be configured so that the code cells can be executed from within the Jupyter notebook.
Run the first code cell to install the required python modules.

When the first cell is executed, a prompt asking to choose a kernel source will appear. Select Python Environments.

On the next screen, select the recommended Python kernel (3.11.2).


Once the libraries have been successfully installed, the kernel must be restarted. Do this by clicking on the Restart option in the menu bar at the top.

On the following pop-up message box, click on Restart again to complete the process.

Please follow the instructions in the Jupyter Notebook in BAS to continue with the rest of the lesson. For the section on connecting to the GenAI Hub orchestration API please use the following as the endpoint for YOUR_API_URL:
1{placeholder|genAI_orchestration_API_ph}
Copy and paste the YOUR_API_URL when prompted as seen below and press Enter:

