Update web-app/src/lib/fileMetadata.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Dinh Long Nguyen 2025-10-09 04:50:31 +07:00 committed by GitHub
parent a2fbce698f
commit f4066e6e5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,7 +84,17 @@ export function extractFilesFromPrompt(prompt: string): {
const type = map['type'] const type = map['type']
const size = map['size'] ? Number(map['size']) : undefined const size = map['size'] ? Number(map['size']) : undefined
const chunkCount = map['chunks'] ? Number(map['chunks']) : undefined const chunkCount = map['chunks'] ? Number(map['chunks']) : undefined
files.push({ id, name, ...(type && { type }), ...(typeof size === 'number' && !Number.isNaN(size) ? { size } : {}), ...(typeof chunkCount === 'number' && !Number.isNaN(chunkCount) ? { chunkCount } : {}) }) const fileObj: FileMetadata = { id, name };
if (type) {
fileObj.type = type;
}
if (typeof size === 'number' && !Number.isNaN(size)) {
fileObj.size = size;
}
if (typeof chunkCount === 'number' && !Number.isNaN(chunkCount)) {
fileObj.chunkCount = chunkCount;
}
files.push(fileObj);
} }
// Extract clean prompt (everything before [ATTACHED_FILES]) // Extract clean prompt (everything before [ATTACHED_FILES])