@jerome-benoit/sap-ai-provider-v2 4.6.8 → 4.7.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/LICENSE +202 -0
- package/README.md +1 -1
- package/dist/{chunk-M3AV2YUV.js → chunk-36DFHUVQ.js} +414 -277
- package/dist/chunk-36DFHUVQ.js.map +1 -0
- package/dist/{chunk-IIBSUXGT.js → chunk-4JIMBRMV.js} +44 -7
- package/dist/chunk-4JIMBRMV.js.map +1 -0
- package/dist/{chunk-6BVUDEKZ.js → chunk-BZZJKLDG.js} +60 -6
- package/dist/chunk-BZZJKLDG.js.map +1 -0
- package/dist/chunk-GMMX46AH.js +93 -0
- package/dist/chunk-GMMX46AH.js.map +1 -0
- package/dist/{chunk-7OGNFVGC.js → chunk-TVXWNZQT.js} +5276 -5608
- package/dist/chunk-TVXWNZQT.js.map +1 -0
- package/dist/chunk-WDUOKIKD.js +188 -0
- package/dist/chunk-WDUOKIKD.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-GXJRGM4X.js → foundation-models-embedding-model-strategy-YWPDIJEN.js} +8 -4
- package/dist/foundation-models-embedding-model-strategy-YWPDIJEN.js.map +1 -0
- package/dist/{foundation-models-language-model-strategy-FGUGQPBL.js → foundation-models-language-model-strategy-WDSQWU64.js} +16 -13
- package/dist/foundation-models-language-model-strategy-WDSQWU64.js.map +1 -0
- package/dist/index.cjs +6349 -6413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -60
- package/dist/index.d.ts +66 -60
- package/dist/index.js +12 -176
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-663QYZL7.js → orchestration-embedding-model-strategy-66QYAO64.js} +14 -4
- package/dist/orchestration-embedding-model-strategy-66QYAO64.js.map +1 -0
- package/dist/{orchestration-language-model-strategy-X3LKHORW.js → orchestration-language-model-strategy-4TKRZK7U.js} +52 -77
- package/dist/orchestration-language-model-strategy-4TKRZK7U.js.map +1 -0
- package/package.json +27 -21
- package/LICENSE.md +0 -187
- package/dist/chunk-6BVUDEKZ.js.map +0 -1
- package/dist/chunk-7OGNFVGC.js.map +0 -1
- package/dist/chunk-IIBSUXGT.js.map +0 -1
- package/dist/chunk-M3AV2YUV.js.map +0 -1
- package/dist/chunk-X66RDDSB.js +0 -61
- package/dist/chunk-X66RDDSB.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-GXJRGM4X.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-FGUGQPBL.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-663QYZL7.js.map +0 -1
- package/dist/orchestration-language-model-strategy-X3LKHORW.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>;
|
|
@@ -255,7 +316,9 @@ interface SAPAISettings {
|
|
|
255
316
|
/** @default false */
|
|
256
317
|
readonly includeReasoning?: boolean;
|
|
257
318
|
/** Orchestration API only. */
|
|
258
|
-
readonly masking?: MaskingModule
|
|
319
|
+
readonly masking?: MaskingModule | {
|
|
320
|
+
providers: MaskingModule["masking_providers"];
|
|
321
|
+
};
|
|
259
322
|
readonly modelParams?: CommonModelParams;
|
|
260
323
|
readonly modelVersion?: string;
|
|
261
324
|
/** Orchestration API only. */
|
|
@@ -518,63 +581,6 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2 {
|
|
|
518
581
|
}>;
|
|
519
582
|
}
|
|
520
583
|
|
|
521
|
-
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
522
|
-
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
523
|
-
/**
|
|
524
|
-
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
525
|
-
* @param providerIdentifier - The full provider identifier string.
|
|
526
|
-
* @returns The provider name without any suffix.
|
|
527
|
-
*/
|
|
528
|
-
declare function getProviderName(providerIdentifier: string): string;
|
|
529
|
-
/** @internal */
|
|
530
|
-
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
531
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
532
|
-
escapeTemplatePlaceholders?: boolean | undefined;
|
|
533
|
-
includeReasoning?: boolean | undefined;
|
|
534
|
-
modelParams?: {
|
|
535
|
-
[x: string]: unknown;
|
|
536
|
-
frequencyPenalty?: number | undefined;
|
|
537
|
-
maxTokens?: number | undefined;
|
|
538
|
-
n?: number | undefined;
|
|
539
|
-
parallel_tool_calls?: boolean | undefined;
|
|
540
|
-
presencePenalty?: number | undefined;
|
|
541
|
-
temperature?: number | undefined;
|
|
542
|
-
topP?: number | undefined;
|
|
543
|
-
} | undefined;
|
|
544
|
-
orchestrationConfigRef?: {
|
|
545
|
-
id: string;
|
|
546
|
-
} | {
|
|
547
|
-
name: string;
|
|
548
|
-
scenario: string;
|
|
549
|
-
version: string;
|
|
550
|
-
} | undefined;
|
|
551
|
-
placeholderValues?: Record<string, string> | undefined;
|
|
552
|
-
promptTemplateRef?: {
|
|
553
|
-
id: string;
|
|
554
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
555
|
-
} | {
|
|
556
|
-
name: string;
|
|
557
|
-
scenario: string;
|
|
558
|
-
version: string;
|
|
559
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
560
|
-
} | undefined;
|
|
561
|
-
}>;
|
|
562
|
-
/** @internal */
|
|
563
|
-
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
564
|
-
/** @internal */
|
|
565
|
-
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
566
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
567
|
-
modelParams?: {
|
|
568
|
-
[x: string]: unknown;
|
|
569
|
-
dimensions?: number | undefined;
|
|
570
|
-
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
571
|
-
normalize?: boolean | undefined;
|
|
572
|
-
} | undefined;
|
|
573
|
-
type?: "text" | "document" | "query" | undefined;
|
|
574
|
-
}>;
|
|
575
|
-
/** @internal */
|
|
576
|
-
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
577
|
-
|
|
578
584
|
/** SAP AI Core deployment configuration: either a deployment ID or a resource group. */
|
|
579
585
|
type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
|
|
580
586
|
/**
|
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>;
|
|
@@ -255,7 +316,9 @@ interface SAPAISettings {
|
|
|
255
316
|
/** @default false */
|
|
256
317
|
readonly includeReasoning?: boolean;
|
|
257
318
|
/** Orchestration API only. */
|
|
258
|
-
readonly masking?: MaskingModule
|
|
319
|
+
readonly masking?: MaskingModule | {
|
|
320
|
+
providers: MaskingModule["masking_providers"];
|
|
321
|
+
};
|
|
259
322
|
readonly modelParams?: CommonModelParams;
|
|
260
323
|
readonly modelVersion?: string;
|
|
261
324
|
/** Orchestration API only. */
|
|
@@ -518,63 +581,6 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2 {
|
|
|
518
581
|
}>;
|
|
519
582
|
}
|
|
520
583
|
|
|
521
|
-
/** Default provider name used as key in `providerOptions` and `providerMetadata` objects. */
|
|
522
|
-
declare const SAP_AI_PROVIDER_NAME: "sap-ai";
|
|
523
|
-
/**
|
|
524
|
-
* Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
|
|
525
|
-
* @param providerIdentifier - The full provider identifier string.
|
|
526
|
-
* @returns The provider name without any suffix.
|
|
527
|
-
*/
|
|
528
|
-
declare function getProviderName(providerIdentifier: string): string;
|
|
529
|
-
/** @internal */
|
|
530
|
-
declare const sapAILanguageModelProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
531
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
532
|
-
escapeTemplatePlaceholders?: boolean | undefined;
|
|
533
|
-
includeReasoning?: boolean | undefined;
|
|
534
|
-
modelParams?: {
|
|
535
|
-
[x: string]: unknown;
|
|
536
|
-
frequencyPenalty?: number | undefined;
|
|
537
|
-
maxTokens?: number | undefined;
|
|
538
|
-
n?: number | undefined;
|
|
539
|
-
parallel_tool_calls?: boolean | undefined;
|
|
540
|
-
presencePenalty?: number | undefined;
|
|
541
|
-
temperature?: number | undefined;
|
|
542
|
-
topP?: number | undefined;
|
|
543
|
-
} | undefined;
|
|
544
|
-
orchestrationConfigRef?: {
|
|
545
|
-
id: string;
|
|
546
|
-
} | {
|
|
547
|
-
name: string;
|
|
548
|
-
scenario: string;
|
|
549
|
-
version: string;
|
|
550
|
-
} | undefined;
|
|
551
|
-
placeholderValues?: Record<string, string> | undefined;
|
|
552
|
-
promptTemplateRef?: {
|
|
553
|
-
id: string;
|
|
554
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
555
|
-
} | {
|
|
556
|
-
name: string;
|
|
557
|
-
scenario: string;
|
|
558
|
-
version: string;
|
|
559
|
-
scope?: "resource_group" | "tenant" | undefined;
|
|
560
|
-
} | undefined;
|
|
561
|
-
}>;
|
|
562
|
-
/** @internal */
|
|
563
|
-
type SAPAILanguageModelProviderOptions = InferSchema<typeof sapAILanguageModelProviderOptions>;
|
|
564
|
-
/** @internal */
|
|
565
|
-
declare const sapAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
566
|
-
api?: "foundation-models" | "orchestration" | undefined;
|
|
567
|
-
modelParams?: {
|
|
568
|
-
[x: string]: unknown;
|
|
569
|
-
dimensions?: number | undefined;
|
|
570
|
-
encoding_format?: "base64" | "binary" | "float" | undefined;
|
|
571
|
-
normalize?: boolean | undefined;
|
|
572
|
-
} | undefined;
|
|
573
|
-
type?: "text" | "document" | "query" | undefined;
|
|
574
|
-
}>;
|
|
575
|
-
/** @internal */
|
|
576
|
-
type SAPAIEmbeddingProviderOptions = InferSchema<typeof sapAIEmbeddingProviderOptions>;
|
|
577
|
-
|
|
578
584
|
/** SAP AI Core deployment configuration: either a deployment ID or a resource group. */
|
|
579
585
|
type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
|
|
580
586
|
/**
|
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-WDUOKIKD.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-TVXWNZQT.js";
|
|
20
24
|
|
|
21
25
|
// src/sap-ai-adapters-v3-to-v2.ts
|
|
22
26
|
function convertFinishReasonToV2(internalFinishReason) {
|
|
@@ -249,183 +253,24 @@ function getOrCreateLanguageModelStrategy(api) {
|
|
|
249
253
|
async function createEmbeddingModelStrategy(api) {
|
|
250
254
|
if (api === "foundation-models") {
|
|
251
255
|
const { AzureOpenAiEmbeddingClient } = await import("@sap-ai-sdk/foundation-models");
|
|
252
|
-
const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-
|
|
256
|
+
const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-YWPDIJEN.js");
|
|
253
257
|
return new FoundationModelsEmbeddingModelStrategy(AzureOpenAiEmbeddingClient);
|
|
254
258
|
}
|
|
255
259
|
const { OrchestrationEmbeddingClient: OrchestrationEmbeddingClient2 } = await import("@sap-ai-sdk/orchestration");
|
|
256
|
-
const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-
|
|
260
|
+
const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-66QYAO64.js");
|
|
257
261
|
return new OrchestrationEmbeddingModelStrategy(OrchestrationEmbeddingClient2);
|
|
258
262
|
}
|
|
259
263
|
async function createLanguageModelStrategy(api) {
|
|
260
264
|
if (api === "foundation-models") {
|
|
261
265
|
const { AzureOpenAiChatClient } = await import("@sap-ai-sdk/foundation-models");
|
|
262
|
-
const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-
|
|
266
|
+
const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-WDSQWU64.js");
|
|
263
267
|
return new FoundationModelsLanguageModelStrategy(AzureOpenAiChatClient);
|
|
264
268
|
}
|
|
265
269
|
const { OrchestrationClient: OrchestrationClient2 } = await import("@sap-ai-sdk/orchestration");
|
|
266
|
-
const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-
|
|
270
|
+
const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-4TKRZK7U.js");
|
|
267
271
|
return new OrchestrationLanguageModelStrategy(OrchestrationClient2);
|
|
268
272
|
}
|
|
269
273
|
|
|
270
|
-
// src/sap-ai-validation.ts
|
|
271
|
-
function validateEscapeTemplatePlaceholders(api, escapeTemplatePlaceholders) {
|
|
272
|
-
if (api === "foundation-models" && escapeTemplatePlaceholders === true) {
|
|
273
|
-
throw new UnsupportedFeatureError(
|
|
274
|
-
ESCAPE_TEMPLATE_PLACEHOLDERS_DESCRIPTION,
|
|
275
|
-
"foundation-models",
|
|
276
|
-
"orchestration"
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function validateFoundationModelsOnlyOptions(settings) {
|
|
281
|
-
if (!settings) return;
|
|
282
|
-
const fmSettings = settings;
|
|
283
|
-
for (const feature of FOUNDATION_MODELS_ONLY_FEATURE_KEYS) {
|
|
284
|
-
if (fmSettings[feature] !== void 0) {
|
|
285
|
-
throw new UnsupportedFeatureError(
|
|
286
|
-
FOUNDATION_MODELS_ONLY_FEATURES[feature],
|
|
287
|
-
"orchestration",
|
|
288
|
-
"foundation-models"
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function validateOrchestrationOnlyEmbeddingOptions(settings) {
|
|
294
|
-
if (!settings) return;
|
|
295
|
-
for (const feature of ORCHESTRATION_ONLY_EMBEDDING_FEATURE_KEYS) {
|
|
296
|
-
if (settings[feature] !== void 0) {
|
|
297
|
-
throw new UnsupportedFeatureError(
|
|
298
|
-
ORCHESTRATION_ONLY_EMBEDDING_FEATURES[feature],
|
|
299
|
-
"foundation-models",
|
|
300
|
-
"orchestration"
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function validateOrchestrationOnlyOptions(settings) {
|
|
306
|
-
if (!settings) return;
|
|
307
|
-
const orchSettings = settings;
|
|
308
|
-
for (const feature of ORCHESTRATION_ONLY_FEATURE_KEYS) {
|
|
309
|
-
if (orchSettings[feature] !== void 0) {
|
|
310
|
-
throw new UnsupportedFeatureError(
|
|
311
|
-
ORCHESTRATION_ONLY_FEATURES[feature],
|
|
312
|
-
"foundation-models",
|
|
313
|
-
"orchestration"
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
var ORCHESTRATION_ONLY_FEATURE_KEYS = [
|
|
319
|
-
"filtering",
|
|
320
|
-
"grounding",
|
|
321
|
-
"masking",
|
|
322
|
-
"orchestrationConfigRef",
|
|
323
|
-
"placeholderValues",
|
|
324
|
-
"promptTemplateRef",
|
|
325
|
-
"streamOptions",
|
|
326
|
-
"tools",
|
|
327
|
-
"translation"
|
|
328
|
-
];
|
|
329
|
-
var ORCHESTRATION_ONLY_FEATURES = {
|
|
330
|
-
filtering: "Content filtering",
|
|
331
|
-
grounding: "Document grounding",
|
|
332
|
-
masking: "Data masking",
|
|
333
|
-
orchestrationConfigRef: "Orchestration config reference (orchestrationConfigRef)",
|
|
334
|
-
placeholderValues: "Placeholder values (placeholderValues)",
|
|
335
|
-
promptTemplateRef: "Prompt template reference (promptTemplateRef)",
|
|
336
|
-
streamOptions: "Stream options for post-LLM modules",
|
|
337
|
-
tools: "SAP-format tool definitions (use AI SDK tools instead)",
|
|
338
|
-
translation: "Translation"
|
|
339
|
-
};
|
|
340
|
-
var FOUNDATION_MODELS_ONLY_FEATURE_KEYS = ["dataSources"];
|
|
341
|
-
var FOUNDATION_MODELS_ONLY_FEATURES = {
|
|
342
|
-
dataSources: "Azure On Your Data (dataSources)"
|
|
343
|
-
};
|
|
344
|
-
var ORCHESTRATION_ONLY_INVOCATION_FEATURE_KEYS = [
|
|
345
|
-
"orchestrationConfigRef",
|
|
346
|
-
"placeholderValues",
|
|
347
|
-
"promptTemplateRef"
|
|
348
|
-
];
|
|
349
|
-
var ORCHESTRATION_ONLY_EMBEDDING_FEATURE_KEYS = ["masking"];
|
|
350
|
-
var ORCHESTRATION_ONLY_EMBEDDING_FEATURES = {
|
|
351
|
-
masking: ORCHESTRATION_ONLY_FEATURES.masking
|
|
352
|
-
};
|
|
353
|
-
var ESCAPE_TEMPLATE_PLACEHOLDERS_DESCRIPTION = "escapeTemplatePlaceholders (Jinja2 template escaping)";
|
|
354
|
-
function validateApiSwitch(fromApi, toApi, modelSettings) {
|
|
355
|
-
if (fromApi === toApi) return;
|
|
356
|
-
if (!modelSettings) return;
|
|
357
|
-
if (fromApi === "orchestration" && toApi === "foundation-models") {
|
|
358
|
-
const orchSettings = modelSettings;
|
|
359
|
-
for (const feature of ORCHESTRATION_ONLY_FEATURE_KEYS) {
|
|
360
|
-
if (orchSettings[feature] !== void 0) {
|
|
361
|
-
throw new ApiSwitchError(fromApi, toApi, feature);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (fromApi === "foundation-models" && toApi === "orchestration") {
|
|
366
|
-
const fmSettings = modelSettings;
|
|
367
|
-
for (const feature of FOUNDATION_MODELS_ONLY_FEATURE_KEYS) {
|
|
368
|
-
if (fmSettings[feature] !== void 0) {
|
|
369
|
-
throw new ApiSwitchError(fromApi, toApi, feature);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
var VALID_API_TYPES = ["orchestration", "foundation-models"];
|
|
375
|
-
function mergeSettingsWithApi(defaultSettings, callSettings, fallbackApi) {
|
|
376
|
-
return {
|
|
377
|
-
...deepMerge(defaultSettings, callSettings),
|
|
378
|
-
api: callSettings.api ?? defaultSettings?.api ?? fallbackApi
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function resolveApi(providerApi, modelApi, invocationApi) {
|
|
382
|
-
return invocationApi ?? modelApi ?? providerApi ?? "orchestration";
|
|
383
|
-
}
|
|
384
|
-
function validateApiInput(api) {
|
|
385
|
-
if (api === void 0) return;
|
|
386
|
-
if (typeof api !== "string" || !VALID_API_TYPES.includes(api)) {
|
|
387
|
-
throw new Error(
|
|
388
|
-
`Invalid API type: ${JSON.stringify(api)}. Valid values are: ${VALID_API_TYPES.map((t) => `"${t}"`).join(", ")}`
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
function validateSettings(options) {
|
|
393
|
-
const { api, embeddingSettings, invocationSettings, modelApi, modelSettings } = options;
|
|
394
|
-
validateApiInput(api);
|
|
395
|
-
if (invocationSettings?.api !== void 0) {
|
|
396
|
-
validateApiInput(invocationSettings.api);
|
|
397
|
-
}
|
|
398
|
-
if (invocationSettings?.api !== void 0) {
|
|
399
|
-
const effectiveModelApi = modelApi ?? "orchestration";
|
|
400
|
-
if (effectiveModelApi !== invocationSettings.api) {
|
|
401
|
-
validateApiSwitch(effectiveModelApi, invocationSettings.api, modelSettings);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
if (api === "foundation-models") {
|
|
405
|
-
validateOrchestrationOnlyOptions(modelSettings);
|
|
406
|
-
validateOrchestrationOnlyInvocationOptions(invocationSettings);
|
|
407
|
-
validateOrchestrationOnlyEmbeddingOptions(embeddingSettings);
|
|
408
|
-
} else {
|
|
409
|
-
validateFoundationModelsOnlyOptions(modelSettings);
|
|
410
|
-
}
|
|
411
|
-
const modelEscape = modelSettings?.escapeTemplatePlaceholders;
|
|
412
|
-
const invocationEscape = invocationSettings?.escapeTemplatePlaceholders;
|
|
413
|
-
const effectiveEscape = invocationEscape ?? modelEscape;
|
|
414
|
-
validateEscapeTemplatePlaceholders(api, effectiveEscape);
|
|
415
|
-
}
|
|
416
|
-
function validateOrchestrationOnlyInvocationOptions(invocationSettings) {
|
|
417
|
-
if (!invocationSettings) return;
|
|
418
|
-
for (const feature of ORCHESTRATION_ONLY_INVOCATION_FEATURE_KEYS) {
|
|
419
|
-
if (invocationSettings[feature] !== void 0) {
|
|
420
|
-
throw new UnsupportedFeatureError(
|
|
421
|
-
ORCHESTRATION_ONLY_FEATURES[feature],
|
|
422
|
-
"foundation-models",
|
|
423
|
-
"orchestration"
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
274
|
// src/sap-ai-embedding-model.ts
|
|
430
275
|
var DEFAULT_MAX_EMBEDDINGS_PER_CALL = 2048;
|
|
431
276
|
var SAPAIEmbeddingModel = class {
|
|
@@ -520,7 +365,7 @@ var SAPAIEmbeddingModelV2 = class {
|
|
|
520
365
|
}
|
|
521
366
|
return {
|
|
522
367
|
embeddings: result.embeddings,
|
|
523
|
-
providerMetadata:
|
|
368
|
+
providerMetadata: convertProviderMetadataToV2(result.providerMetadata),
|
|
524
369
|
response: result.response ? {
|
|
525
370
|
body: result.response.body,
|
|
526
371
|
headers: result.response.headers
|
|
@@ -529,21 +374,12 @@ var SAPAIEmbeddingModelV2 = class {
|
|
|
529
374
|
};
|
|
530
375
|
}
|
|
531
376
|
};
|
|
532
|
-
function castProviderMetadataToV2(metadata) {
|
|
533
|
-
return metadata;
|
|
534
|
-
}
|
|
535
377
|
|
|
536
378
|
// src/sap-ai-language-model.ts
|
|
537
379
|
import { parseProviderOptions as parseProviderOptions2 } from "@ai-sdk/provider-utils";
|
|
538
380
|
var SAPAILanguageModel = class {
|
|
539
381
|
modelId;
|
|
540
382
|
specificationVersion = "v3";
|
|
541
|
-
supportsImageUrls = true;
|
|
542
|
-
supportsMultipleCompletions = true;
|
|
543
|
-
supportsParallelToolCalls = true;
|
|
544
|
-
supportsStreaming = true;
|
|
545
|
-
supportsStructuredOutputs = true;
|
|
546
|
-
supportsToolCalls = true;
|
|
547
383
|
get provider() {
|
|
548
384
|
return this.config.provider;
|
|
549
385
|
}
|