@voidwire/lore 1.0.7 → 1.0.8
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/lib/config.ts +27 -1
- package/lib/semantic.ts +2 -2
- package/package.json +1 -1
package/lib/config.ts
CHANGED
|
@@ -33,6 +33,10 @@ export interface LoreConfig {
|
|
|
33
33
|
sqlite: string;
|
|
34
34
|
custom_sqlite?: string;
|
|
35
35
|
};
|
|
36
|
+
embedding: {
|
|
37
|
+
model: string;
|
|
38
|
+
dimensions: number;
|
|
39
|
+
};
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
let cachedConfig: LoreConfig | null = null;
|
|
@@ -81,9 +85,27 @@ export function getConfig(): LoreConfig {
|
|
|
81
85
|
"Invalid config: missing [database] section in config.toml",
|
|
82
86
|
);
|
|
83
87
|
}
|
|
88
|
+
if (!parsed.embedding || typeof parsed.embedding !== "object") {
|
|
89
|
+
throw new Error(
|
|
90
|
+
"Invalid config: missing [embedding] section in config.toml",
|
|
91
|
+
);
|
|
92
|
+
}
|
|
84
93
|
|
|
85
94
|
const paths = parsed.paths as Record<string, unknown>;
|
|
86
95
|
const database = parsed.database as Record<string, unknown>;
|
|
96
|
+
const embedding = parsed.embedding as Record<string, unknown>;
|
|
97
|
+
|
|
98
|
+
// Validate required embedding fields
|
|
99
|
+
if (typeof embedding.model !== "string") {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"Invalid config: embedding.model is missing or not a string",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (typeof embedding.dimensions !== "number") {
|
|
105
|
+
throw new Error(
|
|
106
|
+
"Invalid config: embedding.dimensions is missing or not a number",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
87
109
|
|
|
88
110
|
// Validate required path fields
|
|
89
111
|
const requiredPaths = [
|
|
@@ -140,7 +162,11 @@ export function getConfig(): LoreConfig {
|
|
|
140
162
|
? resolvePath(database.custom_sqlite)
|
|
141
163
|
: undefined,
|
|
142
164
|
},
|
|
165
|
+
embedding: {
|
|
166
|
+
model: embedding.model as string,
|
|
167
|
+
dimensions: embedding.dimensions as number,
|
|
168
|
+
},
|
|
143
169
|
};
|
|
144
170
|
|
|
145
|
-
return cachedConfig
|
|
171
|
+
return cachedConfig!;
|
|
146
172
|
}
|
package/lib/semantic.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { existsSync } from "fs";
|
|
|
11
11
|
import { pipeline } from "@huggingface/transformers";
|
|
12
12
|
import { getDatabasePath, openDatabase } from "./db.js";
|
|
13
13
|
import { search as keywordSearch, type SearchResult } from "./search.js";
|
|
14
|
+
import { getConfig } from "./config.js";
|
|
14
15
|
|
|
15
16
|
export interface SemanticResult {
|
|
16
17
|
rowid: number;
|
|
@@ -30,8 +31,7 @@ export interface SemanticSearchOptions {
|
|
|
30
31
|
since?: string;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const MODEL_NAME =
|
|
34
|
-
const EMBEDDING_DIM = 768;
|
|
34
|
+
const { model: MODEL_NAME, dimensions: EMBEDDING_DIM } = getConfig().embedding;
|
|
35
35
|
|
|
36
36
|
interface EmbeddingPipeline {
|
|
37
37
|
(
|