jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.56k stars 307 forks source link

Local prompts file doesn't work #440

Open t18n opened 1 month ago

t18n commented 1 month ago

I am trying to setup the local prompts as I would like to add some personal information. However, this setting doesn't work:

predefined_chat_gpt_prompts = home .. "/chatgpt-prompts/prompts.csv",

--- or
predefined_chat_gpt_prompts = "cat " .. home .. "/chatgpt-prompts/prompts.csv",

--- or
predefined_chat_gpt_prompts = "file:///" .. home .. "/packages/chatgpt-prompts/prompts.csv",

Is there a way do do that?

dimroc commented 1 month ago

I am working on something adjacent. I would like to load my own custom actions using read_actions_from_file but couldn't figure it out.

dimroc commented 1 month ago

Heads up that I figured out how to get custom actions by setting the config actions_path to my own customactions.json:

  -- ChatGPT plugins
  {
    "jackMort/ChatGPT.nvim",
    event = "VeryLazy",
    config = function()
      local chatgpt = require("chatgpt")
      chatgpt.setup({
        -- https://github.com/jackMort/ChatGPT.nvim/blob/df53728e05129278d6ea26271ec086aa013bed90/lua/chatgpt/config.lua#L177C5-L177C18
        actions_paths = { "~/.config/nvim/lua/config/chatgpt.customactions.json" }, -- <-- Added line
        openai_params = {
          model = "gpt-4o",
        },
        openai_edit_params = {
          model = "gpt-4o",
        },
      })
      local wk = require("which-key")
      wk.register({
        p = {
          name = "ChatGPT",
          -- all the other run commands can go here: 
          a = { "<cmd>ChatGPTRun add_tests<CR>", "Add Tests", mode = { "n", "v" } },
          y = { "<cmd>ChatGPTRun fix_typos<CR>", "Fix Typos", mode = { "n", "v" } },
        },
      }, {
        prefix = "<leader>",
        mode = "v",
      })
    end,
    dependencies = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
    },
  },

}

Example customactions.json: https://github.com/jackMort/ChatGPT.nvim/blob/df53728e05129278d6ea26271ec086aa013bed90/lua/chatgpt/flows/actions/actions.json

{
  "fix_typos": {
    "type": "chat",
    "opts": {
      "template": "Fix typos and only output the correct spelling in {{lang}}:\n\n{{input}}",
      "strategy": "replace",
      "params": {
        "model": "gpt-4o"
      }
    },
    "args": {
      "lang": {
        "type": "string",
        "optional": "true",
        "default": "english"
      }
    }
  }
}