Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to concatenate field 'OPENAI_API_KEY' (a nil value) #299

Closed
PMassicotte opened this issue Oct 10, 2023 · 6 comments
Closed

attempt to concatenate field 'OPENAI_API_KEY' (a nil value) #299

PMassicotte opened this issue Oct 10, 2023 · 6 comments

Comments

@PMassicotte
Copy link

Looks like the last commit (aa8a969) is breaking something.

I am getting this error:

.../.local/share/nvim/lazy/ChatGPT.nvim/lua/chatgpt/api.lua:267: attempt to concatenate field 'OPENAI_API_KEY' (a nil value)  

Api.AUTHORIZATION_HEADER = "Authorization: Bearer " .. Api.OPENAI_API_KEY

FWIW, here is my config:

  config = function()
    local home = vim.fn.expand("$HOME")
    require("chatgpt").setup({
      api_key_cmd = "gpg --decrypt " .. home .. "/openai_api_key.txt.gpg"
    })
  end,
@comiluv

This comment was marked as duplicate.

@h0pes
Copy link

h0pes commented Oct 11, 2023

Same error using bw (which is the Bitwarden command line client) in plugin custom config like this:
api_key_cmd = bw get password <uniqueid>
results in attempt to concatenate filed OPENAI_API_KEY (a nil value).

uniqueid is an alphanumeric string without spaces

@mhuggins7278
Copy link

same here using builtin mac keychain
security find-generic-password -s NVIM_CHAT_GPT_TOKEN -w

@r3k2
Copy link

r3k2 commented Oct 11, 2023

same here using gopass(compatible with pass)

return {
  "jackMort/ChatGPT.nvim",
  event = "VeryLazy",
  config = function()
    require("chatgpt").setup({
      api_key_cmd = "gopass show -o -f chatgpt/apikey",
    })
  end,
  dependencies = {
    "MunifTanjim/nui.nvim",
    "nvim-lua/plenary.nvim",
    "nvim-telescope/telescope.nvim",
  },
  keys = {
    { "<leader>Cc", "<cmd>ChatGPT<cr>", desc = "ChatGPT" },
  },
}

@phaberest
Copy link

phaberest commented Oct 11, 2023

I can confirm that https://github.com/singular0/ChatGPT.nvim/commit/3d31eacf98b00cc3fd944ef5526be6d738515649 fixed the issue

A PR has been submitted under #301

@jackyu1996
Copy link
Contributor

jackyu1996 commented Oct 11, 2023

Sorry for not testing enough on the api_key_cmd option, I will try to find a workaround and test relevant options in nvim config before submitting another patch. Sorry for the inconveniences again.

Edits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants