skip to Main Content

I have Ollama installed on a Debian 12 machine. Local access is ok but fails on Windows 11.
Works on Ollama server:

http://localhost:11434/  WORKS
http://[local ip]:11434/ WORKS
curl https://www.google.com  WORKS
curl http://localhost:11434/api/generate -d '{ "model": "llava",  "prompt": "Why is the sky blue?", "stream": false}'    WORKS

On client Debian 12:
All works as above

On client Windows 11:

http://server_ip:11434/  WORKS
curl https://www.google.com WORKS
curl http://server_ip:11434/api/generate -d '{ "model": "llava",  "prompt": "Why is the sky blue?", "stream": false}'    ERROR ERROR See Below:

{"error":"invalid character '\'' looking for beginning of value"}curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (3) URL rejected: Bad hostname
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (3) URL rejected: Malformed input to a URL function
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (3) unmatched close brace/bracket in URL position 6:
false}'
     ^

It appears to be a problem with how windows deals with some JSON messages.
Windows applications that attempt to access the server report same errors.

Ideas?
TIA

Attempt with other Debian and Windows clients with same response

2

Answers


  1. So after some researching i came up with this prompt:

    curl http://server_ip:11434/api/generate -d @text.txt

    text.txt is a text file that has your JSON.

    text.txt:

    {"model": "phi3","prompt":"Why is the sky blue?", "stream":false}

    Result:

    {"model":"phi3","created_at":"2024-06-06T10:18:53.665593641Z","response":" The sky appears blue to our eyes due to a phenomenon called Rayleigh scattering. Sunlight, or white light, is made up of different colors with varying wavelengths. When sunlight reaches Earth’s atmosphere, it interacts with molecules and tiny particles present in the air.nnThe shorter-wavelength blue light (with a wavelength around 475 nanometers) scatters more efficiently than other colors because its smaller size causes it to change direction upon interaction with these atmospheric constituents. On the other hand, longer-wavelength colors like red and yellow scatter less as they have larger wavelengths.nnSince blue light is scattered in all directions throughout Earth’s atmosphere, the sky appears predominantly blue when we look up from the ground. However, during sunrise or sunset, the angle of the Sun causes its rays to pass through a thicker portion of our atmosphere, resulting in more scattering of red and orange light (longer wavelengths) that then contributes to the warm colors seen at these times of day.","done":true,"done_reason":"stop","context":[32010,3750,338,278,14744,7254,29973,32007,32001,450,14744,5692,7254,304,1749,5076,2861,304,263,27791,265,2000,9596,280,1141,14801,292,29889,8991,4366,29892,470,4796,3578,29892,338,1754,701,310,1422,11955,411,24099,281,6447,1477,29879,29889,1932,6575,4366,22170,11563,29915,29879,25005,29892,372,16254,29879,411,13206,21337,322,21577,17105,2198,297,278,4799,29889,13,13,1576,20511,29899,29893,6447,1477,7254,3578,313,2541,263,281,6447,1477,2820,29871,29946,29955,29945,23432,290,2699,29897,885,271,2153,901,29497,1135,916,11955,1363,967,7968,2159,9946,372,304,1735,5305,2501,14881,411,1438,15489,8096,293,10719,1237,29889,1551,278,916,1361,29892,5520,29899,29893,6447,1477,11955,763,2654,322,13328,14801,3109,408,896,505,7200,281,6447,1477,29879,29889,13,13,23036,7254,3578,338,29574,297,599,18112,10106,11563,29915,29879,25005,29892,278,14744,5692,758,24130,10835,7254,746,591,1106,701,515,278,5962,29889,2398,29892,2645,6575,29878,895,470,6575,842,29892,278,10696,310,278,8991,9946,967,15570,29879,304,1209,1549,263,266,6541,11910,310,1749,25005,29892,9819,297,901,14801,292,310,2654,322,24841,3578,313,5426,261,281,6447,1477,29879,29897,393,769,640,5026,304,278,14294,11955,3595,472,1438,3064,310,2462,29889,32007],"total_duration":44542960417,"load_duration":18093516,"prompt_eval_duration":270381000,"eval_count":235,"eval_duration":44212965000}

    Hope this helps.
    However, if your prompt has double quotes in it, it faces the same issue. Trying to fix the same

    Update:

    Entering the quotes with a backslash does the trick.

    text.txt:

    {"model": "phi3","prompt":"what is "konichiwa".","stream":false}

    Output:

    {"model":"phi3","created_at":"2024-06-06T10:29:13.422436203Z","response":" "Konichiwa" is a common Japanese greeting that means "hello" or "good afternoon." It’s used to greet people during the daytime, typically from late morning until early evening. The term comes from two characters: "ko" (こ) meaning person and "nichiyō" (日曜), which refers to Sunday, implying a general greeting for someone today or any part of the day. In modern usage, it’s more broadly used as a casual hello regardless of time.","done":true,"done_reason":"stop","context":[32010,825,338,376,8077,18544,2766,1642,32007,32001,376,29968,265,18544,2766,29908,338,263,3619,10369,1395,15133,393,2794,376,12199,29908,470,376,16773,17724,1213,739,29915,29879,1304,304,1395,300,2305,2645,278,2462,2230,29892,12234,515,5683,7250,2745,4688,11005,29889,450,1840,5304,515,1023,4890,29901,376,2901,29908,313,30589,29897,6593,2022,322,376,29876,18544,29891,30099,29908,313,30325,233,158,159,511,607,14637,304,16340,29892,2411,5890,263,2498,1395,15133,363,4856,9826,470,738,760,310,278,2462,29889,512,5400,8744,29892,372,29915,29879,901,7300,368,1304,408,263,3209,950,22172,17126,310,931,29889,32007],"total_duration":24524248615,"load_duration":2357006563,"prompt_eval_count":11,"prompt_eval_duration":1142789000,"eval_count":113,"eval_duration":20982413000}

    Hope this helps.

    Login or Signup to reply.
  2. Facing the same error . Can’t resolve it with the suggestions. However the below in PowerShell can work

    (Invoke-WebRequest -method POST -Body ‘{"model":"llama2", "prompt":"Why is the sky blue?", "stream": false}’ -uri http://localhost:11434/api/generate ).Content | ConvertFrom-json

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search