@jerome-benoit/sap-ai-provider 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -31
- package/dist/{chunk-TVXWNZQT.js → chunk-3ZSXTKOK.js} +607 -210
- package/dist/chunk-3ZSXTKOK.js.map +1 -0
- package/dist/{chunk-GMMX46AH.js → chunk-BVDSJ4IZ.js} +10 -4
- package/dist/chunk-BVDSJ4IZ.js.map +1 -0
- package/dist/{chunk-36DFHUVQ.js → chunk-H5KD4EPO.js} +8 -2
- package/dist/chunk-H5KD4EPO.js.map +1 -0
- package/dist/{chunk-WDUOKIKD.js → chunk-KVOLFUQJ.js} +4 -2
- package/dist/chunk-KVOLFUQJ.js.map +1 -0
- package/dist/{chunk-BZZJKLDG.js → chunk-TQXCNZBC.js} +11 -5
- package/dist/chunk-TQXCNZBC.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-YWPDIJEN.js → foundation-models-embedding-model-strategy-SWRJNFD4.js} +7 -6
- package/dist/foundation-models-embedding-model-strategy-SWRJNFD4.js.map +1 -0
- package/dist/{foundation-models-language-model-strategy-WDSQWU64.js → foundation-models-language-model-strategy-LRAC25ZY.js} +14 -9
- package/dist/foundation-models-language-model-strategy-LRAC25ZY.js.map +1 -0
- package/dist/index.cjs +658 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-66QYAO64.js → orchestration-embedding-model-strategy-C5G735Q2.js} +8 -7
- package/dist/orchestration-embedding-model-strategy-C5G735Q2.js.map +1 -0
- package/dist/{orchestration-language-model-strategy-4TKRZK7U.js → orchestration-language-model-strategy-NUHYRIXH.js} +17 -10
- package/dist/orchestration-language-model-strategy-NUHYRIXH.js.map +1 -0
- package/package.json +19 -21
- package/dist/chunk-36DFHUVQ.js.map +0 -1
- package/dist/chunk-BZZJKLDG.js.map +0 -1
- package/dist/chunk-GMMX46AH.js.map +0 -1
- package/dist/chunk-TVXWNZQT.js.map +0 -1
- package/dist/chunk-WDUOKIKD.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-YWPDIJEN.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-WDSQWU64.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-66QYAO64.js.map +0 -1
- package/dist/orchestration-language-model-strategy-4TKRZK7U.js.map +0 -1
package/README.md
CHANGED
|
@@ -531,29 +531,15 @@ const dpiConfig = buildDpiMaskingProvider({
|
|
|
531
531
|
|
|
532
532
|
### Content Filtering
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
import "dotenv/config"; // Load environment variables
|
|
536
|
-
import { buildAzureContentSafetyFilter, createSAPAIProvider } from "@jerome-benoit/sap-ai-provider";
|
|
537
|
-
|
|
538
|
-
const provider = createSAPAIProvider({
|
|
539
|
-
defaultSettings: {
|
|
540
|
-
filtering: {
|
|
541
|
-
input: {
|
|
542
|
-
filters: [
|
|
543
|
-
buildAzureContentSafetyFilter("input", {
|
|
544
|
-
hate: "ALLOW_SAFE",
|
|
545
|
-
violence: "ALLOW_SAFE_LOW_MEDIUM",
|
|
546
|
-
}),
|
|
547
|
-
],
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
});
|
|
552
|
-
```
|
|
534
|
+
Content filtering is available through the Orchestration API.
|
|
553
535
|
|
|
536
|
+
**Complete example:**
|
|
537
|
+
[examples/example-content-filtering.ts](./examples/example-content-filtering.ts)\
|
|
554
538
|
**Complete documentation:**
|
|
555
539
|
[API Reference - Content Filtering](./API_REFERENCE.md#buildazurecontentsafetyfiltertype-config)
|
|
556
540
|
|
|
541
|
+
**Run it:** `npx tsx examples/example-content-filtering.ts`
|
|
542
|
+
|
|
557
543
|
### Document Grounding (RAG)
|
|
558
544
|
|
|
559
545
|
Ground LLM responses in your own documents using vector databases.
|
|
@@ -567,24 +553,27 @@ Ground LLM responses in your own documents using vector databases.
|
|
|
567
553
|
const provider = createSAPAIProvider({
|
|
568
554
|
defaultSettings: {
|
|
569
555
|
grounding: buildDocumentGroundingConfig({
|
|
570
|
-
filters: [
|
|
571
|
-
|
|
572
|
-
id: "vector-store-1", // Your vector database ID
|
|
573
|
-
data_repositories: ["*"], // Search all repositories
|
|
574
|
-
},
|
|
575
|
-
],
|
|
576
|
-
placeholders: {
|
|
577
|
-
input: ["?question"],
|
|
578
|
-
output: "groundingOutput",
|
|
579
|
-
},
|
|
556
|
+
filters: [{ id: "vector-store-1", data_repositories: ["*"] }],
|
|
557
|
+
placeholders: { input: ["groundingRequest"], output: "groundingOutput" },
|
|
580
558
|
}),
|
|
581
559
|
},
|
|
582
560
|
});
|
|
583
561
|
|
|
584
|
-
|
|
585
|
-
|
|
562
|
+
const result = await generateText({
|
|
563
|
+
model: provider("gpt-4.1"),
|
|
564
|
+
prompt: "Question: {{?groundingRequest}}\nContext: {{?groundingOutput}}",
|
|
565
|
+
providerOptions: {
|
|
566
|
+
"sap-ai": {
|
|
567
|
+
escapeTemplatePlaceholders: false,
|
|
568
|
+
placeholderValues: { groundingRequest: "What is SAP?" },
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
});
|
|
586
572
|
```
|
|
587
573
|
|
|
574
|
+
Set `escapeTemplatePlaceholders` to `false` only when intentionally sending SAP
|
|
575
|
+
or Jinja placeholders in prompts or messages.
|
|
576
|
+
|
|
588
577
|
**Run it:** `npx tsx examples/example-document-grounding.ts`
|
|
589
578
|
|
|
590
579
|
### Translation
|
|
@@ -659,6 +648,11 @@ authentication, model parameters, data masking, content filtering, and more.
|
|
|
659
648
|
`providerOptions`/`providerMetadata`.
|
|
660
649
|
- `resourceGroup`: SAP AI Core resource group (default: 'default')
|
|
661
650
|
- `deploymentId`: Specific deployment ID (auto-resolved if not set)
|
|
651
|
+
- `requestConfig`: Custom HTTP request configuration (headers, params, timeout, etc.)
|
|
652
|
+
forwarded to the underlying SAP AI SDK client on every call. Provider-level scope
|
|
653
|
+
only; use `requestConfig.headers` for SAP-specific headers such as
|
|
654
|
+
`AI-Object-Store-Secret-Name` (feedback service). See
|
|
655
|
+
[API Reference](./API_REFERENCE.md#sapaiprovidersettings) for portability caveats.
|
|
662
656
|
- `modelParams`: Temperature, maxTokens, topP, and other generation parameters
|
|
663
657
|
- `masking`: SAP Data Privacy Integration (DPI) configuration
|
|
664
658
|
- `filtering`: Content safety filters (Azure Content Safety, Llama Guard)
|
|
@@ -736,6 +730,7 @@ features:
|
|
|
736
730
|
| `example-streaming-chat.ts` | Streaming responses | Real-time text generation, SSE |
|
|
737
731
|
| `example-image-recognition.ts` | Multi-modal with images | Vision models, image analysis |
|
|
738
732
|
| `example-data-masking.ts` | Data privacy integration | DPI masking, anonymization |
|
|
733
|
+
| `example-content-filtering.ts` | Content filtering | Azure Content Safety, orchestration |
|
|
739
734
|
| `example-document-grounding.ts` | Document grounding (RAG) | Vector store, retrieval-augmented gen |
|
|
740
735
|
| `example-translation.ts` | Input/output translation | Multi-language support, SAP translation |
|
|
741
736
|
| `example-embeddings.ts` | Text embeddings | Vector generation, semantic similarity |
|