Skip to content

Commit 8ad1ad8

Browse files
authored
Merge pull request #23968 from shibeshduw/fix-js-orchestration-grounding
Fix JavaScript SDK tutorial for consuming Orchestration with Grounding
2 parents ede29bf + a6c8b3d commit 8ad1ad8

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

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

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,37 @@ These steps help inspect vector collections and documents to confirm successful
667667
668668
[OPTION END]
669669
670+
[OPTION BEGIN [JavaScript SDK]]
671+
672+
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.
673+
674+
**Note:** For this step, we are using the [document grounding module](https://sap.github.io/ai-sdk/docs/js/ai-core/document-grounding) of the SDK so make sure to add the dependency to your project.
675+
676+
```javascript
677+
// Request body for pipeline creation request
678+
const pipelineRequest: PipelinePostRequst = {
679+
type: 'MSSharePoint',
680+
configuration: {
681+
destination: '<generic secret name>',
682+
sharePoint: {
683+
site: {
684+
name: '<sharepoint site name>',
685+
includePaths: ['/<folder name>']
686+
}
687+
}
688+
}
689+
};
690+
691+
// Create the pipeline
692+
const pipeline = await PipelinesApi.createPipeline(pipelineRequest, {
693+
'AI-Resource-Group': RESOURCE_GROUP
694+
}).execute();
695+
696+
console.log('Created Pipeline with ID: ', pipeline.pipelineId);
697+
```
698+
699+
[OPTION END]
700+
670701
[OPTION BEGIN [Java SDK]]
671702
672703
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.
@@ -781,6 +812,81 @@ After you have built your orchestration workflow, you can test it to generate ou
781812
782813
[OPTION END]
783814
815+
[OPTION BEGIN [JavaScript SDK]]
816+
817+
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.
818+
819+
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.
820+
821+
```javascript
822+
// Create an orchestration module config for the model gpt-4o with grounding and filtering
823+
const orchestrationModuleConfig: OrchestrationModuleConfig = {
824+
llm: {
825+
model_name: 'gpt-4o'
826+
},
827+
grounding: buildDocumentGroundingConfig({
828+
input_params: ['groundingRequest'],
829+
output_param: 'groundingOutput',
830+
// Create a database filter used for the grounding configuration
831+
filters: [
832+
{
833+
data_repository_type: 'vector',
834+
data_repositories: ['23c**********************5ed6'], //Replace with the value of your data repository ID
835+
id: 'filter1',
836+
search_config: {
837+
max_chunk_count: 10
838+
}
839+
}
840+
]
841+
}),
842+
// Create input and ouput content filters
843+
filtering: {
844+
input: {
845+
filters: [
846+
buildAzureContentSafetyFilter({
847+
Hate: 'ALLOW_SAFE_LOW',
848+
SelfHarm: 'ALLOW_SAFE_LOW',
849+
Sexual: 'ALLOW_SAFE_LOW',
850+
Violence: 'ALLOW_SAFE_LOW'
851+
})
852+
]
853+
},
854+
output: {
855+
filters: [
856+
buildAzureContentSafetyFilter({
857+
Hate: 'ALLOW_SAFE_LOW',
858+
SelfHarm: 'ALLOW_SAFE_LOW',
859+
Sexual: 'ALLOW_SAFE_LOW',
860+
Violence: 'ALLOW_SAFE_LOW'
861+
})
862+
]
863+
}
864+
}
865+
};
866+
867+
// Prompt LLM with a grounding prompt and orchestration module configuration
868+
const groundingResult = await new OrchestrationClient(
869+
orchestrationModuleConfig,
870+
{ resourceGroup: RESOURCE_GROUP }
871+
).chatCompletion({
872+
messages: [
873+
{
874+
role: 'user',
875+
content:
876+
'UserQuestion: {{?groundingRequest}} Context: {{?groundingOutput}}'
877+
}
878+
],
879+
inputParams: {
880+
// Create a grounding prompt which will combine the provided user message with the grounding output
881+
groundingRequest: 'Is there any complaint?'
882+
}
883+
});
884+
885+
console.log(groundingResult.getContent());
886+
```
887+
888+
[OPTION END]
889+
784890
[OPTION BEGIN [Java SDK]]
785891
786892
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.

0 commit comments

Comments
 (0)