feat: change the files encapsulation
This commit is contained in:
@@ -92,7 +92,7 @@ function M.get_file_contents(files)
|
|||||||
local data = uv.fs_read(fd, stat.size, 0)
|
local data = uv.fs_read(fd, stat.size, 0)
|
||||||
uv.fs_close(fd)
|
uv.fs_close(fd)
|
||||||
if data then
|
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
|
end
|
||||||
else
|
else
|
||||||
uv.fs_close(fd)
|
uv.fs_close(fd)
|
||||||
|
|||||||
@@ -39,18 +39,11 @@ function M.run_chatgpt_command()
|
|||||||
local current_file_content, current_file_path = context.get_current_file()
|
local current_file_content, current_file_path = context.get_current_file()
|
||||||
local readme_content = context.get_readme_content()
|
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 = {
|
local sections = {
|
||||||
conf.initial_prompt .. "\n" .. user_input,
|
conf.initial_prompt .. "\n" .. user_input,
|
||||||
"\n\nProject Structure:\n",
|
"\n\nProject Structure:\n",
|
||||||
project_structure,
|
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)
|
table.insert(sections, file_sections)
|
||||||
|
|||||||
Reference in New Issue
Block a user