Git Product home page Git Product logo

sap-samples / btp-genai-starter-kit Goto Github PK

View Code? Open in Web Editor NEW
38.0 10.0 5.0 317 KB

This repo aims to help developers to get into the genAI topic quicker by automating AI Core and HANA Vector Engine provisioning and configuration with Terraform Provider for SAP BTP.

License: Apache License 2.0

Shell 3.77% Dockerfile 2.20% HCL 34.43% Python 59.61%
ai-core genai hana-cloud langchain rag terraform vector-engine

btp-genai-starter-kit's Introduction

SAP BTP genAI starter kit

REUSE status

Description

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.

Architectural overview

Requirements

  • 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 the Dev 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 with git --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

Download and Installation

Step 1: Setup SAP BTP infrastructure

  • 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 file btp_ai_setup.tfvars to my_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 = ["[email protected]"].
    • save the file.
  • In the folder config/secrets rename the file btp_credentials.tfvars to my_btp_credentials.tfvars.
    • adapt the value for the variable BTP_USERNAME to your email address.
    • save the file.
  • Within VS Code open a terminal session.
  • In the terminal simply type ./run.sh and enter your BTP_PASSWORD as well as the password for the HANA 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 to true. 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 (folder config/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 the config/secrets folder.

Step 2: Deploy AI Models for your genAI experiments in AI Core

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 script step02_fetch_metadata.py in the folder scripts.

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).

Step 3: Run GenAI examples

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.

Known Issues

❗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. issue

How to obtain support

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.

Contributing

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.

License

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.

btp-genai-starter-kit's People

Contributors

rui1610 avatar dependabot[bot] avatar sap-ospo-bot avatar evgeniiskrebtcov avatar ospo-bot[bot] avatar

Stargazers

Ryan Fleischmann avatar Akash Mukherjee avatar vcapp avatar Teng Teng avatar Oswald avatar  avatar  avatar CodingCat avatar  avatar Markus Lauff avatar Hemsagar Elugu avatar darkovelkoski avatar  avatar  avatar forensicator avatar  avatar Adrian Bobev avatar  avatar  avatar Boudhayan Dev avatar Benedicto Rodriguez-Castro avatar Merbin J Anselm avatar  avatar  avatar  avatar Maohsiang @github avatar Baloaica Adrian avatar Javier Exposito G avatar  avatar  avatar Hilmar Falkenberg avatar Fabiano Rosa avatar George Drakos avatar Hüseyin Dereli avatar  avatar Anirban Majumdar avatar Peter Conrad avatar  avatar

Watchers

Lee Clemmer avatar  avatar Vipin Menon avatar Peter Conrad avatar Riley Rainey avatar Thomas Jung avatar  avatar ManjunathanRajan avatar  avatar  avatar

btp-genai-starter-kit's Issues

Global Account not found by Terraform script

Observation

The run.sh script throws an error stating that the Global Account is not found.

Reproduction

  1. Take all the steps listed in Step 1: Setup SAP BTP infrastructure.
  2. Observe the following as part of the output (I abbreviated account IDs):
Setting up SAP BTP infrastructure
…
Terraform has been successfully initialized!
…
Applying terraform script
--------------------------------------------------------------------------------
/workspaces/btp-genai-starter-kit/scripts/step01_setup_infra
var.BTP_PASSWORD
  Your BTP password.

  Enter a value: <secret>
…
Terraform planned the following actions, but then encountered a problem:

  # random_id.subaccount_domain_suffix will be created
  + resource "random_id" "subaccount_domain_suffix" {
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 12
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + globalaccount_id        = "cd…55"
  + subaccount_name         = "b9…8c"
  + subaccount_region       = "eu10"
  + timestamp_test_finished = (known after apply)
╷
│ Error: unableToCreateClient
│ 
│   with provider["registry.terraform.io/sap/btp"],
│   on provider.tf line 11, in provider "btp":
│   11: provider "btp" {
│ 
│ Global account 'cd…55' not found. Try again and make sure to provide the global account's subdomain. [Status:
│ 404; Correlation ID: 74b6d037-dd4a-d9a9-7a4e-d43f1cdd56e4]
╵
The 'terraform apply' command was not successful. Exiting.

Remarks

  • The Global Account subdomain used is listed in the Global-Account landing page in Cloud Cockpit.
  • On my machine (i.e. outside the Docker container), btp target --global-account cd…55 does succeed, confirming that the Global Account subdomain is valid.
  • The same problem also occurs if the name (rather than ID, which was just a try) of the subaccount is used.
  • Networking in the container does function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.