nvim-magic
nvim-magic copied to clipboard
Error in OpenAi Response - Engine not found
Describe the bug
OpenAI error in API response engine not found.
To Reproduce Steps to reproduce the behavior: e.g.
- Select some text
- Press
<Leader>mcs
This is using the default setup copied directly from the readme. No changes to configuration at all.
Expected behavior
Return result from OpenAI
Error
{"status": 404, "headers": ["date: Fri, 22 Oct 2021 22:39:23 GMT", "content-type: application/json", "content-length: 129", "access-control-allow-origin: *", "openai-organization: user-bnsxbna6vrmqknqvlmfcgwnb", "openai-processing-ms: 12", "openai-version: 2020-10-01", "strict-transport-security: max-age=15724800; includeSubDomains", "x-request-id: 9136d7e345981c1dc78e25227d659c76", "", ""], "exit": 0, "body": "{\n \"error\": {\n \"code\": null,\n \"message\": \"Engine not found\",\n \"param\": null,\n \"type\": \"invalid_request_error\"\n }\n}"}
Details (please complete the following information):
- OS: MacOS
- Neovim version: 0.5.1
- nvim-magic version: latest master
Thanks for the report, does your OpenAI account have access to use the davinci-codex engine? That "Engine not found" error looks like it might be returned in the case where you don't - https://github.com/mattt/OpenAI/issues/2 . If you only have access to the davinci engine you could substitute that backend in the plugin setup, though the responses from the API won't be as good.
require('nvim-magic').setup({
backends = {
default = require('nvim-magic-openai').new({
api_endpoint = 'https://api.openai.com/v1/engines/davinci/completions',
}),
},
use_default_keymap = false
})
NB: the davinci engine isn't free to use like the current private Codex beta so this could result in charges per call made.
Thanks - this worked for me using the Codex model code-davinci-002, which is in limited beta:
api_endpoint = "https://api.openai.com/v1/engines/code-davinci-002/completions"