jackMort / ChatGPT.nvim

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

OPENAI_API_TYPE not populated when OPENAI_API_KEY is specified #304

Closed rzalawad closed 11 months ago

rzalawad commented 11 months ago

Based on the current code workflow, when environment variable OPENAI_API_KEY is read, the callback https://github.com/jackMort/ChatGPT.nvim/blob/7db348d7b45a84d6144354d90d5d16315c422e5a/lua/chatgpt/api.lua#L258 is not executed and thus OPENAI_API_TYPE is not loaded and loadAzureConfigs isn't executed to load the Azure related environment variables.

This results in an ambiguous api key is invalid prompt when opening a chat session.

rzalawad commented 11 months ago

If its not in the works, I can create a PR that always reads OPENAI_API_TYPE and loads loadAzureConfigs based on the value rather than conditionally reading OPENAI_API_TYPE based on the existence of the api key

ekaj2 commented 11 months ago

This PR will inadvertently resolve this, no?

https://github.com/jackMort/ChatGPT.nvim/pull/305

rzalawad commented 11 months ago

@ekaj2 It does!! Thanks for the PR :) I'll close this issue