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

Simple way to fix error "curl: no URL specified" #266

Closed Mephistophillis closed 1 year ago

Mephistophillis commented 1 year ago

Hello! The changes regarding the addition of alternative APIs are simply amazing! But as far as I understand, the function that checks OPENAI_API_HOST should also trigger a callback if this variable exist for the subsequent determination of COMPLETIONS_URL, CHAT_COMPLETIONS_URL, and EDITS_URL. It should resolve https://github.com/jackMort/ChatGPT.nvim/issues/265

jla2000 commented 1 year ago

@Mephistophillis At least for me, this does not resolve the error. I'm using this config here adapted to your MR:

 {
    "Mephistophillis/ChatGPT.nvim",
    branch = "fix-no-curl-url-error",
    event = "VeryLazy",
    dependencies = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
    },
    opts = {
      api_key_cmd = "/bin/bash " .. vim.fn.expand("$HOME") .. "/.config/nvim/chatgpt-key.sh",
    },
  },
Mephistophillis commented 1 year ago

jla2000 You need to define OPENAI_API_HOST variable as "api.openai.com" (it was deafult). I just add line vim.env.OPENAI_API_HOST = "..." in my neovim configuration.

Also You can try add it as api_host_cmd in yout opts

yandy-r commented 1 year ago

jla2000 You need to define OPENAI_API_HOST variable as "api.openai.com" (it was deafult). I just add line vim.env.OPENAI_API_HOST = "..." in my neovim configuration.

Also You can try add it as api_host_cmd in yout opts

When adding the vim.env.OPENAI_API_HOST configuration, the warning goes away. But I still get the curl: no URL specified! error.

Mephistophillis commented 1 year ago

Added return of default host variable ("api.openai.com") if it is not defined. These changes makes you don't need to define this variable, if you're using original API jla2000 They should also solve https://github.com/jackMort/ChatGPT.nvim/issues/267 probably

kidinstinct This PR is open. If you want to use it right now, you can take my fork as source of plugin like jla2000 did. But I warn you, after solving this problem in this repository, I will probably delete it.

yandy-r commented 1 year ago

@Mephistophillis I cloned this repo and merged your changes into mine, just in case... Thanks for the work, I was going to attempt to fix it, but since you did already. thank you

LalleSX commented 1 year ago

LGTM

simanga-dev commented 1 year ago

what is the way forward with this, are we suppose to always define the host-name, and just out of curiosity what other host-name can it be?

ponymushama commented 1 year ago

Added return of default host variable ("api.openai.com") if it is not defined. These changes makes you don't need to define this variable, if you're using original API jla2000 They should also solve #267 probably

kidinstinct This PR is open. If you want to use it right now, you can take my fork as source of plugin like jla2000 did. But I warn you, after solving this problem in this repository, I will probably delete it.

Thanks a lot. It solves the bug. But I've noticed that gpt-3.5 is always loading, and the generating process is interrupted time by time.

LalleSX commented 1 year ago

just out of curiosity what other host-name can it be?

It can be a self hosted AI model like a Llama 2 model either hosted locally on your own computer if you have enough VRAM, or on Azure / AWS

heimann commented 1 year ago

what is the way forward with this, are we suppose to always define the host-name, and just out of curiosity what other host-name can it be?

I think this is mostly for people who need to use proxies to access the openai api (i.e. their isp / country bans the openai endpoints)

jackMort commented 1 year ago

Thanks for that fix!