Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
shivamshukla12
Contributor

As we are witnessing one of the exciting time in the field of AI and lots of experiments and evolutions are still happening , the things we never thought of are coming into reality hence the only option for us to Keep adopting these beautiful break through in tech. and Keep supporting Supporting community and Humanity by every means.

Intended Audience:

Someone who wants to start exploring these APIs and willing to integrate/consume them inside SAP BTP Box then this is your article to read.

Hi All ,

As i have stated above this article is written to give you information about how can we leverage google vertex AI APIs into SAP Build Apps smoothly by adding the CAP Layer in middle to establish communication between them.

1.png

Lets start enabling and Testing Vertex API on google cloud.

  • Login into your GCP account and create a project name it "callGeminiAPI" or something.
  • Select your project and now enable Vertex AI APIs - Choose enable and go to Vertex AI Dashboard.

Once you enabled these API , you can see this screen and try out few prompts before we switch to consumption of these APIs/Models.

2.png

Lets try some prompt for converting an email request data into particular JSON format using this model , you can try prompts according to your need/testing.

Disclaimer: I am not promoting any AI Product , I am just exploring these APIs and sharing the learning and possibilities of consumption/integration with them.

 

Prompt : I uploaded the above image and added a simple text "What is this image about ?" and got a satisfactory answer from API.

 

4.png

I think we are good here , i am not gonna add other prompts here , i shall request you to try out few more prompts and check accuracy and results carefully before deciding the usage of these APIs.

Next Part: How to consume these APIs in SAP CAP.

  • Create a simple CAP Application using BAS/VSCode , I prefer VSCode hence going with that
  • Install required libraries related to Vertex AI APIs.
  • Get your authentication file downloaded from GCP Account ( Most important ) to Authorize the API Calls

Lets do this. let download the service key from your service Account in GCP.

Navigate to your project -> To Service Account and Click create/ Add new Key download JSON and Save it somewhere on your computer.

5.png

Go to your Vertex AI API Prompt and navigate to Code section and get the Code Choose NodeJS code as we are going to use exactly the same code to call these APIs from CAP.

Note: I am not going to add anything related to CAP Application , this will be a simple Application with one entity called GEMINI prompt as an input and response in output and create a corresponding handler to handle the incoming request from UI.

Once you click on Get Code , you will get the NodeJS Code related to this API , install required libraries and test the integration.

6.png

if you are good with CAP Layer integration with Vertex AI then you will be able to test these APIs from POSTMAN Successfully , Make sure to Authenticate request successfully before model call otherwise it is gonna give you some error related to unauthorized.

Lets test these APIs from POSTMAN now.

8.png

So we have completed CAP Integration , Awesome lets build and deploy this API into your BTP Box.

MBT Build + CF Deploy _mtar -> Done ?

Final Part: Integrate CAP APIs into your SAP Build App.

Go to your BTP Cockpit and Open SAP Build Apps 

Choose create an Application and select Mobile App ( aka Appgyver )

Create a Simple Application with one input one button and an output field ( A Chatbot interface ).

9.png

Integration with CAP APIs.

Go to Data Section and choose Rest Based Direct Integration

  1. Get Oauth token for CAP API Call
  2. Call Gemini API using this token 

These APIs will be integrated at the button click event to complete the call to backend.

Lets Test this Application end-2-end.

 

At last : Don't forget to share feedback/suggestions if any. 

#KeepLearning#KeepSharing

Thanks - Shivam

 

Labels in this area