jackMort / ChatGPT.nvim

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

Prevent warning "OPENAI_API_HOST environment variable not set" if you want to use the default #267

Closed Allaman closed 1 year ago

Allaman commented 1 year ago

As the title suggests, it would be cool if the warning is not displayed when there is no need to change the API host

Allaman commented 1 year ago

Maybe related to https://github.com/jackMort/ChatGPT.nvim/issues/265 ?

heimann commented 1 year ago

Maybe related to #265 ?

They are definitely related as the issue starts occurring with that same commit. However, it does seem like a default of "api.openai.com" is passed at least if you don't provide the host, so I don't think that's the cause of the error :(

kohane27 commented 1 year ago

I'm suddenly having the same error as well.

The following commit works:

  {
    "jackMort/ChatGPT.nvim",
    commit = "2107f7037c775bf0b9bff9015eed68929fcf493e",
    event = "VeryLazy",
    dependencies = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
    },
  },
everdom commented 1 year ago

just edit your .bashrc/.zshrc and add:

export OPENAI_API_HOST="api.openai.com"
teto commented 1 year ago

also looks like a typo in README.md: or environment variable called $OPEN_API_HOST

teto commented 1 year ago

I would prefer to avoid adding yet another environment variable OPENAI_API_HOST. How can I achieve the equivalent by setting api_host_cmd ?

nfwyst commented 1 year ago

Good, it is OPENAI_API_HOST, and not OPEN_AI_HOST

Allaman commented 1 year ago

just edit your .bashrc/.zshrc and add:

export OPENAI_API_HOST="api.openai.com"

Sure, but don't you think that this is redundant? The README states that this variable is

... useful if you can't access OpenAI driectly

IMO, a default setting should not need a configuration nor cause a warning.

Allaman commented 1 year ago

I would prefer to avoid adding yet another environment variable OPENAI_API_HOST. How can I achieve the equivalent by setting api_host_cmd ?

@teto Something like this should work api_host_cmd = "echo -n 'api.openai.com'". Adjust to the correct address!