@jerome-benoit/sap-ai-provider-v2 5.0.1 → 5.0.2

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.
Files changed (40) hide show
  1. package/README.md +39 -32
  2. package/dist/chunk-77JSAAPE.js +778 -0
  3. package/dist/chunk-77JSAAPE.js.map +1 -0
  4. package/dist/{chunk-AFZC2DH2.js → chunk-LEME2MFD.js} +59 -387
  5. package/dist/chunk-LEME2MFD.js.map +1 -0
  6. package/dist/{chunk-U23M3VYO.js → chunk-NLMWIVG7.js} +17 -7
  7. package/dist/chunk-NLMWIVG7.js.map +1 -0
  8. package/dist/chunk-QZOZ3PZT.js +634 -0
  9. package/dist/chunk-QZOZ3PZT.js.map +1 -0
  10. package/dist/{chunk-JRUSQTKB.js → chunk-U6WJSLR7.js} +19 -11
  11. package/dist/chunk-U6WJSLR7.js.map +1 -0
  12. package/dist/{chunk-MF3VO3ER.js → chunk-YP3AADWD.js} +47 -40
  13. package/dist/chunk-YP3AADWD.js.map +1 -0
  14. package/dist/{foundation-models-embedding-model-strategy-2GUADNXT.js → foundation-models-embedding-model-strategy-A3WDDAYK.js} +8 -9
  15. package/dist/foundation-models-embedding-model-strategy-A3WDDAYK.js.map +1 -0
  16. package/dist/{foundation-models-language-model-strategy-5AYZ5KHA.js → foundation-models-language-model-strategy-6U6KK6KH.js} +18 -21
  17. package/dist/foundation-models-language-model-strategy-6U6KK6KH.js.map +1 -0
  18. package/dist/index.cjs +1323 -31666
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +17 -32
  21. package/dist/index.d.ts +17 -32
  22. package/dist/index.js +48 -194
  23. package/dist/index.js.map +1 -1
  24. package/dist/{orchestration-embedding-model-strategy-F7WHDLX7.js → orchestration-embedding-model-strategy-JO3QH5MR.js} +7 -11
  25. package/dist/orchestration-embedding-model-strategy-JO3QH5MR.js.map +1 -0
  26. package/dist/{orchestration-language-model-strategy-Z72AFW62.js → orchestration-language-model-strategy-MBVA7BYX.js} +23 -25
  27. package/dist/orchestration-language-model-strategy-MBVA7BYX.js.map +1 -0
  28. package/package.json +15 -12
  29. package/dist/chunk-2KOXKYVT.js +0 -31083
  30. package/dist/chunk-2KOXKYVT.js.map +0 -1
  31. package/dist/chunk-643USI3B.js +0 -251
  32. package/dist/chunk-643USI3B.js.map +0 -1
  33. package/dist/chunk-AFZC2DH2.js.map +0 -1
  34. package/dist/chunk-JRUSQTKB.js.map +0 -1
  35. package/dist/chunk-MF3VO3ER.js.map +0 -1
  36. package/dist/chunk-U23M3VYO.js.map +0 -1
  37. package/dist/foundation-models-embedding-model-strategy-2GUADNXT.js.map +0 -1
  38. package/dist/foundation-models-language-model-strategy-5AYZ5KHA.js.map +0 -1
  39. package/dist/orchestration-embedding-model-strategy-F7WHDLX7.js.map +0 -1
  40. package/dist/orchestration-language-model-strategy-Z72AFW62.js.map +0 -1
