yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
5.97k stars 204 forks source link

bug: unable to obtain any response for @codebase context #677

Open allenabraham777 opened 5 days ago

allenabraham777 commented 5 days ago

Describe the bug

I'm trying to provide a prompt by keeping the @codebase context. The code response tab shows nothing but just 'Generating response ....' forever.

Screenshot 2024-10-03 at 4 49 59 PM

Can I know what should be done in order to take the whole codebase as context and work over it?

To reproduce

Expected behavior

The response tab should give some response based on the codebase.

Installation method

Use lazy.nvim:

{
  "yetone/avante.nvim",
  event = "VeryLazy",
  lazy = false,
  version = false, -- set this if you want to always pull the latest change
  opts = {
    -- add any opts here
  },
  -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
  build = "make",
  -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    "stevearc/dressing.nvim",
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
  },
}

Environment

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

macOS 15.0 24A335 arm64 (M1 chip)

Repro

return {
  "yetone/avante.nvim",
  event = "VeryLazy",
  lazy = false,
  version = false, -- set this if you want to always pull the latest change
  opts = {
    provider = "claude",
    claude = {
      api_key_name = "cmd:bw get notes anthropic-api-key", -- the shell command must prefixed with `^cmd:(.*)`
      -- api_key_name = {"bw","get","notes","anthropic-api-key"}, -- if it is a table of string, then default to command.
    }
  },
  -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
  build = "make",
  -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    "stevearc/dressing.nvim",
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
    --- The below dependencies are optional,
    "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
    "zbirenbaum/copilot.lua", -- for providers='copilot'
    {
      -- support for image pasting
      "HakonHarnes/img-clip.nvim",
      event = "VeryLazy",
      opts = {
        -- recommended settings
        default = {
          embed_image_as_base64 = false,
          prompt_for_file_name = false,
          drag_and_drop = {
            insert_mode = true,
          },
          -- required for Windows users
          use_absolute_path = true,
        },
      },
    },
    {
      -- Make sure to set this up properly if you have lazy=true
      'MeanderingProgrammer/render-markdown.nvim',
      opts = {
        file_types = { "markdown", "Avante" },
      },
      ft = { "markdown", "Avante" },
    },
  },
}
yetone commented 4 days ago

Is it the latest version?

briskajanis1 commented 4 days ago

I can reproduce this as well. Update config just now.

allenabraham777 commented 3 days ago

Is it the latest version?

I upgraded it to the latest version and still the bug exists.

wiscaksono commented 3 days ago

am having the same issue

PatrickLohan commented 2 days ago

Did any of you try looking through other recent already reported issues? https://github.com/yetone/avante.nvim/issues/612#issuecomment-2375729928

GopherJ commented 2 days ago

I had issue when repo map becomes too big, I saw that lsp-ai has chunked thing. Does that help?

Also c/c++ query doesn't seem to work during my tests

yetone commented 1 day ago

You can turn on the debug mode to check the curl body:

  opts = {
    debug = true,
  },
allenabraham777 commented 1 day ago

The context is never taken I guess, this is what I can see in :messages

E5108: Error executing lua:

When I'm over neo-tree preview and none of the files are open, I get the following message

E5108: Error executing lua: ...ocal/share/nvim/lazy/avante.nvim/lua/avante/repo_map.lua:58: attempt to concatenate local 'file_ext' (a nil value)
stack traceback:
        ...ocal/share/nvim/lazy/avante.nvim/lua/avante/repo_map.lua:58: in function 'get_repo_map'
        ...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1271: in function 'handle_submit'
        ...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1328: in function <...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1318>
tcpessoa commented 3 hours ago

Most likely your language is not supported. If you enable debug mode as suggested you might see something like:

The repo map is empty. Maybe do not support this language: lua

It is also important to understand how this whole thing works. The @codebase will not inject the repo map into the question itself, it will fill the project context part of the request.

Here is a summary of the request which you can debug by typing :messages:

[2024-10-09 11:03:02] [AVANTE] [DEBUG] user prompts: { the object being sent }

The object consists of these keys:

  1. PROJECT CONTEXT: [contents of repo_map, @codebase]
  2. FILEPATH: lua/custom/plugins/avante.lua
  3. CODE: [Lua code for Avante plugin configuration]
  4. INSTRUCTION: [Detailed instructions for code modification requests]
  5. SEARCH/REPLACE block Rules: [Guidelines for using SEARCH/REPLACE blocks]
  6. QUESTION: The actual prompt

The @codebase will inject the repo_map, if supported, into PROJECT CONTEXT.

Try it out with a go project for example, it worked for me.

EDIT: I noticed after writing that this issue is about being stuck at generated response, so what I said is not relevant to your specific problem. I have the latest version btw and I don't face this issue.