svermeulen / text-to-colorscheme

Neovim colorschemes generated on the fly with a text prompt using ChatGPT
MIT License
294 stars 5 forks source link

Error: executing vim.schedule lua callback: ...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:7: [text-to-colorscheme] Assert hit! #5

Open nyngwang opened 1 year ago

nyngwang commented 1 year ago
Error executing vim.schedule lua callback: ...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:7: [text-to-colorscheme] Assert hit!
stack traceback:
    [C]: in function 'error'
    ...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:7: in function '_raise'
    ...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:19: in function 'that'
    ...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:203: in function 'onexit'
    ...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:231: in function <...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:230>

my query: bg=16161d;greytext;orangekeyword;bluestring.

svermeulen commented 1 year ago

I wasn't able to reproduce this when using gpt-4, but do see it now when I switch to one of the gpt-3.5 models. So not sure what we can do about this. I did at least add some a more helpful error message when this does happen, so you can see what is invalid in the response now

nyngwang commented 1 year ago

Now the error becomes

Error executing vim.schedule lua callback: ...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:9: [text-to-colorscheme] Received unexpected response from OpenAI:
return {
  background = "#161616",
  foreground = "#d9d9d9",
  accents = {
     "#76b900",
     "#0066cc",
  },
}
stack traceback:

[C]: in function 'error'

...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:9: in function '_raise'

...colorscheme/lua/text-to-colorscheme/internal/asserts.lua:19: in function 'that'

...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:221: in function 'onexit'

...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:249: in function <...-colorscheme/lua/text-to-colorscheme/internal/openai.lua:248>
svermeulen commented 1 year ago

Looks like openai didn't understand the instructions correctly, and returned only 2 accent colors instead of 7