@jerome-benoit/sap-ai-provider 4.5.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-SD6CRCHX.js → chunk-DQXZH6CW.js} +50 -43
- package/dist/chunk-DQXZH6CW.js.map +1 -0
- package/dist/{chunk-SC6SVJGO.js → chunk-HJZCRF7J.js} +11 -4
- package/dist/chunk-HJZCRF7J.js.map +1 -0
- package/dist/{chunk-T2KXS7WW.js → chunk-I5ZTK7M5.js} +64 -64
- package/dist/{chunk-T2KXS7WW.js.map → chunk-I5ZTK7M5.js.map} +1 -1
- package/dist/{chunk-NRLDO6VY.js → chunk-IAXILSPQ.js} +6 -4
- package/dist/chunk-IAXILSPQ.js.map +1 -0
- package/dist/{chunk-3VLXFYCM.js → chunk-U2HDUNO7.js} +55 -19
- package/dist/chunk-U2HDUNO7.js.map +1 -0
- package/dist/{foundation-models-embedding-model-strategy-FO5RWBZ2.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-COZPNAJ3.js → foundation-models-language-model-strategy-3D4V6PSZ.js} +6 -6
- package/dist/foundation-models-language-model-strategy-3D4V6PSZ.js.map +1 -0
- package/dist/index.cjs +186 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-GEONA32Q.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-PZBP7G5O.js → orchestration-language-model-strategy-FI5HLHWP.js} +9 -5
- package/dist/orchestration-language-model-strategy-FI5HLHWP.js.map +1 -0
- package/package.json +14 -14
- package/dist/chunk-3VLXFYCM.js.map +0 -1
- package/dist/chunk-NRLDO6VY.js.map +0 -1
- package/dist/chunk-SC6SVJGO.js.map +0 -1
- package/dist/chunk-SD6CRCHX.js.map +0 -1
- package/dist/foundation-models-embedding-model-strategy-FO5RWBZ2.js.map +0 -1
- package/dist/foundation-models-language-model-strategy-COZPNAJ3.js.map +0 -1
- package/dist/orchestration-embedding-model-strategy-GEONA32Q.js.map +0 -1
- package/dist/orchestration-language-model-strategy-PZBP7G5O.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -122,51 +122,34 @@ function convertToSAPMessages(prompt, options = {}) {
|
|
|
122
122
|
for (const part of message.content) {
|
|
123
123
|
switch (part.type) {
|
|
124
124
|
case "file": {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
const fileDataUrl = buildDataUrl(part);
|
|
126
|
+
if (part.mediaType.startsWith("image/")) {
|
|
127
|
+
const supportedFormats = [
|
|
128
|
+
"image/png",
|
|
129
|
+
"image/jpeg",
|
|
130
|
+
"image/jpg",
|
|
131
|
+
"image/gif",
|
|
132
|
+
"image/webp"
|
|
133
|
+
];
|
|
134
|
+
if (!supportedFormats.includes(part.mediaType.toLowerCase())) {
|
|
135
|
+
console.warn(
|
|
136
|
+
`Image format ${part.mediaType} may not be supported by all models. Recommended formats: PNG, JPEG, GIF, WebP`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
contentParts.push({
|
|
140
|
+
image_url: {
|
|
141
|
+
url: fileDataUrl
|
|
142
|
+
},
|
|
143
|
+
type: "image_url"
|
|
128
144
|
});
|
|
129
|
-
}
|
|
130
|
-
const supportedFormats = [
|
|
131
|
-
"image/png",
|
|
132
|
-
"image/jpeg",
|
|
133
|
-
"image/jpg",
|
|
134
|
-
"image/gif",
|
|
135
|
-
"image/webp"
|
|
136
|
-
];
|
|
137
|
-
if (!supportedFormats.includes(part.mediaType.toLowerCase())) {
|
|
138
|
-
console.warn(
|
|
139
|
-
`Image format ${part.mediaType} may not be supported by all models. Recommended formats: PNG, JPEG, GIF, WebP`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
let imageUrl;
|
|
143
|
-
if (part.data instanceof URL) {
|
|
144
|
-
imageUrl = part.data.toString();
|
|
145
|
-
} else if (typeof part.data === "string") {
|
|
146
|
-
imageUrl = `data:${part.mediaType};base64,${part.data}`;
|
|
147
|
-
} else if (part.data instanceof Uint8Array) {
|
|
148
|
-
const base64Data = import_node_buffer.Buffer.from(part.data).toString("base64");
|
|
149
|
-
imageUrl = `data:${part.mediaType};base64,${base64Data}`;
|
|
150
|
-
} else if (import_node_buffer.Buffer.isBuffer(part.data)) {
|
|
151
|
-
const base64Data = import_node_buffer.Buffer.from(part.data).toString("base64");
|
|
152
|
-
imageUrl = `data:${part.mediaType};base64,${base64Data}`;
|
|
153
145
|
} else {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
functionality: "Unsupported file data type for image. Expected URL, base64 string, or Uint8Array."
|
|
161
|
-
});
|
|
162
|
-
}
|
|
146
|
+
contentParts.push({
|
|
147
|
+
file: {
|
|
148
|
+
file_data: fileDataUrl
|
|
149
|
+
},
|
|
150
|
+
type: "file"
|
|
151
|
+
});
|
|
163
152
|
}
|
|
164
|
-
contentParts.push({
|
|
165
|
-
image_url: {
|
|
166
|
-
url: imageUrl
|
|
167
|
-
},
|
|
168
|
-
type: "image_url"
|
|
169
|
-
});
|
|
170
153
|
break;
|
|
171
154
|
}
|
|
172
155
|
case "text": {
|
|
@@ -213,6 +196,30 @@ function unescapeOrchestrationPlaceholders(text) {
|
|
|
213
196
|
if (!text) return text;
|
|
214
197
|
return text.replaceAll(JINJA2_DELIMITERS_ESCAPED_PATTERN, "{$1");
|
|
215
198
|
}
|
|
199
|
+
function buildDataUrl(part) {
|
|
200
|
+
if (part.data instanceof URL) {
|
|
201
|
+
return part.data.toString();
|
|
202
|
+
}
|
|
203
|
+
if (typeof part.data === "string") {
|
|
204
|
+
return `data:${part.mediaType};base64,${part.data}`;
|
|
205
|
+
}
|
|
206
|
+
if (part.data instanceof Uint8Array) {
|
|
207
|
+
const base64Data = import_node_buffer.Buffer.from(part.data).toString("base64");
|
|
208
|
+
return `data:${part.mediaType};base64,${base64Data}`;
|
|
209
|
+
}
|
|
210
|
+
if (import_node_buffer.Buffer.isBuffer(part.data)) {
|
|
211
|
+
const base64Data = import_node_buffer.Buffer.from(part.data).toString("base64");
|
|
212
|
+
return `data:${part.mediaType};base64,${base64Data}`;
|
|
213
|
+
}
|
|
214
|
+
const maybeBufferLike = part.data;
|
|
215
|
+
if (maybeBufferLike !== null && typeof maybeBufferLike === "object" && "toString" in maybeBufferLike) {
|
|
216
|
+
const base64Data = maybeBufferLike.toString("base64");
|
|
217
|
+
return `data:${part.mediaType};base64,${base64Data}`;
|
|
218
|
+
}
|
|
219
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
220
|
+
functionality: "Unsupported file data type. Expected URL, base64 string, or Uint8Array."
|
|
221
|
+
});
|
|
222
|
+
}
|
|
216
223
|
var import_provider, import_node_buffer, ZERO_WIDTH_SPACE, JINJA2_DELIMITERS_PATTERN, JINJA2_DELIMITERS_ESCAPED_PATTERN;
|
|
217
224
|
var init_convert_to_sap_messages = __esm({
|
|
218
225
|
"src/convert-to-sap-messages.ts"() {
|
|
@@ -323,6 +330,73 @@ var init_sap_ai_provider_options = __esm({
|
|
|
323
330
|
}
|
|
324
331
|
});
|
|
325
332
|
|
|
333
|
+
// src/deep-merge.ts
|
|
334
|
+
function deepMerge(...sources) {
|
|
335
|
+
let result = {};
|
|
336
|
+
for (const source of sources) {
|
|
337
|
+
if (source == null) continue;
|
|
338
|
+
result = mergeTwo(result, source, /* @__PURE__ */ new Set(), 0);
|
|
339
|
+
}
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
function cloneDeep(obj, ancestors, depth) {
|
|
343
|
+
if (depth > MAX_DEPTH) {
|
|
344
|
+
throw new Error("Maximum merge depth exceeded");
|
|
345
|
+
}
|
|
346
|
+
if (ancestors.has(obj)) {
|
|
347
|
+
throw new Error("Circular reference detected during deep merge");
|
|
348
|
+
}
|
|
349
|
+
ancestors.add(obj);
|
|
350
|
+
const result = {};
|
|
351
|
+
for (const key of Object.keys(obj)) {
|
|
352
|
+
if (!isSafeKey(key)) continue;
|
|
353
|
+
const value = obj[key];
|
|
354
|
+
result[key] = isPlainObject(value) ? cloneDeep(value, ancestors, depth + 1) : value;
|
|
355
|
+
}
|
|
356
|
+
ancestors.delete(obj);
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
function isPlainObject(value) {
|
|
360
|
+
if (value === null || typeof value !== "object") return false;
|
|
361
|
+
const proto = Object.getPrototypeOf(value);
|
|
362
|
+
return proto === Object.prototype || proto === null;
|
|
363
|
+
}
|
|
364
|
+
function isSafeKey(key) {
|
|
365
|
+
return !DANGEROUS_KEYS.has(key);
|
|
366
|
+
}
|
|
367
|
+
function mergeTwo(target, source, ancestors, depth) {
|
|
368
|
+
if (depth > MAX_DEPTH) {
|
|
369
|
+
throw new Error("Maximum merge depth exceeded");
|
|
370
|
+
}
|
|
371
|
+
if (ancestors.has(source)) {
|
|
372
|
+
throw new Error("Circular reference detected during deep merge");
|
|
373
|
+
}
|
|
374
|
+
ancestors.add(source);
|
|
375
|
+
for (const key of Object.keys(source)) {
|
|
376
|
+
if (!isSafeKey(key)) continue;
|
|
377
|
+
const sourceValue = source[key];
|
|
378
|
+
const targetValue = target[key];
|
|
379
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
380
|
+
const cloned = cloneDeep(targetValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
381
|
+
target[key] = mergeTwo(cloned, sourceValue, ancestors, depth + 1);
|
|
382
|
+
} else if (isPlainObject(sourceValue)) {
|
|
383
|
+
target[key] = cloneDeep(sourceValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
384
|
+
} else {
|
|
385
|
+
target[key] = sourceValue;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
ancestors.delete(source);
|
|
389
|
+
return target;
|
|
390
|
+
}
|
|
391
|
+
var DANGEROUS_KEYS, MAX_DEPTH;
|
|
392
|
+
var init_deep_merge = __esm({
|
|
393
|
+
"src/deep-merge.ts"() {
|
|
394
|
+
"use strict";
|
|
395
|
+
DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
396
|
+
MAX_DEPTH = 100;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
|
|
326
400
|
// node_modules/@sap-cloud-sdk/util/dist/array.js
|
|
327
401
|
var require_array = __commonJS({
|
|
328
402
|
"node_modules/@sap-cloud-sdk/util/dist/array.js"(exports2) {
|
|
@@ -30686,73 +30760,6 @@ The model's response was blocked by content safety filters. Try a different prom
|
|
|
30686
30760
|
}
|
|
30687
30761
|
});
|
|
30688
30762
|
|
|
30689
|
-
// src/deep-merge.ts
|
|
30690
|
-
function deepMerge(...sources) {
|
|
30691
|
-
let result = {};
|
|
30692
|
-
for (const source of sources) {
|
|
30693
|
-
if (source == null) continue;
|
|
30694
|
-
result = mergeTwo(result, source, /* @__PURE__ */ new Set(), 0);
|
|
30695
|
-
}
|
|
30696
|
-
return result;
|
|
30697
|
-
}
|
|
30698
|
-
function cloneDeep(obj, ancestors, depth) {
|
|
30699
|
-
if (depth > MAX_DEPTH) {
|
|
30700
|
-
throw new Error("Maximum merge depth exceeded");
|
|
30701
|
-
}
|
|
30702
|
-
if (ancestors.has(obj)) {
|
|
30703
|
-
throw new Error("Circular reference detected during deep merge");
|
|
30704
|
-
}
|
|
30705
|
-
ancestors.add(obj);
|
|
30706
|
-
const result = {};
|
|
30707
|
-
for (const key of Object.keys(obj)) {
|
|
30708
|
-
if (!isSafeKey(key)) continue;
|
|
30709
|
-
const value = obj[key];
|
|
30710
|
-
result[key] = isPlainObject(value) ? cloneDeep(value, ancestors, depth + 1) : value;
|
|
30711
|
-
}
|
|
30712
|
-
ancestors.delete(obj);
|
|
30713
|
-
return result;
|
|
30714
|
-
}
|
|
30715
|
-
function isPlainObject(value) {
|
|
30716
|
-
if (value === null || typeof value !== "object") return false;
|
|
30717
|
-
const proto = Object.getPrototypeOf(value);
|
|
30718
|
-
return proto === Object.prototype || proto === null;
|
|
30719
|
-
}
|
|
30720
|
-
function isSafeKey(key) {
|
|
30721
|
-
return !DANGEROUS_KEYS.has(key);
|
|
30722
|
-
}
|
|
30723
|
-
function mergeTwo(target, source, ancestors, depth) {
|
|
30724
|
-
if (depth > MAX_DEPTH) {
|
|
30725
|
-
throw new Error("Maximum merge depth exceeded");
|
|
30726
|
-
}
|
|
30727
|
-
if (ancestors.has(source)) {
|
|
30728
|
-
throw new Error("Circular reference detected during deep merge");
|
|
30729
|
-
}
|
|
30730
|
-
ancestors.add(source);
|
|
30731
|
-
for (const key of Object.keys(source)) {
|
|
30732
|
-
if (!isSafeKey(key)) continue;
|
|
30733
|
-
const sourceValue = source[key];
|
|
30734
|
-
const targetValue = target[key];
|
|
30735
|
-
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
30736
|
-
const cloned = cloneDeep(targetValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30737
|
-
target[key] = mergeTwo(cloned, sourceValue, ancestors, depth + 1);
|
|
30738
|
-
} else if (isPlainObject(sourceValue)) {
|
|
30739
|
-
target[key] = cloneDeep(sourceValue, /* @__PURE__ */ new Set(), depth + 1);
|
|
30740
|
-
} else {
|
|
30741
|
-
target[key] = sourceValue;
|
|
30742
|
-
}
|
|
30743
|
-
}
|
|
30744
|
-
ancestors.delete(source);
|
|
30745
|
-
return target;
|
|
30746
|
-
}
|
|
30747
|
-
var DANGEROUS_KEYS, MAX_DEPTH;
|
|
30748
|
-
var init_deep_merge = __esm({
|
|
30749
|
-
"src/deep-merge.ts"() {
|
|
30750
|
-
"use strict";
|
|
30751
|
-
DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
30752
|
-
MAX_DEPTH = 100;
|
|
30753
|
-
}
|
|
30754
|
-
});
|
|
30755
|
-
|
|
30756
30763
|
// src/strategy-utils.ts
|
|
30757
30764
|
function applyParameterOverrides(modelParams, options, sapModelParams, settingsModelParams, mappings) {
|
|
30758
30765
|
for (const mapping of mappings) {
|
|
@@ -30794,6 +30801,19 @@ function buildGenerateResult(config) {
|
|
|
30794
30801
|
tokenUsage,
|
|
30795
30802
|
toolCalls
|
|
30796
30803
|
};
|
|
30804
|
+
const citations = response.getCitations?.();
|
|
30805
|
+
if (citations?.length) {
|
|
30806
|
+
for (const citation of citations) {
|
|
30807
|
+
content.push({
|
|
30808
|
+
id: String(citation.ref_id ?? citation.url),
|
|
30809
|
+
sourceType: "url",
|
|
30810
|
+
title: citation.title,
|
|
30811
|
+
type: "source",
|
|
30812
|
+
url: citation.url
|
|
30813
|
+
});
|
|
30814
|
+
}
|
|
30815
|
+
}
|
|
30816
|
+
const intermediateFailures = response.getIntermediateFailures?.();
|
|
30797
30817
|
return {
|
|
30798
30818
|
content,
|
|
30799
30819
|
finishReason,
|
|
@@ -30801,6 +30821,7 @@ function buildGenerateResult(config) {
|
|
|
30801
30821
|
[providerName]: {
|
|
30802
30822
|
finishReason: finishReasonRaw ?? "unknown",
|
|
30803
30823
|
finishReasonMapped: finishReason,
|
|
30824
|
+
...intermediateFailures?.length ? { intermediateFailures } : {},
|
|
30804
30825
|
...typeof responseHeaders?.["x-request-id"] === "string" ? { requestId: responseHeaders["x-request-id"] } : {},
|
|
30805
30826
|
version: version2
|
|
30806
30827
|
}
|
|
@@ -30815,19 +30836,7 @@ function buildGenerateResult(config) {
|
|
|
30815
30836
|
modelId,
|
|
30816
30837
|
timestamp: /* @__PURE__ */ new Date()
|
|
30817
30838
|
},
|
|
30818
|
-
usage:
|
|
30819
|
-
inputTokens: {
|
|
30820
|
-
cacheRead: void 0,
|
|
30821
|
-
cacheWrite: void 0,
|
|
30822
|
-
noCache: tokenUsage?.prompt_tokens,
|
|
30823
|
-
total: tokenUsage?.prompt_tokens
|
|
30824
|
-
},
|
|
30825
|
-
outputTokens: {
|
|
30826
|
-
reasoning: void 0,
|
|
30827
|
-
text: tokenUsage?.completion_tokens,
|
|
30828
|
-
total: tokenUsage?.completion_tokens
|
|
30829
|
-
}
|
|
30830
|
-
},
|
|
30839
|
+
usage: mapTokenUsage(tokenUsage),
|
|
30831
30840
|
warnings
|
|
30832
30841
|
};
|
|
30833
30842
|
}
|
|
@@ -31003,7 +31012,9 @@ function createStreamTransformer(config) {
|
|
|
31003
31012
|
responseHeaders,
|
|
31004
31013
|
responseId,
|
|
31005
31014
|
sdkStream,
|
|
31015
|
+
streamResponseGetCitations,
|
|
31006
31016
|
streamResponseGetFinishReason,
|
|
31017
|
+
streamResponseGetIntermediateFailures,
|
|
31007
31018
|
streamResponseGetTokenUsage,
|
|
31008
31019
|
url,
|
|
31009
31020
|
version: version2,
|
|
@@ -31055,16 +31066,31 @@ function createStreamTransformer(config) {
|
|
|
31055
31066
|
}
|
|
31056
31067
|
const finalUsage = streamResponseGetTokenUsage();
|
|
31057
31068
|
if (finalUsage) {
|
|
31058
|
-
|
|
31059
|
-
streamState.usage.inputTokens
|
|
31060
|
-
streamState.usage.outputTokens
|
|
31061
|
-
streamState.usage.outputTokens.text = finalUsage.completion_tokens;
|
|
31069
|
+
const mapped = mapTokenUsage(finalUsage);
|
|
31070
|
+
streamState.usage.inputTokens = mapped.inputTokens;
|
|
31071
|
+
streamState.usage.outputTokens = mapped.outputTokens;
|
|
31062
31072
|
}
|
|
31073
|
+
const streamCitations = streamResponseGetCitations?.();
|
|
31074
|
+
if (streamCitations?.length) {
|
|
31075
|
+
for (const citation of streamCitations) {
|
|
31076
|
+
controller.enqueue({
|
|
31077
|
+
id: String(citation.ref_id ?? citation.url),
|
|
31078
|
+
sourceType: "url",
|
|
31079
|
+
title: citation.title,
|
|
31080
|
+
type: "source",
|
|
31081
|
+
url: citation.url
|
|
31082
|
+
});
|
|
31083
|
+
}
|
|
31084
|
+
}
|
|
31085
|
+
const streamIntermediateFailures = streamResponseGetIntermediateFailures?.();
|
|
31063
31086
|
controller.enqueue({
|
|
31064
31087
|
finishReason: streamState.finishReason,
|
|
31065
31088
|
providerMetadata: {
|
|
31066
31089
|
[providerName]: {
|
|
31067
31090
|
finishReason: streamState.finishReason.raw,
|
|
31091
|
+
...streamIntermediateFailures?.length ? {
|
|
31092
|
+
intermediateFailures: streamIntermediateFailures
|
|
31093
|
+
} : {},
|
|
31068
31094
|
...typeof responseHeaders?.["x-request-id"] === "string" ? { requestId: responseHeaders["x-request-id"] } : {},
|
|
31069
31095
|
responseId,
|
|
31070
31096
|
version: version2
|
|
@@ -31302,6 +31328,23 @@ function mapFinishReason(reason) {
|
|
|
31302
31328
|
return { raw, unified: "other" };
|
|
31303
31329
|
}
|
|
31304
31330
|
}
|
|
31331
|
+
function mapTokenUsage(tokenUsage) {
|
|
31332
|
+
const cachedTokens = tokenUsage?.prompt_tokens_details?.cached_tokens;
|
|
31333
|
+
const reasoningTokens = tokenUsage?.completion_tokens_details?.reasoning_tokens;
|
|
31334
|
+
return {
|
|
31335
|
+
inputTokens: {
|
|
31336
|
+
cacheRead: cachedTokens,
|
|
31337
|
+
cacheWrite: void 0,
|
|
31338
|
+
noCache: cachedTokens != null ? (tokenUsage?.prompt_tokens ?? 0) - cachedTokens : tokenUsage?.prompt_tokens,
|
|
31339
|
+
total: tokenUsage?.prompt_tokens
|
|
31340
|
+
},
|
|
31341
|
+
outputTokens: {
|
|
31342
|
+
reasoning: reasoningTokens,
|
|
31343
|
+
text: reasoningTokens != null ? (tokenUsage?.completion_tokens ?? 0) - reasoningTokens : tokenUsage?.completion_tokens,
|
|
31344
|
+
total: tokenUsage?.completion_tokens
|
|
31345
|
+
}
|
|
31346
|
+
};
|
|
31347
|
+
}
|
|
31305
31348
|
function mapToolChoice(toolChoice) {
|
|
31306
31349
|
if (!toolChoice) {
|
|
31307
31350
|
return void 0;
|
|
@@ -31392,7 +31435,7 @@ var VERSION;
|
|
|
31392
31435
|
var init_version = __esm({
|
|
31393
31436
|
"src/version.ts"() {
|
|
31394
31437
|
"use strict";
|
|
31395
|
-
VERSION = true ? "4.
|
|
31438
|
+
VERSION = true ? "4.6.1" : "0.0.0-test";
|
|
31396
31439
|
}
|
|
31397
31440
|
});
|
|
31398
31441
|
|
|
@@ -31401,6 +31444,7 @@ var BaseEmbeddingModelStrategy;
|
|
|
31401
31444
|
var init_base_embedding_model_strategy = __esm({
|
|
31402
31445
|
"src/base-embedding-model-strategy.ts"() {
|
|
31403
31446
|
"use strict";
|
|
31447
|
+
init_deep_merge();
|
|
31404
31448
|
init_sap_ai_error();
|
|
31405
31449
|
init_strategy_utils();
|
|
31406
31450
|
init_version();
|
|
@@ -31441,6 +31485,12 @@ var init_base_embedding_model_strategy = __esm({
|
|
|
31441
31485
|
});
|
|
31442
31486
|
}
|
|
31443
31487
|
}
|
|
31488
|
+
mergeModelParams(settings, embeddingOptions) {
|
|
31489
|
+
return deepMerge(
|
|
31490
|
+
settings.modelParams ?? {},
|
|
31491
|
+
embeddingOptions?.modelParams ?? {}
|
|
31492
|
+
);
|
|
31493
|
+
}
|
|
31444
31494
|
};
|
|
31445
31495
|
}
|
|
31446
31496
|
});
|
|
@@ -31455,7 +31505,6 @@ var init_foundation_models_embedding_model_strategy = __esm({
|
|
|
31455
31505
|
"src/foundation-models-embedding-model-strategy.ts"() {
|
|
31456
31506
|
"use strict";
|
|
31457
31507
|
init_base_embedding_model_strategy();
|
|
31458
|
-
init_deep_merge();
|
|
31459
31508
|
init_strategy_utils();
|
|
31460
31509
|
FoundationModelsEmbeddingModelStrategy = class extends BaseEmbeddingModelStrategy {
|
|
31461
31510
|
ClientClass;
|
|
@@ -31464,10 +31513,7 @@ var init_foundation_models_embedding_model_strategy = __esm({
|
|
|
31464
31513
|
this.ClientClass = ClientClass;
|
|
31465
31514
|
}
|
|
31466
31515
|
createClient(config, settings, embeddingOptions) {
|
|
31467
|
-
const mergedParams =
|
|
31468
|
-
settings.modelParams ?? {},
|
|
31469
|
-
embeddingOptions?.modelParams ?? {}
|
|
31470
|
-
);
|
|
31516
|
+
const mergedParams = this.mergeModelParams(settings, embeddingOptions);
|
|
31471
31517
|
return {
|
|
31472
31518
|
client: new this.ClientClass(
|
|
31473
31519
|
buildModelDeployment(config, settings.modelVersion),
|
|
@@ -31511,7 +31557,6 @@ var init_orchestration_embedding_model_strategy = __esm({
|
|
|
31511
31557
|
"src/orchestration-embedding-model-strategy.ts"() {
|
|
31512
31558
|
"use strict";
|
|
31513
31559
|
init_base_embedding_model_strategy();
|
|
31514
|
-
init_deep_merge();
|
|
31515
31560
|
init_strategy_utils();
|
|
31516
31561
|
OrchestrationEmbeddingModelStrategy = class extends BaseEmbeddingModelStrategy {
|
|
31517
31562
|
ClientClass;
|
|
@@ -31520,10 +31565,7 @@ var init_orchestration_embedding_model_strategy = __esm({
|
|
|
31520
31565
|
this.ClientClass = ClientClass;
|
|
31521
31566
|
}
|
|
31522
31567
|
createClient(config, settings, embeddingOptions) {
|
|
31523
|
-
const mergedParams =
|
|
31524
|
-
settings.modelParams ?? {},
|
|
31525
|
-
embeddingOptions?.modelParams ?? {}
|
|
31526
|
-
);
|
|
31568
|
+
const mergedParams = this.mergeModelParams(settings, embeddingOptions);
|
|
31527
31569
|
const embeddingConfig = {
|
|
31528
31570
|
model: {
|
|
31529
31571
|
name: config.modelId,
|
|
@@ -31639,7 +31681,9 @@ var init_base_language_model_strategy = __esm({
|
|
|
31639
31681
|
responseHeaders: streamResponse.responseHeaders,
|
|
31640
31682
|
responseId,
|
|
31641
31683
|
sdkStream: streamResponse.stream,
|
|
31684
|
+
streamResponseGetCitations: streamResponse.getCitations,
|
|
31642
31685
|
streamResponseGetFinishReason: streamResponse.getFinishReason,
|
|
31686
|
+
streamResponseGetIntermediateFailures: streamResponse.getIntermediateFailures,
|
|
31643
31687
|
streamResponseGetTokenUsage: streamResponse.getTokenUsage,
|
|
31644
31688
|
url: this.getUrl(),
|
|
31645
31689
|
version: VERSION,
|
|
@@ -31760,7 +31804,7 @@ var init_foundation_models_language_model_strategy = __esm({
|
|
|
31760
31804
|
super();
|
|
31761
31805
|
this.ClientClass = ClientClass;
|
|
31762
31806
|
}
|
|
31763
|
-
buildRequest(
|
|
31807
|
+
buildRequest(_config, settings, options, commonParts) {
|
|
31764
31808
|
const warnings = [];
|
|
31765
31809
|
const toolsResult = convertToolsToSAPFormat(
|
|
31766
31810
|
options.tools
|
|
@@ -32005,8 +32049,10 @@ var init_orchestration_language_model_strategy = __esm({
|
|
|
32005
32049
|
);
|
|
32006
32050
|
const completionId = response._data?.final_result?.id ?? response.getRequestId();
|
|
32007
32051
|
return {
|
|
32052
|
+
getCitations: () => response.getCitations?.(),
|
|
32008
32053
|
getContent: () => response.getContent(),
|
|
32009
32054
|
getFinishReason: () => response.getFinishReason(),
|
|
32055
|
+
getIntermediateFailures: () => response.getIntermediateFailures?.(),
|
|
32010
32056
|
getTokenUsage: () => response.getTokenUsage(),
|
|
32011
32057
|
getToolCalls: () => response.getToolCalls(),
|
|
32012
32058
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- SAP SDK types headers as any
|
|
@@ -32019,7 +32065,9 @@ var init_orchestration_language_model_strategy = __esm({
|
|
|
32019
32065
|
const streamResponse = await client.stream(request, abortSignal, sdkStreamOptions);
|
|
32020
32066
|
const streamCompletionId = streamResponse._data?.final_result?.id;
|
|
32021
32067
|
return {
|
|
32068
|
+
getCitations: () => streamResponse.getCitations?.(),
|
|
32022
32069
|
getFinishReason: () => streamResponse.getFinishReason(),
|
|
32070
|
+
getIntermediateFailures: () => streamResponse.getIntermediateFailures?.(),
|
|
32023
32071
|
getTokenUsage: () => streamResponse.getTokenUsage(),
|
|
32024
32072
|
responseHeaders: normalizeHeaders(streamResponse.rawResponse.headers),
|
|
32025
32073
|
responseId: streamCompletionId,
|