feat: change the files encapsulation

This commit is contained in:
2024-12-12 21:16:28 +01:00
parent 2b38cb2ebe
commit 21ea793241
2 changed files with 2 additions and 9 deletions

View File

@@ -92,7 +92,7 @@ function M.get_file_contents(files)
local data = uv.fs_read(fd, stat.size, 0)
uv.fs_close(fd)
if data then
table.insert(sections, "\n<<<CGPT Current File\n" .. path .. "\n" .. data .. "\n<<<CGPT Current File END\n")
table.insert(sections, "\nFile: `" .. f .. "`\n```\n" .. data .. "\n```\n")
end
else
uv.fs_close(fd)

View File

@@ -39,18 +39,11 @@ function M.run_chatgpt_command()
local current_file_content, current_file_path = context.get_current_file()
local readme_content = context.get_readme_content()
-- Make the prompt more readable for the O1 model:
-- 1. Include initial prompt and user input at the start.
-- 2. Provide a clear project structure section.
-- 3. Clearly label the files section.
-- 4. The file_sections already include <<<CGPT Current File blocks for each file,
-- we just need to ensure there's a clear intro.
local sections = {
conf.initial_prompt .. "\n" .. user_input,
"\n\nProject Structure:\n",
project_structure,
"\n\nBelow are the files from the project, each enclosed in <<<CGPT Current File ... >>> blocks for clarity.\n"
"\n\nBelow are the files from the project, each preceded by its filename in backticks and enclosed in triple backticks.\n"
}
table.insert(sections, file_sections)