mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
Update folderImport.ts
updated function output
This commit is contained in:
parent
39398ea093
commit
64814d56c5
@ -5,7 +5,7 @@ export const createChatFromFolder = async (
|
|||||||
files: File[],
|
files: File[],
|
||||||
binaryFiles: string[],
|
binaryFiles: string[],
|
||||||
folderName: string
|
folderName: string
|
||||||
): Promise<{ userMessage: Message; assistantMessage: Message }> => {
|
): Promise<Message[]> => {
|
||||||
const fileArtifacts = await Promise.all(
|
const fileArtifacts = await Promise.all(
|
||||||
files.map(async (file) => {
|
files.map(async (file) => {
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
@ -33,17 +33,24 @@ ${content}
|
|||||||
? `\n\nSkipped ${binaryFiles.length} binary files:\n${binaryFiles.map((f) => `- ${f}`).join('\n')}`
|
? `\n\nSkipped ${binaryFiles.length} binary files:\n${binaryFiles.map((f) => `- ${f}`).join('\n')}`
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const assistantMessage: Message = {
|
const assistantMessages: Message[] = [{
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
|
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
|
||||||
|
|
||||||
<boltArtifact id="imported-files" title="Imported Files">
|
<boltArtifact id="imported-files" title="Imported Files">
|
||||||
${fileArtifacts.join('\n\n')}
|
${fileArtifacts.join('\n\n')}
|
||||||
|
</boltArtifact>`,
|
||||||
|
id: generateId(),
|
||||||
|
createdAt: new Date(),
|
||||||
|
},{
|
||||||
|
role: 'assistant',
|
||||||
|
content: `
|
||||||
|
<boltArtifact id="imported-files" title="Imported Files">
|
||||||
${setupCommand}
|
${setupCommand}
|
||||||
</boltArtifact>${followupMessage}`,
|
</boltArtifact>${followupMessage}`,
|
||||||
id: generateId(),
|
id: generateId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
};
|
}];
|
||||||
|
|
||||||
const userMessage: Message = {
|
const userMessage: Message = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
@ -52,5 +59,5 @@ ${setupCommand}
|
|||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return { userMessage, assistantMessage };
|
return [ userMessage, ...assistantMessages ];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user