package/README.md CHANGED
@@ -104,16 +104,17 @@ try {
104
104
 
105
105
  console.log(result.text);
106
106
  } catch (error) {
107
- if (error instanceof APICallError) {
108
- console.error("SAP AI Core API error:", error.message);
109
- console.error("Status:", error.statusCode);
107
+ process.exitCode = 1;
108
+ if (APICallError.isInstance(error)) {
109
+ console.error("SAP AI Core API error:", error.statusCode, error.name);
110
110
  } else {
111
- console.error("Unexpected error:", error);
111
+ console.error("Unexpected error:", error instanceof Error ? error.name : "Unknown error");
112
112
  }
113
113
  }
114
114
  ```
115
115
 
116
- > **Note:** Requires `AICORE_SERVICE_KEY` environment variable. See
116
+ > **Note:** For local service-key setup, set `AICORE_SERVICE_KEY`. SAP BTP service
117
+ > bindings and custom destinations are alternatives. See
117
118
  > [Environment Setup](./ENVIRONMENT_SETUP.md) for configuration.
118
119
 
119
120
  ## Quick Reference
@@ -127,7 +128,7 @@ try {
127
128
  | **Streaming** | `streamText({ model: provider("gpt-4.1"), prompt })` | [Streaming](#streaming-responses) |
128
129
  | **Tool Calling** | `generateText({ tools: { myTool: tool({...}) } })` | [Tool Calling](#tool-calling) |
129
130
  | **Error Handling** | `if (APICallError.isInstance(error)) { /* handle error */ }` | [API Reference](./API_REFERENCE.md#error-handling--reference) |
130
- | **Choose Model** | See 80+ models (GPT, Claude, Gemini, Llama) | [Models](./API_REFERENCE.md#models) |
131
+ | **Choose Model** | Discover models available in your tenant | [Models](./API_REFERENCE.md#models) |
131
132
  | **Embeddings** | `embed({ model: provider.embedding("text-embedding-3-small") })` | [Embeddings](#embeddings) |
132
133
 
133
134
  ## Installation
@@ -140,11 +141,15 @@ The published package targets Node.js. Its ESM output uses Node
140
141
  The source-level Edge test suite does not establish deployability to pure Edge
141
142
  runtimes such as Cloudflare Workers; use a Node.js server runtime for deployment.
142
143
 
143
- | AI SDK | Install | Provider import |
144
- | ------ | -------------------------------------------------- | ----------------------------------- |
145
- | 7 | `npm install @jerome-benoit/sap-ai-provider ai@^7` | `@jerome-benoit/sap-ai-provider/v4` |
146
- | 6 | `npm install @jerome-benoit/sap-ai-provider ai@^6` | `@jerome-benoit/sap-ai-provider` |
147
- | 5 | `npm install @jerome-benoit/sap-ai-provider ai@^5` | `@jerome-benoit/sap-ai-provider/v2` |
144
+ | AI SDK | Install | Provider import |
145
+ | ------ | -------------------------------------------------- | ----------------------------------------------------------------------- |
146
+ | 7 | `npm install @jerome-benoit/sap-ai-provider ai@^7` | `@jerome-benoit/sap-ai-provider/v4` |
147
+ | 6 | `npm install @jerome-benoit/sap-ai-provider ai@^6` | `@jerome-benoit/sap-ai-provider` or `@jerome-benoit/sap-ai-provider/v3` |
148
+ | 5 | `npm install @jerome-benoit/sap-ai-provider ai@^5` | `@jerome-benoit/sap-ai-provider/v2` |
149
+
150
+ `/v3` is an explicit alias for the AI SDK 6 root entrypoint. Both resolve to
151
+ the same runtime modules and TypeScript declarations, including the same `sapai`
152
+ instance within each module format; existing root imports remain valid.
148
153
 
149
154
  The Quick Start and inline snippets on this page use AI SDK 6 with the root V3
150
155
  entrypoint. The runnable files in `examples/` use the repository's installed
@@ -375,11 +380,12 @@ try {
375
380
  // streamText returns a result object; its usage property is a promise.
376
381
  console.log("\n\nUsage:", await result.usage);
377
382
  } catch (error) {
383
+ process.exitCode = 1;
378
384
  if (APICallError.isInstance(error)) {
379
- console.error("API Error:", error.message);
380
- // See Error Handling section for complete error type reference
385
+ console.error("API error:", error.statusCode, error.name);
386
+ } else {
387
+ console.error("Streaming failed:", error instanceof Error ? error.name : "Unknown error");
381
388
  }
382
- throw error;
383
389
  }
384
390
  ```
385
391
 
@@ -507,7 +513,7 @@ const result = await generateText({
507
513
 
508
514
  ⚠️ **Model Limitations:** Some models have tool calling restrictions. See
509
515
  [API Reference - Model-Specific Tool Limitations](./API_REFERENCE.md#model-specific-tool-limitations)
510
- for the complete comparison table.
516
+ for upstream support documentation.
511
517
 
512
518
  ### Multi-modal Input (Images)
513
519
 
@@ -575,7 +581,7 @@ Ground LLM responses in your own documents using vector databases.
575
581
  const provider = createSAPAIProvider({
576
582
  defaultSettings: {
577
583
  grounding: buildDocumentGroundingConfig({
578
- filters: [{ id: "vector-store-1", data_repositories: ["*"] }],
584
+ filters: [{ id: "knowledge-filter", data_repositories: ["*"] }],
579
585
  placeholders: { input: ["groundingRequest"], output: "groundingOutput" },
580
586
  }),
581
587
  },
@@ -675,7 +681,8 @@ authentication, model parameters, data masking, content filtering, and more.
675
681
  - `deploymentId`: Specific deployment ID (auto-resolved if not set)
676
682
  - `requestConfig`: Custom HTTP request configuration (headers, params, timeout, etc.)
677
683
  forwarded to the underlying SAP AI SDK client on every call. Provider-level scope
678
- only; use `requestConfig.headers` for SAP-specific headers such as
684
+ only; per-call `headers` can override individual headers. Use `requestConfig.headers`
685
+ for SAP-specific headers such as
679
686
  `AI-Object-Store-Secret-Name` (feedback service). See
680
687
  [API Reference](./API_REFERENCE.md#sapaiprovidersettings) for portability caveats.
681
688
  - `modelParams`: Temperature, maxTokens, topP, and other generation parameters
@@ -751,19 +758,19 @@ repository's AI SDK 7 dependency and the local `../src/index-v4` entrypoint.
751
758
  In an AI SDK 7 application, import from `@jerome-benoit/sap-ai-provider/v4`.
752
759
  See [Installation](#installation) for other AI SDK versions.
753
760
 
754
- | Example | Description | Key Features |
755
- | ----------------------------------- | --------------------------- | --------------------------------------- |
756
- | `example-generate-text.ts` | Basic text generation | Simple prompts, synchronous generation |
757
- | `example-simple-chat-completion.ts` | Simple chat conversation | System messages, user prompts |
758
- | `example-chat-completion-tool.ts` | Tool calling with functions | Weather API tool, function execution |
759
- | `example-streaming-chat.ts` | Streaming responses | Real-time text generation, SSE |
760
- | `example-image-recognition.ts` | Multi-modal with images | Vision models, image analysis |
761
- | `example-data-masking.ts` | Data privacy integration | DPI masking, anonymization |
762
- | `example-content-filtering.ts` | Content filtering | Azure Content Safety, orchestration |
763
- | `example-document-grounding.ts` | Document grounding (RAG) | Vector store, retrieval-augmented gen |
764
- | `example-translation.ts` | Input/output translation | Multi-language support, SAP translation |
765
- | `example-embeddings.ts` | Text embeddings | Vector generation, semantic similarity |
766
- | `example-foundation-models.ts` | Foundation Models API | Direct model access, logprobs, seed |
761
+ | Example | Description | Key Features |
762
+ | ----------------------------------- | --------------------------- | ---------------------------------------- |
763
+ | `example-generate-text.ts` | Basic text generation | Simple prompts, non-streaming generation |
764
+ | `example-simple-chat-completion.ts` | Simple chat conversation | System messages, user prompts |
765
+ | `example-chat-completion-tool.ts` | Tool calling with functions | Demo weather tool, function execution |
766
+ | `example-streaming-chat.ts` | Streaming responses | Real-time text generation, SSE |
767
+ | `example-image-recognition.ts` | Multi-modal with images | Vision models, image analysis |
768
+ | `example-data-masking.ts` | Data privacy integration | DPI masking, anonymization |
769
+ | `example-content-filtering.ts` | Content filtering | Azure Content Safety, orchestration |
770
+ | `example-document-grounding.ts` | Document grounding (RAG) | Vector store, retrieval-augmented gen |
771
+ | `example-translation.ts` | Input/output translation | Multi-language support, SAP translation |
772
+ | `example-embeddings.ts` | Text embeddings | Vector generation, semantic similarity |
773
+ | `example-foundation-models.ts` | Foundation Models API | Direct model access, logprobs, seed |
767
774
 
768
775
  **Running Examples:**
769
776
 
@@ -771,8 +778,8 @@ See [Installation](#installation) for other AI SDK versions.
771
778
  npx tsx examples/example-generate-text.ts
772
779
  ```
773
780
 
774
- > **Note:** Examples require `AICORE_SERVICE_KEY` environment variable. See
775
- > [Environment Setup](./ENVIRONMENT_SETUP.md) for configuration.
781
+ > **Note:** Configure `AICORE_SERVICE_KEY` locally or bind the application to
782
+ > SAP AI Core on SAP BTP. See [Environment Setup](./ENVIRONMENT_SETUP.md).
776
783
 
777
784
  ## Migration Guides
778
785