@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.d.cts CHANGED
@@ -417,6 +417,14 @@ interface ExtractOptions {
417
417
  gpu?: string;
418
418
  /** Whether to wait for capacity */
419
419
  waitForCapacity?: boolean;
420
+ /**
421
+ * Adapter-specific runtime options forwarded to the server as
422
+ * `params.options`. Used for adapter knobs that aren't part of the
423
+ * core extract API — e.g. `{ overflow_policy: "error" }` for
424
+ * gliclass token-budget control. Mirrors the Python SDK's `options`
425
+ * keyword argument.
426
+ */
427
+ adapterOptions?: Record<string, unknown>;
420
428
  }
421
429
  /**
422
430
  * Helper to convert typed arrays to regular number array.
@@ -732,7 +740,7 @@ declare class SIEClient {
732
740
  private detectEndpointType;
733
741
  }
734
742
 
735
- declare const SDK_VERSION = "0.3.3";
743
+ declare const SDK_VERSION = "0.3.4";
736
744
 
737
745
  /**
738
746
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -981,6 +989,26 @@ declare class ModelLoadFailedError extends ServerError {
981
989
  attempts?: number;
982
990
  });
983
991
  }
992
+ /**
993
+ * Error when the request input exceeds the model's maximum token capacity.
994
+ *
995
+ * Thrown when the server returns HTTP `400 INPUT_TOO_LONG` for an
996
+ * extraction request. Distinct from generic {@link RequestError} so
997
+ * callers can branch on token-budget failures specifically (truncate
998
+ * the input client-side, switch to a longer-context model, or surface
999
+ * a targeted error to the end user) without parsing the error code.
1000
+ *
1001
+ * Subclass of {@link RequestError} so existing 4xx handlers continue
1002
+ * to work; new code can catch {@link InputTooLongError} for tailored
1003
+ * handling.
1004
+ */
1005
+ declare class InputTooLongError extends RequestError {
1006
+ /** The model that was requested */
1007
+ readonly model: string | undefined;
1008
+ constructor(message: string, options?: {
1009
+ model?: string;
1010
+ });
1011
+ }
984
1012
 
985
1013
  /**
986
1014
  * MessagePack serialization with msgpack-numpy compatibility.
@@ -1086,4 +1114,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
1086
1114
  */
1087
1115
  declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
1088
1116
 
1089
- export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1117
+ export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
package/dist/index.d.ts CHANGED
@@ -417,6 +417,14 @@ interface ExtractOptions {
417
417
  gpu?: string;
418
418
  /** Whether to wait for capacity */
419
419
  waitForCapacity?: boolean;
420
+ /**
421
+ * Adapter-specific runtime options forwarded to the server as
422
+ * `params.options`. Used for adapter knobs that aren't part of the
423
+ * core extract API — e.g. `{ overflow_policy: "error" }` for
424
+ * gliclass token-budget control. Mirrors the Python SDK's `options`
425
+ * keyword argument.
426
+ */
427
+ adapterOptions?: Record<string, unknown>;
420
428
  }
421
429
  /**
422
430
  * Helper to convert typed arrays to regular number array.
@@ -732,7 +740,7 @@ declare class SIEClient {
732
740
  private detectEndpointType;
733
741
  }
734
742
 
735
- declare const SDK_VERSION = "0.3.3";
743
+ declare const SDK_VERSION = "0.3.4";
736
744
 
737
745
  /**
738
746
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -981,6 +989,26 @@ declare class ModelLoadFailedError extends ServerError {
981
989
  attempts?: number;
982
990
  });
983
991
  }
992
+ /**
993
+ * Error when the request input exceeds the model's maximum token capacity.
994
+ *
995
+ * Thrown when the server returns HTTP `400 INPUT_TOO_LONG` for an
996
+ * extraction request. Distinct from generic {@link RequestError} so
997
+ * callers can branch on token-budget failures specifically (truncate
998
+ * the input client-side, switch to a longer-context model, or surface
999
+ * a targeted error to the end user) without parsing the error code.
1000
+ *
1001
+ * Subclass of {@link RequestError} so existing 4xx handlers continue
1002
+ * to work; new code can catch {@link InputTooLongError} for tailored
1003
+ * handling.
1004
+ */
1005
+ declare class InputTooLongError extends RequestError {
1006
+ /** The model that was requested */
1007
+ readonly model: string | undefined;
1008
+ constructor(message: string, options?: {
1009
+ model?: string;
1010
+ });
1011
+ }
984
1012
 
