|
@@ -68,14 +68,20 @@ export class QdrantEmbeddingWorkflow {
|
|
|
|
|
|
|
|
// Check if content already has up-to-date embedding
|
|
// Check if content already has up-to-date embedding
|
|
|
const existingEmbeddings = this.database.getShopEmbeddings(contentId);
|
|
const existingEmbeddings = this.database.getShopEmbeddings(contentId);
|
|
|
- const hasCurrentEmbedding = existingEmbeddings.some(
|
|
|
|
|
- emb => emb.embedding_status === 'completed'
|
|
|
|
|
- );
|
|
|
|
|
|
|
|
|
|
- // If content hasn't changed and we have an embedding, skip
|
|
|
|
|
- if (!contentChanged && hasCurrentEmbedding) {
|
|
|
|
|
- logger.debug(`Skipping embedding for content ${contentId}: no changes and embedding exists`);
|
|
|
|
|
- return { contentId, embedded: false, error: 'Content unchanged and embedding exists' };
|
|
|
|
|
|
|
+ // Only skip if:
|
|
|
|
|
+ // 1. Content hasn't changed (contentChanged = false)
|
|
|
|
|
+ // 2. AND we have a completed embedding
|
|
|
|
|
+ // 3. AND the embedding was created for this exact content (by checking if it exists in Qdrant)
|
|
|
|
|
+ if (!contentChanged && existingEmbeddings.length > 0) {
|
|
|
|
|
+ const hasCompletedEmbedding = existingEmbeddings.some(
|
|
|
|
|
+ emb => emb.embedding_status === 'completed'
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (hasCompletedEmbedding) {
|
|
|
|
|
+ logger.debug(`Skipping embedding for content ${contentId}: no changes and embedding exists`);
|
|
|
|
|
+ return { contentId, embedded: false, error: 'Content unchanged and embedding exists' };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Split content into chunks
|
|
// Split content into chunks
|