Happy to provide whatever might be desired, but I think the issue is clearly described :)
Originally created by @dguembel-itomig on GitHub (Oct 28, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/6514
---
## Installation Method
Docker
## Environment
- **Open WebUI Version:** v0.3.35
- **Ollama (if applicable):** 0.3.14
- **Operating System:** Ubuntu 22.04.5 LTS
- **Browser (if applicable):** (does not matter here)
**Confirmation:**
- [X] I have read and followed all the instructions provided in the README.md.
- [X] I am on the latest version of both Open WebUI and Ollama.
- [X] I have included the browser console logs.
- [X] I have included the Docker container logs.
- [X] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.
## Expected Behavior:
The follwing JSON is a valid request to the OpenAI API, with the `content" being an array. This is valid as per the OpenAI API doc: https://platform.openai.com/docs/api-reference/chat/create and even supported according to ollama: https://github.com/ollama/ollama/blob/main/docs/openai.md ("Supported request fields": "Array of content parts")
`{
"top_p": 1,
"frequency_penalty": 0,
"messages": [
{
"role": "system",
"content": "Du bist ein hilfreicher Assistent."
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "Wer ist Emmanuel Macron"
}
]
}
],
"temperature": 1,
"presence_penalty": 0,
"stream": false,
"model": "llama3.2:latest"
}`
Changing the request to `content` being plain text (not an array) as follows returns a valid response from the server:
`{
"top_p": 1,
"frequency_penalty": 0,
"messages": [
{
"role": "system",
"content": "Du bist ein hilfreicher Assistent."
},
{
"role": "user",
"content": "Wer ist Emmanuel Macron"
}
],
"temperature": 1,
"presence_penalty": 0,
"stream": false,
"model": "llama3.2:latest"
}`
## Actual Behavior:
Crash with error 500.
## Description
The OpenAI API allows for the "content" element to be either a string/text or an array[1]. If the latter is used, it crashes open-webui.
[1] https://platform.openai.com/docs/api-reference/chat/create
## Reproduction Details
**Steps to Reproduce:**
Send HTTP request to `https://<your-webui-instance>/v1/chat/completions` as detailed before. Observe error 500.
## Logs and Screenshots
**Browser Console Logs:**
N/A
**Docker Container Logs:**
Open-WebUI docker container log entry:
`INFO: 172.19.0.1:49182 - "POST /ollama/v1/chat/completions HTTP/1.0" 500 Internal Server Error `
Ollama docker image logs show nothing, request seems not to reach it.
**Screenshots/Screen Recordings (if applicable):**
N/A
## Additional Information
Happy to provide whatever might be desired, but I think the issue is clearly described :)
@dguembel-itomig commented on GitHub (Oct 29, 2024):
I had a look at the code. I think all is missing would be
# If content is a single dict, convert it to a list
if isinstance(content, dict):
content = [content]
In Line 108 of /backend/open_webui/utils/payload.py
That should ensure the code is always working with a list even if the content has only one element (one-element list).
Does that sound about right?-)
<!-- gh-comment-id:2443270692 -->
@dguembel-itomig commented on GitHub (Oct 29, 2024):
I had a look at the code. I think all is missing would be
```
# If content is a single dict, convert it to a list
if isinstance(content, dict):
content = [content]
```
In Line 108 of `/backend/open_webui/utils/payload.py`
That should ensure the code is always working with a list even if the `content` has only one element (one-element list).
Does that sound about right?-)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @dguembel-itomig on GitHub (Oct 28, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/6514
Installation Method
Docker
Environment
Open WebUI Version: v0.3.35
Ollama (if applicable): 0.3.14
Operating System: Ubuntu 22.04.5 LTS
Browser (if applicable): (does not matter here)
Confirmation:
Expected Behavior:
The follwing JSON is a valid request to the OpenAI API, with the `content" being an array. This is valid as per the OpenAI API doc: https://platform.openai.com/docs/api-reference/chat/create and even supported according to ollama: https://github.com/ollama/ollama/blob/main/docs/openai.md ("Supported request fields": "Array of content parts")
{ "top_p": 1, "frequency_penalty": 0, "messages": [ { "role": "system", "content": "Du bist ein hilfreicher Assistent." }, { "role": "user", "content": [ { "type": "text", "text": "Wer ist Emmanuel Macron" } ] } ], "temperature": 1, "presence_penalty": 0, "stream": false, "model": "llama3.2:latest" }Changing the request to
contentbeing plain text (not an array) as follows returns a valid response from the server:{ "top_p": 1, "frequency_penalty": 0, "messages": [ { "role": "system", "content": "Du bist ein hilfreicher Assistent." }, { "role": "user", "content": "Wer ist Emmanuel Macron" } ], "temperature": 1, "presence_penalty": 0, "stream": false, "model": "llama3.2:latest" }Actual Behavior:
Crash with error 500.
Description
The OpenAI API allows for the "content" element to be either a string/text or an array[1]. If the latter is used, it crashes open-webui.
[1] https://platform.openai.com/docs/api-reference/chat/create
Reproduction Details
Steps to Reproduce:
Send HTTP request to
https://<your-webui-instance>/v1/chat/completionsas detailed before. Observe error 500.Logs and Screenshots
Browser Console Logs:
N/A
Docker Container Logs:
Open-WebUI docker container log entry:
INFO: 172.19.0.1:49182 - "POST /ollama/v1/chat/completions HTTP/1.0" 500 Internal Server ErrorOllama docker image logs show nothing, request seems not to reach it.
Screenshots/Screen Recordings (if applicable):
N/A
Additional Information
Happy to provide whatever might be desired, but I think the issue is clearly described :)
@tjbck commented on GitHub (Oct 28, 2024):
PR welcome!
@dguembel-itomig commented on GitHub (Oct 29, 2024):
I had a look at the code. I think all is missing would be
In Line 108 of
/backend/open_webui/utils/payload.pyThat should ensure the code is always working with a list even if the
contenthas only one element (one-element list).Does that sound about right?-)
@tjbck commented on GitHub (Nov 3, 2024):
Fixed on dev!