specially handle Buffer objects into Base64 and back for Becca

This commit is contained in:
perf3ct 2025-03-12 22:43:58 +00:00
parent 67766e3e9f
commit 6bb4bbb1af
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
2 changed files with 14 additions and 0 deletions

View File

@ -364,6 +364,15 @@ function getEntityChangeRow(entityChange: EntityChange) {
} }
} }
// Special handling for note_embeddings embedding field
if (entityName === "note_embeddings") {
// Cast to any to access the embedding property
const row = entityRow as any;
if (row.embedding && Buffer.isBuffer(row.embedding)) {
row.embedding = row.embedding.toString("base64");
}
}
return entityRow; return entityRow;
} }
} }

View File

@ -174,6 +174,11 @@ function updateNoteEmbedding(remoteEC: EntityChange, remoteEntityRow: EntityRow
// Cast remoteEntityRow to include required embedding properties // Cast remoteEntityRow to include required embedding properties
const typedRemoteEntityRow = remoteEntityRow as unknown as NoteEmbeddingRow; const typedRemoteEntityRow = remoteEntityRow as unknown as NoteEmbeddingRow;
// Convert embedding from base64 string to Buffer if needed
if (typedRemoteEntityRow.embedding && typeof typedRemoteEntityRow.embedding === "string") {
typedRemoteEntityRow.embedding = Buffer.from(typedRemoteEntityRow.embedding, "base64");
}
const localEntityRow = sql.getRow<NoteEmbeddingRow>(`SELECT * FROM note_embeddings WHERE embedId = ?`, [remoteEC.entityId]); const localEntityRow = sql.getRow<NoteEmbeddingRow>(`SELECT * FROM note_embeddings WHERE embedId = ?`, [remoteEC.entityId]);
if (localEntityRow) { if (localEntityRow) {