@jerome-benoit/sap-ai-provider 4.6.0 → 4.6.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/dist/{chunk-BV5Y6RMC.js → chunk-HJZCRF7J.js} +11 -4
- package/dist/chunk-HJZCRF7J.js.map +1 -0
- package/dist/{chunk-DBAIFR3B.js → chunk-I5ZTK7M5.js} +64 -64
- package/dist/{chunk-DBAIFR3B.js.map → chunk-I5ZTK7M5.js.map} +1 -1
- package/dist/{chunk-WYDTQDMJ.js → chunk-IAXILSPQ.js} +3 -3
- package/dist/chunk-IAXILSPQ.js.map +1 -0
- package/dist/{chunk-KS5QNMYZ.js → chunk-U2HDUNO7.js} +23 -21
- package/dist/chunk-U2HDUNO7.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-XLD3PGCK.js → foundation-models-embedding-model-strategy-C4SXGZ66.js} +5 -10
- package/dist/foundation-models-embedding-model-strategy-C4SXGZ66.js.map +1 -0
- package/dist/{foundation-models-language-model-strategy-SNBZBWX4.js → foundation-models-language-model-strategy-3D4V6PSZ.js} +5 -5
- package/dist/foundation-models-language-model-strategy-3D4V6PSZ.js.map +1 -0
- package/dist/index.cjs +99 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-6BKD5NW7.js → orchestration-embedding-model-strategy-7FY6NJD7.js} +5 -10
- package/dist/orchestration-embedding-model-strategy-7FY6NJD7.js.map +1 -0
- package/dist/{orchestration-language-model-strategy-OYSEPGQG.js → orchestration-language-model-strategy-FI5HLHWP.js} +4 -4
- package/dist/orchestration-language-model-strategy-FI5HLHWP.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-BV5Y6RMC.js.map +0 -1
- package/dist/chunk-KS5QNMYZ.js.map +0 -1
- package/dist/chunk-WYDTQDMJ.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-XLD3PGCK.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-SNBZBWX4.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-6BKD5NW7.js.map +0 -1
- package/dist/orchestration-language-model-strategy-OYSEPGQG.js.map +0 -1
|
@@ -2,11 +2,12 @@ import {createRequire as __createRequire} from 'module';var require=__createRequ
|
|
|
2
2
|
import {
|
|
3
3
|
buildEmbeddingResult,
|
|
4
4
|
prepareEmbeddingCall
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-U2HDUNO7.js";
|
|
6
6
|
import {
|
|
7
7
|
VERSION,
|
|
8
|
-
convertToAISDKError
|
|
9
|
-
|
|
8
|
+
convertToAISDKError,
|
|
9
|
+
deepMerge
|
|
10
|
+
} from "./chunk-I5ZTK7M5.js";
|
|
10
11
|
|
|
11
12
|
// src/base-embedding-model-strategy.ts
|
|
12
13
|
var BaseEmbeddingModelStrategy = class {
|
|
@@ -46,9 +47,15 @@ var BaseEmbeddingModelStrategy = class {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
mergeModelParams(settings, embeddingOptions) {
|
|
51
|
+
return deepMerge(
|
|
52
|
+
settings.modelParams ?? {},
|
|
53
|
+
embeddingOptions?.modelParams ?? {}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
export {
|
|
52
59
|
BaseEmbeddingModelStrategy
|
|
53
60
|
};
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-HJZCRF7J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/base-embedding-model-strategy.ts"],"sourcesContent":["/** Base class for embedding model strategies using the Template Method pattern. */\nimport type {\n EmbeddingModelV3CallOptions,\n EmbeddingModelV3Embedding,\n EmbeddingModelV3Result,\n} from \"@ai-sdk/provider\";\n\nimport type { SAPAIEmbeddingSettings } from \"./sap-ai-settings.js\";\nimport type { EmbeddingModelAPIStrategy, EmbeddingModelStrategyConfig } from \"./sap-ai-strategy.js\";\n\nimport { deepMerge } from \"./deep-merge.js\";\nimport { convertToAISDKError } from \"./sap-ai-error.js\";\nimport {\n buildEmbeddingResult,\n type EmbeddingProviderOptions,\n type EmbeddingType,\n prepareEmbeddingCall,\n} from \"./strategy-utils.js\";\nimport { VERSION } from \"./version.js\";\n\n/**\n * Abstract base class for embedding model strategies using the Template Method pattern.\n * @template TClient - The SDK client type (e.g., AzureOpenAiEmbeddingClient, OrchestrationEmbeddingClient).\n * @template TResponse - The API response type from the SDK client.\n * @internal\n */\nexport abstract class BaseEmbeddingModelStrategy<\n TClient,\n TResponse,\n> implements EmbeddingModelAPIStrategy {\n /**\n * Template method implementing the shared embedding algorithm.\n * @param config - Strategy configuration.\n * @param settings - Embedding model settings.\n * @param options - AI SDK call options.\n * @param maxEmbeddingsPerCall - Maximum embeddings per call.\n * @returns Complete embedding result for AI SDK.\n * @internal\n */\n async doEmbed(\n config: EmbeddingModelStrategyConfig,\n settings: SAPAIEmbeddingSettings,\n options: EmbeddingModelV3CallOptions,\n maxEmbeddingsPerCall: number,\n ): Promise<EmbeddingModelV3Result> {\n const { abortSignal, values } = options;\n\n const { embeddingOptions, providerName } = await prepareEmbeddingCall(\n { maxEmbeddingsPerCall, modelId: config.modelId, provider: config.provider },\n options,\n );\n\n const embeddingType =\n embeddingOptions?.type ?? (settings.type as EmbeddingType | undefined) ?? \"text\";\n\n try {\n const client = this.createClient(config, settings, embeddingOptions);\n\n const response = await this.executeCall(client, values, embeddingType, abortSignal);\n\n const embeddings = this.extractEmbeddings(response);\n const totalTokens = this.extractTokenCount(response);\n\n return buildEmbeddingResult({\n embeddings,\n modelId: config.modelId,\n providerName,\n totalTokens,\n version: VERSION,\n });\n } catch (error) {\n throw convertToAISDKError(error, {\n operation: \"doEmbed\",\n requestBody: { values: values.length },\n url: this.getUrl(),\n });\n }\n }\n\n /**\n * Creates the appropriate SDK client for this API.\n * @param config - Strategy configuration.\n * @param settings - Embedding model settings.\n * @param embeddingOptions - Parsed provider options from the call.\n * @returns SDK client instance.\n * @internal\n */\n protected abstract createClient(\n config: EmbeddingModelStrategyConfig,\n settings: SAPAIEmbeddingSettings,\n embeddingOptions: EmbeddingProviderOptions | undefined,\n ): TClient;\n\n /**\n * Executes the embedding API call.\n * @param client - SDK client instance.\n * @param values - Input strings to embed.\n * @param embeddingType - Type of embedding (text, query, document).\n * @param abortSignal - Optional abort signal.\n * @returns SDK response containing embeddings.\n * @internal\n */\n protected abstract executeCall(\n client: TClient,\n values: string[],\n embeddingType: EmbeddingType,\n abortSignal: AbortSignal | undefined,\n ): Promise<TResponse>;\n\n /**\n * Extracts embeddings from the SDK response.\n * @param response - SDK response containing embedding data.\n * @returns Array of normalized embedding vectors.\n * @internal\n */\n protected abstract extractEmbeddings(response: TResponse): EmbeddingModelV3Embedding[];\n\n /**\n * Extracts total token count from the SDK response.\n * @param response - SDK response containing usage data.\n * @returns Total token count used for the embedding request.\n * @internal\n */\n protected abstract extractTokenCount(response: TResponse): number;\n\n /**\n * Returns the URL identifier for this API (used in error messages).\n * @returns URL string identifier.\n * @internal\n */\n protected abstract getUrl(): string;\n\n protected mergeModelParams(\n settings: SAPAIEmbeddingSettings,\n embeddingOptions: EmbeddingProviderOptions | undefined,\n ): Record<string, unknown> {\n return deepMerge(\n (settings.modelParams as Record<string, unknown> | undefined) ?? {},\n embeddingOptions?.modelParams ?? {},\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AA0BO,IAAe,6BAAf,MAGgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUrC,MAAM,QACJ,QACA,UACA,SACA,sBACiC;AACjC,UAAM,EAAE,aAAa,OAAO,IAAI;AAEhC,UAAM,EAAE,kBAAkB,aAAa,IAAI,MAAM;AAAA,MAC/C,EAAE,sBAAsB,SAAS,OAAO,SAAS,UAAU,OAAO,SAAS;AAAA,MAC3E;AAAA,IACF;AAEA,UAAM,gBACJ,kBAAkB,QAAS,SAAS,QAAsC;AAE5E,QAAI;AACF,YAAM,SAAS,KAAK,aAAa,QAAQ,UAAU,gBAAgB;AAEnE,YAAM,WAAW,MAAM,KAAK,YAAY,QAAQ,QAAQ,eAAe,WAAW;AAElF,YAAM,aAAa,KAAK,kBAAkB,QAAQ;AAClD,YAAM,cAAc,KAAK,kBAAkB,QAAQ;AAEnD,aAAO,qBAAqB;AAAA,QAC1B;AAAA,QACA,SAAS,OAAO;AAAA,QAChB;AAAA,QACA;AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAM,oBAAoB,OAAO;AAAA,QAC/B,WAAW;AAAA,QACX,aAAa,EAAE,QAAQ,OAAO,OAAO;AAAA,QACrC,KAAK,KAAK,OAAO;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAuDU,iBACR,UACA,kBACyB;AACzB,WAAO;AAAA,MACJ,SAAS,eAAuD,CAAC;AAAA,MAClE,kBAAkB,eAAe,CAAC;AAAA,IACpC;AAAA,EACF;AACF;","names":[]}
|
|
@@ -30000,6 +30000,67 @@ var sapAIEmbeddingProviderOptions = lazySchema(
|
|
|
30000
30000
|
)
|
|
30001
30001
|
);
|
|
30002
30002
|
|
|
30003
|
+
// src/deep-merge.ts
|
|
30004
|
+
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
30005
|
+
var MAX_DEPTH = 100;
|
|
30006
|
+
function deepMerge(...sources) {
|
|
30007
|
+
let result = {};
|
|
30008
|
+
for (const source of sources) {
|
|
30009
|
+
if (source == null) continue;
|
|
30010
|
+
result = mergeTwo(result, source, /* @__PURE__ */ new Set(), 0);
|
|
30011
|
+
}
|
|
30012
|
+
return result;
|
|
30013
|
+
}
|
|
30014
|
+
function cloneDeep(obj, ancestors, depth) {
|
|
30015
|
+
if (depth > MAX_DEPTH) {
|
|
30016
|
+
throw new Error("Maximum merge depth exceeded");
|
|
30017
|
+
}
|
|
30018
|
+
if (ancestors.has(obj)) {
|
|
30019
|
+
throw new Error("Circular reference detected during deep merge");
|
|
30020
|
+
}
|
|
30021
|
+
ancestors.add(obj);
|
|
30022
|
+
const result = {};
|
|
30023
|
+
for (const key of Object.keys(obj)) {
|
|
30024
|
+
if (!isSafeKey(key)) continue;
|
|
30025
|
+
const value = obj[key];
|
|
30026
|
+
result[key] = isPlainObject(value) ? cloneDeep(value, ancestors, depth + 1) : value;
|
|
30027
|
+
}
|
|
30028
|
+
ancestors.delete(obj);
|
|
30029
|
+
return result;
|
|
30030
|
+
}
|
|
30031
|
+
function isPlainObject(value) {
|
|
30032
|
+
if (value === null || typeof value !== "object") return false;
|
|
30033
|
+
const proto = Object.getPrototypeOf(value);
|
|
30034
|
+
return proto === Object.prototype || proto === null;
|
|
30035
|
+
}
|
|
30036
|
+
function isSafeKey(key) {
|
|
30037
|
+
return !DANGEROUS_KEYS.has(key);
|
|
30038
|
+
}
|
|
30039
|
+
function mergeTwo(target, source, ancestors, depth) {
|
|
30040
|
+
if (depth > MAX_DEPTH) {
|
|
30041
|
+
throw new Error("Maximum merge depth exceeded");
|
|
30042
|
+
}
|
|
30043
|
+
if (ancestors.has(source)) {
|
|
30044
|
+
throw new Error("Circular reference detected during deep merge");
|
|
30045
|
+
}
|
|
30046
|
+
ancestors.add(source);
|
|
30047
|
+
for (const key of Object.keys(source)) {
|
|
30048
|
+
if (!isSafeKey(key)) continue;
|
|
30049
|
+
const sourceValue = source[key];
|
|
30050
|
+
const targetValue = target[key];
|
|
30051
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
30052
|
+
const cloned = cloneDeep(targetValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30053
|
+
target[key] = mergeTwo(cloned, sourceValue, ancestors, depth + 1);
|
|
30054
|
+
} else if (isPlainObject(sourceValue)) {
|
|
30055
|
+
target[key] = cloneDeep(sourceValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30056
|
+
} else {
|
|
30057
|
+
target[key] = sourceValue;
|
|
30058
|
+
}
|
|
30059
|
+
}
|
|
30060
|
+
ancestors.delete(source);
|
|
30061
|
+
return target;
|
|
30062
|
+
}
|
|
30063
|
+
|
|
30003
30064
|
// src/sap-ai-error.ts
|
|
30004
30065
|
var import_util = __toESM(require_dist(), 1);
|
|
30005
30066
|
import { APICallError, LoadAPIKeyError, NoSuchModelError } from "@ai-sdk/provider";
|
|
@@ -30488,69 +30549,8 @@ function tryExtractSAPErrorFromMessage(message) {
|
|
|
30488
30549
|
}
|
|
30489
30550
|
}
|
|
30490
30551
|
|
|
30491
|
-
// src/deep-merge.ts
|
|
30492
|
-
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
30493
|
-
var MAX_DEPTH = 100;
|
|
30494
|
-
function deepMerge(...sources) {
|
|
30495
|
-
let result = {};
|
|
30496
|
-
for (const source of sources) {
|
|
30497
|
-
if (source == null) continue;
|
|
30498
|
-
result = mergeTwo(result, source, /* @__PURE__ */ new Set(), 0);
|
|
30499
|
-
}
|
|
30500
|
-
return result;
|
|
30501
|
-
}
|
|
30502
|
-
function cloneDeep(obj, ancestors, depth) {
|
|
30503
|
-
if (depth > MAX_DEPTH) {
|
|
30504
|
-
throw new Error("Maximum merge depth exceeded");
|
|
30505
|
-
}
|
|
30506
|
-
if (ancestors.has(obj)) {
|
|
30507
|
-
throw new Error("Circular reference detected during deep merge");
|
|
30508
|
-
}
|
|
30509
|
-
ancestors.add(obj);
|
|
30510
|
-
const result = {};
|
|
30511
|
-
for (const key of Object.keys(obj)) {
|
|
30512
|
-
if (!isSafeKey(key)) continue;
|
|
30513
|
-
const value = obj[key];
|
|
30514
|
-
result[key] = isPlainObject(value) ? cloneDeep(value, ancestors, depth + 1) : value;
|
|
30515
|
-
}
|
|
30516
|
-
ancestors.delete(obj);
|
|
30517
|
-
return result;
|
|
30518
|
-
}
|
|
30519
|
-
function isPlainObject(value) {
|
|
30520
|
-
if (value === null || typeof value !== "object") return false;
|
|
30521
|
-
const proto = Object.getPrototypeOf(value);
|
|
30522
|
-
return proto === Object.prototype || proto === null;
|
|
30523
|
-
}
|
|
30524
|
-
function isSafeKey(key) {
|
|
30525
|
-
return !DANGEROUS_KEYS.has(key);
|
|
30526
|
-
}
|
|
30527
|
-
function mergeTwo(target, source, ancestors, depth) {
|
|
30528
|
-
if (depth > MAX_DEPTH) {
|
|
30529
|
-
throw new Error("Maximum merge depth exceeded");
|
|
30530
|
-
}
|
|
30531
|
-
if (ancestors.has(source)) {
|
|
30532
|
-
throw new Error("Circular reference detected during deep merge");
|
|
30533
|
-
}
|
|
30534
|
-
ancestors.add(source);
|
|
30535
|
-
for (const key of Object.keys(source)) {
|
|
30536
|
-
if (!isSafeKey(key)) continue;
|
|
30537
|
-
const sourceValue = source[key];
|
|
30538
|
-
const targetValue = target[key];
|
|
30539
|
-
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
30540
|
-
const cloned = cloneDeep(targetValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30541
|
-
target[key] = mergeTwo(cloned, sourceValue, ancestors, depth + 1);
|
|
30542
|
-
} else if (isPlainObject(sourceValue)) {
|
|
30543
|
-
target[key] = cloneDeep(sourceValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30544
|
-
} else {
|
|
30545
|
-
target[key] = sourceValue;
|
|
30546
|
-
}
|
|
30547
|
-
}
|
|
30548
|
-
ancestors.delete(source);
|
|
30549
|
-
return target;
|
|
30550
|
-
}
|
|
30551
|
-
|
|
30552
30552
|
// src/version.ts
|
|
30553
|
-
var VERSION = true ? "4.6.
|
|
30553
|
+
var VERSION = true ? "4.6.1" : "0.0.0-test";
|
|
30554
30554
|
|
|
30555
30555
|
export {
|
|
30556
30556
|
__toESM,
|
|
@@ -30562,12 +30562,12 @@ export {
|
|
|
30562
30562
|
orchestrationConfigRefSchema,
|
|
30563
30563
|
sapAILanguageModelProviderOptions,
|
|
30564
30564
|
sapAIEmbeddingProviderOptions,
|
|
30565
|
+
deepMerge,
|
|
30565
30566
|
require_dist,
|
|
30566
30567
|
ApiSwitchError,
|
|
30567
30568
|
UnsupportedFeatureError,
|
|
30568
30569
|
convertToAISDKError,
|
|
30569
30570
|
normalizeHeaders,
|
|
30570
|
-
deepMerge,
|
|
30571
30571
|
VERSION
|
|
30572
30572
|
};
|
|
30573
30573
|
/*! Bundled license information:
|
|
@@ -30603,4 +30603,4 @@ mime-types/index.js:
|
|
|
30603
30603
|
axios/dist/node/axios.cjs:
|
|
30604
30604
|
(*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors *)
|
|
30605
30605
|
*/
|
|
30606
|
-
//# sourceMappingURL=chunk-
|
|
30606
|
+
//# sourceMappingURL=chunk-I5ZTK7M5.js.map
|