Skip to content

Commit 334be0e

Browse files
committed
Merge remote-tracking branch 'origin/master' into orchestration-tutorial-improvement
2 parents 31e0e92 + 8aadfb3 commit 334be0e

20 files changed

Lines changed: 310 additions & 61 deletions

tutorials/ai-core-custom-slm/ai-core-custom-slm.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ primary_tag: software-product>sap-ai-core
77
author_name: Dhrubajyoti Paul
88
author_profile: https://github.com/dhrubpaul
99
---
10-
# Using Custom models on SAP AI Core VIA ollama
11-
<!-- description --> In this tutorial we are going to learn on how to deploy a custom LLM on AI core using ollama for the example we would be taking Gemma as a model from hugging face and deploy it on SAP AI core.
10+
# Using Small Language models on SAP AI Core VIA ollama
11+
<!-- description --> In this tutorial we are going to learn on how to deploy a SLM on AI core using ollama for the example we would be taking llava-phi3 as a model from hugging face and deploy it on SAP AI core
1212

1313
## You will learn
1414
- How to Deploy ollama on AI core
15-
- Add models to ollama and infrence models
15+
- Add models to ollama and inference models
1616

1717
## Prerequisites
1818
Ai core setup and basic knowledge: [Link to documentation](https://developers.sap.com/tutorials/ai-core-setup.html)
@@ -25,7 +25,7 @@ In this tutorial we are deploying ollama an open-source project that serves as a
2525

2626
![image](img/solution-architecture.png)
2727

28-
We can pick any model from the above model hubs and connect it to AI core for the example we are going to deploy ollama on AI core and enable Gemma and inference the same.
28+
We can pick any model from the above model hubs and connect it to AI core for the example we are going to deploy ollama on AI core and enable llava-phi3 and inference the same.
2929

3030
### Adding workflow file to github
3131
Workflows for SAP AI Core are created using YAML or JSON files that are compatible with the SAP AI Core schema. Let’s start with adding a Argo Workflow file to manage: `ollama`.

tutorials/ai-core-orchestration-consumption-opt/ai-core-orchestration-consumption-opt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const cvContent = await readFile('path/to/cv.txt', 'utf-8');
110110

111111
- Here, we extend the use case introduced in Previous Tutorial, where orchestration was executed without incorporating data masking or content filtering. Here, we will include these advanced modules to improve data privacy, security, and response quality.
112112

113-
**NOTE** : If you are continuing with the same project from the previous tutorial, skip steps 1 and 2. Otherwise, create a new Java Maven project using the already deployed orchestration URL to access the Harmonized API. Please find detailed information on orchestration configuration and deployment in the previous tutorial or our [GitHub repository](https://github.com/SAP/ai-sdk-java).
113+
**NOTE** : If you are continuing with the same project from the previous tutorial, skip steps 1 and 2. Otherwise, create a new Java Maven project using the already deployed orchestration URL to access the Harmonized API. Please find detailed information on orchestration configuration and deployment in the previous tutorial or in our [documentation](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java).
114114

115115

116116

tutorials/ai-core-orchestration-consumption/ai-core-orchestration-consumption.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ AICORE_SERVICE_KEY={"clientid": "...", "clientsecret": "...", "url": "...", "ser
102102
</dependency>
103103
```
104104

105-
• For other options of access configuration and detailed information on installation and usage of the **SAP Cloud SDK for AI (for Java)**, visit the official [GitHub repository](https://github.com/SAP/ai-sdk-java). This page provides comprehensive steps to set up and integrate the SDK effectively in your projects.
105+
• For other options of access configuration and detailed information on installation and usage of the **SAP Cloud SDK for AI (Java)**, visit the official [documentation platform](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java). This page provides comprehensive steps to set up and integrate the SDK effectively in your projects.
106106

107107
[OPTION END]
108108

@@ -271,7 +271,7 @@ console.log(configuration?.message); // Print the configuration response message
271271
272272
[OPTION BEGIN [Java SDK]]
273273
274-
In this step, we will create an orchestration configuration using the core module of the [SAP Cloud SDK for Java](https://github.com/SAP/cloud-sdk-java). This configuration integrates various parameters needed for orchestration, such as the executable ID and scenario ID.
274+
In this step, we will create an orchestration configuration using the core module of the [SAP Cloud SDK for AI (Java)](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java). This configuration integrates various parameters needed for orchestration, such as the executable ID and scenario ID.
275275
276276
• Add the following code to your project to create an orchestration configuration:
277277
@@ -442,7 +442,7 @@ console.log(deployment?.message) // Print the deployment creation response
442442
443443
[OPTION BEGIN [Java SDK]]
444444
445-
In this step, we will create a deployment from the configuration created in the previous step using the core module of the [SAP Cloud SDK for Java](https://github.com/SAP/cloud-sdk-java).
445+
In this step, we will create a deployment from the configuration created in the previous step using the core module of the [SAP Cloud SDK for AI (Java)](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java).
446446
447447
• Add the following code to your project to create an orchestration deployment:
448448
@@ -915,7 +915,7 @@ Ensure at least one orchestration deployment is ready to be consumed during this
915915
916916
[OPTION BEGIN [Java SDK]]
917917
918-
In this step, we will consume an LLM through the orchestration service with the created deployment, using the core and orchestration module of the [SAP Cloud SDK for Java](https://github.com/SAP/cloud-sdk-java).
918+
In this step, we will consume an LLM through the orchestration service with the created deployment, using the core and orchestration module of the [SAP Cloud SDK for AI (Java)](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java).
919919
920920
To begin the consumption process, follow the steps below:
921921

tutorials/ai-core-orchestration-grounding/ai-core-orchestration-Grounding.md

Lines changed: 258 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ To interact with SAP AI Core using **SAP Cloud SDK for AI (for JavaScript)**, yo
4141

4242
[OPTION END]
4343

44-
[OPTION BEGIN [Gen AI SDK]]
44+
[OPTION BEGIN [Java SDK]]
4545

46-
To interact with SAP AI Core using Gen AI SDK, you first need to create a service key that grants secure access to your AI Core instance. Follow the step Set Up Your Environment and Configure Access in the [tutorial] (https://developers.sap.com/tutorials/ai-core-orchestration-consumption.html) to establish your connection.
46+
To interact with SAP AI Core using the [Java SDK](https://sap.github.io/ai-sdk/docs/java/overview-cloud-sdk-for-ai-java), you first need to create a service key that grants secure access to your AI Core instance. Follow the step Set Up Your Environment and Configure Access in the [tutorial](https://developers.sap.com/tutorials/ai-core-orchestration-consumption.html) to establish your connection.
47+
48+
[OPTION END]
49+
50+
[OPTION BEGIN [Python SDK]]
51+
52+
To interact with SAP AI Core using the python Gen AI SDK, you first need to create a service key that grants secure access to your AI Core instance. Follow the step Set Up Your Environment and Configure Access in the [tutorial](https://developers.sap.com/tutorials/ai-core-orchestration-consumption.html) to establish your connection.
4753

4854
[OPTION END]
4955

@@ -111,7 +117,13 @@ The JavaScript SDK automatically retrieves the AI Core service credentials and r
111117

112118
[OPTION END]
113119

114-
[OPTION BEGIN [Gen AI SDK]]
120+
[OPTION BEGIN [Java SDK]]
121+
122+
As the access token is automatically initially requested and sent with every request to the server, this step is not necessary for the Java SDK.
123+
124+
[OPTION END]
125+
126+
[OPTION BEGIN [Python SDK]]
115127

116128
This step generates an access token, required for authenticating API requests during the process.
117129

@@ -240,7 +252,32 @@ console.log("Created Resource Group with ID: ", resourceGroup?.resourceGroupId)
240252
241253
[OPTION END]
242254
243-
[OPTION BEGIN [Gen AI SDK]]
255+
[OPTION BEGIN [Java SDK]]
256+
257+
Create a resource group in SAP AI Core. Please note that for using the document grounding service, your request must contain the document grounding label set to true. Therefore, existing resource groups without the label won't work.
258+
259+
```java
260+
// Your resource group ID, please change to your desired ID
261+
var RESOURCE_GROUP = "YourResourceGroupId";
262+
263+
// Request to create the resource group
264+
var resourceGroupRequest = BckndResourceGroupsPostRequest.create()
265+
.resourceGroupId(RESOURCE_GROUP)
266+
.addLabelsItem(BckndResourceGroupLabel.create()
267+
.key("ext.ai.sap.com/document-grounding")
268+
.value("true")
269+
);
270+
271+
// Create resource group
272+
var resourceGroup = new ResourceGroupApi().create(resourceGroupRequest);
273+
274+
System.out.println("Created Resource Group with ID: " + resourceGroup.getResourceGroupId());
275+
276+
```
277+
278+
[OPTION END]
279+
280+
[OPTION BEGIN [Python SDK]]
244281
245282
Create a resource group in SAP AI Core by defining its ID and quota, ensuring efficient resource allocation for AI workloads.
246283
@@ -412,7 +449,43 @@ console.log(secret?.message)
412449
413450
[OPTION END]
414451
415-
[OPTION BEGIN [Gen AI SDK]]
452+
[OPTION BEGIN [Java SDK]]
453+
454+
Generic secrets securely store SharePoint credentials required for document access. Please change the values to your SharePoint credentials.
455+
456+
```java
457+
// Request to create the secret
458+
var secretRequest = BckndGenericSecretPostBody.create()
459+
.name("canary-rg1-secret")
460+
.data(Map.ofEntries(
461+
Map.entry("type", "SFRUUA=="),
462+
Map.entry("description", "<description of generic secret>"),
463+
Map.entry("clientId", "<client id>"),
464+
Map.entry("authentication", "<AUTHENTICATION>"),
465+
Map.entry("tokenServiceUrl", "<token service url>"),
466+
Map.entry("password", "<password>"),
467+
Map.entry("proxyType", "<PROXY>"),
468+
Map.entry("url", "<URL>"),
469+
Map.entry("tokenServiceURLType", "<TOKEN SERVICE URL TYPE>"),
470+
Map.entry("user", "<user>"),
471+
Map.entry("clientSecret", "<clientSecret>"),
472+
Map.entry("scope", "<SCOPE>")
473+
))
474+
.addLabelsItem(BckndGenericSecretLabel.create()
475+
.key("ext.ai.sap.com/document-grounding")
476+
.value("true")
477+
);
478+
479+
// Create secret
480+
var secret = new SecretApi().create(secretRequest);
481+
482+
System.out.println(secret.getMessage());
483+
484+
```
485+
486+
[OPTION END]
487+
488+
[OPTION BEGIN [Python SDK]]
416489
417490
Generic secrets securely store SharePoint credentials required for document access
418491
@@ -456,12 +529,12 @@ secret.json()
456529
457530
[OPTION END]
458531
459-
### 7. Prepare knowledge base(data repository) and verification
460-
461-
#### 7.a Using Pipeline API [Option-1]
532+
### 7. Prepare knowledge base (data repository) and verification
462533
463534
[OPTION BEGIN [Bruno]]
464535
536+
### 7.a Using Pipeline API
537+
465538
#### Create Pipeline
466539
467540
- Pipelines define the process for grounding and retrieving content from SharePoint repositories.
@@ -647,6 +720,131 @@ These steps help inspect vector collections and documents to confirm successful
647720
648721
[OPTION END]
649722
723+
[OPTION BEGIN [JavaScript SDK]]
724+
725+
we are creating a document-grounding pipeline using SAP AI Core. The pipeline is configured to integrate with Microsoft SharePoint as a data source, enabling AI-driven document processing. This setup allows seamless ingestion of documents from a specified SharePoint site, ensuring efficient data retrieval and processing.
726+
727+
**Note:** At present, pipeline creation is not supported in the grounding feature of Cloud SDK, as we have utilized API requests to establish the pipeline.
728+
729+
```javascript
730+
731+
const jsonData = {
732+
type: 'MSSharePoint',
733+
configuration: {
734+
destination: '<generic secret name>',
735+
sharePoint: {
736+
site: {
737+
name: '<sharepoint site name>',
738+
includePaths: [
739+
"/<folder name>"
740+
]
741+
}
742+
}
743+
}
744+
};
745+
746+
const headers = {
747+
"Authorization": `Bearer ${token}`, // Use your actual token
748+
"Content-Type": "application/json",
749+
"AI-Resource-Group": "default" // Replace with your resource group
750+
};
751+
752+
async function createPipeline() {
753+
try {
754+
while (true) {
755+
const response = await axios.post(
756+
`${AI_API_URL}/v2/lm/document-grounding/pipelines`,
757+
jsonData,
758+
{ headers: headers }
759+
);
760+
761+
if (response.status === 201) {
762+
console.log('Pipeline Created:', response.data);
763+
return response.data.pipelineId;
764+
}
765+
}
766+
} catch (error) {
767+
console.error('Error creating pipeline:', error.response ? error.response.data : error.message);
768+
}
769+
}
770+
771+
createPipeline().then(pipelineId => {
772+
console.log('Pipeline ID:', pipelineId);
773+
});
774+
775+
```
776+
![img](img/image058.png)
777+
778+
[OPTION END]
779+
780+
[OPTION BEGIN [Java SDK]]
781+
782+
We are creating a document-grounding pipeline using SAP AI Core. The pipeline is configured to integrate with Microsoft SharePoint as a data source, enabling AI-driven document processing. This setup allows seamless ingestion of documents from a specified SharePoint site, ensuring efficient data retrieval and processing.
783+
784+
**Note:** For this step, we are using the [document grounding module](https://sap.github.io/ai-sdk/docs/java/guides/document-grounding) of the SDK so make sure to add the dependency to your project.
785+
786+
```java
787+
// Request to create the pipeline
788+
var pipelineRequest = PipelinePostRequst.create()
789+
.type("MSSharePoint")
790+
._configuration(PipelinePostRequstConfiguration.create()
791+
.destination("<generic secret name>")
792+
.sharePoint(PipelinePostRequstConfigurationSharePoint.create()
793+
.site(PipelinePostRequstConfigurationSharePointSite.create()
794+
.name("<sharepoint site name>")
795+
.addIncludePathsItem("/<folder name>")
796+
)
797+
)
798+
);
799+
800+
// Create the pipeline
801+
var pipeline = new GroundingClient().pipelines().createPipeline(
802+
RESOURCE_GROUP,
803+
pipelineRequest
804+
);
805+
806+
System.out.println("Created Pipeline with ID: " + pipeline.getPipelineId());
807+
808+
```
809+
810+
[OPTION END]
811+
812+
[OPTION BEGIN [Python SDK]]
813+
814+
we are creating a document-grounding pipeline using SAP AI Core. The pipeline is configured to integrate with Microsoft SharePoint as a data source, enabling AI-driven document processing. This setup allows seamless ingestion of documents from a specified SharePoint site, ensuring efficient data retrieval and processing.
815+
816+
**Note:** At present, pipeline creation is not supported in the grounding feature of Gen AI SDK, as we have utilized API requests to establish the pipeline.
817+
818+
```python
819+
820+
json_data = {
821+
'type': 'MSSharePoint',
822+
'configuration': {
823+
'destination': '<generic secret name>',
824+
'sharePoint': {
825+
'site': {
826+
'name': '<sharepoint site name>',
827+
"includePaths": [
828+
"/<folder name>"
829+
]
830+
},
831+
},
832+
},
833+
}
834+
835+
while True:
836+
pipeline = requests.post(f'{AI_API_URL}/v2/lm/document-grounding/pipelines', headers=headers, json=json_data)
837+
if(pipeline.status_code == 201):
838+
break
839+
840+
pipeline.json()['pipelineId']
841+
842+
```
843+
844+
![img](img/image063.png)
845+
846+
[OPTION END]
847+
650848
### 8. Ensuring Accurate Responses with Grounding
651849
652850
In the previous steps, we have completed the data preparation for grounding. Before initiating model inference or orchestration, ensure that there is an active orchestration deployment (**scenario ID: orchestration**). To verify the available orchestration deployments and their status, use the **get_deployment** API under the **"Deployments"** section in the **Bruno collection**. Additionally, update the **orchestration_service_url** in the environment.
@@ -811,7 +1009,58 @@ console.log(groudingResponse);
8111009
8121010
[OPTION END]
8131011
814-
[OPTION BEGIN [Gen AI SDK]]
1012+
[OPTION BEGIN [Java SDK]]
1013+
1014+
We are configuring an AI Orchestration Pipeline using SAP AI Core. The pipeline integrates multiple AI modules to process and refine inputs efficiently. This setup enables **document grounding, LLM processing, templating, and content filtering**, ensuring accurate and safe AI-generated responses.
1015+
1016+
The configuration defines a document grounding module that retrieves relevant context from a vector-based repository, a GPT-4o model for response generation, a templating module to structure responses, and Azure Content Safety filters to ensure compliance and content moderation. This orchestration streamlines AI-driven summarization while maintaining reliability and security.
1017+
1018+
```java
1019+
// Create a database filter used for the grounding configuration
1020+
var dataBaseFilter = DocumentGroundingFilter.create()
1021+
.dataRepositoryType(DataRepositoryType.VECTOR)
1022+
.id("filter1")
1023+
.addDataRepositoriesItem("23c**********************5ed6") //Replace with the value of your data repository ID
1024+
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(10));
1025+
1026+
// Create a grounding configuration with the database filter
1027+
var groundingConfig = Grounding.create()
1028+
.filters(dataBaseFilter);
1029+
1030+
// Create a grounding prompt which will combine the provided user message with the grounding output
1031+
var groundingPrompt = groundingConfig.createGroundingPrompt("Is there any complaint?");
1032+
1033+
// Create an input content filter
1034+
var inputFilter = new AzureContentFilter()
1035+
.hate(ALLOW_SAFE_LOW)
1036+
.selfHarm(ALLOW_SAFE_LOW)
1037+
.sexual(ALLOW_SAFE_LOW)
1038+
.violence(ALLOW_SAFE_LOW);
1039+
1040+
// Create an output content filter
1041+
var outputFilter = new AzureContentFilter()
1042+
.hate(ALLOW_SAFE_LOW)
1043+
.selfHarm(ALLOW_SAFE_LOW)
1044+
.sexual(ALLOW_SAFE_LOW)
1045+
.violence(ALLOW_SAFE_LOW);
1046+
1047+
// Create an orchestration module config for the model gpt-4o with grounding and filtering
1048+
var orchestrationModuleConfig = new OrchestrationModuleConfig()
1049+
.withLlmConfig(OrchestrationAiModel.GPT_4O)
1050+
.withGrounding(groundingConfig)
1051+
.withInputFiltering(inputFilter)
1052+
.withOutputFiltering(outputFilter);
1053+
1054+
// Prompt LLM with created grounding prompt and orchestration module configuration
1055+
var response = client.chatCompletion(groundingPrompt, orchestrationModuleConfig);
1056+
1057+
System.out.println(response.getContent());
1058+
1059+
```
1060+
1061+
[OPTION END]
1062+
1063+
[OPTION BEGIN [Python SDK]]
8151064
8161065
We are configuring an AI Orchestration Pipeline using SAP AI Core. The pipeline integrates multiple AI modules to process and refine inputs efficiently. This setup enables **document grounding, LLM processing, templating, and content filtering**, ensuring accurate and safe AI-generated responses.
8171066
-60.6 KB
Loading

tutorials/fiori-tools-cap-create-application/fiori-tools-cap-create-application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ auto_validation: true
55
time: 15
66
tags: [ software-product>sap-fiori, software-product>sap-fiori-tools, tutorial>beginner, software-product>sap-fiori, software-product>sap-business-application-studio, software-product-function>sap-cloud-application-programming-model, software-product>sap-business-technology-platform]
77
primary_tag: software-product>sap-fiori
8-
contributors: [ Dimitri Herber>https://github.com/fakirdi, Conrad Bernal>https://github.com/cjbernal, Hitesh Parmar>https://github.com/hitesh-parmar, Joachim Fiess>https://github.com/jo-fiess ]
8+
contributors: [ Hitesh Parmar>https://github.com/hitesh-parmar, Joachim Fiess>https://github.com/jo-fiess ]
99
---
1010
## You will learn
1111
- How to create an SAP Fiori application of type list report application
-72.7 KB
Loading
26.1 KB
Loading

0 commit comments

Comments
 (0)