import * as path from 'path' import { readFile } from '../filesystem/readFile' const DIFF_DOCUMENT_INTRO = "Here are the diffs for all the commits in my PR:" const finalInstruction = readFile(path.join(__dirname, '..', '..', 'prompt', 'instruction', 'finalInstruction.md')) const DIVIDER = "\n---------------------------------------------------------------\n" /** * Generates the prompt to send to OpenAI. * * @param context The context to send to OpenAI * @param diffDocument The diff document to send to OpenAI * @returns The prompt to send to OpenAI */ function generateOpenAiPrompt(context: string, diffDocument: string): string { const output: string[] = [] // Add the context to the prompt output.push(context) output.push(DIVIDER) output.push(DIFF_DOCUMENT_INTRO) output.push(diffDocument) // Re-iterate the basic instruction to ensure the LLM doesn't forget it output.push(DIVIDER) output.push(finalInstruction) return output.join('\n') } export { generateOpenAiPrompt }