@jerome-benoit/sap-ai-provider 4.0.0-rc.1 → 4.0.0-rc.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.
- package/README.md +109 -90
- package/dist/index.cjs +622 -609
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +256 -188
- package/dist/index.d.ts +256 -188
- package/dist/index.js +613 -599
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
|
|
3
|
-
import { ResourceGroupConfig, DeploymentIdConfig } from '@sap-ai-sdk/ai-api/internal.js';
|
|
4
|
-
import { MaskingModule, FilteringModule, ChatCompletionTool, ChatModel } from '@sap-ai-sdk/orchestration';
|
|
1
|
+
import { FilteringModule, GroundingModule, MaskingModule, ChatCompletionTool, TranslationModule, ChatModel } from '@sap-ai-sdk/orchestration';
|
|
5
2
|
export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMessage, DeveloperChatMessage, DocumentTranslationApplyToSelector, FilteringModule, FunctionObject, GroundingModule, LlmModelDetails, LlmModelParams, MaskingModule, OrchestrationClient, OrchestrationConfigRef, OrchestrationErrorResponse, OrchestrationModuleConfig, OrchestrationResponse, OrchestrationStreamChunkResponse, OrchestrationStreamResponse, PromptTemplatingModule, SystemChatMessage, ToolChatMessage, TranslationApplyToCategory, TranslationInputParameters, TranslationModule, TranslationOutputParameters, TranslationTargetLanguage, UserChatMessage, buildAzureContentSafetyFilter, buildDocumentGroundingConfig, buildDpiMaskingProvider, buildLlamaGuard38BFilter, buildTranslationConfig, isConfigReference } from '@sap-ai-sdk/orchestration';
|
|
3
|
+
import { DeploymentIdConfig, ResourceGroupConfig } from '@sap-ai-sdk/ai-api/internal.js';
|
|
4
|
+
import { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
|
|
5
|
+
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, ProviderV3 } from '@ai-sdk/provider';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Supported model IDs in SAP AI Core.
|
|
9
|
+
*
|
|
10
|
+
* These models are available through the SAP AI Core Orchestration service.
|
|
11
|
+
* **Note:** The models listed here are representative examples. Actual model availability
|
|
12
|
+
* depends on your SAP AI Core tenant configuration, region, and subscription.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios SAP AI Core Models Documentation}
|
|
15
|
+
*
|
|
16
|
+
* **Azure OpenAI Models:**
|
|
17
|
+
* - gpt-4o, gpt-4o-mini
|
|
18
|
+
* - gpt-4.1, gpt-4.1-mini, gpt-4.1-nano
|
|
19
|
+
* - o1, o3, o3-mini, o4-mini
|
|
20
|
+
*
|
|
21
|
+
* **Google Vertex AI Models:**
|
|
22
|
+
* - gemini-2.0-flash, gemini-2.0-flash-lite
|
|
23
|
+
* - gemini-2.5-flash, gemini-2.5-pro
|
|
24
|
+
*
|
|
25
|
+
* **AWS Bedrock Models:**
|
|
26
|
+
* - anthropic--claude-3-haiku, anthropic--claude-3-sonnet, anthropic--claude-3-opus
|
|
27
|
+
* - anthropic--claude-3.5-sonnet, anthropic--claude-3.7-sonnet
|
|
28
|
+
* - anthropic--claude-4-sonnet, anthropic--claude-4-opus
|
|
29
|
+
* - amazon--nova-pro, amazon--nova-lite, amazon--nova-micro, amazon--nova-premier
|
|
30
|
+
*
|
|
31
|
+
* **AI Core Open Source Models:**
|
|
32
|
+
* - mistralai--mistral-large-instruct, mistralai--mistral-medium-instruct, mistralai--mistral-small-instruct
|
|
33
|
+
* - cohere--command-a-reasoning
|
|
34
|
+
*/
|
|
35
|
+
type SAPAIModelId = ChatModel;
|
|
7
36
|
/**
|
|
8
37
|
* Settings for configuring SAP AI Core model behavior.
|
|
9
38
|
*
|
|
@@ -55,10 +84,61 @@ export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMe
|
|
|
55
84
|
*/
|
|
56
85
|
interface SAPAISettings {
|
|
57
86
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
87
|
+
* Filtering configuration for input and output content safety.
|
|
88
|
+
* Supports Azure Content Safety and Llama Guard filters.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/content-filtering SAP Content Filtering Documentation}
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import { buildAzureContentSafetyFilter } from '@sap-ai-sdk/orchestration';
|
|
95
|
+
*
|
|
96
|
+
* const model = provider('gpt-4o', {
|
|
97
|
+
* filtering: {
|
|
98
|
+
* input: {
|
|
99
|
+
* filters: [
|
|
100
|
+
* buildAzureContentSafetyFilter('input', {
|
|
101
|
+
* hate: 'ALLOW_SAFE',
|
|
102
|
+
* violence: 'ALLOW_SAFE_LOW_MEDIUM'
|
|
103
|
+
* })
|
|
104
|
+
* ]
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
60
109
|
*/
|
|
61
|
-
|
|
110
|
+
filtering?: FilteringModule;
|
|
111
|
+
/**
|
|
112
|
+
* Grounding module configuration for document-based retrieval (RAG).
|
|
113
|
+
* Enables retrieval-augmented generation using SAP Document Grounding Service.
|
|
114
|
+
*
|
|
115
|
+
* Use `buildDocumentGroundingConfig()` to create the configuration.
|
|
116
|
+
*
|
|
117
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/document-grounding SAP Document Grounding Documentation}
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { buildDocumentGroundingConfig } from '@mymediset/sap-ai-provider';
|
|
122
|
+
*
|
|
123
|
+
* const model = provider('gpt-4o', {
|
|
124
|
+
* grounding: buildDocumentGroundingConfig({
|
|
125
|
+
* filters: [
|
|
126
|
+
* {
|
|
127
|
+
* id: 'my-vector-store',
|
|
128
|
+
* data_repository_type: 'vector',
|
|
129
|
+
* data_repositories: ['document-repo-1'],
|
|
130
|
+
* chunk_overlap: 50
|
|
131
|
+
* }
|
|
132
|
+
* ],
|
|
133
|
+
* placeholders: {
|
|
134
|
+
* input: ['?question'],
|
|
135
|
+
* output: 'groundingOutput'
|
|
136
|
+
* }
|
|
137
|
+
* })
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
grounding?: GroundingModule;
|
|
62
142
|
/**
|
|
63
143
|
* Whether to include assistant reasoning parts in the SAP prompt conversion.
|
|
64
144
|
*
|
|
@@ -94,27 +174,34 @@ interface SAPAISettings {
|
|
|
94
174
|
* ```
|
|
95
175
|
*/
|
|
96
176
|
includeReasoning?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Masking configuration for SAP AI Core orchestration.
|
|
179
|
+
* When provided, sensitive information in prompts can be anonymized or
|
|
180
|
+
* pseudonymized by SAP Data Privacy Integration (DPI).
|
|
181
|
+
*
|
|
182
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/data-privacy-integration SAP DPI Documentation}
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import { buildDpiMaskingProvider } from '@sap-ai-sdk/orchestration';
|
|
187
|
+
*
|
|
188
|
+
* const model = provider('gpt-4o', {
|
|
189
|
+
* masking: {
|
|
190
|
+
* masking_providers: [
|
|
191
|
+
* buildDpiMaskingProvider({
|
|
192
|
+
* method: 'anonymization',
|
|
193
|
+
* entities: ['profile-email', 'profile-phone']
|
|
194
|
+
* })
|
|
195
|
+
* ]
|
|
196
|
+
* }
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
masking?: MaskingModule;
|
|
97
201
|
/**
|
|
98
202
|
* Model generation parameters that control the output.
|
|
99
203
|
*/
|
|
100
204
|
modelParams?: {
|
|
101
|
-
/**
|
|
102
|
-
* Maximum number of tokens to generate.
|
|
103
|
-
* Higher values allow for longer responses but increase latency and cost.
|
|
104
|
-
*/
|
|
105
|
-
maxTokens?: number;
|
|
106
|
-
/**
|
|
107
|
-
* Sampling temperature between 0 and 2.
|
|
108
|
-
* Higher values make output more random, lower values more deterministic.
|
|
109
|
-
* If not specified, the model's default temperature is used.
|
|
110
|
-
*/
|
|
111
|
-
temperature?: number;
|
|
112
|
-
/**
|
|
113
|
-
* Nucleus sampling parameter between 0 and 1.
|
|
114
|
-
* Controls diversity via cumulative probability cutoff.
|
|
115
|
-
* If not specified, the model's default topP is used (typically 1).
|
|
116
|
-
*/
|
|
117
|
-
topP?: number;
|
|
118
205
|
/**
|
|
119
206
|
* Frequency penalty between -2.0 and 2.0.
|
|
120
207
|
* Positive values penalize tokens based on their frequency.
|
|
@@ -122,11 +209,10 @@ interface SAPAISettings {
|
|
|
122
209
|
*/
|
|
123
210
|
frequencyPenalty?: number;
|
|
124
211
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* If not specified, the model's default is used (typically 0).
|
|
212
|
+
* Maximum number of tokens to generate.
|
|
213
|
+
* Higher values allow for longer responses but increase latency and cost.
|
|
128
214
|
*/
|
|
129
|
-
|
|
215
|
+
maxTokens?: number;
|
|
130
216
|
/**
|
|
131
217
|
* Number of completions to generate.
|
|
132
218
|
* Multiple completions provide alternative responses.
|
|
@@ -141,52 +227,30 @@ interface SAPAISettings {
|
|
|
141
227
|
* Note: This uses the SAP/OpenAI-style key `parallel_tool_calls`.
|
|
142
228
|
*/
|
|
143
229
|
parallel_tool_calls?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Presence penalty between -2.0 and 2.0.
|
|
232
|
+
* Positive values penalize tokens that have appeared in the text.
|
|
233
|
+
* If not specified, the model's default is used (typically 0).
|
|
234
|
+
*/
|
|
235
|
+
presencePenalty?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Sampling temperature between 0 and 2.
|
|
238
|
+
* Higher values make output more random, lower values more deterministic.
|
|
239
|
+
* If not specified, the model's default temperature is used.
|
|
240
|
+
*/
|
|
241
|
+
temperature?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Nucleus sampling parameter between 0 and 1.
|
|
244
|
+
* Controls diversity via cumulative probability cutoff.
|
|
245
|
+
* If not specified, the model's default topP is used (typically 1).
|
|
246
|
+
*/
|
|
247
|
+
topP?: number;
|
|
144
248
|
};
|
|
145
249
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* pseudonymized by SAP Data Privacy Integration (DPI).
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* import { buildDpiMaskingProvider } from '@sap-ai-sdk/orchestration';
|
|
153
|
-
*
|
|
154
|
-
* const model = provider('gpt-4o', {
|
|
155
|
-
* masking: {
|
|
156
|
-
* masking_providers: [
|
|
157
|
-
* buildDpiMaskingProvider({
|
|
158
|
-
* method: 'anonymization',
|
|
159
|
-
* entities: ['profile-email', 'profile-phone']
|
|
160
|
-
* })
|
|
161
|
-
* ]
|
|
162
|
-
* }
|
|
163
|
-
* });
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
masking?: MaskingModule;
|
|
167
|
-
/**
|
|
168
|
-
* Filtering configuration for input and output content safety.
|
|
169
|
-
* Supports Azure Content Safety and Llama Guard filters.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```typescript
|
|
173
|
-
* import { buildAzureContentSafetyFilter } from '@sap-ai-sdk/orchestration';
|
|
174
|
-
*
|
|
175
|
-
* const model = provider('gpt-4o', {
|
|
176
|
-
* filtering: {
|
|
177
|
-
* input: {
|
|
178
|
-
* filters: [
|
|
179
|
-
* buildAzureContentSafetyFilter('input', {
|
|
180
|
-
* hate: 'ALLOW_SAFE',
|
|
181
|
-
* violence: 'ALLOW_SAFE_LOW_MEDIUM'
|
|
182
|
-
* })
|
|
183
|
-
* ]
|
|
184
|
-
* }
|
|
185
|
-
* }
|
|
186
|
-
* });
|
|
187
|
-
* ```
|
|
250
|
+
* Specific version of the model to use.
|
|
251
|
+
* If not provided, the latest version will be used.
|
|
188
252
|
*/
|
|
189
|
-
|
|
253
|
+
modelVersion?: string;
|
|
190
254
|
/**
|
|
191
255
|
* Response format for templating prompt (OpenAI-compatible)
|
|
192
256
|
* Allows specifying structured output formats
|
|
@@ -206,17 +270,17 @@ interface SAPAISettings {
|
|
|
206
270
|
* ```
|
|
207
271
|
*/
|
|
208
272
|
responseFormat?: {
|
|
209
|
-
type: "text";
|
|
210
|
-
} | {
|
|
211
|
-
type: "json_object";
|
|
212
|
-
} | {
|
|
213
|
-
type: "json_schema";
|
|
214
273
|
json_schema: {
|
|
215
|
-
name: string;
|
|
216
274
|
description?: string;
|
|
275
|
+
name: string;
|
|
217
276
|
schema?: unknown;
|
|
218
277
|
strict?: boolean | null;
|
|
219
278
|
};
|
|
279
|
+
type: "json_schema";
|
|
280
|
+
} | {
|
|
281
|
+
type: "json_object";
|
|
282
|
+
} | {
|
|
283
|
+
type: "text";
|
|
220
284
|
};
|
|
221
285
|
/**
|
|
222
286
|
* Tool definitions in SAP AI SDK format
|
|
@@ -251,43 +315,42 @@ interface SAPAISettings {
|
|
|
251
315
|
* ```
|
|
252
316
|
*/
|
|
253
317
|
tools?: ChatCompletionTool[];
|
|
318
|
+
/**
|
|
319
|
+
* Translation module configuration for input/output translation.
|
|
320
|
+
* Enables automatic translation using SAP Document Translation service.
|
|
321
|
+
*
|
|
322
|
+
* Use `buildTranslationConfig()` to create input/output configurations.
|
|
323
|
+
*
|
|
324
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/translation SAP Translation Documentation}
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* import { buildTranslationConfig } from '@mymediset/sap-ai-provider';
|
|
329
|
+
*
|
|
330
|
+
* const model = provider('gpt-4o', {
|
|
331
|
+
* translation: {
|
|
332
|
+
* input: buildTranslationConfig('input', {
|
|
333
|
+
* sourceLanguage: 'de-DE',
|
|
334
|
+
* targetLanguage: 'en-US'
|
|
335
|
+
* }),
|
|
336
|
+
* output: buildTranslationConfig('output', {
|
|
337
|
+
* targetLanguage: 'de-DE'
|
|
338
|
+
* })
|
|
339
|
+
* }
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
translation?: TranslationModule;
|
|
254
344
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Supported model IDs in SAP AI Core.
|
|
257
|
-
*
|
|
258
|
-
* These models are available through the SAP AI Core Orchestration service.
|
|
259
|
-
* **Note:** The models listed here are representative examples. Actual model availability
|
|
260
|
-
* depends on your SAP AI Core tenant configuration, region, and subscription.
|
|
261
|
-
*
|
|
262
|
-
* **Azure OpenAI Models:**
|
|
263
|
-
* - gpt-4o, gpt-4o-mini
|
|
264
|
-
* - gpt-4.1, gpt-4.1-mini, gpt-4.1-nano
|
|
265
|
-
* - o1, o3, o3-mini, o4-mini
|
|
266
|
-
*
|
|
267
|
-
* **Google Vertex AI Models:**
|
|
268
|
-
* - gemini-2.0-flash, gemini-2.0-flash-lite
|
|
269
|
-
* - gemini-2.5-flash, gemini-2.5-pro
|
|
270
|
-
*
|
|
271
|
-
* **AWS Bedrock Models:**
|
|
272
|
-
* - anthropic--claude-3-haiku, anthropic--claude-3-sonnet, anthropic--claude-3-opus
|
|
273
|
-
* - anthropic--claude-3.5-sonnet, anthropic--claude-3.7-sonnet
|
|
274
|
-
* - anthropic--claude-4-sonnet, anthropic--claude-4-opus
|
|
275
|
-
* - amazon--nova-pro, amazon--nova-lite, amazon--nova-micro, amazon--nova-premier
|
|
276
|
-
*
|
|
277
|
-
* **AI Core Open Source Models:**
|
|
278
|
-
* - mistralai--mistral-large-instruct, mistralai--mistral-medium-instruct, mistralai--mistral-small-instruct
|
|
279
|
-
* - cohere--command-a-reasoning
|
|
280
|
-
*/
|
|
281
|
-
type SAPAIModelId = ChatModel;
|
|
282
345
|
|
|
283
346
|
/**
|
|
284
347
|
* Internal configuration for the SAP AI Chat Language Model.
|
|
285
348
|
* @internal
|
|
286
349
|
*/
|
|
287
350
|
interface SAPAIConfig {
|
|
288
|
-
|
|
289
|
-
deploymentConfig: ResourceGroupConfig | DeploymentIdConfig;
|
|
351
|
+
deploymentConfig: DeploymentIdConfig | ResourceGroupConfig;
|
|
290
352
|
destination?: HttpDestinationOrFetchOptions;
|
|
353
|
+
provider: string;
|
|
291
354
|
}
|
|
292
355
|
/**
|
|
293
356
|
* SAP AI Chat Language Model implementation.
|
|
@@ -309,6 +372,9 @@ interface SAPAIConfig {
|
|
|
309
372
|
* - AWS Bedrock models (anthropic--claude-*, amazon--nova-*, etc.)
|
|
310
373
|
* - AI Core open source models (mistralai--, cohere--, etc.)
|
|
311
374
|
*
|
|
375
|
+
* @see {@link https://sdk.vercel.ai/docs/ai-sdk-core/language-model-v3 Vercel AI SDK LanguageModelV3}
|
|
376
|
+
* @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/orchestration SAP AI Core Orchestration}
|
|
377
|
+
*
|
|
312
378
|
* @example
|
|
313
379
|
* ```typescript
|
|
314
380
|
* // Create via provider
|
|
@@ -324,35 +390,27 @@ interface SAPAIConfig {
|
|
|
324
390
|
*
|
|
325
391
|
* @implements {LanguageModelV3}
|
|
326
392
|
*/
|
|
327
|
-
declare class
|
|
328
|
-
readonly specificationVersion = "v3";
|
|
393
|
+
declare class SAPAILanguageModel implements LanguageModelV3 {
|
|
329
394
|
readonly modelId: SAPAIModelId;
|
|
330
|
-
|
|
331
|
-
private readonly settings;
|
|
332
|
-
/**
|
|
333
|
-
* Creates a new SAP AI Chat Language Model instance.
|
|
334
|
-
*
|
|
335
|
-
* @param modelId - The model identifier
|
|
336
|
-
* @param settings - Model-specific configuration settings
|
|
337
|
-
* @param config - Internal configuration (deployment config, destination, etc.)
|
|
338
|
-
*
|
|
339
|
-
* @internal This constructor is not meant to be called directly.
|
|
340
|
-
* Use the provider function instead.
|
|
341
|
-
*/
|
|
342
|
-
constructor(modelId: SAPAIModelId, settings: SAPAISettings, config: SAPAIConfig);
|
|
343
|
-
/**
|
|
344
|
-
* Checks if a URL is supported for file/image uploads.
|
|
345
|
-
*
|
|
346
|
-
* @param url - The URL to check
|
|
347
|
-
* @returns True if the URL protocol is HTTPS or data with valid image format
|
|
348
|
-
*/
|
|
349
|
-
supportsUrl(url: URL): boolean;
|
|
395
|
+
readonly specificationVersion = "v3";
|
|
350
396
|
/**
|
|
351
|
-
*
|
|
397
|
+
* Model capabilities.
|
|
352
398
|
*
|
|
353
|
-
*
|
|
399
|
+
* These defaults assume “modern” model behavior to avoid maintaining a
|
|
400
|
+
* per-model capability matrix. If a deployment doesn't support a feature,
|
|
401
|
+
* SAP AI Core will fail the request at runtime.
|
|
354
402
|
*/
|
|
355
|
-
|
|
403
|
+
readonly supportsImageUrls: boolean;
|
|
404
|
+
/** Multiple completions via the `n` parameter (provider-specific support). */
|
|
405
|
+
readonly supportsMultipleCompletions: boolean;
|
|
406
|
+
/** Parallel tool calls. */
|
|
407
|
+
readonly supportsParallelToolCalls: boolean;
|
|
408
|
+
/** Streaming responses. */
|
|
409
|
+
readonly supportsStreaming: boolean;
|
|
410
|
+
/** Structured JSON outputs (json_schema response format). */
|
|
411
|
+
readonly supportsStructuredOutputs: boolean;
|
|
412
|
+
/** Tool/function calling. */
|
|
413
|
+
readonly supportsToolCalls: boolean;
|
|
356
414
|
/**
|
|
357
415
|
* Generates text completion using SAP AI Core's Orchestration API.
|
|
358
416
|
*
|
|
@@ -396,39 +454,24 @@ declare class SAPAIChatLanguageModel implements LanguageModelV3 {
|
|
|
396
454
|
*/
|
|
397
455
|
get provider(): string;
|
|
398
456
|
/**
|
|
399
|
-
*
|
|
457
|
+
* Returns supported URL patterns for different content types.
|
|
400
458
|
*
|
|
401
|
-
*
|
|
402
|
-
* per-model capability matrix. If a deployment doesn't support a feature,
|
|
403
|
-
* SAP AI Core will fail the request at runtime.
|
|
459
|
+
* @returns Record of content types to regex patterns
|
|
404
460
|
*/
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
readonly
|
|
408
|
-
/** Tool/function calling. */
|
|
409
|
-
readonly supportsToolCalls: boolean;
|
|
410
|
-
/** Streaming responses. */
|
|
411
|
-
readonly supportsStreaming: boolean;
|
|
412
|
-
/** Multiple completions via the `n` parameter (provider-specific support). */
|
|
413
|
-
readonly supportsMultipleCompletions: boolean;
|
|
414
|
-
/** Parallel tool calls. */
|
|
415
|
-
readonly supportsParallelToolCalls: boolean;
|
|
461
|
+
get supportedUrls(): Record<string, RegExp[]>;
|
|
462
|
+
private readonly config;
|
|
463
|
+
private readonly settings;
|
|
416
464
|
/**
|
|
417
|
-
*
|
|
465
|
+
* Creates a new SAP AI Chat Language Model instance.
|
|
418
466
|
*
|
|
419
|
-
* @param
|
|
420
|
-
* @
|
|
421
|
-
* @
|
|
422
|
-
*/
|
|
423
|
-
private buildOrchestrationConfig;
|
|
424
|
-
/**
|
|
425
|
-
* Creates an OrchestrationClient instance.
|
|
467
|
+
* @param modelId - The model identifier
|
|
468
|
+
* @param settings - Model-specific configuration settings
|
|
469
|
+
* @param config - Internal configuration (deployment config, destination, etc.)
|
|
426
470
|
*
|
|
427
|
-
* @
|
|
428
|
-
*
|
|
429
|
-
* @internal
|
|
471
|
+
* @internal This constructor is not meant to be called directly.
|
|
472
|
+
* Use the provider function instead.
|
|
430
473
|
*/
|
|
431
|
-
|
|
474
|
+
constructor(modelId: SAPAIModelId, settings: SAPAISettings, config: SAPAIConfig);
|
|
432
475
|
/**
|
|
433
476
|
* Generates a single completion (non-streaming).
|
|
434
477
|
*
|
|
@@ -489,6 +532,8 @@ declare class SAPAIChatLanguageModel implements LanguageModelV3 {
|
|
|
489
532
|
* - Usage format: `{ inputTokens: { total, ... }, outputTokens: { total, ... } }`
|
|
490
533
|
* - Warnings only in `stream-start` event
|
|
491
534
|
*
|
|
535
|
+
* @see {@link https://sdk.vercel.ai/docs/ai-sdk-core/streaming Vercel AI SDK Streaming}
|
|
536
|
+
*
|
|
492
537
|
* @param options - Streaming options including prompt, tools, and settings
|
|
493
538
|
* @returns Promise resolving to stream and request metadata
|
|
494
539
|
*
|
|
@@ -513,8 +558,35 @@ declare class SAPAIChatLanguageModel implements LanguageModelV3 {
|
|
|
513
558
|
* @since 4.0.0
|
|
514
559
|
*/
|
|
515
560
|
doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
|
|
561
|
+
/**
|
|
562
|
+
* Checks if a URL is supported for file/image uploads.
|
|
563
|
+
*
|
|
564
|
+
* @param url - The URL to check
|
|
565
|
+
* @returns True if the URL protocol is HTTPS or data with valid image format
|
|
566
|
+
*/
|
|
567
|
+
supportsUrl(url: URL): boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Builds orchestration module config for SAP AI SDK.
|
|
570
|
+
*
|
|
571
|
+
* @param options - Call options from the AI SDK
|
|
572
|
+
* @returns Object containing orchestration config, messages, and warnings
|
|
573
|
+
* @internal
|
|
574
|
+
*/
|
|
575
|
+
private buildOrchestrationConfig;
|
|
576
|
+
/**
|
|
577
|
+
* Creates an OrchestrationClient instance.
|
|
578
|
+
*
|
|
579
|
+
* @param config - Orchestration module configuration
|
|
580
|
+
* @returns OrchestrationClient instance
|
|
581
|
+
* @internal
|
|
582
|
+
*/
|
|
583
|
+
private createClient;
|
|
516
584
|
}
|
|
517
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Deployment configuration type used by SAP AI SDK.
|
|
588
|
+
*/
|
|
589
|
+
type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
|
|
518
590
|
/**
|
|
519
591
|
* SAP AI Provider interface.
|
|
520
592
|
*
|
|
@@ -547,7 +619,7 @@ interface SAPAIProvider extends ProviderV3 {
|
|
|
547
619
|
* @param settings - Optional model configuration settings
|
|
548
620
|
* @returns Configured SAP AI chat language model instance
|
|
549
621
|
*/
|
|
550
|
-
(modelId: SAPAIModelId, settings?: SAPAISettings):
|
|
622
|
+
(modelId: SAPAIModelId, settings?: SAPAISettings): SAPAILanguageModel;
|
|
551
623
|
/**
|
|
552
624
|
* Explicit method for creating chat models.
|
|
553
625
|
*
|
|
@@ -558,7 +630,7 @@ interface SAPAIProvider extends ProviderV3 {
|
|
|
558
630
|
* @param settings - Optional model configuration settings
|
|
559
631
|
* @returns Configured SAP AI chat language model instance
|
|
560
632
|
*/
|
|
561
|
-
chat(modelId: SAPAIModelId, settings?: SAPAISettings):
|
|
633
|
+
chat(modelId: SAPAIModelId, settings?: SAPAISettings): SAPAILanguageModel;
|
|
562
634
|
}
|
|
563
635
|
/**
|
|
564
636
|
* Configuration settings for the SAP AI Provider.
|
|
@@ -587,28 +659,10 @@ interface SAPAIProvider extends ProviderV3 {
|
|
|
587
659
|
*/
|
|
588
660
|
interface SAPAIProviderSettings {
|
|
589
661
|
/**
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
* When enabled (default), the provider will warn when mutually-exclusive
|
|
593
|
-
* settings are provided (e.g. both `deploymentId` and `resourceGroup`).
|
|
594
|
-
*/
|
|
595
|
-
warnOnAmbiguousConfig?: boolean;
|
|
596
|
-
/**
|
|
597
|
-
* SAP AI Core resource group.
|
|
598
|
-
*
|
|
599
|
-
* Logical grouping of AI resources in SAP AI Core.
|
|
600
|
-
* Used for resource isolation and access control.
|
|
601
|
-
* Different resource groups can have different permissions and quotas.
|
|
602
|
-
*
|
|
603
|
-
* @default 'default'
|
|
604
|
-
* @example
|
|
605
|
-
* ```typescript
|
|
606
|
-
* resourceGroup: 'default' // Default resource group
|
|
607
|
-
* resourceGroup: 'production' // Production environment
|
|
608
|
-
* resourceGroup: 'development' // Development environment
|
|
609
|
-
* ```
|
|
662
|
+
* Default model settings applied to every model instance created by this provider.
|
|
663
|
+
* Per-call settings provided to the model will override these.
|
|
610
664
|
*/
|
|
611
|
-
|
|
665
|
+
defaultSettings?: SAPAISettings;
|
|
612
666
|
/**
|
|
613
667
|
* SAP AI Core deployment ID.
|
|
614
668
|
*
|
|
@@ -638,15 +692,29 @@ interface SAPAIProviderSettings {
|
|
|
638
692
|
*/
|
|
639
693
|
destination?: HttpDestinationOrFetchOptions;
|
|
640
694
|
/**
|
|
641
|
-
*
|
|
642
|
-
*
|
|
695
|
+
* SAP AI Core resource group.
|
|
696
|
+
*
|
|
697
|
+
* Logical grouping of AI resources in SAP AI Core.
|
|
698
|
+
* Used for resource isolation and access control.
|
|
699
|
+
* Different resource groups can have different permissions and quotas.
|
|
700
|
+
*
|
|
701
|
+
* @default 'default'
|
|
702
|
+
* @example
|
|
703
|
+
* ```typescript
|
|
704
|
+
* resourceGroup: 'default' // Default resource group
|
|
705
|
+
* resourceGroup: 'production' // Production environment
|
|
706
|
+
* resourceGroup: 'development' // Development environment
|
|
707
|
+
* ```
|
|
643
708
|
*/
|
|
644
|
-
|
|
709
|
+
resourceGroup?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Whether to emit warnings for ambiguous configurations.
|
|
712
|
+
*
|
|
713
|
+
* When enabled (default), the provider will warn when mutually-exclusive
|
|
714
|
+
* settings are provided (e.g. both `deploymentId` and `resourceGroup`).
|
|
715
|
+
*/
|
|
716
|
+
warnOnAmbiguousConfig?: boolean;
|
|
645
717
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Deployment configuration type used by SAP AI SDK.
|
|
648
|
-
*/
|
|
649
|
-
type DeploymentConfig = ResourceGroupConfig | DeploymentIdConfig;
|
|
650
718
|
/**
|
|
651
719
|
* Creates a SAP AI Core provider instance for use with the AI SDK.
|
|
652
720
|
*
|