fix(copilot): support credentials saved with copilot.vim (#404)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
5ff5dcf72b
commit
b09ff856b7
@ -85,7 +85,7 @@ Your task is to modify the provided code according to the user's request. Follow
|
|||||||
|
|
||||||
8. Only return the new code snippets to be updated, DO NOT return the entire file content.
|
8. Only return the new code snippets to be updated, DO NOT return the entire file content.
|
||||||
|
|
||||||
Remember: Your response should contain nothing but ONLY the modified code, ready to be used as a direct replacement for the original file.
|
Remember: Your response should contain ONLY the modified code, ready to be used as a direct replacement for the original file.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local group = api.nvim_create_augroup("avante_llm", { clear = true })
|
local group = api.nvim_create_augroup("avante_llm", { clear = true })
|
||||||
|
@ -52,10 +52,20 @@ H.get_oauth_token = function()
|
|||||||
config_dir = vim.fn.expand("~/AppData/Local")
|
config_dir = vim.fn.expand("~/AppData/Local")
|
||||||
end
|
end
|
||||||
|
|
||||||
local yason = Path:new(config_dir):joinpath("github-copilot", "hosts.json")
|
--- hosts.json (copilot.lua), apps.json (copilot.vim)
|
||||||
if not yason:exists() then
|
---@type Path[]
|
||||||
|
local paths = vim.iter({ "hosts.json", "apps.json" }):fold({}, function(acc, path)
|
||||||
|
local yason = Path:new(config_dir):joinpath("github-copilot", path)
|
||||||
|
if yason:exists() then
|
||||||
|
table.insert(acc, yason)
|
||||||
|
end
|
||||||
|
return acc
|
||||||
|
end)
|
||||||
|
if #paths == 0 then
|
||||||
error("You must setup copilot with either copilot.lua or copilot.vim", 2)
|
error("You must setup copilot with either copilot.lua or copilot.vim", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local yason = paths[1]
|
||||||
return vim
|
return vim
|
||||||
.iter(
|
.iter(
|
||||||
---@type table<string, OAuthToken>
|
---@type table<string, OAuthToken>
|
||||||
@ -119,16 +129,12 @@ M.state = nil
|
|||||||
M.api_key_name = P.AVANTE_INTERNAL_KEY
|
M.api_key_name = P.AVANTE_INTERNAL_KEY
|
||||||
|
|
||||||
M.parse_message = function(opts)
|
M.parse_message = function(opts)
|
||||||
local user_prompt = ""
|
|
||||||
for _, user_prompt_ in ipairs(opts.user_prompts) do
|
|
||||||
user_prompt = user_prompt .. "\n\n" .. user_prompt_
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{ role = "system", content = opts.system_prompt },
|
{ role = "system", content = opts.system_prompt },
|
||||||
{ role = "user", content = user_prompt },
|
{ role = "user", content = table.concat(opts.user_prompts, "\n\n") },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
M.parse_response = O.parse_response
|
M.parse_response = O.parse_response
|
||||||
|
|
||||||
M.parse_curl_args = function(provider, code_opts)
|
M.parse_curl_args = function(provider, code_opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user