refactor(llm): update handling of note embeddings and clean up LoadResults class

This commit is contained in:
perf3ct 2025-06-02 19:10:47 +00:00
parent b0d60f8004
commit 934efab533
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
3 changed files with 9 additions and 14 deletions

View File

@ -36,7 +36,7 @@ async function processEntityChanges(entityChanges: EntityChange[]) {
} else if (ec.entityName === "attachments") {
processAttachment(loadResults, ec);
} else if (ec.entityName === "blobs" || ec.entityName === "etapi_tokens" || ec.entityName === "note_embeddings") {
// NOOP - these entities don't require frontend processing
// NOOP - these entities are handled at the backend level and don't require frontend processing
} else {
throw new Error(`Unknown entityName '${ec.entityName}'`);
}

View File

@ -80,7 +80,6 @@ export default class LoadResults {
private contentNoteIdToComponentId: ContentNoteIdToComponentIdRow[];
private optionNames: string[];
private attachmentRows: AttachmentRow[];
private noteEmbeddingRows: NoteEmbeddingRow[];
constructor(entityChanges: EntityChange[]) {
const entities: Record<string, Record<string, any>> = {};
@ -109,8 +108,6 @@ export default class LoadResults {
this.optionNames = [];
this.attachmentRows = [];
this.noteEmbeddingRows = [];
}
getEntityRow<T extends EntityRowNames>(entityName: T, entityId: string): EntityRowMappings[T] {
@ -213,14 +210,6 @@ export default class LoadResults {
return this.attachmentRows;
}
addNoteEmbedding(embedding: NoteEmbeddingRow) {
this.noteEmbeddingRows.push(embedding);
}
getNoteEmbeddingRows() {
return this.noteEmbeddingRows;
}
/**
* @returns {boolean} true if there are changes which could affect the attributes (including inherited ones)
* notably changes in note itself should not have any effect on attributes
@ -238,8 +227,7 @@ export default class LoadResults {
this.revisionRows.length === 0 &&
this.contentNoteIdToComponentId.length === 0 &&
this.optionNames.length === 0 &&
this.attachmentRows.length === 0 &&
this.noteEmbeddingRows.length === 0
this.attachmentRows.length === 0
);
}

View File

@ -203,6 +203,13 @@ function fillInAdditionalProperties(entityChange: EntityChange) {
WHERE attachmentId = ?`,
[entityChange.entityId]
);
} else if (entityChange.entityName === "note_embeddings") {
// Note embeddings are backend-only entities for AI/vector search
// Frontend doesn't need the full embedding data (which is large binary data)
// Just ensure entity is marked as handled - actual sync happens at database level
if (!entityChange.isErased) {
entityChange.entity = { embedId: entityChange.entityId };
}
}
if (entityChange.entity instanceof AbstractBeccaEntity) {