mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-08 02:01:07 -05:00
issue: Chat metadata missing with openai compliant backends #4262
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tylerwmarrs on GitHub (Mar 5, 2025).
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.5.7
Ollama Version (if applicable)
No response
Operating System
Ubuntu 22.04
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
When creating a custom OpenAI compliant backend the chat_id and possibly other metadata should be handed off to the compliant API. This ensures that the chat session remains in context instead of a new chat session per prompt.
Actual Behavior
In the open-webui backend code all metadata is removed from the backend request to the OpenAI compliant API.
incoming form_data:
https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L577
metadata is popped from payload removing it from later request:
https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L587
request is made to API without metadata:
https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L684
Steps to Reproduce
This is a code issue.
Logs & Screenshots
This is a code issue.
Additional Information
My team worked on an AWS Bedrock Agent model and interfaced with Open WebUI based on the AWS Bedrock Gateway code:
https://github.com/aws-samples/bedrock-access-gateway
While that source does not completely handle agents, we leveraged it as a starting point to make a compatible backend. In the source code above they always generate a new session instead of leveraging an existing chat_id. Adding the chat_id will make the user experience better.
@Classic298 commented on GitHub (Mar 5, 2025):
You need to call the chat_completed() endpoint (or something like that, i forgot the actual endpoint name, but it is something with 'complet') -> this will create a chat for the respective user and user's API key in OpenWebUI.
But when using the API, you are responsible on your own to handle the 'chat' and 'chat history' and so forth.
A simple completion request to the AI is just that. A completion based on what you send to the AI.
Whenever you send a completion request YOU need to send the entire chat history!
LLMs are stateless, and OpenWebUI does exactly what it needs to do. Which is completions, if you call the completions endpoint.
Either handle the chat and chat history yourself or use the completed endpoint to then create a chat within OpenWebUI itself - you'd then use OpenWebUI to handle the chat history.
Either you provide an explanation of what you are doing and what you want to do or it will be hard to help you with your specific issue.
I do not think this is a code issue. Please first tell the people what you are trying to do and what steps you are doing and what you expect to happen.
What API endpoint(s) are you using? Are you creating a chat in OpenWebUI via the API? Yes or no? Without steps to reproduce, it is impossible to tell.
Edit: The function you need to call is called chat_completed() - the API endpoint for it is /api/chat/completed - Assuming I understood correctly what you want to do.
@tjbck commented on GitHub (Mar 5, 2025):
You should use Functions for this