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,9 +266,11 @@ 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');
|
||||||
|
// Only proceed if it looks like actual text (not arbitrary binary data)
|
||||||
|
if (!textContent.includes('\u0000\u0000')) {
|
||||||
const subChunks = this.splitText(textContent, 600);
|
const subChunks = this.splitText(textContent, 600);
|
||||||
subChunks.forEach((text, i) => {
|
subChunks.forEach((text, i) => {
|
||||||
chunks.push({
|
chunks.push({
|
||||||
@ -285,6 +287,7 @@ export class ExtractionService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user