@jerome-benoit/sap-ai-provider 4.6.9 → 4.7.1
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/LICENSE +202 -0
- package/README.md +22 -32
- package/dist/{chunk-EXOXZ5OU.js → chunk-4JIMBRMV.js} +44 -7
- package/dist/chunk-4JIMBRMV.js.map +1 -0
- package/dist/{chunk-4RRRJBEL.js → chunk-BZWUUBX2.js} +407 -275
- package/dist/chunk-BZWUUBX2.js.map +1 -0
- package/dist/chunk-HDOSHLV6.js +190 -0
- package/dist/chunk-HDOSHLV6.js.map +1 -0
- package/dist/chunk-OA6TJHD2.js +93 -0
- package/dist/chunk-OA6TJHD2.js.map +1 -0
- package/dist/{chunk-DYFBCE2W.js → chunk-RUCURXS7.js} +60 -6
- package/dist/chunk-RUCURXS7.js.map +1 -0
- package/dist/{chunk-F4MUYVQJ.js → chunk-XIWHF23D.js} +1919 -955
- package/dist/chunk-XIWHF23D.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-3MMM3QDC.js → foundation-models-embedding-model-strategy-TACUPFS2.js} +8 -4
- package/dist/foundation-models-embedding-model-strategy-TACUPFS2.js.map +1 -0
- package/dist/{foundation-models-language-model-strategy-OPGTN6DA.js → foundation-models-language-model-strategy-LLWYUGA3.js} +15 -10
- package/dist/foundation-models-language-model-strategy-LLWYUGA3.js.map +1 -0
- package/dist/index.cjs +2546 -1311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -66
- package/dist/index.d.ts +68 -66
- package/dist/index.js +11 -172
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-R6G6VVU6.js → orchestration-embedding-model-strategy-RYI3HWRZ.js} +14 -4
- package/dist/orchestration-embedding-model-strategy-RYI3HWRZ.js.map +1 -0
- package/dist/{orchestration-language-model-strategy-KFW3CFRY.js → orchestration-language-model-strategy-NIUPRYDW.js} +53 -77
- package/dist/orchestration-language-model-strategy-NIUPRYDW.js.map +1 -0
- package/package.json +18 -14
- package/LICENSE.md +0 -187
- package/dist/chunk-4RRRJBEL.js.map +0 -1
- package/dist/chunk-DYFBCE2W.js.map +0 -1
- package/dist/chunk-EXOXZ5OU.js.map +0 -1
- package/dist/chunk-F4MUYVQJ.js.map +0 -1
- package/dist/chunk-NQJIUL3F.js +0 -61
- package/dist/chunk-NQJIUL3F.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-3MMM3QDC.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-OPGTN6DA.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-R6G6VVU6.js.map +0 -1
- package/dist/orchestration-language-model-strategy-KFW3CFRY.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,63 @@ export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMe
|
|
|
7
7
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
8
8
|
import { InferSchema } from '@ai-sdk/provider-utils';
|
|
9
9
|
|
|
10
|
+
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
11
|
+
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
12
|
+
/**
|
|
13
|
+
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
14
|
+
* @param providerIdentifier - The full provider identifier string.
|
|
15
|
+
* @returns The provider name without any suffix.
|
|
16
|
+
*/
|
|
17
|
+
declare function getProviderName(providerIdentifier: string): string;
|
|
18
|
+
/** @internal */
|
|
19
|
+
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
20
|
+
api?: "orchestration" | "foundation-models" | undefined;
|
|
21
|
+
escapeTemplatePlaceholders?: boolean | undefined;
|
|
22
|
+
includeReasoning?: boolean | undefined;
|
|
23
|
+
modelParams?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
frequencyPenalty?: number | undefined;
|
|
26
|
+
maxTokens?: number | undefined;
|
|
27
|
+
n?: number | undefined;
|
|
28
|
+
parallel_tool_calls?: boolean | undefined;
|
|
29
|
+
presencePenalty?: number | undefined;
|
|
30
|
+
temperature?: number | undefined;
|
|
31
|
+
topP?: number | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
orchestrationConfigRef?: {
|
|
34
|
+
id: string;
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
scenario: string;
|
|
38
|
+
version: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
placeholderValues?: Record<string, string> | undefined;
|
|
41
|
+
promptTemplateRef?: {
|
|
42
|
+
id: string;
|
|
43
|
+
scope?: "tenant" | "resource_group" | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
name: string;
|
|
46
|
+
scenario: string;
|
|
47
|
+
version: string;
|
|
48
|
+
scope?: "tenant" | "resource_group" | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
53
|
+
/** @internal */
|
|
54
|
+
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
55
|
+
api?: "orchestration" | "foundation-models" | undefined;
|
|
56
|
+
modelParams?: {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
dimensions?: number | undefined;
|
|
59
|
+
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
60
|
+
normalize?: boolean | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
type?: "document" | "query" | "text" | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
/** @internal */
|
|
65
|
+
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
66
|
+
|
|
10
67
|
/**
|
|
11
68
|
* Escapes Jinja2 template delimiters by inserting zero-width spaces.
|
|
12
69
|
*
|
|
@@ -138,7 +195,9 @@ interface OrchestrationModelSettings {
|
|
|
138
195
|
readonly grounding?: GroundingModule;
|
|
139
196
|
/** @default false */
|
|
140
197
|
readonly includeReasoning?: boolean;
|
|
141
|
-
readonly masking?: MaskingModule
|
|
198
|
+
readonly masking?: MaskingModule | {
|
|
199
|
+
providers: MaskingModule["masking_providers"];
|
|
200
|
+
};
|
|
142
201
|
readonly modelParams?: OrchestrationModelParams;
|
|
143
202
|
readonly modelVersion?: string;
|
|
144
203
|
/**
|
|
@@ -214,7 +273,9 @@ type SAPAIDefaultSettingsConfig = FoundationModelsDefaultSettings | Orchestratio
|
|
|
214
273
|
interface SAPAIEmbeddingSettings {
|
|
215
274
|
readonly api?: SAPAIApiType;
|
|
216
275
|
/** Orchestration API only. */
|
|
217
|
-
readonly masking?: MaskingModule
|
|
276
|
+
readonly masking?: MaskingModule | {
|
|
277
|
+
providers: MaskingModule["masking_providers"];
|
|
278
|
+
};
|
|
218
279
|
/** @default 2048 */
|
|
219
280
|
readonly maxEmbeddingsPerCall?: number;
|
|
220
281
|
readonly modelParams?: FoundationModelsEmbeddingParams | Record<string, unknown>;
|
|
@@ -249,13 +310,17 @@ interface SAPAISettings {
|
|
|
249
310
|
/** @default true */
|
|
250
311
|
readonly escapeTemplatePlaceholders?: boolean;
|
|
251
312
|
/** Orchestration API only. */
|
|
313
|
+
readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
|
|
314
|
+
/** Orchestration API only. */
|
|
252
315
|
readonly filtering?: FilteringModule;
|
|
253
316
|
/** Orchestration API only. */
|
|
254
317
|
readonly grounding?: GroundingModule;
|
|
255
318
|
/** @default false */
|
|
256
319
|
readonly includeReasoning?: boolean;
|
|
257
320
|
/** Orchestration API only. */
|
|
258
|
-
readonly masking?: MaskingModule
|
|
321
|
+
readonly masking?: MaskingModule | {
|
|
322
|
+
providers: MaskingModule["masking_providers"];
|
|
323
|
+
};
|
|
259
324
|
readonly modelParams?: CommonModelParams;
|
|
260
325
|
readonly modelVersion?: string;
|
|
261
326
|
/** Orchestration API only. */
|
|
@@ -457,12 +522,6 @@ interface SAPAILanguageModelConfig {
|
|
|
457
522
|
declare class SAPAILanguageModel implements LanguageModelV3 {
|
|
458
523
|
readonly modelId: SAPAIModelId;
|
|
459
524
|
readonly specificationVersion = "v3";
|
|
460
|
-
readonly supportsImageUrls: boolean;
|
|
461
|
-
readonly supportsMultipleCompletions: boolean;
|
|
462
|
-
readonly supportsParallelToolCalls: boolean;
|
|
463
|
-
readonly supportsStreaming: boolean;
|
|
464
|
-
readonly supportsStructuredOutputs: boolean;
|
|
465
|
-
readonly supportsToolCalls: boolean;
|
|
466
525
|
get provider(): string;
|
|
467
526
|
get supportedUrls(): Record<string, RegExp[]>;
|
|
468
527
|
/** @internal */
|
|
@@ -488,63 +547,6 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
|
|
|
488
547
|
private prepareInvocation;
|
|
489
548
|
}
|
|
490
549
|
|
|
491
|
-
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
492
|
-
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
493
|
-
/**
|
|
494
|
-
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
495
|
-
* @param providerIdentifier - The full provider identifier string.
|
|
496
|
-
* @returns The provider name without any suffix.
|
|
497
|
-
*/
|
|
498
|
-
declare function getProviderName(providerIdentifier: string): string;
|
|
499
|
-
/** @internal */
|
|
500
|
-
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
501
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
502
|
-
escapeTemplatePlaceholders?: boolean | undefined;
|
|
503
|
-
includeReasoning?: boolean | undefined;
|
|
504
|
-
modelParams?: {
|
|
505
|
-
[x: string]: unknown;
|
|
506
|
-
frequencyPenalty?: number | undefined;
|
|
507
|
-
maxTokens?: number | undefined;
|
|
508
|
-
n?: number | undefined;
|
|
509
|
-
parallel_tool_calls?: boolean | undefined;
|
|
510
|
-
presencePenalty?: number | undefined;
|
|
511
|
-
temperature?: number | undefined;
|
|
512
|
-
topP?: number | undefined;
|
|
513
|
-
} | undefined;
|
|
514
|
-
orchestrationConfigRef?: {
|
|
515
|
-
id: string;
|
|
516
|
-
} | {
|
|
517
|
-
name: string;
|
|
518
|
-
scenario: string;
|
|
519
|
-
version: string;
|
|
520
|
-
} | undefined;
|
|
521
|
-
placeholderValues?: Record<string, string> | undefined;
|
|
522
|
-
promptTemplateRef?: {
|
|
523
|
-
id: string;
|
|
524
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
525
|
-
} | {
|
|
526
|
-
name: string;
|
|
527
|
-
scenario: string;
|
|
528
|
-
version: string;
|
|
529
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
530
|
-
} | undefined;
|
|
531
|
-
}>;
|
|
532
|
-
/** @internal */
|
|
533
|
-
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
534
|
-
/** @internal */
|
|
535
|
-
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
536
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
537
|
-
modelParams?: {
|
|
538
|
-
[x: string]: unknown;
|
|
539
|
-
dimensions?: number | undefined;
|
|
540
|
-
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
541
|
-
normalize?: boolean | undefined;
|
|
542
|
-
} | undefined;
|
|
543
|
-
type?: "text" | "document" | "query" | undefined;
|
|
544
|
-
}>;
|
|
545
|
-
/** @internal */
|
|
546
|
-
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
547
|
-
|
|
548
550
|
/** SAP AI Core deployment configuration: either a deployment ID or a resource group. */
|
|
549
551
|
type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
|
|
550
552
|
/** SAP AI Provider interface extending Vercel AI SDK ProviderV3. */
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,63 @@ export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMe
|
|
|
7
7
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
8
8
|
import { InferSchema } from '@ai-sdk/provider-utils';
|
|
9
9
|
|
|
10
|
+
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
11
|
+
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
12
|
+
/**
|
|
13
|
+
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
14
|
+
* @param providerIdentifier - The full provider identifier string.
|
|
15
|
+
* @returns The provider name without any suffix.
|
|
16
|
+
*/
|
|
17
|
+
declare function getProviderName(providerIdentifier: string): string;
|
|
18
|
+
/** @internal */
|
|
19
|
+
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
20
|
+
api?: "orchestration" | "foundation-models" | undefined;
|
|
21
|
+
escapeTemplatePlaceholders?: boolean | undefined;
|
|
22
|
+
includeReasoning?: boolean | undefined;
|
|
23
|
+
modelParams?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
frequencyPenalty?: number | undefined;
|
|
26
|
+
maxTokens?: number | undefined;
|
|
27
|
+
n?: number | undefined;
|
|
28
|
+
parallel_tool_calls?: boolean | undefined;
|
|
29
|
+
presencePenalty?: number | undefined;
|
|
30
|
+
temperature?: number | undefined;
|
|
31
|
+
topP?: number | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
orchestrationConfigRef?: {
|
|
34
|
+
id: string;
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
scenario: string;
|
|
38
|
+
version: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
placeholderValues?: Record<string, string> | undefined;
|
|
41
|
+
promptTemplateRef?: {
|
|
42
|
+
id: string;
|
|
43
|
+
scope?: "tenant" | "resource_group" | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
name: string;
|
|
46
|
+
scenario: string;
|
|
47
|
+
version: string;
|
|
48
|
+
scope?: "tenant" | "resource_group" | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
53
|
+
/** @internal */
|
|
54
|
+
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
55
|
+
api?: "orchestration" | "foundation-models" | undefined;
|
|
56
|
+
modelParams?: {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
dimensions?: number | undefined;
|
|
59
|
+
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
60
|
+
normalize?: boolean | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
type?: "document" | "query" | "text" | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
/** @internal */
|
|
65
|
+
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
66
|
+
|
|
10
67
|
/**
|
|
11
68
|
* Escapes Jinja2 template delimiters by inserting zero-width spaces.
|
|
12
69
|
*
|
|
@@ -138,7 +195,9 @@ interface OrchestrationModelSettings {
|
|
|
138
195
|
readonly grounding?: GroundingModule;
|
|
139
196
|
/** @default false */
|
|
140
197
|
readonly includeReasoning?: boolean;
|
|
141
|
-
readonly masking?: MaskingModule
|
|
198
|
+
readonly masking?: MaskingModule | {
|
|
199
|
+
providers: MaskingModule["masking_providers"];
|
|
200
|
+
};
|
|
142
201
|
readonly modelParams?: OrchestrationModelParams;
|
|
143
202
|
readonly modelVersion?: string;
|
|
144
203
|
/**
|
|
@@ -214,7 +273,9 @@ type SAPAIDefaultSettingsConfig = FoundationModelsDefaultSettings | Orchestratio
|
|
|
214
273
|
interface SAPAIEmbeddingSettings {
|
|
215
274
|
readonly api?: SAPAIApiType;
|
|
216
275
|
/** Orchestration API only. */
|
|
217
|
-
readonly masking?: MaskingModule
|
|
276
|
+
readonly masking?: MaskingModule | {
|
|
277
|
+
providers: MaskingModule["masking_providers"];
|
|
278
|
+
};
|
|
218
279
|
/** @default 2048 */
|
|
219
280
|
readonly maxEmbeddingsPerCall?: number;
|
|
220
281
|
readonly modelParams?: FoundationModelsEmbeddingParams | Record<string, unknown>;
|
|
@@ -249,13 +310,17 @@ interface SAPAISettings {
|
|
|
249
310
|
/** @default true */
|
|
250
311
|
readonly escapeTemplatePlaceholders?: boolean;
|
|
251
312
|
/** Orchestration API only. */
|
|
313
|
+
readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
|
|
314
|
+
/** Orchestration API only. */
|
|
252
315
|
readonly filtering?: FilteringModule;
|
|
253
316
|
/** Orchestration API only. */
|
|
254
317
|
readonly grounding?: GroundingModule;
|
|
255
318
|
/** @default false */
|
|
256
319
|
readonly includeReasoning?: boolean;
|
|
257
320
|
/** Orchestration API only. */
|
|
258
|
-
readonly masking?: MaskingModule
|
|
321
|
+
readonly masking?: MaskingModule | {
|
|
322
|
+
providers: MaskingModule["masking_providers"];
|
|
323
|
+
};
|
|
259
324
|
readonly modelParams?: CommonModelParams;
|
|
260
325
|
readonly modelVersion?: string;
|
|
261
326
|
/** Orchestration API only. */
|
|
@@ -457,12 +522,6 @@ interface SAPAILanguageModelConfig {
|
|
|
457
522
|
declare class SAPAILanguageModel implements LanguageModelV3 {
|
|
458
523
|
readonly modelId: SAPAIModelId;
|
|
459
524
|
readonly specificationVersion = "v3";
|
|
460
|
-
readonly supportsImageUrls: boolean;
|
|
461
|
-
readonly supportsMultipleCompletions: boolean;
|
|
462
|
-
readonly supportsParallelToolCalls: boolean;
|
|
463
|
-
readonly supportsStreaming: boolean;
|
|
464
|
-
readonly supportsStructuredOutputs: boolean;
|
|
465
|
-
readonly supportsToolCalls: boolean;
|
|
466
525
|
get provider(): string;
|
|
467
526
|
get supportedUrls(): Record<string, RegExp[]>;
|
|
468
527
|
/** @internal */
|
|
@@ -488,63 +547,6 @@ declare class SAPAILanguageModel implements LanguageModelV3 {
|
|
|
488
547
|
private prepareInvocation;
|
|
489
548
|
}
|
|
490
549
|
|
|
491
|
-
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
492
|
-
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
493
|
-
/**
|
|
494
|
-
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
495
|
-
* @param providerIdentifier - The full provider identifier string.
|
|
496
|
-
* @returns The provider name without any suffix.
|
|
497
|
-
*/
|
|
498
|
-
declare function getProviderName(providerIdentifier: string): string;
|
|
499
|
-
/** @internal */
|
|
500
|
-
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
501
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
502
|
-
escapeTemplatePlaceholders?: boolean | undefined;
|
|
503
|
-
includeReasoning?: boolean | undefined;
|
|
504
|
-
modelParams?: {
|
|
505
|
-
[x: string]: unknown;
|
|
506
|
-
frequencyPenalty?: number | undefined;
|
|
507
|
-
maxTokens?: number | undefined;
|
|
508
|
-
n?: number | undefined;
|
|
509
|
-
parallel_tool_calls?: boolean | undefined;
|
|
510
|
-
presencePenalty?: number | undefined;
|
|
511
|
-
temperature?: number | undefined;
|
|
512
|
-
topP?: number | undefined;
|
|
513
|
-
} | undefined;
|
|
514
|
-
orchestrationConfigRef?: {
|
|
515
|
-
id: string;
|
|
516
|
-
} | {
|
|
517
|
-
name: string;
|
|
518
|
-
scenario: string;
|
|
519
|
-
version: string;
|
|
520
|
-
} | undefined;
|
|
521
|
-
placeholderValues?: Record<string, string> | undefined;
|
|
522
|
-
promptTemplateRef?: {
|
|
523
|
-
id: string;
|
|
524
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
525
|
-
} | {
|
|
526
|
-
name: string;
|
|
527
|
-
scenario: string;
|
|
528
|
-
version: string;
|
|
529
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
530
|
-
} | undefined;
|
|
531
|
-
}>;
|
|
532
|
-
/** @internal */
|
|
533
|
-
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
534
|
-
/** @internal */
|
|
535
|
-
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
536
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
537
|
-
modelParams?: {
|
|
538
|
-
[x: string]: unknown;
|
|
539
|
-
dimensions?: number | undefined;
|
|
540
|
-
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
541
|
-
normalize?: boolean | undefined;
|
|
542
|
-
} | undefined;
|
|
543
|
-
type?: "text" | "document" | "query" | undefined;
|
|
544
|
-
}>;
|
|
545
|
-
/** @internal */
|
|
546
|
-
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
547
|
-
|
|
548
550
|
/** SAP AI Core deployment configuration: either a deployment ID or a resource group. */
|
|
549
551
|
type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
|
|
550
552
|
/** SAP AI Provider interface extending Vercel AI SDK ProviderV3. */
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
mergeSettingsWithApi,
|
|
4
|
+
resolveApi,
|
|
5
|
+
validateSettings
|
|
6
|
+
} from "./chunk-HDOSHLV6.js";
|
|
2
7
|
import {
|
|
3
8
|
escapeOrchestrationPlaceholders,
|
|
4
9
|
unescapeOrchestrationPlaceholders
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4JIMBRMV.js";
|
|
6
11
|
import {
|
|
7
12
|
ApiSwitchError,
|
|
8
13
|
SAP_AI_PROVIDER_NAME,
|
|
9
14
|
UnsupportedFeatureError,
|
|
10
15
|
VERSION,
|
|
11
16
|
__toESM,
|
|
12
|
-
deepMerge,
|
|
13
17
|
getProviderName,
|
|
14
18
|
require_dist,
|
|
15
19
|
sapAIEmbeddingProviderOptions,
|
|
16
20
|
sapAILanguageModelProviderOptions,
|
|
17
21
|
validateEmbeddingModelParamsSettings,
|
|
18
22
|
validateModelParamsSettings
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XIWHF23D.js";
|
|
20
24
|
|
|
21
25
|
// src/sap-ai-embedding-model.ts
|
|
22
26
|
import { parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
@@ -51,183 +55,24 @@ function getOrCreateLanguageModelStrategy(api) {
|
|
|
51
55
|
async function createEmbeddingModelStrategy(api) {
|
|
52
56
|
if (api === "foundation-models") {
|
|
53
57
|
const { AzureOpenAiEmbeddingClient } = await import("@sap-ai-sdk/foundation-models");
|
|
54
|
-
const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-
|
|
58
|
+
const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-TACUPFS2.js");
|
|
55
59
|
return new FoundationModelsEmbeddingModelStrategy(AzureOpenAiEmbeddingClient);
|
|
56
60
|
}
|
|
57
61
|
const { OrchestrationEmbeddingClient: OrchestrationEmbeddingClient2 } = await import("@sap-ai-sdk/orchestration");
|
|
58
|
-
const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-
|
|
62
|
+
const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-RYI3HWRZ.js");
|
|
59
63
|
return new OrchestrationEmbeddingModelStrategy(OrchestrationEmbeddingClient2);
|
|
60
64
|
}
|
|
61
65
|
async function createLanguageModelStrategy(api) {
|
|
62
66
|
if (api === "foundation-models") {
|
|
63
67
|
const { AzureOpenAiChatClient } = await import("@sap-ai-sdk/foundation-models");
|
|
64
|
-
const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-
|
|
68
|
+
const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-LLWYUGA3.js");
|
|
65
69
|
return new FoundationModelsLanguageModelStrategy(AzureOpenAiChatClient);
|
|
66
70
|
}
|
|
67
71
|
const { OrchestrationClient: OrchestrationClient2 } = await import("@sap-ai-sdk/orchestration");
|
|
68
|
-
const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-
|
|
72
|
+
const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-NIUPRYDW.js");
|
|
69
73
|
return new OrchestrationLanguageModelStrategy(OrchestrationClient2);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
// src/sap-ai-validation.ts
|
|
73
|
-
function validateEscapeTemplatePlaceholders(api, escapeTemplatePlaceholders) {
|
|
74
|
-
if (api === "foundation-models" && escapeTemplatePlaceholders === true) {
|
|
75
|
-
throw new UnsupportedFeatureError(
|
|
76
|
-
ESCAPE_TEMPLATE_PLACEHOLDERS_DESCRIPTION,
|
|
77
|
-
"foundation-models",
|
|
78
|
-
"orchestration"
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function validateFoundationModelsOnlyOptions(settings) {
|
|
83
|
-
if (!settings) return;
|
|
84
|
-
const fmSettings = settings;
|
|
85
|
-
for (const feature of FOUNDATION_MODELS_ONLY_FEATURE_KEYS) {
|
|
86
|
-
if (fmSettings[feature] !== void 0) {
|
|
87
|
-
throw new UnsupportedFeatureError(
|
|
88
|
-
FOUNDATION_MODELS_ONLY_FEATURES[feature],
|
|
89
|
-
"orchestration",
|
|
90
|
-
"foundation-models"
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function validateOrchestrationOnlyEmbeddingOptions(settings) {
|
|
96
|
-
if (!settings) return;
|
|
97
|
-
for (const feature of ORCHESTRATION_ONLY_EMBEDDING_FEATURE_KEYS) {
|
|
98
|
-
if (settings[feature] !== void 0) {
|
|
99
|
-
throw new UnsupportedFeatureError(
|
|
100
|
-
ORCHESTRATION_ONLY_EMBEDDING_FEATURES[feature],
|
|
101
|
-
"foundation-models",
|
|
102
|
-
"orchestration"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function validateOrchestrationOnlyOptions(settings) {
|
|
108
|
-
if (!settings) return;
|
|
109
|
-
const orchSettings = settings;
|
|
110
|
-
for (const feature of ORCHESTRATION_ONLY_FEATURE_KEYS) {
|
|
111
|
-
if (orchSettings[feature] !== void 0) {
|
|
112
|
-
throw new UnsupportedFeatureError(
|
|
113
|
-
ORCHESTRATION_ONLY_FEATURES[feature],
|
|
114
|
-
"foundation-models",
|
|
115
|
-
"orchestration"
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
var ORCHESTRATION_ONLY_FEATURE_KEYS = [
|
|
121
|
-
"filtering",
|
|
122
|
-
"grounding",
|
|
123
|
-
"masking",
|
|
124
|
-
"orchestrationConfigRef",
|
|
125
|
-
"placeholderValues",
|
|
126
|
-
"promptTemplateRef",
|
|
127
|
-
"streamOptions",
|
|
128
|
-
"tools",
|
|
129
|
-
"translation"
|
|
130
|
-
];
|
|
131
|
-
var ORCHESTRATION_ONLY_FEATURES = {
|
|
132
|
-
filtering: "Content filtering",
|
|
133
|
-
grounding: "Document grounding",
|
|
134
|
-
masking: "Data masking",
|
|
135
|
-
orchestrationConfigRef: "Orchestration config reference (orchestrationConfigRef)",
|
|
136
|
-
placeholderValues: "Placeholder values (placeholderValues)",
|
|
137
|
-
promptTemplateRef: "Prompt template reference (promptTemplateRef)",
|
|
138
|
-
streamOptions: "Stream options for post-LLM modules",
|
|
139
|
-
tools: "SAP-format tool definitions (use AI SDK tools instead)",
|
|
140
|
-
translation: "Translation"
|
|
141
|
-
};
|
|
142
|
-
var FOUNDATION_MODELS_ONLY_FEATURE_KEYS = ["dataSources"];
|
|
143
|
-
var FOUNDATION_MODELS_ONLY_FEATURES = {
|
|
144
|
-
dataSources: "Azure On Your Data (dataSources)"
|
|
145
|
-
};
|
|
146
|
-
var ORCHESTRATION_ONLY_INVOCATION_FEATURE_KEYS = [
|
|
147
|
-
"orchestrationConfigRef",
|
|
148
|
-
"placeholderValues",
|
|
149
|
-
"promptTemplateRef"
|
|
150
|
-
];
|
|
151
|
-
var ORCHESTRATION_ONLY_EMBEDDING_FEATURE_KEYS = ["masking"];
|
|
152
|
-
var ORCHESTRATION_ONLY_EMBEDDING_FEATURES = {
|
|
153
|
-
masking: ORCHESTRATION_ONLY_FEATURES.masking
|
|
154
|
-
};
|
|
155
|
-
var ESCAPE_TEMPLATE_PLACEHOLDERS_DESCRIPTION = "escapeTemplatePlaceholders (Jinja2 template escaping)";
|
|
156
|
-
function validateApiSwitch(fromApi, toApi, modelSettings) {
|
|
157
|
-
if (fromApi === toApi) return;
|
|
158
|
-
if (!modelSettings) return;
|
|
159
|
-
if (fromApi === "orchestration" && toApi === "foundation-models") {
|
|
160
|
-
const orchSettings = modelSettings;
|
|
161
|
-
for (const feature of ORCHESTRATION_ONLY_FEATURE_KEYS) {
|
|
162
|
-
if (orchSettings[feature] !== void 0) {
|
|
163
|
-
throw new ApiSwitchError(fromApi, toApi, feature);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (fromApi === "foundation-models" && toApi === "orchestration") {
|
|
168
|
-
const fmSettings = modelSettings;
|
|
169
|
-
for (const feature of FOUNDATION_MODELS_ONLY_FEATURE_KEYS) {
|
|
170
|
-
if (fmSettings[feature] !== void 0) {
|
|
171
|
-
throw new ApiSwitchError(fromApi, toApi, feature);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
var VALID_API_TYPES = ["orchestration", "foundation-models"];
|
|
177
|
-
function mergeSettingsWithApi(defaultSettings, callSettings, fallbackApi) {
|
|
178
|
-
return {
|
|
179
|
-
...deepMerge(defaultSettings, callSettings),
|
|
180
|
-
api: callSettings.api ?? defaultSettings?.api ?? fallbackApi
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function resolveApi(providerApi, modelApi, invocationApi) {
|
|
184
|
-
return invocationApi ?? modelApi ?? providerApi ?? "orchestration";
|
|
185
|
-
}
|
|
186
|
-
function validateApiInput(api) {
|
|
187
|
-
if (api === void 0) return;
|
|
188
|
-
if (typeof api !== "string" || !VALID_API_TYPES.includes(api)) {
|
|
189
|
-
throw new Error(
|
|
190
|
-
`Invalid API type: ${JSON.stringify(api)}. Valid values are: ${VALID_API_TYPES.map((t) => `"${t}"`).join(", ")}`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function validateSettings(options) {
|
|
195
|
-
const { api, embeddingSettings, invocationSettings, modelApi, modelSettings } = options;
|
|
196
|
-
validateApiInput(api);
|
|
197
|
-
if (invocationSettings?.api !== void 0) {
|
|
198
|
-
validateApiInput(invocationSettings.api);
|
|
199
|
-
}
|
|
200
|
-
if (invocationSettings?.api !== void 0) {
|
|
201
|
-
const effectiveModelApi = modelApi ?? "orchestration";
|
|
202
|
-
if (effectiveModelApi !== invocationSettings.api) {
|
|
203
|
-
validateApiSwitch(effectiveModelApi, invocationSettings.api, modelSettings);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (api === "foundation-models") {
|
|
207
|
-
validateOrchestrationOnlyOptions(modelSettings);
|
|
208
|
-
validateOrchestrationOnlyInvocationOptions(invocationSettings);
|
|
209
|
-
validateOrchestrationOnlyEmbeddingOptions(embeddingSettings);
|
|
210
|
-
} else {
|
|
211
|
-
validateFoundationModelsOnlyOptions(modelSettings);
|
|
212
|
-
}
|
|
213
|
-
const modelEscape = modelSettings?.escapeTemplatePlaceholders;
|
|
214
|
-
const invocationEscape = invocationSettings?.escapeTemplatePlaceholders;
|
|
215
|
-
const effectiveEscape = invocationEscape ?? modelEscape;
|
|
216
|
-
validateEscapeTemplatePlaceholders(api, effectiveEscape);
|
|
217
|
-
}
|
|
218
|
-
function validateOrchestrationOnlyInvocationOptions(invocationSettings) {
|
|
219
|
-
if (!invocationSettings) return;
|
|
220
|
-
for (const feature of ORCHESTRATION_ONLY_INVOCATION_FEATURE_KEYS) {
|
|
221
|
-
if (invocationSettings[feature] !== void 0) {
|
|
222
|
-
throw new UnsupportedFeatureError(
|
|
223
|
-
ORCHESTRATION_ONLY_FEATURES[feature],
|
|
224
|
-
"foundation-models",
|
|
225
|
-
"orchestration"
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
76
|
// src/sap-ai-embedding-model.ts
|
|
232
77
|
var DEFAULT_MAX_EMBEDDINGS_PER_CALL = 2048;
|
|
233
78
|
var SAPAIEmbeddingModel = class {
|
|
@@ -284,12 +129,6 @@ import { parseProviderOptions as parseProviderOptions2 } from "@ai-sdk/provider-
|
|
|
284
129
|
var SAPAILanguageModel = class {
|
|
285
130
|
modelId;
|
|
286
131
|
specificationVersion = "v3";
|
|
287
|
-
supportsImageUrls = true;
|
|
288
|
-
supportsMultipleCompletions = true;
|
|
289
|
-
supportsParallelToolCalls = true;
|
|
290
|
-
supportsStreaming = true;
|
|
291
|
-
supportsStructuredOutputs = true;
|
|
292
|
-
supportsToolCalls = true;
|
|
293
132
|
get provider() {
|
|
294
133
|
return this.config.provider;
|
|
295
134
|
}
|