Closed JoseConseco closed 9 months ago
Seems to work for me, which OS do you use?
Note: '
characters are already escaped.
This is the resulting command:
ollama run mistral 'Summarize the following text:
Add \'aa_\' prefix to module names
I think they should be escaped for command line with ` ?'
Did you maybe override require('gen').command
since you couldn't set the model?
Ok, did some debugging on this, as this is happening with me too.
The issue is in escaping the '
character, for shell it needs to be '\''
see :h shellescape
the fix is pretty simple, I can open a pr for it
text = string.gsub(text, "'", "'\\''")
Fixed with https://github.com/David-Kunz/gen.nvim/pull/5, thank you again @alaaibrahim !
I still have this issue for some reason 🤔
this is a 'test' - works
this is a test
- works
this is a "test" - doesn't work
i have this issue too, also happening with double quotes, for example calling :Gen Review_Code
on the following input:
"test"
generates the following query:
curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d "{""model"": ""zephyr"", ""stream"": true, ""prompt"": ""Review the following code and make concise suggestions:\n```cpp\n\""test\""\n```""}"
but calling it with the code:
'test'
generates:
curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d "{""model"": ""zephyr"", ""stream"": true, ""prompt"": ""Review the following code and make concise suggestions:\n```cpp\n'test'\n```""}"
my OS is windows
Unfortunately I don't have a windows machine to test, but just ran the same tests above, and both works
Input: "test"
command
curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d '{"model": "codellama", "stream": true, "prompt": "Review the following code and make concise suggestions:\n```cpp\n\"test\"\n```"}'
Input: 'test'
command
curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d '{"model": "codellama", "stream": true, "prompt": "Review the following code and make concise suggestions:\n```cpp\n'\''test'\''\n```"}'
Although cannot say for sure, but it might be that neovim doesn't recognize your shell that you are using, or it's mis-configured somewhere.
see
help 'shell'
help 'shellquote'
and help 'shellxquote'
it seems to be a windows only problem, it has to do with the fact that the commands are being called with cmd so [vim.fn.shellescape()
](https://neovim.io/doc/user/builtin.html#shellescape()) has to substitute every double quote with two double quotes, but vim.fn.json_encode()
already tries to escape double quotes like \"
.
so when the command is called the json is all messed up and doesn't have consistent escaping.
i think I've already fixed it on my end, I'll open a PR.
eg. this wont work