@loghead/core 0.1.7 → 0.1.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/dist/services/db.js +7 -4
- package/package.json +1 -1
- package/src/services/db.ts +7 -4
package/dist/services/db.js
CHANGED
|
@@ -79,12 +79,15 @@ class DbService {
|
|
|
79
79
|
// Manual Transaction
|
|
80
80
|
const insertTx = client_1.db.transaction(() => {
|
|
81
81
|
// 1. Insert into logs
|
|
82
|
-
client_1.db.prepare("INSERT INTO logs (id, stream_id, content, metadata) VALUES (?, ?, ?, ?)").run(id, streamId, content, metadataStr);
|
|
83
|
-
// 2. Get rowid
|
|
84
|
-
const
|
|
85
|
-
const rowid = rowInfo.rowid;
|
|
82
|
+
const info = client_1.db.prepare("INSERT INTO logs (id, stream_id, content, metadata) VALUES (?, ?, ?, ?)").run(id, streamId, content, metadataStr);
|
|
83
|
+
// 2. Get rowid directly
|
|
84
|
+
const rowid = info.lastInsertRowid;
|
|
86
85
|
// 3. Insert into vec_logs if embedding exists
|
|
87
86
|
if (embedding && embedding.length > 0) {
|
|
87
|
+
if (embedding.length !== 1024) {
|
|
88
|
+
console.warn(`[Warning] Embedding dimension mismatch. Expected 1024, got ${embedding.length}. Skipping vector index.`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
88
91
|
const vectorJson = JSON.stringify(embedding);
|
|
89
92
|
client_1.db.prepare("INSERT INTO vec_logs(rowid, embedding) VALUES (?, ?)").run(rowid, vectorJson);
|
|
90
93
|
}
|
package/package.json
CHANGED
package/src/services/db.ts
CHANGED
|
@@ -88,16 +88,19 @@ export class DbService {
|
|
|
88
88
|
// Manual Transaction
|
|
89
89
|
const insertTx = db.transaction(() => {
|
|
90
90
|
// 1. Insert into logs
|
|
91
|
-
(db.prepare("INSERT INTO logs (id, stream_id, content, metadata) VALUES (?, ?, ?, ?)") as unknown as DbAny).run(
|
|
91
|
+
const info = (db.prepare("INSERT INTO logs (id, stream_id, content, metadata) VALUES (?, ?, ?, ?)") as unknown as DbAny).run(
|
|
92
92
|
id, streamId, content, metadataStr
|
|
93
93
|
);
|
|
94
94
|
|
|
95
|
-
// 2. Get rowid
|
|
96
|
-
const
|
|
97
|
-
const rowid = rowInfo.rowid;
|
|
95
|
+
// 2. Get rowid directly
|
|
96
|
+
const rowid = info.lastInsertRowid;
|
|
98
97
|
|
|
99
98
|
// 3. Insert into vec_logs if embedding exists
|
|
100
99
|
if (embedding && embedding.length > 0) {
|
|
100
|
+
if (embedding.length !== 1024) {
|
|
101
|
+
console.warn(`[Warning] Embedding dimension mismatch. Expected 1024, got ${embedding.length}. Skipping vector index.`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
101
104
|
const vectorJson = JSON.stringify(embedding);
|
|
102
105
|
(db.prepare("INSERT INTO vec_logs(rowid, embedding) VALUES (?, ?)") as unknown as DbAny).run(rowid, vectorJson);
|
|
103
106
|
}
|