magicalne / nvim.ai

Inspired by Zed AI, it allows you to chat with your buffers, insert code with an inline assistant, and leverage various LLM providers for context-aware AI assistance.
Apache License 2.0
120 stars 2 forks source link

Gemini API from google aistudio support #20

Closed GustavoJCL closed 1 month ago

GustavoJCL commented 2 months ago

Hi, how can I use Gemini experimental versions for autocompletion? it seems they provide an API key, but I'm not sure if I can use it with this plugin aistudio.google.com

magicalne commented 2 months ago

The Gemini API is currently not supported. I will add it later today, so please stay tuned.

magicalne commented 2 months ago

I just added Gemini. You can check it out with this config:

local ai = require('ai')
ai.setup({
  provider = "gemini",
  gemini = { 
    model = "gemini-1.5-pro-latest" -- This is optional, the default config uses flash.
  },
})

Remember to source your key or put it in your dotfile:

export GOOGLE_API_KEY=""
GustavoJCL commented 1 month ago

I tried this configuration, and the environment variable is set correctly, I also tried with gemini pro latest and the default, but I still get this error:

Error executing vim.schedule lua callback: ...ocal/share/nvim/lazy/nvim.ai/lua/ai/providers/gemini.lua:15: bad argument #1 to 'decode' (string expected, got nil)
stack traceback:
    [C]: in function 'decode'
    ...ocal/share/nvim/lazy/nvim.ai/lua/ai/providers/gemini.lua:15: in function 'parse_response'
    /home/gus/.local/share/nvim/lazy/nvim.ai/lua/ai/http.lua:48: in function </home/gus/.local/share/nvim/lazy/nvim.ai/lua/ai/http.lua:46>
magicalne commented 1 month ago

Sorry about the bug :sob:. I didn't thoroughly test it. Please pull the new code, it should work now.

GustavoJCL commented 1 month ago

don't worry, thanks for making the plugin, it's very useful