Skip to content

Commit b1db9de

Browse files
committed
Update ai-core-orchestration-grounding.md
1 parent 6be52cd commit b1db9de

1 file changed

Lines changed: 75 additions & 7 deletions

File tree

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

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,81 @@ After you have built your orchestration workflow, you can test it to generate ou
895895
896896
[OPTION END]
897897
898+
[OPTION BEGIN [JavaScript SDK]]
899+
900+
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.
901+
902+
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.
903+
904+
```javascript
905+
// Create an orchestration module config for the model gpt-4o with grounding and filtering
906+
const orchestrationModuleConfig: OrchestrationModuleConfig = {
907+
llm: {
908+
model_name: 'gpt-4o'
909+
},
910+
grounding: buildDocumentGroundingConfig({
911+
input_params: ['groundingRequest'],
912+
output_param: 'groundingOutput',
913+
// Create a database filter used for the grounding configuration
914+
filters: [
915+
{
916+
data_repository_type: 'vector',
917+
data_repositories: ['23c**********************5ed6'], //Replace with the value of your data repository ID
918+
id: 'filter1',
919+
search_config: {
920+
max_chunk_count: 10
921+
}
922+
}
923+
]
924+
}),
925+
// Create input and ouput content filters
926+
filtering: {
927+
input: {
928+
filters: [
929+
buildAzureContentSafetyFilter({
930+
Hate: 'ALLOW_SAFE_LOW',
931+
SelfHarm: 'ALLOW_SAFE_LOW',
932+
Sexual: 'ALLOW_SAFE_LOW',
933+
Violence: 'ALLOW_SAFE_LOW'
934+
})
935+
]
936+
},
937+
output: {
938+
filters: [
939+
buildAzureContentSafetyFilter({
940+
Hate: 'ALLOW_SAFE_LOW',
941+
SelfHarm: 'ALLOW_SAFE_LOW',
942+
Sexual: 'ALLOW_SAFE_LOW',
943+
Violence: 'ALLOW_SAFE_LOW'
944+
})
945+
]
946+
}
947+
}
948+
};
949+
950+
// Prompt LLM with a grounding prompt and orchestration module configuration
951+
const groundingResult = await new OrchestrationClient(
952+
orchestrationModuleConfig,
953+
{ resourceGroup: RESOURCE_GROUP }
954+
).chatCompletion({
955+
messages: [
956+
{
957+
role: 'user',
958+
content:
959+
'UserQuestion: {{?groundingRequest}} Context: {{?groundingOutput}}'
960+
}
961+
],
962+
inputParams: {
963+
// Create a grounding prompt which will combine the provided user message with the grounding output
964+
groundingRequest: 'Is there any complaint?'
965+
}
966+
});
967+
968+
console.log(groundingResult.getContent());
969+
```
970+
971+
[OPTION END]
972+
898973
[OPTION BEGIN [Java SDK]]
899974
900975
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.
@@ -1028,10 +1103,3 @@ print(response.orchestration_result.choices[0].message.content)
10281103
### Conclusion
10291104
10301105
Adding Grounding significantly enhances the model's ability to provide Accurate and Context-specific responses. Without Grounding, the model generates generic replies, while with grounding, it retrieves precise information from the uploaded document. Screenshots showcasing both responses are provided for comparison.
1031-
1032-
1033-
1034-
1035-
1036-
1037-

0 commit comments

Comments
 (0)