-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
curl: option -H: requires parameter when running :ChatGPT #303
Comments
I reverted to commit d4aa4d9 and it's working again. |
won't fix mine ! |
After removing my self-compiled version of Neovim and replacing it with Neovim v0.9.0 / LuaJIT 2.1.0 from the official release image, and reverting to commit d4aa4d9, the issue has been successfully resolved. |
Experiencing the same issue. Here is my neovim and chatGPT version: ChatGPT.nvim": { "branch": "main", "commit": "7db348d7b45a84d6144354d90d5d16315c422e5a" } NVIM v0.10.0-dev-1063+g5e3cf9fb4b |
Try using as commit d4aa4d9 it worked for me. I'm leaving this open in case this get's fixed in a pull request which can be referenced, so we can use the latest version again. |
I have the same issue |
Same issue |
Same issue... :( |
Seems to be related to this change here from this PR that tries to add support for AZURE environment variables as well. I'm looking into this a bit more, but @jackMort or @jackyu1996 could probably put an update in place faster if they see this. The latest version is very much broken and unusable. |
The callback passed to local function loadConfigFromEnv(envName, configName)
local variable = os.getenv(envName)
if not variable then
return
end
Api[configName] = variable:gsub("%s+$", "")
end
-- ...
local function loadApiKey(envName, configName, optionName, callback, defaultValue)
loadConfigFromEnv(envName, configName)
if not Api[configName] then
if Config.options[optionName] ~= nil and Config.options[optionName] ~= "" then
loadConfigFromCommand(Config.options[optionName], optionName, callback, defaultValue)
else
logger.warn(envName .. " environment variable not set")
return
end
end
end A simple solution is to pass the callback function in to handle handle if the environment variable is picked up in the config. I'm making a PR for that now. One potential workaround although I haven't confirmed it is to delete the environment variable and use the passed in parameter in your packer.lua or similar. See this part of the readme: Secrets ManagementProviding the OpenAI API key via an environment variable is dangerous, as it As an alternative to providing the API key via the The following configuration would use 1Passwords CLI, require("chatgpt").setup({
api_key_cmd = "op read op://private/OpenAI/credential --no-newline"
}) The following configuration would use GPG to decrypt a local file containing the local home = vim.fn.expand("$HOME")
require("chatgpt").setup({
api_key_cmd = "gpg --decrypt " .. home .. "/secret.txt.gpg"
}) Note that the |
curl: option -H: requires parameter error Seems to be related to this change here from this PR that tries to add support for AZURE environment variables as well. https://github.com/jackMort/ChatGPT.nvim/pull/293/files Api.AUTHORIZATION_HEADER is nil in Api.chat_completions... The callback passed to loadApiKey is not guaranteed to be called in the case that the environment variable for OPENAI_API_KEY exists. ``` local function loadConfigFromEnv(envName, configName) local variable = os.getenv(envName) if not variable then return end Api[configName] = variable:gsub("%s+$", "") end -- ... local function loadApiKey(envName, configName, optionName, callback, defaultValue) loadConfigFromEnv(envName, configName) if not Api[configName] then if Config.options[optionName] ~= nil and Config.options[optionName] ~= "" then loadConfigFromCommand(Config.options[optionName], optionName, callback, defaultValue) else logger.warn(envName .. " environment variable not set") return end end end ``` A simple solution is to pass the callback function in to handle handle if the environment variable is picked up in the config. I'm making a PR for that now.
PR here: #305 |
This issue seems to persists for me on the latest version. |
I'm also still getting this issue on the latest version |
@molleweide @jurdunnn Hi, could you please test whether the second to last commit ( |
Yeah it looks like that commit is working fine |
I also have this problem, tested commit 9f8062c but it haven't fixed it |
@jumski Hi, does your neovim config require recompilation after you switched commit? I currently don't have the time to look into this as I am using my own fork which uses sync reading of API related configs. Maybe I will investigate the newest commit when I have the time. |
@jackyu1996 what do you mean by recompilation? I didn't noticed thus, but if you ask about updating (really downgrading) the plugin I confirm I have done that |
@jumski If you are using |
I'm using Lazy. I verified the OPENAI_API_KEY env var is properly set via running
What possible issue you are thinking of while suggesting to recompile plugins @jackyu1996 ? I've opened a clean instance and verified if the Api.AUTHORIZATION_HEADER is properly set and seems like it is :lua print(require('chatgpt.api').AUTHORIZATION_HEADER)
-- "Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXX" |
@jumski When you reverted to the second to last commit (back then and was |
@jackyu1996 i just gave it another try and it works correctly now! sorry for such a delay - not replied immediately and later forgot about the issue cheers! |
I am still seeing this issue happening. is anyone having the issue even at the latest commit |
Very strange: It worked with the same neovim config on my arm mac but not on my intel mac. It was not the curl version (8.4 ships with the mac, 8.6 can be installed using e.g. the homebrew package manager). Re-installing the plugin in lazy did also not change anything. I tried to uninstall curl 8.6 on the intel machine and it did not fix things, BUT FWIW: After i reinstalled curl 8.6 with homebrew, it suddenly started to work on the intel machine. It is the very same version though, i think ( Any idea why this could have fixed things? @vkbytes if you're also on macos, maybe you could check on your machine if 1) a reinstall fixes things for you and 2) what it is that changes between removing/adding curl? |
Same problem here. Installed for the first time today (using Lazy), it worked once then I started a new session
Update: I noticed another error message about |
I still see the same problem!!
…On Tue, Mar 5, 2024 at 9:43 PM Jonathan ***@***.***> wrote:
Same problem here. Installed for the first time today (using Lazy), it
worked once then I started a new session <C-n> and it never worked again.
Error message:
curl: option -H: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information
—
Reply to this email directly, view it on GitHub
<#303 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AS4MFJAHZJKM6OC4JM3PGA3YWY37DAVCNFSM6AAAAAA55XU2VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGY4DMMJQGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I installed latest curl (8.7.1) from brew and it seems to work :) |
Hi,
I'm using NvChad as base neovim config and added the plugin on macOS. Before that I successfully used the plugin with my own NeoVim config from scratch, which ended up being NvChad. I exported the key as environment variable for testing which also worked before but now when I try the standard :ChatGPT command I get:
When I try :ChatGPTCompleteCode I get:
An Error Occurred ...
Error executing vim.schedule lua callback: Vim:E474: Attempt to decode a blank string
stack traceback:
[C]: in function 'json_decode'
.../.local/share/nvim/lazy/ChatGPT.nvim/lua/chatgpt/api.lua:125: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
My plugin config, where I simply added the plugin to the end:
https://pastebin.com/xb9zVvyV
The text was updated successfully, but these errors were encountered: