@superlinked/sie-sdk 0.3.3 → 0.3.4

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
@@ -109,6 +109,15 @@ var ModelLoadFailedError = class extends ServerError {
109
109
  this.attempts = options?.attempts ?? 1;
110
110
  }
111
111
  };
112
+ var InputTooLongError = class extends RequestError {
113
+ /** The model that was requested */
114
+ model;
115
+ constructor(message, options) {
116
+ super(message, "INPUT_TOO_LONG", 400);
117
+ this.name = "InputTooLongError";
118
+ this.model = options?.model;
119
+ }
120
+ };
112
121
 
113
122
  // src/internal/constants.ts
114
123
  var MSGPACK_CONTENT_TYPE = "application/msgpack";
@@ -380,6 +389,14 @@ async function throwIfModelLoadFailed(response, model) {
380
389
  attempts
381
390
  });
382
391
  }
392
+ async function throwIfInputTooLong(response, model) {
393
+ if (response.status !== 400) return;
394
+ const detail = await getErrorDetail(response.clone());
395
+ if (!detail) return;
396
+ if (detail.code !== "INPUT_TOO_LONG") return;
397
+ const message = typeof detail.message === "string" ? detail.message : "Input exceeds the model's maximum token capacity";
398
+ throw new InputTooLongError(message, { model });
399
+ }
383
400
  async function handleError(response, gpu) {
384
401
  const { status } = response;
385
402
  const detail = await getErrorDetail(response.clone());
@@ -413,6 +430,9 @@ async function handleError(response, gpu) {
413
430
  throw new ProvisioningError(message, gpu, retryAfter);
414
431
  }
415
432
  if (status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_CLIENT_ERROR_MAX) {
433
+ if (status === 400 && code === "INPUT_TOO_LONG") {
434
+ throw new InputTooLongError(message);
435
+ }
416
436
  throw new RequestError(message, code, status);
417
437
  }
418
438
  if (status >= HTTP_SERVER_ERROR_MIN && status <= HTTP_SERVER_ERROR_MAX) {
@@ -531,7 +551,7 @@ function parseCapacityInfo(data, gpuFilter) {
531
551
  }
532
552
 
533
553
  // src/version.ts
534
- var SDK_VERSION = "0.3.3";
554
+ var SDK_VERSION = "0.3.4";
535
555
 
536
556
  // src/client.ts
537
557
  function sleep(ms) {
@@ -820,6 +840,9 @@ var SIEClient = class {
820
840
  if (options.threshold !== void 0) {
821
841
  params.threshold = options.threshold;
822
842
  }
843
+ if (options.adapterOptions !== void 0) {
844
+ params.options = options.adapterOptions;
845
+ }
823
846
  body.params = params;
824
847
  const waitForCapacity = options.waitForCapacity ?? this.defaultWaitForCapacity;
825
848
  const { pool, gpu } = this.parseGpuParam(options.gpu);
@@ -1236,6 +1259,7 @@ var SIEClient = class {
1236
1259
  continue;
1237
1260
  }
1238
1261
  await throwIfModelLoadFailed(response, model);
1262
+ await throwIfInputTooLong(response, model);
1239
1263
  if (response.status === 503) {
1240
1264
  const clonedResponse = response.clone();
1241
1265
  const errorCode = await getErrorCode(clonedResponse);
@@ -1557,6 +1581,7 @@ function detectImageFormat(bytes) {
1557
1581
  return "unknown";
1558
1582
  }
1559
1583
 
1584
+ exports.InputTooLongError = InputTooLongError;
1560
1585
  exports.LoraLoadingError = LoraLoadingError;
1561
1586
  exports.ModelLoadFailedError = ModelLoadFailedError;
1562
1587
  exports.ModelLoadingError = ModelLoadingError;