@jerome-benoit/sap-ai-provider 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: () => SAPAIEmbeddingModel,
29746
29748
  SAPAILanguageModel: () => SAPAILanguageModel,
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,
@@ -29846,10 +29849,14 @@ function convertSAPErrorToAPICallError(errorResponse, context) {
29846
29849
  let requestId;
29847
29850
  if (Array.isArray(error)) {
29848
29851
  const firstError = error[0];
29849
- message = firstError.message;
29850
- code = firstError.code;
29851
- location = firstError.location;
29852
- requestId = firstError.request_id;
29852
+ if (firstError) {
29853
+ message = firstError.message;
29854
+ code = firstError.code;
29855
+ location = firstError.location;
29856
+ requestId = firstError.request_id;
29857
+ } else {
29858
+ message = "Unknown SAP AI error";
29859
+ }
29853
29860
  } else {
29854
29861
  message = error.message;
29855
29862
  code = error.code;
@@ -29992,7 +29999,7 @@ The model's response was blocked by content safety filters. Try a different prom
29992
29999
  );
29993
30000
  }
29994
30001
  const statusMatch = /status code (\d+)/i.exec(originalErrorMsg);
29995
- if (statusMatch) {
30002
+ if (statusMatch?.[1]) {
29996
30003
  const extractedStatus = Number.parseInt(statusMatch[1], 10);
29997
30004
  return createAPICallError(
29998
30005
  error,
@@ -30461,7 +30468,7 @@ var SAPAIEmbeddingModel = class {
30461
30468
  // src/sap-ai-language-model.ts
30462
30469
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
30463
30470
  var import_orchestration2 = require("@sap-ai-sdk/orchestration");
30464
- var import_zod_to_json_schema = require("zod-to-json-schema");
30471
+ var import_zod2 = require("zod");
30465
30472
 
30466
30473
  // src/convert-to-sap-messages.ts
30467
30474
  var import_provider3 = require("@ai-sdk/provider");
@@ -30605,8 +30612,9 @@ function convertToSAPMessages(prompt, options = {}) {
30605
30612
  }
30606
30613
  }
30607
30614
  }
30608
- const userMessage = contentParts.length === 1 && contentParts[0].type === "text" ? {
30609
- content: contentParts[0].text ?? "",
30615
+ const firstPart = contentParts[0];
30616
+ const userMessage = contentParts.length === 1 && firstPart?.type === "text" ? {
30617
+ content: firstPart.text ?? "",
30610
30618
  role: "user"
30611
30619
  } : {
30612
30620
  content: contentParts,
@@ -30840,7 +30848,6 @@ var SAPAILanguageModel = class {
30840
30848
  const modelId = this.modelId;
30841
30849
  const providerName = getProviderName(this.config.provider);
30842
30850
  const warningsSnapshot = [...warnings];
30843
- const warningsOut = [...warningsSnapshot];
30844
30851
  const transformedStream = new ReadableStream({
30845
30852
  cancel(reason) {
30846
30853
  if (reason) {
@@ -30953,12 +30960,6 @@ var SAPAILanguageModel = class {
30953
30960
  type: "tool-input-start"
30954
30961
  });
30955
30962
  }
30956
- if (!tc.toolName) {
30957
- warningsOut.push({
30958
- message: "Received tool-call delta without a tool name. Emitting tool-call with an empty tool name.",
30959
- type: "other"
30960
- });
30961
- }
30962
30963
  tc.didEmitCall = true;
30963
30964
  controller.enqueue({ id: tc.id, type: "tool-input-end" });
30964
30965
  controller.enqueue({
@@ -30989,12 +30990,6 @@ var SAPAILanguageModel = class {
30989
30990
  type: "tool-input-start"
30990
30991
  });
30991
30992
  }
30992
- if (!tc.toolName) {
30993
- warningsOut.push({
30994
- message: "Received tool-call delta without a tool name. Emitting tool-call with an empty tool name.",
30995
- type: "other"
30996
- });
30997
- }
30998
30993
  didEmitAnyToolCalls = true;
30999
30994
  tc.didEmitCall = true;
31000
30995
  controller.enqueue({ id: tc.id, type: "tool-input-end" });
@@ -31115,9 +31110,7 @@ var SAPAILanguageModel = class {
31115
31110
  let parameters;
31116
31111
  if (toolWithParams.parameters && isZodSchema(toolWithParams.parameters)) {
31117
31112
  try {
31118
- const jsonSchema = (0, import_zod_to_json_schema.zodToJsonSchema)(toolWithParams.parameters, {
31119
- $refStrategy: "none"
31120
- });
31113
+ const jsonSchema = import_zod2.z.toJSONSchema(toolWithParams.parameters);
31121
31114
  const schemaRecord = jsonSchema;
31122
31115
  delete schemaRecord.$schema;
31123
31116
  parameters = buildSAPToolParameters(schemaRecord);
@@ -31428,18 +31421,24 @@ var sapai = createSAPAIProvider();
31428
31421
  var import_orchestration3 = require("@sap-ai-sdk/orchestration");
31429
31422
  var import_orchestration4 = require("@sap-ai-sdk/orchestration");
31430
31423
 
31424
+ // src/version.ts
31425
+ var VERSION = true ? "4.2.6" : "0.0.0-test";
31426
+
31431
31427
  // src/index.ts
31432
31428
  var import_orchestration5 = require("@sap-ai-sdk/orchestration");
31433
31429
  // Annotate the CommonJS export names for ESM import in node:
31434
31430
  0 && (module.exports = {
31435
31431
  OrchestrationClient,
31436
31432
  OrchestrationEmbeddingClient,
31433
+ OrchestrationEmbeddingResponse,
31437
31434
  OrchestrationResponse,
31435
+ OrchestrationStream,
31438
31436
  OrchestrationStreamChunkResponse,
31439
31437
  OrchestrationStreamResponse,
31440
31438
  SAPAIEmbeddingModel,
31441
31439
  SAPAILanguageModel,
31442
31440
  SAP_AI_PROVIDER_NAME,
31441
+ VERSION,
31443
31442
  buildAzureContentSafetyFilter,
31444
31443
  buildDocumentGroundingConfig,
31445
31444
  buildDpiMaskingProvider,