Production
This commit is contained in:
parent
73b1d35754
commit
61126a546a
@ -92,12 +92,17 @@ export class ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Fetch Embeddings & Data Sources
|
// 2. Fetch Embeddings & Data Sources
|
||||||
let embeddingsCount = await prisma.assetEmbedding.count({
|
// Ensure ALL accessible assets have embeddings generated
|
||||||
where: { assetId: { in: accessibleAssetIds } }
|
const embeddedAssets = await prisma.assetEmbedding.findMany({
|
||||||
|
where: { assetId: { in: accessibleAssetIds } },
|
||||||
|
select: { assetId: true },
|
||||||
|
distinct: ['assetId']
|
||||||
});
|
});
|
||||||
|
const embeddedAssetIds = embeddedAssets.map(e => e.assetId);
|
||||||
|
const missingAssetIds = accessibleAssetIds.filter(id => !embeddedAssetIds.includes(id));
|
||||||
|
|
||||||
if (embeddingsCount === 0 && accessibleAssetIds.length > 0) {
|
if (missingAssetIds.length > 0) {
|
||||||
await this.autoIndexCatalog(accessibleAssetIds);
|
await this.autoIndexCatalog(missingAssetIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
const embeddings = await prisma.assetEmbedding.findMany({
|
const embeddings = await prisma.assetEmbedding.findMany({
|
||||||
|
|||||||
@ -266,23 +266,26 @@ export class ExtractionService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// E. Plain Text / Markdown
|
// E. Plain Text / Markdown / Code (Excluding binaries)
|
||||||
else {
|
else if (!ext.match(/\.(png|jpe?g|gif|webp|svg|mp4|webm|avi|mp3|wav)$/i)) {
|
||||||
const textContent = buffer.toString('utf-8');
|
const textContent = buffer.toString('utf-8');
|
||||||
const subChunks = this.splitText(textContent, 600);
|
// Only proceed if it looks like actual text (not arbitrary binary data)
|
||||||
subChunks.forEach((text, i) => {
|
if (!textContent.includes('\u0000\u0000')) {
|
||||||
chunks.push({
|
const subChunks = this.splitText(textContent, 600);
|
||||||
chunkIndex: chunkIndex++,
|
subChunks.forEach((text, i) => {
|
||||||
chunkType: 'TEXT',
|
chunks.push({
|
||||||
content: text,
|
chunkIndex: chunkIndex++,
|
||||||
sourceMetadata: {
|
chunkType: 'TEXT',
|
||||||
assetId: asset.id,
|
content: text,
|
||||||
assetTitle: asset.title,
|
sourceMetadata: {
|
||||||
assetType: asset.type,
|
assetId: asset.id,
|
||||||
location: `Document Text: Segment ${i + 1}`,
|
assetTitle: asset.title,
|
||||||
},
|
assetType: asset.type,
|
||||||
|
location: `Document Text: Segment ${i + 1}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user