@storecraft/database-turso 1.0.13 → 1.0.14
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/package.json +1 -1
- package/vector-store/index.js +12 -1
package/package.json
CHANGED
package/vector-store/index.js
CHANGED
@@ -71,6 +71,14 @@ export class LibSQLVectorStore {
|
|
71
71
|
};
|
72
72
|
}
|
73
73
|
|
74
|
+
get metric() {
|
75
|
+
return this.config.similarity;
|
76
|
+
};
|
77
|
+
|
78
|
+
get dimensions() {
|
79
|
+
return this.config.dimensions;
|
80
|
+
};
|
81
|
+
|
74
82
|
get client() {
|
75
83
|
if(!this.config.url) {
|
76
84
|
throw new Error('LibSQLVectorStore::client() - missing url');
|
@@ -251,7 +259,10 @@ export class LibSQLVectorStore {
|
|
251
259
|
metadata: parse_json_safely(row.metadata),
|
252
260
|
namespace: String(row.namespace),
|
253
261
|
},
|
254
|
-
score
|
262
|
+
// `libsql` score is (1 - Cosine Similarity) which yields a distance
|
263
|
+
// between [0, 2] where 0 is the most similar.
|
264
|
+
// This is not in accordance with other apis, so we invert it to [-1, 1]
|
265
|
+
score: (this.metric==='cosine') ? (1.0 - Number(row.score)) : Number(row.score)
|
255
266
|
}
|
256
267
|
)
|
257
268
|
);
|