1
- import { DatabaseAdapter } from "@ai16z/eliza/src/database.ts" ;
2
- import { embeddingZeroVector } from "@ai16z/eliza/src/memory.ts" ;
1
+ export * from "./sqliteTables.ts" ;
2
+ export * from "./sqlite_vec.ts" ;
3
+
4
+ import { DatabaseAdapter } from "@ai16z/eliza" ;
5
+ import { embeddingZeroVector } from "@ai16z/eliza" ;
3
6
import {
4
7
Account ,
5
8
Actor ,
@@ -9,7 +12,7 @@ import {
9
12
type Memory ,
10
13
type Relationship ,
11
14
type UUID ,
12
- } from "@ai16z/eliza/src/types.ts " ;
15
+ } from "@ai16z/eliza" ;
13
16
import { Database } from "better-sqlite3" ;
14
17
import { v4 } from "uuid" ;
15
18
import { load } from "./sqlite_vec.ts" ;
@@ -277,7 +280,6 @@ export class SqliteDatabaseAdapter extends DatabaseAdapter {
277
280
} ) ) ;
278
281
}
279
282
280
-
281
283
async searchMemoriesByEmbedding (
282
284
embedding : number [ ] ,
283
285
params : {
@@ -369,22 +371,24 @@ export class SqliteDatabaseAdapter extends DatabaseAdapter {
369
371
LIMIT ?
370
372
` ;
371
373
372
- const rows = this . db . prepare ( sql ) . all (
373
- opts . query_field_name ,
374
- opts . query_field_sub_name ,
375
- opts . query_table_name ,
376
- opts . query_field_name ,
377
- opts . query_field_sub_name ,
378
- opts . query_input ,
379
- opts . query_input ,
380
- opts . query_input ,
381
- opts . query_input ,
382
- opts . query_match_count
383
- ) as { embedding : Buffer ; levenshtein_score : number } [ ] ;
384
-
385
- return rows . map ( row => ( {
374
+ const rows = this . db
375
+ . prepare ( sql )
376
+ . all (
377
+ opts . query_field_name ,
378
+ opts . query_field_sub_name ,
379
+ opts . query_table_name ,
380
+ opts . query_field_name ,
381
+ opts . query_field_sub_name ,
382
+ opts . query_input ,
383
+ opts . query_input ,
384
+ opts . query_input ,
385
+ opts . query_input ,
386
+ opts . query_match_count
387
+ ) as { embedding : Buffer ; levenshtein_score : number } [ ] ;
388
+
389
+ return rows . map ( ( row ) => ( {
386
390
embedding : Array . from ( new Float32Array ( row . embedding as Buffer ) ) ,
387
- levenshtein_score : row . levenshtein_score
391
+ levenshtein_score : row . levenshtein_score ,
388
392
} ) ) ;
389
393
}
390
394
0 commit comments