Spaces:
Paused
Paused
Download src/memory/sqlite-vec.ts from amos-fernandes/melbot: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/spaces/amos-fernandes/melbot/resolve/main/src/memory/sqlite-vec.ts
- Command line
-
hf download hf://spaces/amos-fernandes/melbot/src/memory/sqlite-vec.ts
-
curl -L -o sqlite-vec.ts https://huggingface.co/spaces/amos-fernandes/melbot/resolve/main/src/memory/sqlite-vec.ts
789 Bytes
| import type { DatabaseSync } from "node:sqlite"; | |
| export async function loadSqliteVecExtension(params: { | |
| db: DatabaseSync; | |
| extensionPath?: string; | |
| }): Promise<{ ok: boolean; extensionPath?: string; error?: string }> { | |
| try { | |
| const sqliteVec = await import("sqlite-vec"); | |
| const resolvedPath = params.extensionPath?.trim() ? params.extensionPath.trim() : undefined; | |
| const extensionPath = resolvedPath ?? sqliteVec.getLoadablePath(); | |
| params.db.enableLoadExtension(true); | |
| if (resolvedPath) { | |
| params.db.loadExtension(extensionPath); | |
| } else { | |
| sqliteVec.load(params.db); | |
| } | |
| return { ok: true, extensionPath }; | |
| } catch (err) { | |
| const message = err instanceof Error ? err.message : String(err); | |
| return { ok: false, error: message }; | |
| } | |
| } | |