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

feat: handle o1 when used with copilot provider #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading