@jerome-benoit/sap-ai-provider-v2 4.6.6 → 4.6.8

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.
Files changed (24) hide show
  1. package/dist/{chunk-26WNWERS.js → chunk-6BVUDEKZ.js} +3 -48
  2. package/dist/chunk-6BVUDEKZ.js.map +1 -0
  3. package/dist/{chunk-SWBHSRPT.js → chunk-7OGNFVGC.js} +8 -22
  4. package/dist/{chunk-SWBHSRPT.js.map → chunk-7OGNFVGC.js.map} +1 -1
  5. package/dist/{chunk-OQIELEJP.js → chunk-M3AV2YUV.js} +2 -2
  6. package/dist/{chunk-NXIKTWY3.js → chunk-X66RDDSB.js} +3 -3
  7. package/dist/{foundation-models-embedding-model-strategy-FVVUOPNF.js → foundation-models-embedding-model-strategy-GXJRGM4X.js} +4 -4
  8. package/dist/{foundation-models-language-model-strategy-WNNDNZNZ.js → foundation-models-language-model-strategy-FGUGQPBL.js} +4 -4
  9. package/dist/index.cjs +8 -65
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +0 -6
  12. package/dist/index.d.ts +0 -6
  13. package/dist/index.js +5 -5
  14. package/dist/index.js.map +1 -1
  15. package/dist/{orchestration-embedding-model-strategy-HV7ACKOY.js → orchestration-embedding-model-strategy-663QYZL7.js} +4 -4
  16. package/dist/{orchestration-language-model-strategy-GIWRWQNG.js → orchestration-language-model-strategy-X3LKHORW.js} +4 -4
  17. package/package.json +11 -11
  18. package/dist/chunk-26WNWERS.js.map +0 -1
  19. /package/dist/{chunk-OQIELEJP.js.map → chunk-M3AV2YUV.js.map} +0 -0
  20. /package/dist/{chunk-NXIKTWY3.js.map → chunk-X66RDDSB.js.map} +0 -0
  21. /package/dist/{foundation-models-embedding-model-strategy-FVVUOPNF.js.map → foundation-models-embedding-model-strategy-GXJRGM4X.js.map} +0 -0
  22. /package/dist/{foundation-models-language-model-strategy-WNNDNZNZ.js.map → foundation-models-language-model-strategy-FGUGQPBL.js.map} +0 -0
  23. /package/dist/{orchestration-embedding-model-strategy-HV7ACKOY.js.map → orchestration-embedding-model-strategy-663QYZL7.js.map} +0 -0
  24. /package/dist/{orchestration-language-model-strategy-GIWRWQNG.js.map → orchestration-language-model-strategy-X3LKHORW.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  getProviderName,
5
5
  sapAIEmbeddingProviderOptions,
6
6
  validateModelParamsWithWarnings
7
- } from "./chunk-SWBHSRPT.js";
7
+ } from "./chunk-7OGNFVGC.js";
8
8
 
9
9
  // src/strategy-utils.ts
10
10
  import { TooManyEmbeddingValuesForCallError } from "@ai-sdk/provider";
@@ -682,4 +682,4 @@ export {
682
682
  normalizeEmbedding,
683
683
  prepareEmbeddingCall
684
684
  };
685
- //# sourceMappingURL=chunk-OQIELEJP.js.map
685
+ //# sourceMappingURL=chunk-M3AV2YUV.js.map
@@ -2,12 +2,12 @@ import {createRequire as __createRequire} from 'module';var require=__createRequ
2
2
  import {
3
3
  buildEmbeddingResult,
4
4
  prepareEmbeddingCall
5
- } from "./chunk-OQIELEJP.js";
5
+ } from "./chunk-M3AV2YUV.js";
6
6
  import {
7
7
  VERSION,
8
8
  convertToAISDKError,
9
9
  deepMerge
10
- } from "./chunk-SWBHSRPT.js";
10
+ } from "./chunk-7OGNFVGC.js";
11
11
 
12
12
  // src/base-embedding-model-strategy.ts
13
13
  var BaseEmbeddingModelStrategy = class {
@@ -58,4 +58,4 @@ var BaseEmbeddingModelStrategy = class {
58
58
  export {
59
59
  BaseEmbeddingModelStrategy
60
60
  };
61
- //# sourceMappingURL=chunk-NXIKTWY3.js.map
61
+ //# sourceMappingURL=chunk-X66RDDSB.js.map
@@ -1,13 +1,13 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
2
  import {
3
3
  BaseEmbeddingModelStrategy
4
- } from "./chunk-NXIKTWY3.js";
4
+ } from "./chunk-X66RDDSB.js";
5
5
  import {
6
6
  buildModelDeployment,
7
7
  hasKeys,
8
8
  normalizeEmbedding
9
- } from "./chunk-OQIELEJP.js";
10
- import "./chunk-SWBHSRPT.js";
9
+ } from "./chunk-M3AV2YUV.js";
10
+ import "./chunk-7OGNFVGC.js";
11
11
 
