mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-25 06:01:40 +08:00
specially handle Buffer objects into Base64 and back for Becca
This commit is contained in:
parent
67766e3e9f
commit
6bb4bbb1af
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,11 @@ function updateNoteEmbedding(remoteEC: EntityChange, remoteEntityRow: EntityRow
|
||||
// Cast remoteEntityRow to include required embedding properties
|
||||
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]);
|
||||
|
||||
if (localEntityRow) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user