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