12
12
  // src/foundation-models-embedding-model-strategy.ts
13
13
  var FoundationModelsEmbeddingModelStrategy = class extends BaseEmbeddingModelStrategy {
@@ -51,4 +51,4 @@ var FoundationModelsEmbeddingModelStrategy = class extends BaseEmbeddingModelStr
51
51
  export {
52
52
  FoundationModelsEmbeddingModelStrategy
53
53
  };
54
- //# sourceMappingURL=foundation-models-embedding-model-strategy-FVVUOPNF.js.map
54
+ //# sourceMappingURL=foundation-models-embedding-model-strategy-GXJRGM4X.js.map
@@ -1,16 +1,16 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
2
  import {
3
3
  BaseLanguageModelStrategy
4
- } from "./chunk-26WNWERS.js";
4
+ } from "./chunk-6BVUDEKZ.js";
5
5
  import "./chunk-IIBSUXGT.js";
6
6
  import {
7
7
  buildModelDeployment,
8
8
  convertResponseFormat,
9
9
  convertToolsToSAPFormat
10
- } from "./chunk-OQIELEJP.js";
10
+ } from "./chunk-M3AV2YUV.js";
11
11
  import {
12
12
  normalizeHeaders
13
- } from "./chunk-SWBHSRPT.js";
13
+ } from "./chunk-7OGNFVGC.js";
14
14
 
15
15
  // src/foundation-models-language-model-strategy.ts
16
16
  var FOUNDATION_MODELS_PARAM_MAPPINGS = [
@@ -89,4 +89,4 @@ var FoundationModelsLanguageModelStrategy = class extends BaseLanguageModelStrat
89
89
  export {
90
90
  FoundationModelsLanguageModelStrategy
91
91
  };
92
- //# sourceMappingURL=foundation-models-language-model-strategy-WNNDNZNZ.js.map
92
+ //# sourceMappingURL=foundation-models-language-model-strategy-FGUGQPBL.js.map
package/dist/index.cjs CHANGED
@@ -30244,10 +30244,6 @@ See: https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-depl
30244
30244
  context
30245
30245
  );
30246
30246
  }
30247
- function isPrefillError(error) {
30248
- const message = extractSAPErrorMessage(error)?.toLowerCase();
30249
- return message !== void 0 && PREFILL_ERROR_KEYWORDS.some((kw) => message.includes(kw));
30250
- }
30251
30247
  function normalizeHeaders(headers) {
30252
30248
  if (!headers || typeof headers !== "object") return void 0;
30253
30249
  const record = headers;
@@ -30323,17 +30319,6 @@ function extractModelIdentifier(message, location) {
30323
30319
  }
30324
30320
  return void 0;
30325
30321
  }
