[GH-ISSUE #4915] Original ollama send Content-Type: application/x-ndjson #117096

Closed
opened 2026-05-20 18:47:27 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @unixshaman on GitHub (Aug 26, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4915

Is your feature request related to a problem? Please describe.
When I send request to original ollama service, like this:

POST http://127.0.0.1:11434/api/chat HTTP/1.1
Cache-Control: no-cache
Accept: text/event-stream
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:11434
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/4.12.0

{"model":"llama3.1:8b","messages":[{"role":"system","content":""},{"role":"user","content":"Привет"}],"options":{"temperature":0.10000000149011612,"num_predict":2048},"stream":true}

get next response:

HTTP/1.1 200 OK
Content-Type: application/x-ndjson
Date: Mon, 26 Aug 2024 13:14:53 GMT
Content-Length: 25933

{"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.7962491Z","message":{"role":"assistant","content":"H"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.9117733Z","message":{"role":"assistant","content":"e"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.9882669Z","message":{"role":"assistant","content":"ll"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:14:54.0081587Z","message":{"role":"assistant","content":"o"},"done":false}

When I send equal request to ollama through topen-webui

POST https://host.com:443/ollama/api/chat HTTP/1.1
Cache-Control: no-cache
Accept: text/event-stream
Authorization: Bearer sk-*****
Content-Type: application/json; charset=utf-8
Host: host.com:443
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/4.12.0

{"model":"llama3.1:8b","messages":[{"role":"system","content":""},{"role":"user","content":"Hello"}],"options":{"temperature":0.10000000149011612,"num_predict":2048},"stream":true}

get next response:

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 26 Aug 2024 13:18:11 GMT
Connection: keep-alive
x-process-time: 5
Content-Length: 22054

{"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.678360742Z","message":{"role":"assistant","content":"H"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.705184821Z","message":{"role":"assistant","content":"e"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.731536581Z","message":{"role":"assistant","content":"ll"},"done":false}
{"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.75741211Z","message":{"role":"assistant","content":"o"},"done":false}

Describe the solution you'd like
It is necessary to pass all headers from the original ollama service. Well, or at least the correct Content-Type: application/x-ndjson.

Describe alternatives you've considered
I tried to use openAI compatible API through /v1/chat/completions and this work correctly, i get Content-Type: application/json.

Originally created by @unixshaman on GitHub (Aug 26, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4915 **Is your feature request related to a problem? Please describe.** When I send request to original ollama service, like this: ``` POST http://127.0.0.1:11434/api/chat HTTP/1.1 Cache-Control: no-cache Accept: text/event-stream Content-Type: application/json; charset=utf-8 Host: 127.0.0.1:11434 Connection: Keep-Alive Accept-Encoding: gzip User-Agent: okhttp/4.12.0 {"model":"llama3.1:8b","messages":[{"role":"system","content":""},{"role":"user","content":"Привет"}],"options":{"temperature":0.10000000149011612,"num_predict":2048},"stream":true} ``` get next response: ``` HTTP/1.1 200 OK Content-Type: application/x-ndjson Date: Mon, 26 Aug 2024 13:14:53 GMT Content-Length: 25933 {"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.7962491Z","message":{"role":"assistant","content":"H"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.9117733Z","message":{"role":"assistant","content":"e"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:14:53.9882669Z","message":{"role":"assistant","content":"ll"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:14:54.0081587Z","message":{"role":"assistant","content":"o"},"done":false} ``` When I send equal request to ollama through topen-webui ``` POST https://host.com:443/ollama/api/chat HTTP/1.1 Cache-Control: no-cache Accept: text/event-stream Authorization: Bearer sk-***** Content-Type: application/json; charset=utf-8 Host: host.com:443 Connection: Keep-Alive Accept-Encoding: gzip User-Agent: okhttp/4.12.0 {"model":"llama3.1:8b","messages":[{"role":"system","content":""},{"role":"user","content":"Hello"}],"options":{"temperature":0.10000000149011612,"num_predict":2048},"stream":true} ``` get next response: ``` HTTP/1.1 200 OK Server: nginx/1.18.0 (Ubuntu) Date: Mon, 26 Aug 2024 13:18:11 GMT Connection: keep-alive x-process-time: 5 Content-Length: 22054 {"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.678360742Z","message":{"role":"assistant","content":"H"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.705184821Z","message":{"role":"assistant","content":"e"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.731536581Z","message":{"role":"assistant","content":"ll"},"done":false} {"model":"llama3.1:8b","created_at":"2024-08-26T13:18:11.75741211Z","message":{"role":"assistant","content":"o"},"done":false} ``` **Describe the solution you'd like** It is necessary to pass all headers from the original ollama service. Well, or at least the correct Content-Type: application/x-ndjson. **Describe alternatives you've considered** I tried to use openAI compatible API through /v1/chat/completions and this work correctly, i get Content-Type: application/json.
Author
Owner

@silentoplayz commented on GitHub (Aug 26, 2024):

@unixshaman Ignore the comment above that tells you to download something at all costs. These are bot accounts attempting to spread some form of unwanted malware. Our GitHub Updates channel on Discord has made us aware today that newly opened posts on the repository are being targeted by an unknown actor.

<!-- gh-comment-id:2310431762 --> @silentoplayz commented on GitHub (Aug 26, 2024): @unixshaman Ignore the comment above that tells you to download something at all costs. These are bot accounts attempting to spread some form of unwanted malware. Our GitHub Updates channel on Discord has made us aware today that newly opened posts on the repository are being targeted by an unknown actor.
Author
Owner

@unixshaman commented on GitHub (Aug 26, 2024):

Thank you very much for the explanation! I understood it as soon as I saw it.

<!-- gh-comment-id:2310456788 --> @unixshaman commented on GitHub (Aug 26, 2024): Thank you very much for the explanation! I understood it as soon as I saw it.
Author
Owner

@unixshaman commented on GitHub (Aug 26, 2024):

By the way, I need this modification so that the GhatGPT plugin for IntelliJ IDEA works correctly: https://github.com/carlrobertoh/CodeGPT/issues/674

<!-- gh-comment-id:2310465463 --> @unixshaman commented on GitHub (Aug 26, 2024): By the way, I need this modification so that the GhatGPT plugin for IntelliJ IDEA works correctly: https://github.com/carlrobertoh/CodeGPT/issues/674
Author
Owner

@tjbck commented on GitHub (Aug 27, 2024):

Should be fixed on dev, testing wanted here!

<!-- gh-comment-id:2312384383 --> @tjbck commented on GitHub (Aug 27, 2024): Should be fixed on dev, testing wanted here!
Author
Owner

@unixshaman commented on GitHub (Aug 28, 2024):

Hello @tjbck !
Thank you very much for working on the feature.
I saw commit 689b05a73d, and it into release https://github.com/open-webui/open-webui/releases/tag/v0.3.16 , if I'm not mistaken.
I update my service and check this again, but result is same, no header in response.

<!-- gh-comment-id:2315129209 --> @unixshaman commented on GitHub (Aug 28, 2024): Hello @tjbck ! Thank you very much for working on the feature. I saw commit https://github.com/open-webui/open-webui/commit/689b05a73df2f12858d798ce90cdbde500cc0747, and it into release https://github.com/open-webui/open-webui/releases/tag/v0.3.16 , if I'm not mistaken. I update my service and check this again, but result is same, no header in response.
Author
Owner

@Peter-De-Ath commented on GitHub (Sep 5, 2024):

It looks okay to me

> POST /ollama/api/chat HTTP/1.1
> Host: 192.168.0.39:3000
> User-Agent: curl/8.5.0
> Accept: */*
> Authorization: Bearer sk-***
> Content-Type: application/json
> Content-Length: 125
> 
< HTTP/1.1 200 OK
< date: Thu, 05 Sep 2024 21:26:03 GMT
< server: uvicorn
< content-type: application/x-ndjson
< date: Thu, 05 Sep 2024 21:26:08 GMT
< transfer-encoding: chunked
< x-process-time: 4
< 
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.252662827Z","message":{"role":"assistant","content":"The"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.354145735Z","message":{"role":"assistant","content":" reason"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.453732267Z","message":{"role":"assistant","content":" the"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.553543444Z","message":{"role":"assistant","content":" sky"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.652179514Z","message":{"role":"assistant","content":" appears"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.752044153Z","message":{"role":"assistant","content":" pre"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.851070429Z","message":{"role":"assistant","content":"domin"},"done":false}
{"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.950933914Z","message":{"role":"assistant","content":"antly"},"done":false}
<!-- gh-comment-id:2332660826 --> @Peter-De-Ath commented on GitHub (Sep 5, 2024): It looks okay to me ``` > POST /ollama/api/chat HTTP/1.1 > Host: 192.168.0.39:3000 > User-Agent: curl/8.5.0 > Accept: */* > Authorization: Bearer sk-*** > Content-Type: application/json > Content-Length: 125 > < HTTP/1.1 200 OK < date: Thu, 05 Sep 2024 21:26:03 GMT < server: uvicorn < content-type: application/x-ndjson < date: Thu, 05 Sep 2024 21:26:08 GMT < transfer-encoding: chunked < x-process-time: 4 < {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.252662827Z","message":{"role":"assistant","content":"The"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.354145735Z","message":{"role":"assistant","content":" reason"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.453732267Z","message":{"role":"assistant","content":" the"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.553543444Z","message":{"role":"assistant","content":" sky"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.652179514Z","message":{"role":"assistant","content":" appears"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.752044153Z","message":{"role":"assistant","content":" pre"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.851070429Z","message":{"role":"assistant","content":"domin"},"done":false} {"model":"phi3.5:latest","created_at":"2024-09-05T21:26:08.950933914Z","message":{"role":"assistant","content":"antly"},"done":false} ```
Author
Owner

@unixshaman commented on GitHub (Sep 6, 2024):

Yes, now it's works! Many many thanks!

<!-- gh-comment-id:2333337990 --> @unixshaman commented on GitHub (Sep 6, 2024): Yes, now it's works! Many many thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#117096