Skip to content

Commit 885cde9

Browse files
committed
nes: refactor: tagging
1 parent bb411d6 commit 885cde9

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

src/extension/xtab/common/promptCrafting.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,29 @@ import { StringText } from '../../../util/vs/editor/common/core/text/abstractTex
2020
export namespace PromptTags {
2121
export const CURSOR = "<|cursor|>";
2222

23-
export const EDIT_WINDOW = {
24-
start: "<|code_to_edit|>",
25-
end: "<|/code_to_edit|>"
23+
type Tag = {
24+
start: string;
25+
end: string;
2626
};
2727

28-
export const AREA_AROUND = {
29-
start: "<|area_around_code_to_edit|>",
30-
end: "<|/area_around_code_to_edit|>"
31-
};
28+
function createTag(key: string): Tag {
29+
return {
30+
start: `<|${key}|>`,
31+
end: `<|/${key}|>`
32+
};
33+
}
3234

33-
export const CURRENT_FILE = {
34-
start: "<|current_file_content|>",
35-
end: "<|/current_file_content|>"
36-
};
35+
export const EDIT_WINDOW = createTag("code_to_edit");
3736

38-
export const EDIT_HISTORY = {
39-
start: "<|edit_diff_history|>",
40-
end: "<|/edit_diff_history|>"
41-
};
37+
export const AREA_AROUND = createTag("area_around_code_to_edit");
4238

43-
export const RECENT_FILES = {
44-
start: "<|recently_viewed_code_snippets|>",
45-
end: "<|/recently_viewed_code_snippets|>"
46-
};
39+
export const CURRENT_FILE = createTag("current_file_content");
4740

48-
export const RECENT_FILE = {
49-
start: "<|recently_viewed_code_snippet|>",
50-
end: "<|/recently_viewed_code_snippet|>"
51-
};
41+
export const EDIT_HISTORY = createTag("edit_diff_history");
42+
43+
export const RECENT_FILES = createTag("recently_viewed_code_snippets");
44+
45+
export const RECENT_FILE = createTag("recently_viewed_code_snippet");
5246
}
5347

5448
export const systemPromptTemplate = `Your role as an AI assistant is to help developers complete their code tasks by assisting in editing specific sections of code marked by the ${PromptTags.EDIT_WINDOW.start} and ${PromptTags.EDIT_WINDOW.end} tags, while adhering to Microsoft's content policies and avoiding the creation of content that violates copyrights.

0 commit comments

Comments
 (0)