From cae2c9149e7138b6c1e6699d00c594fb4bbc1f59 Mon Sep 17 00:00:00 2001 From: willheryanto Date: Fri, 3 Jan 2025 11:47:00 +0700 Subject: [PATCH 1/2] fix: gemini --- lua/avante/providers/gemini.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/avante/providers/gemini.lua b/lua/avante/providers/gemini.lua index 3a42124bf..c8d04d7c1 100644 --- a/lua/avante/providers/gemini.lua +++ b/lua/avante/providers/gemini.lua @@ -69,8 +69,13 @@ M.parse_response = function(data_stream, _, opts) if not ok then opts.on_complete(json) end if json.candidates then if #json.candidates > 0 then - opts.on_chunk(json.candidates[1].content.parts[1].text) - elseif json.candidates.finishReason and json.candidates.finishReason == "STOP" then + if json.candidates[1].finishReason and json.candidates[1].finishReason == "STOP" then + opts.on_chunk(json.candidates[1].content.parts[1].text) + vim.schedule(function() opts.on_complete(nil) end) + else + opts.on_chunk(json.candidates[1].content.parts[1].text) + end + else opts.on_complete(nil) end end From aa9a3e246440b5ac96a496fa2d0698619ecca0f7 Mon Sep 17 00:00:00 2001 From: willheryanto Date: Sun, 5 Jan 2025 19:50:24 +0700 Subject: [PATCH 2/2] fix: remove schedule --- lua/avante/providers/gemini.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/avante/providers/gemini.lua b/lua/avante/providers/gemini.lua index c8d04d7c1..11a166053 100644 --- a/lua/avante/providers/gemini.lua +++ b/lua/avante/providers/gemini.lua @@ -71,7 +71,7 @@ M.parse_response = function(data_stream, _, opts) if #json.candidates > 0 then if json.candidates[1].finishReason and json.candidates[1].finishReason == "STOP" then opts.on_chunk(json.candidates[1].content.parts[1].text) - vim.schedule(function() opts.on_complete(nil) end) + opts.on_complete(nil) else opts.on_chunk(json.candidates[1].content.parts[1].text) end