30326
- function extractSAPErrorMessage(error) {
30327
- const errorResponse = findStructuredErrorResponse(error);
30328
- if (errorResponse) {
30329
- return extractErrorFields(errorResponse).message;
30330
- }
30331
- const rootError = getRootError(error);
30332
- if (rootError instanceof Error) {
30333
- return rootError.message;
30334
- }
30335
- return typeof rootError === "string" ? rootError : void 0;
30336
- }
30337
30322
  function findStructuredErrorResponse(error) {
30338
30323
  const rootError = getRootError(error);
30339
30324
  if (isStructuredErrorResponse(rootError)) {
@@ -30460,7 +30445,7 @@ function tryExtractSAPErrorFromMessage(message) {
30460
30445
  return null;
30461
30446
  }
30462
30447
  }
30463
- var import_provider2, import_util, HTTP_STATUS, ERROR_MATCHERS, AUTHENTICATION_ERROR_KEYWORDS, DEPLOYMENT_ERROR_KEYWORDS, ApiSwitchError, UnsupportedFeatureError, PREFILL_ERROR_KEYWORDS;
30448
+ var import_provider2, import_util, HTTP_STATUS, ERROR_MATCHERS, AUTHENTICATION_ERROR_KEYWORDS, DEPLOYMENT_ERROR_KEYWORDS, ApiSwitchError, UnsupportedFeatureError;
30464
30449
  var init_sap_ai_error = __esm({
30465
30450
  "src/sap-ai-error.ts"() {
30466
30451
  "use strict";
@@ -30599,6 +30584,9 @@ The model's response was blocked by content safety filters. Try a different prom
30599
30584
  this.conflictingFeature = conflictingFeature;
30600
30585
  this.name = "ApiSwitchError";
30601
30586
  }
30587
+ fromApi;
30588
+ toApi;
30589
+ conflictingFeature;
30602
30590
  };
30603
30591
  UnsupportedFeatureError = class extends Error {
30604
30592
  /**
@@ -30618,11 +30606,10 @@ The model's response was blocked by content safety filters. Try a different prom
30618
30606
  this.suggestedApi = suggestedApi;
30619
30607
  this.name = "UnsupportedFeatureError";
30620
30608
  }
30609
+ feature;
30610
+ api;
30611
+ suggestedApi;
30621
30612
  };
30622
- PREFILL_ERROR_KEYWORDS = [
30623
- "does not support assistant message prefill",
30624
- "conversation must end with a user message"
30625
- ];
30626
30613
  }
30627
30614
  });
30628
30615
 
@@ -31301,7 +31288,7 @@ var VERSION;
31301
31288
  var init_version = __esm({
31302
31289
  "src/version.ts"() {
31303
31290
  "use strict";
31304
- VERSION = true ? "4.6.6" : "0.0.0-test";
31291
+ VERSION = true ? "4.6.8" : "0.0.0-test";
31305
31292
  }
31306
31293
  });
31307
31294
 
@@ -31516,15 +31503,6 @@ var init_base_language_model_strategy = __esm({
31516
31503
  warnings: [...commonParts.warnings, ...warnings]
31517
31504
  });
31518
31505
  } catch (error) {
31519
- if (this.shouldRetryWithoutPrefill(error, settings, options)) {
31520
- const retryPrompt = this.stripTrailingAssistantMessages(options.prompt);
31521
- if (retryPrompt.length > 0) {
31522
- return this.doGenerate(config, settings, {
31523
- ...options,
31524
- prompt: retryPrompt
31525
- });
31526
- }
31527
- }
31528
31506
  throw convertToAISDKError(error, {
31529
31507
  operation: "doGenerate",
31530
31508
  requestBody: createAISDKRequestBodySummary(options),
@@ -31574,15 +31552,6 @@ var init_base_language_model_strategy = __esm({
31574
31552
  stream: transformedStream
31575
31553
  };
31576
31554
  } catch (error) {
31577
- if (this.shouldRetryWithoutPrefill(error, settings, options)) {
31578
- const retryPrompt = this.stripTrailingAssistantMessages(options.prompt);
31579
- if (retryPrompt.length > 0) {
31580
- return this.doStream(config, settings, {
31581
- ...options,
31582
- prompt: retryPrompt
31583
- });
31584
- }
31585
- }
31586
31555
  throw convertToAISDKError(error, {
31587
31556
  operation: "doStream",
31588
31557
  requestBody: createAISDKRequestBodySummary(options),
@@ -31658,32 +31627,6 @@ var init_base_language_model_strategy = __esm({
31658
31627
  getIncludeReasoning(sapOptions, settings) {
31659
31628
  return sapOptions?.includeReasoning ?? settings.includeReasoning ?? false;
31660
31629
  }
31661
- /**
31662
- * Checks whether a prefill error should trigger a retry without trailing assistant messages.
31663
- * @param error - Caught error from API call.
31664
- * @param settings - Model settings.
31665
- * @param options - Call options containing the prompt.
31666
- * @returns Whether the request should be retried without trailing assistant messages.
31667
- * @internal
31668
- */
31669
- shouldRetryWithoutPrefill(error, settings, options) {
31670
- const suppress = settings.suppressPrefillErrors ?? true;
31671
- return suppress && isPrefillError(error) && options.prompt.length > 0 && options.prompt.at(-1)?.role === "assistant";
31672
- }
31673
- /**
31674
- * Strips all trailing assistant messages from a prompt for prefill retry.
31675
- * Removes all (not just the last) to guarantee the retry cannot re-trigger.
31676
- * @param prompt - Original prompt array.
31677
- * @returns Prompt with trailing assistant messages removed.
31678
- * @internal
31679
- */
31680
- stripTrailingAssistantMessages(prompt) {
31681
- let end = prompt.length;
31682
- while (end > 0 && prompt[end - 1]?.role === "assistant") {
31683
- end--;
31684
- }
31685
- return prompt.slice(0, end);
31686
- }
31687
31630
  };
31688
31631
  }
31689
31632
  });