gen.nvim icon indicating copy to clipboard operation
gen.nvim copied to clipboard

Error: Unexpected EOF

Open Kahitar opened this issue 11 months ago • 2 comments

Hi,

this plugin is not working for me and I don't quite understand why (maybe because I'm on windows?).

I don't get a response from ollama when using this plugin, so the response modal is always empty. Enabling debug output, I get these logs:

curl --silent --no-buffer -X POST http://localhost:11434/api/chat -d "{""messages"": [{""role"": ""user"", ""content"": ""Regarding the following text, hi:\n""}], ""model"": ""mistral"", ""stream"": true}"
Response data:
{ '{"error":"unexpected EOF"}' }
Response data:
{ "" }

When I try to run the same curl command in git-bash, the output is this:

$ curl --silent --no-buffer -X POST http://localhost:11434/api/chat -d "{""messages"": [{""role"": ""user"", ""content"": ""Regarding the following text, hi:\n""}], ""model"": ""mistral"", ""stream"": true}"
{"error":"invalid character 'm' looking for beginning of object key string"}

I don't quite understand why the json body contains doubled quotes. When I remove them and surround the body with single quotes, than it works:

curl --silent --no-buffer -X POST http://localhost:11434/api/chat -d '{"messages": [{"role": "user", "content": "Regarding the following text, hi:\n"}], "model": "mis
tral", "stream": true}'
{"model":"mistral","created_at":"2024-03-17T16:18:22.8339767Z","message":{"role":"assistant","content":" Hello"},"done":false}
...

Don't know if this is really the cause of the issue or if the "unexpected EOF" comes from something else. But that's what I was able to figure out so far.

Here's a screenshot of this issue in action: image

Kahitar avatar Mar 17 '24 16:03 Kahitar

Seems like my initial hunch with the double quotes "" is wrong, considering this is apparently the way to escape them in windows cmd (according to #4). So I realized from mentioned issue, that neovim executes the curl in windows cmd, instead of git bash, and if I execute the command there I get an empty response:

curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d "{""messages"": [{""role"": ""user"", ""content"": ""Regarding the following text, hi:\n""}], ""model"": ""mistral"", ""stream"": true}"
{"model":"mistral","created_at":"2024-03-17T17:02:41.9377754Z","response":"","done":true}

I guess I will have to debug my setup with ollama in cmd.

Edit: Acutally, the /api/generate command is just not working. But /api/chat is working even in cmd. So I'm still no wiser as to why it's working in cmd but not in neovim when executing with this plugin...

Kahitar avatar Mar 17 '24 17:03 Kahitar

Hi @Kahitar ,

Thanks for opening this issue. Unfortunately, I have no access to a windows machine, therefore I cannot debug this problem. Would you mind modifying the escaping mechanism to investigate?

David-Kunz avatar Mar 22 '24 11:03 David-Kunz