feat: remove old prompt_chat_limit
This commit is contained in:
@@ -57,7 +57,7 @@ function M.load()
|
||||
initial_prompt = "",
|
||||
directories = { "." },
|
||||
default_prompt_blocks = {},
|
||||
prompt_char_limit = 300000,
|
||||
-- Removed prompt_char_limit
|
||||
project_name = "",
|
||||
debug = false,
|
||||
initial_files = {},
|
||||
@@ -109,9 +109,7 @@ function M.load()
|
||||
if type(result.default_prompt_blocks) == "table" then
|
||||
config.default_prompt_blocks = result.default_prompt_blocks
|
||||
end
|
||||
if type(result.prompt_char_limit) == "number" then
|
||||
config.prompt_char_limit = result.prompt_char_limit
|
||||
end
|
||||
-- Removed prompt_char_limit handling
|
||||
if type(result.project_name) == "string" then
|
||||
config.project_name = result.project_name
|
||||
end
|
||||
|
||||
@@ -198,13 +198,7 @@ function M.get_project_prompt(directories, conf)
|
||||
if conf.include_file_contents then
|
||||
local files = M.get_project_files(directories, conf)
|
||||
local contents = M.get_file_contents(files, conf)
|
||||
local total_chars = #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
|
||||
return structure .. "\n" .. contents
|
||||
else
|
||||
return structure
|
||||
end
|
||||
|
||||
@@ -179,11 +179,7 @@ local function build_prompt(user_input, dirs, conf)
|
||||
return final_prompt
|
||||
end
|
||||
|
||||
-- New token estimation function.
|
||||
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
|
||||
for chunk in text:gmatch("%S+") 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"] }
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- :ChatGPT
|
||||
------------------------------------------------------------------------------
|
||||
local function run_chatgpt_command()
|
||||
package.loaded["chatgpt_nvim.config"] = nil
|
||||
local config = require("chatgpt_nvim.config")
|
||||
@@ -273,9 +266,6 @@ local function run_chatgpt_command()
|
||||
vim.cmd("buffer " .. bufnr)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- :ChatGPTPaste
|
||||
------------------------------------------------------------------------------
|
||||
local function run_chatgpt_paste_command()
|
||||
package.loaded["chatgpt_nvim.config"] = nil
|
||||
local config = require("chatgpt_nvim.config")
|
||||
@@ -403,16 +393,6 @@ local function run_chatgpt_paste_command()
|
||||
local length = #prompt
|
||||
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)
|
||||
print("Prompt (with requested files) copied to clipboard! Paste it into ChatGPT.")
|
||||
end
|
||||
@@ -421,9 +401,6 @@ local function run_chatgpt_paste_command()
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- :ChatGPTCurrentBuffer
|
||||
------------------------------------------------------------------------------
|
||||
local function run_chatgpt_current_buffer_command()
|
||||
package.loaded["chatgpt_nvim.config"] = nil
|
||||
local config = require("chatgpt_nvim.config")
|
||||
@@ -462,9 +439,6 @@ local function run_chatgpt_current_buffer_command()
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- PUBLIC API
|
||||
------------------------------------------------------------------------------
|
||||
M.run_chatgpt_command = run_chatgpt_command
|
||||
M.run_chatgpt_paste_command = run_chatgpt_paste_command
|
||||
M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command
|
||||
|
||||
Reference in New Issue
Block a user