@zabaca/lattice 1.0.4 → 1.0.5
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/main.js +18 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -711,7 +711,14 @@ class VoyageEmbeddingProvider {
|
|
|
711
711
|
const embeddings = await this.generateEmbeddings([text]);
|
|
712
712
|
return embeddings[0];
|
|
713
713
|
}
|
|
714
|
+
async generateQueryEmbedding(text) {
|
|
715
|
+
const embeddings = await this.generateEmbeddingsWithType([text], "query");
|
|
716
|
+
return embeddings[0];
|
|
717
|
+
}
|
|
714
718
|
async generateEmbeddings(texts) {
|
|
719
|
+
return this.generateEmbeddingsWithType(texts, this.inputType);
|
|
720
|
+
}
|
|
721
|
+
async generateEmbeddingsWithType(texts, inputType) {
|
|
715
722
|
if (!texts || texts.length === 0) {
|
|
716
723
|
return [];
|
|
717
724
|
}
|
|
@@ -726,7 +733,7 @@ class VoyageEmbeddingProvider {
|
|
|
726
733
|
model: this.model,
|
|
727
734
|
input: texts,
|
|
728
735
|
output_dimension: this.dimensions,
|
|
729
|
-
input_type:
|
|
736
|
+
input_type: inputType
|
|
730
737
|
})
|
|
731
738
|
});
|
|
732
739
|
if (!response.ok) {
|
|
@@ -813,6 +820,15 @@ class EmbeddingService {
|
|
|
813
820
|
}
|
|
814
821
|
return this.provider.generateEmbedding(text);
|
|
815
822
|
}
|
|
823
|
+
async generateQueryEmbedding(text) {
|
|
824
|
+
if (!text || text.trim().length === 0) {
|
|
825
|
+
throw new Error("Cannot generate embedding for empty text");
|
|
826
|
+
}
|
|
827
|
+
if (this.provider.generateQueryEmbedding) {
|
|
828
|
+
return this.provider.generateQueryEmbedding(text);
|
|
829
|
+
}
|
|
830
|
+
return this.provider.generateEmbedding(text);
|
|
831
|
+
}
|
|
816
832
|
async generateEmbeddings(texts) {
|
|
817
833
|
const validTexts = texts.filter((t) => t && t.trim().length > 0);
|
|
818
834
|
if (validTexts.length === 0) {
|
|
@@ -1234,7 +1250,7 @@ class SearchCommand extends CommandRunner3 {
|
|
|
1234
1250
|
const query = inputs[0];
|
|
1235
1251
|
const limit = Math.min(parseInt(options.limit || "20", 10), 100);
|
|
1236
1252
|
try {
|
|
1237
|
-
const queryEmbedding = await this.embeddingService.
|
|
1253
|
+
const queryEmbedding = await this.embeddingService.generateQueryEmbedding(query);
|
|
1238
1254
|
let results;
|
|
1239
1255
|
if (options.label) {
|
|
1240
1256
|
const labelResults = await this.graphService.vectorSearch(options.label, queryEmbedding, limit);
|