[GH-ISSUE #2447] [Bug] OpenWebUI fails to communicate with OpenAI-like local server when in chat #12886

Closed
opened 2026-04-19 19:43:47 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @AlyMobarak on GitHub (May 21, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/2447

Hey there! I love your tool so much already.. just had a tiny little problem that I'll work on fixing (but I don't know if I'll be able to). P.S. I can't find the template anywhere so I hope I've provided enough information.

Simply speaking, whenever the WebUI tries to get completion from the local OpenAI API server (hosted through LM Studio fyi), it sends over an empty assistant message. I get the following error on the UI,
WebUI Error

Screenshot 2024-05-21 at 11 51 19 AM

And on my local server, I get this:
Screenshot 2024-05-21 at 11 21 55 AM

Expected Behavior: only the user message is sent over to the API, and then when the completion is generated, it gets added to the history.

Actual behavior: the API receives an empty assistant message and can't generate a completion from there.

I confirm that I am on the latest version of OpenWebUI and LM Studio that follows the same exact API format as OpenAI.

After digging a bit into your code, I understand why you are creating this message and adding it to the history before the completion. I think it is to send over the ID of that message and update the message when the completion is done.

My initial thinking is that we could somehow prevent it from being sent over to the API with the simple check (though its still in messages to ensure it gets updated). I'll try to work on it and update you. Thank you for your helpful tool!!

References:
3355577bac/src/routes/(app)/c/%5Bid%5D/%2Bpage.svelte#L272-L286

Changes could be maybe done to solve this issue
3355577bac/src/routes/(app)/c/%5Bid%5D/%2Bpage.svelte#L609-L621

Originally created by @AlyMobarak on GitHub (May 21, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/2447 Hey there! I love your tool so much already.. just had a tiny little problem that I'll work on fixing (but I don't know if I'll be able to). P.S. I can't find the template anywhere so I hope I've provided enough information. Simply speaking, whenever the WebUI tries to get completion from the local OpenAI API server (hosted through LM Studio fyi), it sends over an empty assistant message. I get the following error on the UI, ![WebUI Error](https://github.com/open-webui/open-webui/assets/147055589/88747ca3-fe11-4f2c-8aeb-b6284ec5610d) ![Screenshot 2024-05-21 at 11 51 19 AM](https://github.com/open-webui/open-webui/assets/147055589/65fae7d1-24ec-4261-98c1-3a58e3c7ecc5) And on my local server, I get this: ![Screenshot 2024-05-21 at 11 21 55 AM](https://github.com/open-webui/open-webui/assets/147055589/b406c42c-ed90-4673-9ad3-84d7677ea6ff) Expected Behavior: only the user message is sent over to the API, and then when the completion is generated, it gets added to the history. Actual behavior: the API receives an empty assistant message and can't generate a completion from there. I confirm that I am on the latest version of OpenWebUI and LM Studio that follows the same exact API format as OpenAI. After digging a bit into your code, I understand why you are creating this message and adding it to the history before the completion. I think it is to send over the ID of that message and update the message when the completion is done. My initial thinking is that we could somehow prevent it from being sent over to the API with the simple check (though its still in messages to ensure it gets updated). I'll try to work on it and update you. Thank you for your helpful tool!! References: https://github.com/open-webui/open-webui/blob/3355577bac260d5f4ffb0d84a78bacd7be236c20/src/routes/(app)/c/%5Bid%5D/%2Bpage.svelte#L272-L286 Changes could be maybe done to solve this issue https://github.com/open-webui/open-webui/blob/3355577bac260d5f4ffb0d84a78bacd7be236c20/src/routes/(app)/c/%5Bid%5D/%2Bpage.svelte#L609-L621
Author
Owner

@AlyMobarak commented on GitHub (May 21, 2024):

Found a fix. I just literally added .filter((messages) => message.content != "") after filter((messages) => message) and it worked.

Screenshot 2024-05-21 at 1 06 46 PM

Working on a good PR rn.

<!-- gh-comment-id:2122262305 --> @AlyMobarak commented on GitHub (May 21, 2024): Found a fix. I just literally added .filter((messages) => message.content != "") after filter((messages) => message) and it worked. ![Screenshot 2024-05-21 at 1 06 46 PM](https://github.com/open-webui/open-webui/assets/147055589/1b07e753-5645-4838-aa77-6dc189dde1c1) Working on a good PR rn.
Author
Owner

@justinh-rahb commented on GitHub (May 21, 2024):

As usual with any new release, we often do some fixes afterwards that push direct to main and build new Docker images. If you haven't already done so as of 3hrs ago please try re-pulling again.

<!-- gh-comment-id:2122393302 --> @justinh-rahb commented on GitHub (May 21, 2024): As usual with any new release, we often do some fixes afterwards that push direct to `main` and build new Docker images. If you haven't already done so as of 3hrs ago please try re-pulling again.
Author
Owner

@AlyMobarak commented on GitHub (May 21, 2024):

I have just downloaded OpenWebUI like 1 hr prior to addressing this issue. It works now using my PR.. should I do anything else?

<!-- gh-comment-id:2122397325 --> @AlyMobarak commented on GitHub (May 21, 2024): I have just downloaded OpenWebUI like 1 hr prior to addressing this issue. It works now using my PR.. should I do anything else?
Author
Owner

@AlyMobarak commented on GitHub (May 21, 2024):

#2453 PR

<!-- gh-comment-id:2122399550 --> @AlyMobarak commented on GitHub (May 21, 2024): #2453 PR
Author
Owner

@tjbck commented on GitHub (May 21, 2024):

PR Merged! Thanks!

<!-- gh-comment-id:2123081620 --> @tjbck commented on GitHub (May 21, 2024): PR Merged! Thanks!
Author
Owner

@AlyMobarak commented on GitHub (May 21, 2024):

Thank you!

<!-- gh-comment-id:2123095468 --> @AlyMobarak commented on GitHub (May 21, 2024): Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#12886