@superlinked/sie-sdk 0.1.9 → 0.2.0
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 +94 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -4
- package/dist/index.d.ts +121 -4
- package/dist/index.js +90 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -146,6 +146,39 @@ interface Entity {
|
|
|
146
146
|
/** Bounding box [x, y, width, height] for image-based extraction */
|
|
147
147
|
bbox?: number[];
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A relation triple between two entities.
|
|
151
|
+
*/
|
|
152
|
+
interface Relation {
|
|
153
|
+
/** Head entity text */
|
|
154
|
+
head: string;
|
|
155
|
+
/** Tail entity text */
|
|
156
|
+
tail: string;
|
|
157
|
+
/** Relation type label (e.g., "works_at", "founded_by") */
|
|
158
|
+
relation: string;
|
|
159
|
+
/** Confidence score */
|
|
160
|
+
score: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A text classification result.
|
|
164
|
+
*/
|
|
165
|
+
interface Classification {
|
|
166
|
+
/** Classification label (e.g., "positive", "negative") */
|
|
167
|
+
label: string;
|
|
168
|
+
/** Confidence score */
|
|
169
|
+
score: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A detected object with bounding box.
|
|
173
|
+
*/
|
|
174
|
+
interface DetectedObject {
|
|
175
|
+
/** Object class label (e.g., "person", "car") */
|
|
176
|
+
label: string;
|
|
177
|
+
/** Confidence score */
|
|
178
|
+
score: number;
|
|
179
|
+
/** Bounding box [x, y, width, height] */
|
|
180
|
+
bbox: number[];
|
|
181
|
+
}
|
|
149
182
|
/**
|
|
150
183
|
* Result of extraction for a single item.
|
|
151
184
|
*/
|
|
@@ -154,6 +187,12 @@ interface ExtractResult {
|
|
|
154
187
|
id?: string;
|
|
155
188
|
/** List of extracted entities */
|
|
156
189
|
entities: Entity[];
|
|
190
|
+
/** List of extracted relation triples */
|
|
191
|
+
relations: Relation[];
|
|
192
|
+
/** List of classification results */
|
|
193
|
+
classifications: Classification[];
|
|
194
|
+
/** List of detected objects */
|
|
195
|
+
objects: DetectedObject[];
|
|
157
196
|
}
|
|
158
197
|
/**
|
|
159
198
|
* Information about a worker in the cluster.
|
|
@@ -343,8 +382,6 @@ interface EncodeOptions {
|
|
|
343
382
|
* Options for score operation.
|
|
344
383
|
*/
|
|
345
384
|
interface ScoreOptions {
|
|
346
|
-
/** Return only top K results */
|
|
347
|
-
topK?: number;
|
|
348
385
|
/** GPU type for this request */
|
|
349
386
|
gpu?: string;
|
|
350
387
|
/** Whether to wait for capacity */
|
|
@@ -474,6 +511,17 @@ declare class SIEClient {
|
|
|
474
511
|
* @returns Array of model information
|
|
475
512
|
*/
|
|
476
513
|
listModels(): Promise<ModelInfo[]>;
|
|
514
|
+
/**
|
|
515
|
+
* Get details for a specific model.
|
|
516
|
+
*
|
|
517
|
+
* Returns model metadata including dimensions, supported inputs/outputs,
|
|
518
|
+
* loaded status, and max sequence length. This is a lightweight call that
|
|
519
|
+
* reads from model config — it does not load the model or trigger inference.
|
|
520
|
+
*
|
|
521
|
+
* @param name - Model name (e.g., "BAAI/bge-m3")
|
|
522
|
+
* @returns Model information
|
|
523
|
+
*/
|
|
524
|
+
getModel(name: string): Promise<ModelInfo>;
|
|
477
525
|
/**
|
|
478
526
|
* Stream real-time status updates from a worker or router.
|
|
479
527
|
*
|
|
@@ -658,7 +706,76 @@ declare class SIEClient {
|
|
|
658
706
|
private detectEndpointType;
|
|
659
707
|
}
|
|
660
708
|
|
|
661
|
-
declare const SDK_VERSION = "0.
|
|
709
|
+
declare const SDK_VERSION = "0.2.0";
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Helpers for converting SIE encode results to plain JavaScript types.
|
|
713
|
+
*
|
|
714
|
+
* These functions bridge SDK result types (Float32Array, typed dicts) to the
|
|
715
|
+
* plain `number[]` / object formats that framework integrations and vector
|
|
716
|
+
* databases expect.
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```typescript
|
|
720
|
+
* import { SIEClient, denseEmbedding, sparseEmbedding } from "@superlinked/sie-sdk";
|
|
721
|
+
*
|
|
722
|
+
* const client = new SIEClient("http://localhost:8080");
|
|
723
|
+
* const result = await client.encode("BAAI/bge-m3", { text: "hello" });
|
|
724
|
+
* const vec = denseEmbedding(result); // number[]
|
|
725
|
+
* const sp = sparseEmbedding(result); // { indices: number[], values: number[] }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
|
|
729
|
+
/** Sparse vector in `{ indices, values }` format. */
|
|
730
|
+
interface SparseVector {
|
|
731
|
+
indices: number[];
|
|
732
|
+
values: number[];
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Extract the dense embedding from an encode result as `number[]`.
|
|
736
|
+
*
|
|
737
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
738
|
+
* @param strict - If `true` (default), throw when dense is missing. If `false`, return `[]`.
|
|
739
|
+
* @returns The dense vector as a plain JavaScript number array.
|
|
740
|
+
*/
|
|
741
|
+
declare function denseEmbedding(result: EncodeResult, strict?: boolean): number[];
|
|
742
|
+
/**
|
|
743
|
+
* Extract the sparse embedding from an encode result.
|
|
744
|
+
*
|
|
745
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
746
|
+
* @returns Object with `indices: number[]` and `values: number[]`. Empty arrays if sparse is absent.
|
|
747
|
+
*/
|
|
748
|
+
declare function sparseEmbedding(result: EncodeResult): SparseVector;
|
|
749
|
+
/**
|
|
750
|
+
* Extract the sparse embedding as a `Map<number, number>` (token index → weight).
|
|
751
|
+
*
|
|
752
|
+
* Useful for ChromaDB which expects sparse embeddings in this format.
|
|
753
|
+
*
|
|
754
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
755
|
+
* @returns Map from integer token indices to float weights. Empty map if sparse is absent.
|
|
756
|
+
*/
|
|
757
|
+
declare function sparseEmbeddingMap(result: EncodeResult): Map<number, number>;
|
|
758
|
+
/**
|
|
759
|
+
* Convert a raw sparse sub-object to plain JavaScript arrays.
|
|
760
|
+
*
|
|
761
|
+
* Unlike {@link sparseEmbedding}, this takes the sparse value itself
|
|
762
|
+
* (already extracted from the result) — useful inside named-vector
|
|
763
|
+
* loops where you've already pulled `result.sparse`.
|
|
764
|
+
*
|
|
765
|
+
* @param sparse - A {@link SparseResult} with `indices` and `values` typed arrays.
|
|
766
|
+
* @returns Object with `indices: number[]` and `values: number[]`.
|
|
767
|
+
*/
|
|
768
|
+
declare function normalizeSparseVector(sparse: SparseResult): SparseVector;
|
|
769
|
+
/**
|
|
770
|
+
* Convert a multivector (ColBERT) result to `number[][]`.
|
|
771
|
+
*
|
|
772
|
+
* SIE returns multivectors as `Float32Array[]`. Vector databases expect
|
|
773
|
+
* nested plain JavaScript arrays.
|
|
774
|
+
*
|
|
775
|
+
* @param raw - Array of Float32Array token vectors.
|
|
776
|
+
* @returns Nested array of number vectors.
|
|
777
|
+
*/
|
|
778
|
+
declare function multivectorEmbedding(raw: Float32Array[]): number[][];
|
|
662
779
|
|
|
663
780
|
/**
|
|
664
781
|
* Error classes for the SIE TypeScript SDK.
|
|
@@ -904,4 +1021,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
|
|
|
904
1021
|
*/
|
|
905
1022
|
declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
|
|
906
1023
|
|
|
907
|
-
export { type CapacityInfo, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, 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, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, detectImageFormat, packMessage, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1024
|
+
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, 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
|
@@ -146,6 +146,39 @@ interface Entity {
|
|
|
146
146
|
/** Bounding box [x, y, width, height] for image-based extraction */
|
|
147
147
|
bbox?: number[];
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A relation triple between two entities.
|
|
151
|
+
*/
|
|
152
|
+
interface Relation {
|
|
153
|
+
/** Head entity text */
|
|
154
|
+
head: string;
|
|
155
|
+
/** Tail entity text */
|
|
156
|
+
tail: string;
|
|
157
|
+
/** Relation type label (e.g., "works_at", "founded_by") */
|
|
158
|
+
relation: string;
|
|
159
|
+
/** Confidence score */
|
|
160
|
+
score: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A text classification result.
|
|
164
|
+
*/
|
|
165
|
+
interface Classification {
|
|
166
|
+
/** Classification label (e.g., "positive", "negative") */
|
|
167
|
+
label: string;
|
|
168
|
+
/** Confidence score */
|
|
169
|
+
score: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A detected object with bounding box.
|
|
173
|
+
*/
|
|
174
|
+
interface DetectedObject {
|
|
175
|
+
/** Object class label (e.g., "person", "car") */
|
|
176
|
+
label: string;
|
|
177
|
+
/** Confidence score */
|
|
178
|
+
score: number;
|
|
179
|
+
/** Bounding box [x, y, width, height] */
|
|
180
|
+
bbox: number[];
|
|
181
|
+
}
|
|
149
182
|
/**
|
|
150
183
|
* Result of extraction for a single item.
|
|
151
184
|
*/
|
|
@@ -154,6 +187,12 @@ interface ExtractResult {
|
|
|
154
187
|
id?: string;
|
|
155
188
|
/** List of extracted entities */
|
|
156
189
|
entities: Entity[];
|
|
190
|
+
/** List of extracted relation triples */
|
|
191
|
+
relations: Relation[];
|
|
192
|
+
/** List of classification results */
|
|
193
|
+
classifications: Classification[];
|
|
194
|
+
/** List of detected objects */
|
|
195
|
+
objects: DetectedObject[];
|
|
157
196
|
}
|
|
158
197
|
/**
|
|
159
198
|
* Information about a worker in the cluster.
|
|
@@ -343,8 +382,6 @@ interface EncodeOptions {
|
|
|
343
382
|
* Options for score operation.
|
|
344
383
|
*/
|
|
345
384
|
interface ScoreOptions {
|
|
346
|
-
/** Return only top K results */
|
|
347
|
-
topK?: number;
|
|
348
385
|
/** GPU type for this request */
|
|
349
386
|
gpu?: string;
|
|
350
387
|
/** Whether to wait for capacity */
|
|
@@ -474,6 +511,17 @@ declare class SIEClient {
|
|
|
474
511
|
* @returns Array of model information
|
|
475
512
|
*/
|
|
476
513
|
listModels(): Promise<ModelInfo[]>;
|
|
514
|
+
/**
|
|
515
|
+
* Get details for a specific model.
|
|
516
|
+
*
|
|
517
|
+
* Returns model metadata including dimensions, supported inputs/outputs,
|
|
518
|
+
* loaded status, and max sequence length. This is a lightweight call that
|
|
519
|
+
* reads from model config — it does not load the model or trigger inference.
|
|
520
|
+
*
|
|
521
|
+
* @param name - Model name (e.g., "BAAI/bge-m3")
|
|
522
|
+
* @returns Model information
|
|
523
|
+
*/
|
|
524
|
+
getModel(name: string): Promise<ModelInfo>;
|
|
477
525
|
/**
|
|
478
526
|
* Stream real-time status updates from a worker or router.
|
|
479
527
|
*
|
|
@@ -658,7 +706,76 @@ declare class SIEClient {
|
|
|
658
706
|
private detectEndpointType;
|
|
659
707
|
}
|
|
660
708
|
|
|
661
|
-
declare const SDK_VERSION = "0.
|
|
709
|
+
declare const SDK_VERSION = "0.2.0";
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Helpers for converting SIE encode results to plain JavaScript types.
|
|
713
|
+
*
|
|
714
|
+
* These functions bridge SDK result types (Float32Array, typed dicts) to the
|
|
715
|
+
* plain `number[]` / object formats that framework integrations and vector
|
|
716
|
+
* databases expect.
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```typescript
|
|
720
|
+
* import { SIEClient, denseEmbedding, sparseEmbedding } from "@superlinked/sie-sdk";
|
|
721
|
+
*
|
|
722
|
+
* const client = new SIEClient("http://localhost:8080");
|
|
723
|
+
* const result = await client.encode("BAAI/bge-m3", { text: "hello" });
|
|
724
|
+
* const vec = denseEmbedding(result); // number[]
|
|
725
|
+
* const sp = sparseEmbedding(result); // { indices: number[], values: number[] }
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
|
|
729
|
+
/** Sparse vector in `{ indices, values }` format. */
|
|
730
|
+
interface SparseVector {
|
|
731
|
+
indices: number[];
|
|
732
|
+
values: number[];
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Extract the dense embedding from an encode result as `number[]`.
|
|
736
|
+
*
|
|
737
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
738
|
+
* @param strict - If `true` (default), throw when dense is missing. If `false`, return `[]`.
|
|
739
|
+
* @returns The dense vector as a plain JavaScript number array.
|
|
740
|
+
*/
|
|
741
|
+
declare function denseEmbedding(result: EncodeResult, strict?: boolean): number[];
|
|
742
|
+
/**
|
|
743
|
+
* Extract the sparse embedding from an encode result.
|
|
744
|
+
*
|
|
745
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
746
|
+
* @returns Object with `indices: number[]` and `values: number[]`. Empty arrays if sparse is absent.
|
|
747
|
+
*/
|
|
748
|
+
declare function sparseEmbedding(result: EncodeResult): SparseVector;
|
|
749
|
+
/**
|
|
750
|
+
* Extract the sparse embedding as a `Map<number, number>` (token index → weight).
|
|
751
|
+
*
|
|
752
|
+
* Useful for ChromaDB which expects sparse embeddings in this format.
|
|
753
|
+
*
|
|
754
|
+
* @param result - An {@link EncodeResult} from `client.encode()`.
|
|
755
|
+
* @returns Map from integer token indices to float weights. Empty map if sparse is absent.
|
|
756
|
+
*/
|
|
757
|
+
declare function sparseEmbeddingMap(result: EncodeResult): Map<number, number>;
|
|
758
|
+
/**
|
|
759
|
+
* Convert a raw sparse sub-object to plain JavaScript arrays.
|
|
760
|
+
*
|
|
761
|
+
* Unlike {@link sparseEmbedding}, this takes the sparse value itself
|
|
762
|
+
* (already extracted from the result) — useful inside named-vector
|
|
763
|
+
* loops where you've already pulled `result.sparse`.
|
|
764
|
+
*
|
|
765
|
+
* @param sparse - A {@link SparseResult} with `indices` and `values` typed arrays.
|
|
766
|
+
* @returns Object with `indices: number[]` and `values: number[]`.
|
|
767
|
+
*/
|
|
768
|
+
declare function normalizeSparseVector(sparse: SparseResult): SparseVector;
|
|
769
|
+
/**
|
|
770
|
+
* Convert a multivector (ColBERT) result to `number[][]`.
|
|
771
|
+
*
|
|
772
|
+
* SIE returns multivectors as `Float32Array[]`. Vector databases expect
|
|
773
|
+
* nested plain JavaScript arrays.
|
|
774
|
+
*
|
|
775
|
+
* @param raw - Array of Float32Array token vectors.
|
|
776
|
+
* @returns Nested array of number vectors.
|
|
777
|
+
*/
|
|
778
|
+
declare function multivectorEmbedding(raw: Float32Array[]): number[][];
|
|
662
779
|
|
|
663
780
|
/**
|
|
664
781
|
* Error classes for the SIE TypeScript SDK.
|
|
@@ -904,4 +1021,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
|
|
|
904
1021
|
*/
|
|
905
1022
|
declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
|
|
906
1023
|
|
|
907
|
-
export { type CapacityInfo, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, 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, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, detectImageFormat, packMessage, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1024
|
+
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, 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
|
@@ -105,7 +105,7 @@ var SDK_VERSION_HEADER = "X-SIE-SDK-Version";
|
|
|
105
105
|
var SERVER_VERSION_HEADER = "X-SIE-Server-Version";
|
|
106
106
|
|
|
107
107
|
// src/version.ts
|
|
108
|
-
var SDK_VERSION = "0.
|
|
108
|
+
var SDK_VERSION = "0.2.0";
|
|
109
109
|
var EXT_TYPE_NUMPY = 78;
|
|
110
110
|
function parseDtype(dtype) {
|
|
111
111
|
const typeChar = dtype.slice(-2, -1);
|
|
@@ -422,7 +422,28 @@ function parseEntity(data) {
|
|
|
422
422
|
function parseExtractResult(data) {
|
|
423
423
|
return {
|
|
424
424
|
id: data.id,
|
|
425
|
-
entities: data.entities.map(parseEntity)
|
|
425
|
+
entities: data.entities.map(parseEntity),
|
|
426
|
+
relations: (data.relations ?? []).map(
|
|
427
|
+
(r) => ({
|
|
428
|
+
head: r.head,
|
|
429
|
+
tail: r.tail,
|
|
430
|
+
relation: r.relation,
|
|
431
|
+
score: r.score
|
|
432
|
+
})
|
|
433
|
+
),
|
|
434
|
+
classifications: (data.classifications ?? []).map(
|
|
435
|
+
(c) => ({
|
|
436
|
+
label: c.label,
|
|
437
|
+
score: c.score
|
|
438
|
+
})
|
|
439
|
+
),
|
|
440
|
+
objects: (data.objects ?? []).map(
|
|
441
|
+
(o) => ({
|
|
442
|
+
label: o.label,
|
|
443
|
+
score: o.score,
|
|
444
|
+
bbox: o.bbox
|
|
445
|
+
})
|
|
446
|
+
)
|
|
426
447
|
};
|
|
427
448
|
}
|
|
428
449
|
function parseExtractResults(data) {
|
|
@@ -570,6 +591,28 @@ var SIEClient = class {
|
|
|
570
591
|
maxSequenceLength: m.max_sequence_length
|
|
571
592
|
}));
|
|
572
593
|
}
|
|
594
|
+
/**
|
|
595
|
+
* Get details for a specific model.
|
|
596
|
+
*
|
|
597
|
+
* Returns model metadata including dimensions, supported inputs/outputs,
|
|
598
|
+
* loaded status, and max sequence length. This is a lightweight call that
|
|
599
|
+
* reads from model config — it does not load the model or trigger inference.
|
|
600
|
+
*
|
|
601
|
+
* @param name - Model name (e.g., "BAAI/bge-m3")
|
|
602
|
+
* @returns Model information
|
|
603
|
+
*/
|
|
604
|
+
async getModel(name) {
|
|
605
|
+
const response = await this.requestJson(`/v1/models/${encodeURIComponent(name)}`, "GET");
|
|
606
|
+
const data = await response.json();
|
|
607
|
+
return {
|
|
608
|
+
name: data.name,
|
|
609
|
+
loaded: data.loaded,
|
|
610
|
+
inputs: data.inputs,
|
|
611
|
+
outputs: data.outputs,
|
|
612
|
+
dims: data.dims,
|
|
613
|
+
maxSequenceLength: data.max_sequence_length
|
|
614
|
+
};
|
|
615
|
+
}
|
|
573
616
|
/**
|
|
574
617
|
* Stream real-time status updates from a worker or router.
|
|
575
618
|
*
|
|
@@ -674,9 +717,6 @@ var SIEClient = class {
|
|
|
674
717
|
query,
|
|
675
718
|
items
|
|
676
719
|
};
|
|
677
|
-
if (options.topK !== void 0) {
|
|
678
|
-
body.top_k = options.topK;
|
|
679
|
-
}
|
|
680
720
|
const waitForCapacity = options.waitForCapacity ?? this.defaultWaitForCapacity;
|
|
681
721
|
const { pool, gpu } = this.parseGpuParam(options.gpu);
|
|
682
722
|
const response = await this.requestWithRetry(
|
|
@@ -1293,6 +1333,50 @@ function toFloat32Array(arr) {
|
|
|
1293
1333
|
return new Float32Array(arr);
|
|
1294
1334
|
}
|
|
1295
1335
|
|
|
1336
|
+
// src/encoding.ts
|
|
1337
|
+
function denseEmbedding(result, strict = true) {
|
|
1338
|
+
const dense = result.dense;
|
|
1339
|
+
if (!dense) {
|
|
1340
|
+
if (strict) {
|
|
1341
|
+
throw new Error("Encode result missing dense embedding");
|
|
1342
|
+
}
|
|
1343
|
+
return [];
|
|
1344
|
+
}
|
|
1345
|
+
return toNumberArray(dense);
|
|
1346
|
+
}
|
|
1347
|
+
function sparseEmbedding(result) {
|
|
1348
|
+
const sparse = result.sparse;
|
|
1349
|
+
if (!sparse) {
|
|
1350
|
+
return { indices: [], values: [] };
|
|
1351
|
+
}
|
|
1352
|
+
return {
|
|
1353
|
+
indices: toNumberArray(sparse.indices),
|
|
1354
|
+
values: toNumberArray(sparse.values)
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
function sparseEmbeddingMap(result) {
|
|
1358
|
+
const sparse = result.sparse;
|
|
1359
|
+
if (!sparse) {
|
|
1360
|
+
return /* @__PURE__ */ new Map();
|
|
1361
|
+
}
|
|
1362
|
+
const indices = toNumberArray(sparse.indices);
|
|
1363
|
+
const values = toNumberArray(sparse.values);
|
|
1364
|
+
const map = /* @__PURE__ */ new Map();
|
|
1365
|
+
for (let i = 0; i < indices.length; i++) {
|
|
1366
|
+
map.set(indices[i], values[i]);
|
|
1367
|
+
}
|
|
1368
|
+
return map;
|
|
1369
|
+
}
|
|
1370
|
+
function normalizeSparseVector(sparse) {
|
|
1371
|
+
return {
|
|
1372
|
+
indices: toNumberArray(sparse.indices),
|
|
1373
|
+
values: toNumberArray(sparse.values)
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
function multivectorEmbedding(raw) {
|
|
1377
|
+
return raw.map((v) => toNumberArray(v));
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1296
1380
|
// src/scoring.ts
|
|
1297
1381
|
function maxsim(query, document) {
|
|
1298
1382
|
if (query.length === 0 || document.length === 0) {
|
|
@@ -1380,6 +1464,6 @@ function detectImageFormat(bytes) {
|
|
|
1380
1464
|
return "unknown";
|
|
1381
1465
|
}
|
|
1382
1466
|
|
|
1383
|
-
export { LoraLoadingError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, packMessage, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1467
|
+
export { LoraLoadingError, 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 };
|
|
1384
1468
|
//# sourceMappingURL=index.js.map
|
|
1385
1469
|
//# sourceMappingURL=index.js.map
|