-
I want to get the API key from a local file rather than an environment variable. local command = "cat " .. vim.fn.expand("$HOME") .. "/.config/openaikey"
local handle = io.popen(command)
API_KEY = nil
if handle ~= nil then
API_KEY = handle:read("*a")
handle:close()
end
return {
{
"robitx/gp.nvim",
opts = { openai_api_key = API_KEY },
}
} .. gives this error message, whenever I try to submit a prompt. Just pasting the key (
Could anyone please help me? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@Dronakurl hey, try to strip the white spaces like a newline from the key API_KEY = handle:read("*a"):match("%S+") You might miss those using simple print => print("API_KEY: " .. vim.inspect(API_KEY)) Also thanks, I forgot to wrap new error/warn/info messages (which use nvim_echo) into vim.schedule (that's why you saw E5560 instead of what actually happened). Fixed in the latest version. |
Beta Was this translation helpful? Give feedback.
-
I got it to work, thank you very much for your help.
I am very new to lua, so I could not figure this out
…On Sun Nov 12, 2023 at 9:04 AM CET, Tibor Schmidt wrote:
@Dronakurl hey, try to strip the white spaces like a newline from the key
``` lua
API_KEY = handle:read("*a"):match("%S+")
```
You might miss those using simple print =>
``` lua
print("API_KEY: " .. vim.inspect(API_KEY))
```
Also thanks, I forgot to wrap new error/warn/info messages (which use nvim_echo) into vim.schedule (that's why you saw E5560 instead of what actually happened). Fixed in the latest version.
--
Reply to this email directly or view it on GitHub:
#55 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
@Dronakurl hey, try to strip the white spaces like a newline from the key
You might miss those using simple print =>
Also thanks, I forgot to wrap new error/warn/info messages (which use nvim_echo) into vim.schedule (that's why you saw E5560 instead of what actually happened). Fixed in the latest version.