feat: remove old prompt_chat_limit
This commit is contained in:
@@ -18,16 +18,12 @@ interactive_file_selection: false
|
|||||||
partial_acceptance: false
|
partial_acceptance: false
|
||||||
|
|
||||||
enable_debug_commands: true
|
enable_debug_commands: true
|
||||||
prompt_char_limit: 300000
|
|
||||||
enable_chunking: false
|
enable_chunking: false
|
||||||
enable_step_by_step: true
|
enable_step_by_step: true
|
||||||
auto_lint: true
|
auto_lint: true
|
||||||
|
|
||||||
# New tool auto-accept config
|
|
||||||
tool_auto_accept:
|
tool_auto_accept:
|
||||||
read_file: true
|
read_file: true
|
||||||
edit_file: true
|
edit_file: true
|
||||||
replace_in_file: true
|
replace_in_file: true
|
||||||
execute_command: false
|
execute_command: false
|
||||||
# If you set any of these to true, it will auto accept them without prompting.
|
|
||||||
# 'executeCommand' should remain false by default unless you're certain it's safe.
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function M.load()
|
|||||||
initial_prompt = "",
|
initial_prompt = "",
|
||||||
directories = { "." },
|
directories = { "." },
|
||||||
default_prompt_blocks = {},
|
default_prompt_blocks = {},
|
||||||
prompt_char_limit = 300000,
|
-- Removed prompt_char_limit
|
||||||
project_name = "",
|
project_name = "",
|
||||||
debug = false,
|
debug = false,
|
||||||
initial_files = {},
|
initial_files = {},
|
||||||
@@ -109,9 +109,7 @@ function M.load()
|
|||||||
if type(result.default_prompt_blocks) == "table" then
|
if type(result.default_prompt_blocks) == "table" then
|
||||||
config.default_prompt_blocks = result.default_prompt_blocks
|
config.default_prompt_blocks = result.default_prompt_blocks
|
||||||
end
|
end
|
||||||
if type(result.prompt_char_limit) == "number" then
|
-- Removed prompt_char_limit handling
|
||||||
config.prompt_char_limit = result.prompt_char_limit
|
|
||||||
end
|
|
||||||
if type(result.project_name) == "string" then
|
if type(result.project_name) == "string" then
|
||||||
config.project_name = result.project_name
|
config.project_name = result.project_name
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -198,13 +198,7 @@ function M.get_project_prompt(directories, conf)
|
|||||||
if conf.include_file_contents then
|
if conf.include_file_contents then
|
||||||
local files = M.get_project_files(directories, conf)
|
local files = M.get_project_files(directories, conf)
|
||||||
local contents = M.get_file_contents(files, conf)
|
local contents = M.get_file_contents(files, conf)
|
||||||
local total_chars = #contents
|
return structure .. "\n" .. contents
|
||||||
if total_chars > conf.prompt_char_limit then
|
|
||||||
vim.notify("Total file contents (" .. total_chars .. " characters) exceed the prompt limit (" .. conf.prompt_char_limit .. "). Please disable 'include_file_contents' in your config.", vim.log.levels.ERROR)
|
|
||||||
return structure
|
|
||||||
else
|
|
||||||
return structure .. "\n" .. contents
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return structure
|
return structure
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -179,11 +179,7 @@ local function build_prompt(user_input, dirs, conf)
|
|||||||
return final_prompt
|
return final_prompt
|
||||||
end
|
end
|
||||||
|
|
||||||
-- New token estimation function.
|
|
||||||
local function estimate_token_count(text)
|
local function estimate_token_count(text)
|
||||||
-- Instead of simply dividing the character count by 4,
|
|
||||||
-- split the text into non-whitespace chunks and further split each chunk
|
|
||||||
-- into sequences of alphanumeric characters and punctuation.
|
|
||||||
local token_count = 0
|
local token_count = 0
|
||||||
for chunk in text:gmatch("%S+") do
|
for chunk in text:gmatch("%S+") do
|
||||||
for token in chunk:gmatch("(%w+|%p+)") do
|
for token in chunk:gmatch("(%w+|%p+)") do
|
||||||
@@ -202,9 +198,6 @@ local function handle_step_by_step_if_needed(prompt, conf)
|
|||||||
return { prompts["step-prompt"] }
|
return { prompts["step-prompt"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
-- :ChatGPT
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
local function run_chatgpt_command()
|
local function run_chatgpt_command()
|
||||||
package.loaded["chatgpt_nvim.config"] = nil
|
package.loaded["chatgpt_nvim.config"] = nil
|
||||||
local config = require("chatgpt_nvim.config")
|
local config = require("chatgpt_nvim.config")
|
||||||
@@ -273,9 +266,6 @@ local function run_chatgpt_command()
|
|||||||
vim.cmd("buffer " .. bufnr)
|
vim.cmd("buffer " .. bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
-- :ChatGPTPaste
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
local function run_chatgpt_paste_command()
|
local function run_chatgpt_paste_command()
|
||||||
package.loaded["chatgpt_nvim.config"] = nil
|
package.loaded["chatgpt_nvim.config"] = nil
|
||||||
local config = require("chatgpt_nvim.config")
|
local config = require("chatgpt_nvim.config")
|
||||||
@@ -403,16 +393,6 @@ local function run_chatgpt_paste_command()
|
|||||||
local length = #prompt
|
local length = #prompt
|
||||||
ui.debug_log("Returning requested files. Character count: " .. length)
|
ui.debug_log("Returning requested files. Character count: " .. length)
|
||||||
|
|
||||||
if length > (conf.prompt_char_limit or 8000) and conf.enable_step_by_step then
|
|
||||||
local large_step = prompts["step-prompt"]
|
|
||||||
copy_to_clipboard(large_step)
|
|
||||||
print("Step-by-step guidance copied to clipboard!")
|
|
||||||
return
|
|
||||||
elseif length > (conf.prompt_char_limit or 8000) then
|
|
||||||
vim.api.nvim_err_writeln("Requested files exceed prompt character limit. No step-by-step support enabled.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
copy_to_clipboard(prompt)
|
copy_to_clipboard(prompt)
|
||||||
print("Prompt (with requested files) copied to clipboard! Paste it into ChatGPT.")
|
print("Prompt (with requested files) copied to clipboard! Paste it into ChatGPT.")
|
||||||
end
|
end
|
||||||
@@ -421,9 +401,6 @@ local function run_chatgpt_paste_command()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
-- :ChatGPTCurrentBuffer
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
local function run_chatgpt_current_buffer_command()
|
local function run_chatgpt_current_buffer_command()
|
||||||
package.loaded["chatgpt_nvim.config"] = nil
|
package.loaded["chatgpt_nvim.config"] = nil
|
||||||
local config = require("chatgpt_nvim.config")
|
local config = require("chatgpt_nvim.config")
|
||||||
@@ -462,9 +439,6 @@ local function run_chatgpt_current_buffer_command()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
-- PUBLIC API
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
M.run_chatgpt_command = run_chatgpt_command
|
M.run_chatgpt_command = run_chatgpt_command
|
||||||
M.run_chatgpt_paste_command = run_chatgpt_paste_command
|
M.run_chatgpt_paste_command = run_chatgpt_paste_command
|
||||||
M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command
|
M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command
|
||||||
|
|||||||
Reference in New Issue
Block a user