This repo wants to give users of the SAP Business Technology Platform (BTP) a quick way to learn how to use generative AI with BTP services.
-
You have access to an SAP BTP global account or an existing SAP BTP sub account.
-
Visual Studio Code
is installed on your machine with theDev Container
extension. You understand purpose and basic concepts of Dev Containers in VS Code. -
As prerequisite for using dev containers,
Docker
is installed on your machine and you understand its basics concepts. -
Git
is available on your machine (test withgit --version
) and you know how to clone a project from github. -
The SAP BTP global account needs to be sufficiently entitled to use the following services and applications:
Name Service/ Application Plan AI Core aicore
(service)extended
AI Launchpad (optional) ai-launchpad
(app subscription)standard
HANA Cloud hana-cloud
(service)hana
HANA Cloud Tools hana-cloud-tools
(app subscription)tools
- Clone this GitHub repository to your local machine and open it in VS Code.
- Open the Dev Container on your machine from within VS Code (
Reopen in Dev Container
). - Wait for the dev container to be built and the project to be loaded within it.
Be aware that opening the dev container can take a while!
- In the folder
config/secrets
rename the filebtp_ai_setup.tfvars
tomy_btp_ai_setup.tfvars
.- adapt the value for
globalaccount
for the subaccount to be created within. You find in the global account landing page ("Subdomain: ....."). - if you would like to use custom IDP, provide the value for
idp
e.g.<your-ias-tenant>.accounts.ondemand.com
. - add your email address to the variable
admins
. This should be looking similar to this:admins = ["your.email@sap.com"]
. - save the file.
- adapt the value for
- In the folder
config/secrets
rename the filebtp_credentials.tfvars
tomy_btp_credentials.tfvars
.- adapt the value for the variable
BTP_USERNAME
to your email address. - save the file.
- adapt the value for the variable
- Within VS Code open a terminal session.
- In the terminal simply type
./run.sh
and enter yourBTP_PASSWORD
as well as the password for theHANA DB
(you will be prompted accordingly).Make sure that the password for the HANA DB matches the minimum requirements (length >= 8, 1+ upper case chars, 2+ lower case chars, 1+ digit)!
In case you want to authenticate via Single-Sign-On (SSO) you should set the enironment variable
BTP_ENABLE_SSO
totrue
. You do this by running the following command within your dev container:export BTP_ENABLE_SSO=true
The startet script will now setup the following things for you in your SAP BTP global account:
- It creates a subaccount with the name configured in the
my_btp_ai_setup.tfvars
file (folderconfig/secrets
). - It creates service instances/subscriptions for the following services
- SAP AI Core (service)
- SAP HANA Cloud (service) with integrated vector engine
- SAP HANA Cloud tools (app subscription)
- It creates a file called
.env
that will be copied into theconfig/secrets
folder.
The second step will automatically be taken care of by the running
./run.sh
command from step 1.
After the successful setup of the BTP subaccount, it calls the python scriptpoetry run python main.py
in the folderscripts
.
That python script does the following:
- It loads the content of the newly created
.env
file from step 1 into the environment variables of the session. - It calls the AI Core APIs to give you access to the models you have defined in the file config/secrets/my_btp_ai_setup.tfvars (through the variable
target_ai_core_model
).
After the steps above, you are all set for your first genAI experiments on SAP BTP.
You can proceed by switching to the folder scripts/step03_explore_examples
.
Here you will find some examples with respective instructions and sample code.
❗There is an existing issue that makes AI Core API token invalid for about 1-2 hours after it was created. We implemented a retry mechanism, nevertheless, until the issue is resolved, running the
./run.sh
might result in the following error. As a temporary workaround, just re-run the./run.sh
in 1-2 hours.
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.
Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.