Robitx / gp.nvim

Gp.nvim (GPT prompt) Neovim AI plugin: ChatGPT sessions & Instructable text/code operations & Speech to text [OpenAI, Ollama, Anthropic, ..]
MIT License
784 stars 67 forks source link

File "does not look like a chat file" #104

Closed lennartack closed 7 months ago

lennartack commented 7 months ago

Recently GpChat stopped working.

Steps to reproduce:

I see an error message: Gp: file "/path/to/chat.md" does not look like a chat file.

kingfirewxm commented 7 months ago

Previously, to facilitate switching between different Neovim configurations, I created symbolic links for the nvim folders located under the .local/share/ and .config/ directories, linking them to different distro. However, this approach led to the this issue.

I resolved my problem by explicitly specifying the real address of the chat folder in the chat_dir option. ———————————————————————— Same

yanosea commented 7 months ago

I'm using gp.nvim and it is really useful for me. Thank you for your developping!!!

I'm also encountering the same problem. I wanted to change the directory where gp/persited and gp/chats are stored, so I changed the state_dir and chat_dir in the configuration file and now it happens. I am using Lazy.nvim to manage plugins for Neovim and the configuration looks like this.

config = function()
  require("gp").setup({
    agents = {
        -- some config for agents
    },
    state_dir = os.getenv("ENV_VAR_INCLUDING_A_CERTAIN_DIR") .. "/gp-nvim/persisted",
    chat_dir = os.getenv("ENV_VAR_INCLUDING_A_CERTAIN_DIR") .. "/gp-nvim/chats",
  })
  vim.api.nvim_set_hl(0, "GpHandlerStandout", { link = "Normal" })
  vim.api.nvim_set_hl(0, "GpExplorerSearch", { link = "Normal" })
end,

As a catch, the md files under gp/chats/ and gp/persited/state.json under the configured directory seem to be stored correctly.

I am not familiar with Lua and may have configured it incorrectly. If so, please let me know.

Sincerely,

Robitx commented 7 months ago

Hi everyone,
sorry I've been away for few weeks.

Checking whether or not a file is a chat uses several conditions. The latest version, I've just pushed, should provide more verbose message.

If anyone would be willing to try it and share the error (ideally in it's entirety - for example real file path on which it failed), it would greatly help to hone on the problem.

Tomorrow I'll try to replicate and debug the issue with symlinks mentioned by @kingfirewxm.

Robitx commented 7 months ago

Note for myself: https://vi.stackexchange.com/questions/44028/weird-interaction-between-gp-nvim-and-syntastic (I guess I have to install Windows :cry: )

yanosea commented 7 months ago

@Robitx Hi👋 Thank you for your maintaining!

I updated gp.nvim to v2.4.7 and did the same things. I got the message below. I don't mask values to clear the problem.

Gp: File "/mnt/c/Users/yanosea/GoogleDrive/gp-nvim/chats/date.md" does not look like a chat file: "not in chat directory (/home/yanosea/GoogleDrive/gp-nvim/chats)"

I'm sorry I forgot to say that I'm using gp.nvim on WSL2🙏 The config I use is below.

state_dir = os.getenv("GOOGLE_DRIVE") .. "/gp-nvim/persisted",
chat_dir = os.getenv("GOOGLE_DRIVE") .. "/gp-nvim/chats",

I change state_dir and chat_dir because I want to sync chats around the devices I use via GoogleDrive.

I created symbolic link on WSL2 home.

ln -s /mnt/c/Users/yanosea/GoogleDrive ~/GoogleDrive

then, I set the env in .zshenv below.

export GOOGLE_DRIVE=$HOME/GoogleDrive

I tried two settings.

state_dir = "/home/yanosea/GoogleDrive/gp-nvim/persisted",
chat_dir = "/home/yanosea/GoogleDrive/gp-nvim/chats",

This config set dirs not using envs, but this sent the same message.

state_dir = "/mnt/c/Users/yanosea/GoogleDrive/gp-nvim/persited",
chat_dir = "/mnt/c/Users/yanosea/GoogleDrive/gp-nvim/chats",

This config set dirs not using the symbolic links. This goes well.

From this and kingfirewxm's comments, I think the symbolic link is causing the problem🤔

yanosea commented 7 months ago

Additionaly I tried below.

  1. mkdir on WSL2 Home
mkdir ~/test
  1. create a symbolic link
ln -s ~/test ~/test_symlink
  1. edit gp.nvim config
state_dir = "/home/yanosea/test_symlink/gp-nvim/persisted",
chat_dir = "/home/yanosea/test_symlink/gp-nvim/chats",
  1. use gp.nvim

Then, I got the same message.

Gp: File "/home/yanosea/test/gp-nvim/chats/date.md" does not look like a chat file: "not in chat directory (/home/yanosea/test_symlink/gp-nvim/chats)"
lennartack commented 7 months ago

I can confirm that the problem is also caused by a symlink for me. Specifying chat_dir explicitly as suggested by @kingfirewxm fixed the problem. However, I would prefer to not specify chat_dir as it would make it easier to use my config accross different systems.

Robitx commented 7 months ago

@lennartack @yanosea @kingfirewxm The latest version 2.4.9 should be able to handle symlinks properly, please give it go.

kingfirewxm commented 7 months ago

@lennartack @yanosea @kingfirewxm The latest version 2.4.9 should be able to handle symlinks properly, please give it go.

It works, thank you!

yanosea commented 7 months ago

@Robitx It worked!!! Thank you very much🙏