yetone / avante.nvim

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

bug: Avante starts a empty new chat every time it being called out. #558

Closed Dakai closed 1 month ago

Dakai commented 1 month ago

Describe the bug

From the #516 it seems that the avante.nvim should keep a chat history and so it is what I guessed by reading the code, however, the sidebar is empty after I closed and reopen it. my config is:

To reproduce


{
    --"yetone/avante.nvim",
    "dakai/avante.nvim", -- My forked repo, which I mod the openai.lua just to use my custom genmini API, nothing else changed.
    branch = "gemini_proxy",
    event = "VeryLazy",
    lazy = false,
    opts = {
      provider = "openai", -- You can then change this provider here
      --vendors = {
      --  ["Gemini"] = {
      --    endpoint = "url",
      --    model = "gpt-4o",
      --    api_key_name = "GOOGLEAI_API_KEY",
      --  }
      --},
    },
    build = 'make',
    keys = {
      { "<leader>aa", function() require("avante.api").ask() end,     desc = "avante: ask",    mode = { "n", "v" } },
      { "<leader>ar", function() require("avante.api").refresh() end, desc = "avante: refresh" },
      { "<leader>ae", function() require("avante.api").edit() end,    desc = "avante: edit",   mode = "v" },
    },
    dependencies = {
      "stevearc/dressing.nvim",
      "nvim-lua/plenary.nvim",
      "MunifTanjim/nui.nvim",
      --- The below dependencies are optional,
      "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
      {
        -- 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 setup it properly if you have lazy=true
        'MeanderingProgrammer/render-markdown.nvim',
        opts = {
          file_types = { "markdown", "Avante" },
        },
        ft = { "markdown", "Avante" },
      },
    },
  },
``

### Expected behavior

I hope the previous chat content can be preserved after I close and reopen the plugin's UI.

### Environment

Manjaro KDE Plasma
nvim v0.10.1
aarnphm commented 1 month ago

check wiki for custom providers, but I'm not entirely sure what the problem is.

Dakai commented 1 month ago

I don't think it is about the custom provider, I am using a OpenAI compatible proxy which input and output format should be the same as OpenAI's, so I just changed the API key name and endpoint in openai.lua, the mechanism and functions are intact.

yuchanns commented 1 month ago

This is not the right way to use a custom provider. You are using a custom provider. The history is not saved just because your inappropriate hacking broke the response parser and Avante cannot complete the chat.