Update folderImport.ts

updated function output
This commit is contained in:
Anirban Kar 2024-12-08 04:11:34 +05:30 committed by GitHub
parent 39398ea093
commit 64814d56c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ export const createChatFromFolder = async (
files: File[],
binaryFiles: string[],
folderName: string
): Promise<{ userMessage: Message; assistantMessage: Message }> => {
): Promise<Message[]> => {
const fileArtifacts = await Promise.all(
files.map(async (file) => {
return new Promise<string>((resolve, reject) => {
@ -33,17 +33,24 @@ ${content}
? `\n\nSkipped ${binaryFiles.length} binary files:\n${binaryFiles.map((f) => `- ${f}`).join('\n')}`
: '';
const assistantMessage: Message = {
const assistantMessages: Message[] = [{
role: 'assistant',
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
<boltArtifact id="imported-files" title="Imported Files">
${fileArtifacts.join('\n\n')}
</boltArtifact>`,
id: generateId(),
createdAt: new Date(),
},{
role: 'assistant',
content: `
<boltArtifact id="imported-files" title="Imported Files">
${setupCommand}
</boltArtifact>${followupMessage}`,
id: generateId(),
createdAt: new Date(),
};
}];
const userMessage: Message = {
role: 'user',
@ -52,5 +59,5 @@ ${setupCommand}
createdAt: new Date(),
};
return { userMessage, assistantMessage };
return [ userMessage, ...assistantMessages ];
};