985
1013
  /**
986
1014
  * MessagePack serialization with msgpack-numpy compatibility.
@@ -1086,4 +1114,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
1086
1114
  */
1087
1115
  declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
1088
1116
 
1089
- export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1117
+ export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
package/dist/index.js CHANGED
@@ -107,6 +107,15 @@ var ModelLoadFailedError = class extends ServerError {
107
107
  this.attempts = options?.attempts ?? 1;
108
108
  }
109
109
  };
110
+ var InputTooLongError = class extends RequestError {
111
+ /** The model that was requested */
112
+ model;
113
+ constructor(message, options) {
114
+ super(message, "INPUT_TOO_LONG", 400);
115
+ this.name = "InputTooLongError";
116
+ this.model = options?.model;
117
+ }
118
+ };
110
119
 
111
120
  // src/internal/constants.ts
112
121
  var MSGPACK_CONTENT_TYPE = "application/msgpack";
@@ -378,6 +387,14 @@ async function throwIfModelLoadFailed(response, model) {
378
387
  attempts
379
388
  });
380
389
  }
390
+ async function throwIfInputTooLong(response, model) {
391
+ if (response.status !== 400) return;
392
+ const detail = await getErrorDetail(response.clone());
393
+ if (!detail) return;
394
+ if (detail.code !== "INPUT_TOO_LONG") return;
395
+ const message = typeof detail.message === "string" ? detail.message : "Input exceeds the model's maximum token capacity";
396
+ throw new InputTooLongError(message, { model });
397
+ }
381
398
  async function handleError(response, gpu) {
382
399
  const { status } = response;
383
400
  const detail = await getErrorDetail(response.clone());
@@ -411,6 +428,9 @@ async function handleError(response, gpu) {
411
428
  throw new ProvisioningError(message, gpu, retryAfter);
412
429
  }
413
430
  if (status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_CLIENT_ERROR_MAX) {
431
+ if (status === 400 && code === "INPUT_TOO_LONG") {
432
+ throw new InputTooLongError(message);
433
+ }
414
434
  throw new RequestError(message, code, status);
415
435
  }
416
436
  if (status >= HTTP_SERVER_ERROR_MIN && status <= HTTP_SERVER_ERROR_MAX) {
@@ -529,7 +549,7 @@ function parseCapacityInfo(data, gpuFilter) {
529
549
  }
530
550
 
531
551
  // src/version.ts
532
- var SDK_VERSION = "0.3.3";
552
+ var SDK_VERSION = "0.3.4";
533
553
 
534
554
  // src/client.ts
535
555
  function sleep(ms) {
@@ -818,6 +838,9 @@ var SIEClient = class {
818
838
  if (options.threshold !== void 0) {
819
839
  params.threshold = options.threshold;
820
840
  }
841
+ if (options.adapterOptions !== void 0) {
842
+ params.options = options.adapterOptions;
843
+ }
821
844
  body.params = params;
822
845
  const waitForCapacity = options.waitForCapacity ?? this.defaultWaitForCapacity;
823
846
  const { pool, gpu } = this.parseGpuParam(options.gpu);
@@ -1234,6 +1257,7 @@ var SIEClient = class {
1234
1257
  continue;
1235
1258
  }
1236
1259
  await throwIfModelLoadFailed(response, model);
1260
+ await throwIfInputTooLong(response, model);
1237
1261
  if (response.status === 503) {
1238
1262
  const clonedResponse = response.clone();
1239
1263
  const errorCode = await getErrorCode(clonedResponse);
@@ -1555,6 +1579,6 @@ function detectImageFormat(bytes) {
1555
1579
  return "unknown";
1556
1580
  }
1557
1581
 
1558
- export { LoraLoadingError, ModelLoadFailedError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1582
+ export { InputTooLongError, LoraLoadingError, ModelLoadFailedError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1559
1583
  //# sourceMappingURL=index.js.map
1560
1584
  //# sourceMappingURL=index.js.map