-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: knowledge base engine change to libsql
- Loading branch information
1 parent
77e0c51
commit 153e7a9
Showing
9 changed files
with
270 additions
and
176 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
.yarn/patches/@llm-tools-embedjs-libsql-npm-0.1.25-fad000d74c.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/src/libsql-db.js b/src/libsql-db.js | ||
index 58c42e4910bd0e53bc497ff9b9702b1f7a961266..250bc97c50a9b790e8798441d904d040f2d2af43 100644 | ||
--- a/src/libsql-db.js | ||
+++ b/src/libsql-db.js | ||
@@ -41,9 +41,9 @@ export class LibSqlDb { | ||
} | ||
async similaritySearch(query, k) { | ||
const statement = `SELECT id, pageContent, uniqueLoaderId, source, metadata, | ||
- vector_distance_cos(vector, vector32('[${query.join(',')}]')) | ||
+ vector_distance_cos(vector, vector32('[${query.join(',')}]')) as distance | ||
FROM ${this.tableName} | ||
- ORDER BY vector_distance_cos(vector, vector32('[${query.join(',')}]')) ASC | ||
+ ORDER BY distance ASC | ||
LIMIT ${k};`; | ||
this.debug(`Executing statement - ${truncateCenterString(statement, 700)}`); | ||
const results = await this.client.execute(statement); | ||
@@ -52,7 +52,7 @@ export class LibSqlDb { | ||
return { | ||
metadata, | ||
pageContent: result.pageContent.toString(), | ||
- score: 1, | ||
+ score: 1 - result.distance, | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.