add current file path to prompt
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { HelperVars } from "../../autocomplete/util/HelperVars.js";
|
||||
import { NEXT_EDIT_MODELS } from "../../llm/constants.js";
|
||||
import { getUriPathBasename } from "../../util/uri.js";
|
||||
import { MERCURY_SYSTEM_PROMPT, UNIQUE_TOKEN } from "../constants.js";
|
||||
import {
|
||||
currentFileContentBlock,
|
||||
@@ -58,7 +59,7 @@ export class MercuryCoderProvider extends BaseNextEditModelProvider {
|
||||
editableRegionStartLine: context.editableRegionStartLine,
|
||||
editableRegionEndLine: context.editableRegionEndLine,
|
||||
editDiffHistory: context.diffContext,
|
||||
currentFilePath: context.helper.filepath,
|
||||
currentFilePath: getUriPathBasename(context.helper.filepath),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export const NEXT_EDIT_MODEL_TEMPLATES: Record<
|
||||
NextEditTemplate
|
||||
> = {
|
||||
"mercury-coder": {
|
||||
template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`,
|
||||
template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\ncurrent_file_path: {{{currentFilePath}}}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`,
|
||||
},
|
||||
instinct: {
|
||||
template: `${INSTINCT_USER_PROMPT_PREFIX}\n\n### Context:\n{{{contextSnippets}}}\n\n### User Edits:\n\n{{{editDiffHistory}}}\n\n### User Excerpt:\n{{{currentFilePath}}}\n\n{{{currentFileContent}}}\`\`\`\n### Response:`,
|
||||
|
||||
@@ -39,6 +39,7 @@ describe("NextEditPromptEngine", () => {
|
||||
expect(template).toContain("{{{recentlyViewedCodeSnippets}}}");
|
||||
expect(template).toContain("{{{currentFileContent}}}");
|
||||
expect(template).toContain("{{{editDiffHistory}}}");
|
||||
expect(template).toContain("{{{currentFilePath}}}");
|
||||
});
|
||||
|
||||
it("instinct template should contain expected tokens", () => {
|
||||
@@ -87,11 +88,13 @@ describe("NextEditPromptEngine", () => {
|
||||
recentlyViewedCodeSnippets: "snippet1",
|
||||
currentFileContent: "file content",
|
||||
editDiffHistory: "diff history",
|
||||
currentFilePath: "file.py",
|
||||
});
|
||||
|
||||
expect(result).toContain("snippet1");
|
||||
expect(result).toContain("file content");
|
||||
expect(result).toContain("diff history");
|
||||
expect(result).toContain("current_file_path: file.py");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user