From d33e9114a72ba18562b04d74f82322f77463143d Mon Sep 17 00:00:00 2001 From: Jonas Widen Date: Mon, 17 Mar 2025 07:48:20 +0100 Subject: [PATCH] debug completion --- lua/gemini/api.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/gemini/api.lua b/lua/gemini/api.lua index 05f8efb..b8f0b70 100644 --- a/lua/gemini/api.lua +++ b/lua/gemini/api.lua @@ -10,6 +10,7 @@ end local function create_contents(prompt, context) local contents = {} + -- Add conversation history for _, message in ipairs(chat.get_conversation_history()) do table.insert(contents, { role = message.role, @@ -17,6 +18,7 @@ local function create_contents(prompt, context) }) end + -- Add current prompt if context then table.insert(contents, { role = "user", @@ -29,6 +31,16 @@ local function create_contents(prompt, context) }) end + -- Ensure we have at least one content item + if #contents == 0 then + contents = { + { + role = "user", + parts = {{text = prompt}} + } + } + end + return contents end