@jerome-benoit/sap-ai-provider-v2 4.2.4 → 4.2.6

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/index.cjs CHANGED
@@ -8655,23 +8655,23 @@ var require_index_cjs = __commonJS({
8655
8655
  const b = srgbNonlinearTransformInv(rgb[2] / 255);
8656
8656
  const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
8657
8657
  const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
8658
- const z2 = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
8659
- return [x * 100, y * 100, z2 * 100];
8658
+ const z3 = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
8659
+ return [x * 100, y * 100, z3 * 100];
8660
8660
  };
8661
8661
  convert$1.rgb.lab = function(rgb) {
8662
8662
  const xyz = convert$1.rgb.xyz(rgb);
8663
8663
  let x = xyz[0];
8664
8664
  let y = xyz[1];
8665
- let z2 = xyz[2];
8665
+ let z3 = xyz[2];
8666
8666
  x /= 95.047;
8667
8667
  y /= 100;
8668
- z2 /= 108.883;
8668
+ z3 /= 108.883;
8669
8669
  x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
8670
8670
  y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
8671
- z2 = z2 > LAB_FT ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
8671
+ z3 = z3 > LAB_FT ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
8672
8672
  const l = 116 * y - 16;
8673
8673
  const a = 500 * (x - y);
8674
- const b = 200 * (y - z2);
8674
+ const b = 200 * (y - z3);
8675
8675
  return [l, a, b];
8676
8676
  };
8677
8677
  convert$1.hsl.rgb = function(hsl) {
@@ -8842,13 +8842,13 @@ var require_index_cjs = __commonJS({
8842
8842
  convert$1.xyz.rgb = function(xyz) {
8843
8843
  const x = xyz[0] / 100;
8844
8844
  const y = xyz[1] / 100;
8845
- const z2 = xyz[2] / 100;
8845
+ const z3 = xyz[2] / 100;
8846
8846
  let r;
8847
8847
  let g;
8848
8848
  let b;
8849
- r = x * 3.2404542 + y * -1.5371385 + z2 * -0.4985314;
8850
- g = x * -0.969266 + y * 1.8760108 + z2 * 0.041556;
8851
- b = x * 0.0556434 + y * -0.2040259 + z2 * 1.0572252;
8849
+ r = x * 3.2404542 + y * -1.5371385 + z3 * -0.4985314;
8850
+ g = x * -0.969266 + y * 1.8760108 + z3 * 0.041556;
8851
+ b = x * 0.0556434 + y * -0.2040259 + z3 * 1.0572252;
8852
8852
  r = srgbNonlinearTransform(r);
8853
8853
  g = srgbNonlinearTransform(g);
8854
8854
  b = srgbNonlinearTransform(b);
@@ -8857,25 +8857,25 @@ var require_index_cjs = __commonJS({
8857
8857
  convert$1.xyz.lab = function(xyz) {
8858
8858
  let x = xyz[0];
8859
8859
  let y = xyz[1];
8860
- let z2 = xyz[2];
8860
+ let z3 = xyz[2];
8861
8861
  x /= 95.047;
8862
8862
  y /= 100;
8863
- z2 /= 108.883;
8863
+ z3 /= 108.883;
8864
8864
  x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
8865
8865
  y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
8866
- z2 = z2 > LAB_FT ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
8866
+ z3 = z3 > LAB_FT ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
8867
8867
  const l = 116 * y - 16;
8868
8868
  const a = 500 * (x - y);
8869
- const b = 200 * (y - z2);
8869
+ const b = 200 * (y - z3);
8870
8870
  return [l, a, b];
8871
8871
  };
8872
8872
  convert$1.xyz.oklab = function(xyz) {
8873
8873
  const x = xyz[0] / 100;
8874
8874
  const y = xyz[1] / 100;
8875
- const z2 = xyz[2] / 100;
8876
- const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z2);
8877
- const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z2);
8878
- const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z2);
8875
+ const z3 = xyz[2] / 100;
8876
+ const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z3);
8877
+ const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z3);
8878
+ const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z3);
8879
8879
  const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
8880
8880
  const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
8881
8881
  const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
@@ -8893,8 +8893,8 @@ var require_index_cjs = __commonJS({
8893
8893
  const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
8894
8894
  const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;
8895
8895
  const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;
8896
- const z2 = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
8897
- return [x * 100, y * 100, z2 * 100];
8896
+ const z3 = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
8897
+ return [x * 100, y * 100, z3 * 100];
8898
8898
  };
8899
8899
  convert$1.oklab.rgb = function(oklab) {
8900
8900
  const ll = oklab[0] / 100;
@@ -8917,20 +8917,20 @@ var require_index_cjs = __commonJS({
8917
8917
  const b = lab[2];
8918
8918
  let x;
8919
8919
  let y;
8920
- let z2;
8920
+ let z3;
8921
8921
  y = (l + 16) / 116;
8922
8922
  x = a / 500 + y;
8923
- z2 = y - b / 200;
8923
+ z3 = y - b / 200;
8924
8924
  const y2 = y ** 3;
8925
8925
  const x2 = x ** 3;
8926
- const z22 = z2 ** 3;
8926
+ const z22 = z3 ** 3;
8927
8927
  y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;
8928
8928
  x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
8929
- z2 = z22 > LAB_FT ? z22 : (z2 - 16 / 116) / 7.787;
8929
+ z3 = z22 > LAB_FT ? z22 : (z3 - 16 / 116) / 7.787;
8930
8930
  x *= 95.047;
8931
8931
  y *= 100;
8932
- z2 *= 108.883;
8933
- return [x, y, z2];
8932
+ z3 *= 108.883;
8933
+ return [x, y, z3];
8934
8934
  };
8935
8935
  convert$1.lab.lch = function(lab) {
8936
8936
  const l = lab[0];
@@ -12811,23 +12811,23 @@ var require_conversions = __commonJS({
12811
12811
  b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
12812
12812
  const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
12813
12813
  const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
12814
- const z2 = r * 0.0193 + g * 0.1192 + b * 0.9505;
12815
- return [x * 100, y * 100, z2 * 100];
12814
+ const z3 = r * 0.0193 + g * 0.1192 + b * 0.9505;
12815
+ return [x * 100, y * 100, z3 * 100];
12816
12816
  };
12817
12817
  convert.rgb.lab = function(rgb) {
12818
12818
  const xyz = convert.rgb.xyz(rgb);
12819
12819
  let x = xyz[0];
12820
12820
  let y = xyz[1];
12821
- let z2 = xyz[2];
12821
+ let z3 = xyz[2];
12822
12822
  x /= 95.047;
12823
12823
  y /= 100;
12824
- z2 /= 108.883;
12824
+ z3 /= 108.883;
12825
12825
  x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
12826
12826
  y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
12827
- z2 = z2 > 8856e-6 ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
12827
+ z3 = z3 > 8856e-6 ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
12828
12828
  const l = 116 * y - 16;
12829
12829
  const a = 500 * (x - y);
12830
- const b = 200 * (y - z2);
12830
+ const b = 200 * (y - z3);
12831
12831
  return [l, a, b];
12832
12832
  };
12833
12833
  convert.hsl.rgb = function(hsl) {
@@ -12991,13 +12991,13 @@ var require_conversions = __commonJS({
12991
12991
  convert.xyz.rgb = function(xyz) {
12992
12992
  const x = xyz[0] / 100;
12993
12993
  const y = xyz[1] / 100;
12994
- const z2 = xyz[2] / 100;
12994
+ const z3 = xyz[2] / 100;
12995
12995
  let r;
12996
12996
  let g;
12997
12997
  let b;
12998
- r = x * 3.2406 + y * -1.5372 + z2 * -0.4986;
12999
- g = x * -0.9689 + y * 1.8758 + z2 * 0.0415;
13000
- b = x * 0.0557 + y * -0.204 + z2 * 1.057;
12998
+ r = x * 3.2406 + y * -1.5372 + z3 * -0.4986;
12999
+ g = x * -0.9689 + y * 1.8758 + z3 * 0.0415;
13000
+ b = x * 0.0557 + y * -0.204 + z3 * 1.057;
13001
13001
  r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
13002
13002
  g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
13003
13003
  b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
@@ -13009,16 +13009,16 @@ var require_conversions = __commonJS({
13009
13009
  convert.xyz.lab = function(xyz) {
13010
13010
  let x = xyz[0];
13011
13011
  let y = xyz[1];
13012
- let z2 = xyz[2];
13012
+ let z3 = xyz[2];
13013
13013
  x /= 95.047;
13014
13014
  y /= 100;
13015
- z2 /= 108.883;
13015
+ z3 /= 108.883;
13016
13016
  x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
13017
13017
  y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
13018
- z2 = z2 > 8856e-6 ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
13018
+ z3 = z3 > 8856e-6 ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
13019
13019
  const l = 116 * y - 16;
13020
13020
  const a = 500 * (x - y);
13021
- const b = 200 * (y - z2);
13021
+ const b = 200 * (y - z3);
13022
13022
  return [l, a, b];
13023
13023
  };
13024
13024
  convert.lab.xyz = function(lab) {
@@ -13027,20 +13027,20 @@ var require_conversions = __commonJS({
13027
13027
  const b = lab[2];
13028
13028
  let x;
13029
13029
  let y;
13030
- let z2;
13030
+ let z3;
13031
13031
  y = (l + 16) / 116;
13032
13032
  x = a / 500 + y;
13033
- z2 = y - b / 200;
13033
+ z3 = y - b / 200;
13034
13034
  const y2 = y ** 3;
13035
13035
  const x2 = x ** 3;
13036
- const z22 = z2 ** 3;
13036
+ const z22 = z3 ** 3;
13037
13037
  y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
13038
13038
  x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
13039
- z2 = z22 > 8856e-6 ? z22 : (z2 - 16 / 116) / 7.787;
13039
+ z3 = z22 > 8856e-6 ? z22 : (z3 - 16 / 116) / 7.787;
13040
13040
  x *= 95.047;
13041
13041
  y *= 100;
13042
- z2 *= 108.883;
13043
- return [x, y, z2];
13042
+ z3 *= 108.883;
13043
+ return [x, y, z3];
13044
13044
  };
13045
13045
  convert.lab.lch = function(lab) {
13046
13046
  const l = lab[0];
@@ -27465,7 +27465,7 @@ var require_axios = __commonJS({
27465
27465
  }
27466
27466
  return requestedURL;
27467
27467
  }
27468
- var VERSION = "1.13.2";
27468
+ var VERSION2 = "1.13.2";
27469
27469
  function parseProtocol(url2) {
27470
27470
  const match2 = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url2);
27471
27471
  return match2 && match2[1] || "";
@@ -28194,7 +28194,7 @@ var require_axios = __commonJS({
28194
28194
  ));
28195
28195
  }
28196
28196
  const headers = AxiosHeaders$1.from(config.headers).normalize();
28197
- headers.set("User-Agent", "axios/" + VERSION, false);
28197
+ headers.set("User-Agent", "axios/" + VERSION2, false);
28198
28198
  const { onUploadProgress, onDownloadProgress } = config;
28199
28199
  const maxRate = config.maxRate;
28200
28200
  let maxUploadRate = void 0;
@@ -28204,7 +28204,7 @@ var require_axios = __commonJS({
28204
28204
  data = formDataToStream$1(data, (formHeaders) => {
28205
28205
  headers.set(formHeaders);
28206
28206
  }, {
28207
- tag: `axios-${VERSION}-boundary`,
28207
+ tag: `axios-${VERSION2}-boundary`,
28208
28208
  boundary: userBoundary && userBoundary[1] || void 0
28209
28209
  });
28210
28210
  } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
@@ -29241,7 +29241,7 @@ var require_axios = __commonJS({
29241
29241
  var deprecatedWarnings = {};
29242
29242
  validators$1.transitional = function transitional(validator2, version2, message) {
29243
29243
  function formatMessage(opt, desc) {
29244
- return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
29244
+ return "[Axios v" + VERSION2 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
29245
29245
  }
29246
29246
  return (value, opt, opts) => {
29247
29247
  if (validator2 === false) {
@@ -29658,7 +29658,7 @@ var require_axios = __commonJS({
29658
29658
  axios.CanceledError = CanceledError;
29659
29659
  axios.CancelToken = CancelToken$1;
29660
29660
  axios.isCancel = isCancel;
29661
- axios.VERSION = VERSION;
29661
+ axios.VERSION = VERSION2;
29662
29662
  axios.toFormData = toFormData;
29663
29663
  axios.AxiosError = AxiosError;
29664
29664
  axios.Cancel = axios.CanceledError;
@@ -29739,12 +29739,15 @@ var index_exports = {};
29739
29739
  __export(index_exports, {
29740
29740
  OrchestrationClient: () => import_orchestration5.OrchestrationClient,
29741
29741
  OrchestrationEmbeddingClient: () => import_orchestration5.OrchestrationEmbeddingClient,
29742
+ OrchestrationEmbeddingResponse: () => import_orchestration4.OrchestrationEmbeddingResponse,
29742
29743
  OrchestrationResponse: () => import_orchestration4.OrchestrationResponse,
29744
+ OrchestrationStream: () => import_orchestration4.OrchestrationStream,
29743
29745
  OrchestrationStreamChunkResponse: () => import_orchestration4.OrchestrationStreamChunkResponse,
29744
29746
  OrchestrationStreamResponse: () => import_orchestration4.OrchestrationStreamResponse,
29745
29747
  SAPAIEmbeddingModel: () => SAPAIEmbeddingModelV2,
29746
29748
  SAPAILanguageModel: () => SAPAILanguageModelV2,
29747
29749
  SAP_AI_PROVIDER_NAME: () => SAP_AI_PROVIDER_NAME,
29750
+ VERSION: () => VERSION,
29748
29751
  buildAzureContentSafetyFilter: () => import_orchestration3.buildAzureContentSafetyFilter,
29749
29752
  buildDocumentGroundingConfig: () => import_orchestration3.buildDocumentGroundingConfig,
29750
29753
  buildDpiMaskingProvider: () => import_orchestration3.buildDpiMaskingProvider,
@@ -29917,10 +29920,14 @@ function convertSAPErrorToAPICallError(errorResponse, context) {
29917
29920
  let requestId;
29918
29921
  if (Array.isArray(error)) {
29919
29922
  const firstError = error[0];
29920
- message = firstError.message;
29921
- code = firstError.code;
29922
- location = firstError.location;
29923
- requestId = firstError.request_id;
29923
+ if (firstError) {
29924
+ message = firstError.message;
29925
+ code = firstError.code;
29926
+ location = firstError.location;
29927
+ requestId = firstError.request_id;
29928
+ } else {
29929
+ message = "Unknown SAP AI error";
29930
+ }
29924
29931
  } else {
29925
29932
  message = error.message;
29926
29933
  code = error.code;
@@ -30063,7 +30070,7 @@ The model's response was blocked by content safety filters. Try a different prom
30063
30070
  );
30064
30071
  }
30065
30072
  const statusMatch = /status code (\d+)/i.exec(originalErrorMsg);
30066
- if (statusMatch) {
30073
+ if (statusMatch?.[1]) {
30067
30074
  const extractedStatus = Number.parseInt(statusMatch[1], 10);
30068
30075
  return createAPICallError(
30069
30076
  error,
@@ -30613,7 +30620,7 @@ function castProviderMetadataV3ToV2(v3Metadata) {
30613
30620
  // src/sap-ai-language-model.ts
30614
30621
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
30615
30622
  var import_orchestration2 = require("@sap-ai-sdk/orchestration");
30616
- var import_zod_to_json_schema = require("zod-to-json-schema");
30623
+ var import_zod2 = require("zod");
30617
30624
 
30618
30625
  // src/convert-to-sap-messages.ts
30619
30626
  var import_provider3 = require("@ai-sdk/provider");
@@ -30757,8 +30764,9 @@ function convertToSAPMessages(prompt, options = {}) {
30757
30764
  }
30758
30765
  }
30759
30766
  }
30760
- const userMessage = contentParts.length === 1 && contentParts[0].type === "text" ? {
30761
- content: contentParts[0].text ?? "",
30767
+ const firstPart = contentParts[0];
30768
+ const userMessage = contentParts.length === 1 && firstPart?.type === "text" ? {
30769
+ content: firstPart.text ?? "",
30762
30770
  role: "user"
30763
30771
  } : {
30764
30772
  content: contentParts,
@@ -30992,7 +31000,6 @@ var SAPAILanguageModel = class {
30992
31000
  const modelId = this.modelId;
30993
31001
  const providerName = getProviderName(this.config.provider);
30994
31002
  const warningsSnapshot = [...warnings];
30995
- const warningsOut = [...warningsSnapshot];
30996
31003
  const transformedStream = new ReadableStream({
30997
31004
  cancel(reason) {
30998
31005
  if (reason) {
@@ -31105,12 +31112,6 @@ var SAPAILanguageModel = class {
31105
31112
  type: "tool-input-start"
31106
31113
  });
31107
31114
  }
31108
- if (!tc.toolName) {
31109
- warningsOut.push({
31110
- message: "Received tool-call delta without a tool name. Emitting tool-call with an empty tool name.",
31111
- type: "other"
31112
- });
31113
- }
31114
31115
  tc.didEmitCall = true;
31115
31116
  controller.enqueue({ id: tc.id, type: "tool-input-end" });
31116
31117
  controller.enqueue({
@@ -31141,12 +31142,6 @@ var SAPAILanguageModel = class {
31141
31142
  type: "tool-input-start"
31142
31143
  });
31143
31144
  }
31144
- if (!tc.toolName) {
31145
- warningsOut.push({
31146
- message: "Received tool-call delta without a tool name. Emitting tool-call with an empty tool name.",
31147
- type: "other"
31148
- });
31149
- }
31150
31145
  didEmitAnyToolCalls = true;
31151
31146
  tc.didEmitCall = true;
31152
31147
  controller.enqueue({ id: tc.id, type: "tool-input-end" });
@@ -31267,9 +31262,7 @@ var SAPAILanguageModel = class {
31267
31262
  let parameters;
31268
31263
  if (toolWithParams.parameters && isZodSchema(toolWithParams.parameters)) {
31269
31264
  try {
31270
- const jsonSchema = (0, import_zod_to_json_schema.zodToJsonSchema)(toolWithParams.parameters, {
31271
- $refStrategy: "none"
31272
- });
31265
+ const jsonSchema = import_zod2.z.toJSONSchema(toolWithParams.parameters);
31273
31266
  const schemaRecord = jsonSchema;
31274
31267
  delete schemaRecord.$schema;
31275
31268
  parameters = buildSAPToolParameters(schemaRecord);
@@ -31671,18 +31664,24 @@ var sapai = createSAPAIProvider();
31671
31664
  var import_orchestration3 = require("@sap-ai-sdk/orchestration");
31672
31665
  var import_orchestration4 = require("@sap-ai-sdk/orchestration");
31673
31666
 
31667
+ // src/version.ts
31668
+ var VERSION = true ? "4.2.6" : "0.0.0-test";
31669
+
31674
31670
  // src/index.ts
31675
31671
  var import_orchestration5 = require("@sap-ai-sdk/orchestration");
31676
31672
  // Annotate the CommonJS export names for ESM import in node:
31677
31673
  0 && (module.exports = {
31678
31674
  OrchestrationClient,
31679
31675
  OrchestrationEmbeddingClient,
31676
+ OrchestrationEmbeddingResponse,
31680
31677
  OrchestrationResponse,
31678
+ OrchestrationStream,
31681
31679
  OrchestrationStreamChunkResponse,
31682
31680
  OrchestrationStreamResponse,
31683
31681
  SAPAIEmbeddingModel,
31684
31682
  SAPAILanguageModel,
31685
31683
  SAP_AI_PROVIDER_NAME,
31684
+ VERSION,
31686
31685
  buildAzureContentSafetyFilter,
31687
31686
  buildDocumentGroundingConfig,
31688
31687
  buildDpiMaskingProvider,