Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape original_content #5

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/avante/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ local function call_openai_api_stream(question, code_lang, code_content, on_chun
end

local function call_ai_api_stream(question, code_lang, code_content, on_chunk, on_complete)
code_content = utils.escape(code_content)
if M.config.provider == "openai" or M.config.provider == "azure" then
call_openai_api_stream(question, code_lang, code_content, on_chunk, on_complete)
elseif M.config.provider == "claude" then
Expand Down
4 changes: 4 additions & 0 deletions lua/avante/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ function M.trim_suffix(str, suffix)
return string.gsub(str, suffix .. "$", "")
end

function M.escape(str)
return string.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1")
end

return M