Skip to content

Commit

Permalink
feat: handle o1 when used with copilot provider
Browse files Browse the repository at this point in the history
The o1-preview and o1-mini models can be used with copilot provider when
you have a copilot pro subscription. This ensures the request/response
are handled in those cases (currently only openai provider is handled).
  • Loading branch information
tarruda committed Dec 19, 2024
1 parent 2372d53 commit e8fc382
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/gp/dispatcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ D.prepare_payload = function(messages, model, provider)
top_p = math.max(0, math.min(1, model.top_p or 1)),
}

if provider == "openai" and model.model:sub(1, 2) == "o1" then
if (provider == "openai" or provider == "copilot") and model.model:sub(1, 2) == "o1" then
for i = #messages, 1, -1 do
if messages[i].role == "system" then
table.remove(messages, i)
Expand Down Expand Up @@ -300,7 +300,7 @@ local query = function(buf, provider, payload, handler, on_exit, callback)
end
local raw_response = qt.raw_response
local content = qt.response
if qt.provider == 'openai' and content == "" and raw_response:match('choices') and raw_response:match("content") then
if (qt.provider == 'openai' or qt.provider == 'copilot') and content == "" and raw_response:match('choices') and raw_response:match("content") then
local response = vim.json.decode(raw_response)
if response.choices and response.choices[1] and response.choices[1].message and response.choices[1].message.content then
content = response.choices[1].message.content
Expand Down

0 comments on commit e8fc382

Please sign in to comment.