Skip to content

Commit

Permalink
Default to openai compatible headers
Browse files Browse the repository at this point in the history
  • Loading branch information
marceldev89 committed Jul 24, 2024
1 parent 872f537 commit fe4f24b
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1440,40 +1440,20 @@ M.query = function(buf, provider, payload, handler, on_exit, callback)
"-H",
"Authorization: Bearer " .. bearer,
}
end

if provider == "openai" then
elseif provider == "openai" then
headers = {
"-H",
"Authorization: Bearer " .. bearer,
-- backwards compatibility
"-H",
"api-key: " .. bearer,
}
end

if provider == "openrouter" then
headers = {
"-H",
"Authorization: Bearer " .. bearer,
}
end

if provider == "pplx" then
headers = {
"-H",
"Authorization: Bearer " .. bearer,
}
end

if provider == "googleai" then
elseif provider == "googleai" then
headers = {}
endpoint = M._H.template_replace(endpoint, "{{secret}}", bearer)
endpoint = M._H.template_replace(endpoint, "{{model}}", payload.model)
payload.model = nil
end

if provider == "anthropic" then
elseif provider == "anthropic" then
headers = {
"-H",
"x-api-key: " .. bearer,
Expand All @@ -1482,14 +1462,17 @@ M.query = function(buf, provider, payload, handler, on_exit, callback)
"-H",
"anthropic-beta: messages-2023-12-15",
}
end

if provider == "azure" then
elseif provider == "azure" then
headers = {
"-H",
"api-key: " .. bearer,
}
endpoint = M._H.template_replace(endpoint, "{{model}}", payload.model)
else -- default to openai compatible headers
headers = {
"-H",
"Authorization: Bearer " .. bearer,
}
end

local curl_params = vim.deepcopy(M.config.curl_params or {})
Expand Down

0 comments on commit fe4f24b

Please sign in to comment.