diff --git a/core/commands/index.ts b/core/commands/index.ts index 6837449ef..3037d7ef7 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -35,16 +35,21 @@ export function slashFromCustomCommand( { input }, ); } else { - renderedPrompt = await renderPromptFileV2(customCommand.prompt, { - config, - llm, - ide, - selectedCode, - fetch, - fullInput: input, - embeddingsProvider: config.modelsByRole.embed[0], - reranker: config.modelsByRole.rerank[0], - }); + const renderedPromptFile = await renderPromptFileV2( + customCommand.prompt, + { + config, + llm, + ide, + selectedCode, + fetch, + fullInput: input, + embeddingsProvider: config.modelsByRole.embed[0], + reranker: config.modelsByRole.rerank[0], + }, + ); + + renderedPrompt = renderedPromptFile[1]; } // Replaces slash command messages with the rendered prompt diff --git a/core/promptFiles/v1/slashCommandFromPromptFile.ts b/core/promptFiles/v1/slashCommandFromPromptFile.ts index cfe3d409a..fd0b48b2c 100644 --- a/core/promptFiles/v1/slashCommandFromPromptFile.ts +++ b/core/promptFiles/v1/slashCommandFromPromptFile.ts @@ -68,7 +68,7 @@ export function slashCommandFromPromptFileV1( context.llm.systemMessage = systemMessage; const userInput = extractUserInput(context.input, name); - const renderedPrompt = await renderPromptFileV2(prompt, { + const [_, renderedPrompt] = await renderPromptFileV2(prompt, { config: context.config, fullInput: userInput, embeddingsProvider: context.config.modelsByRole.embed[0], diff --git a/core/promptFiles/v2/renderPromptFile.ts b/core/promptFiles/v2/renderPromptFile.ts index c13a3ef93..4d52c7ba1 100644 --- a/core/promptFiles/v2/renderPromptFile.ts +++ b/core/promptFiles/v2/renderPromptFile.ts @@ -65,7 +65,7 @@ async function resolveAttachment( export async function renderPromptFileV2( rawContent: string, extras: ContextProviderExtras, -) { +): Promise<[ContextItem[], string]> { const [_, body] = getPreambleAndBody(rawContent); const contextItemsPromises: Promise[] = []; @@ -75,10 +75,10 @@ export async function renderPromptFileV2( }); const contextItems = (await Promise.all(contextItemsPromises)).flat(); - - return ( + const renderedPrompt = contextItems.map((item) => item.content).join("\n\n") + "\n\n" + - renderedBody - ); + renderedBody; + + return [contextItems, renderedPrompt]; }