Originally created by @Seniorsimo on GitHub (Feb 10, 2025).
Bug Report
Installation Method
Docker
Environment
Open WebUI Version: v0.5.10
Ollama (if applicable): 0.5.7-0-ga420a45-dirty
Operating System: Windows 11
Confirmation:
I have read and followed all the instructions provided in the README.md.
I am on the latest version of both Open WebUI and Ollama.
I have included the browser console logs.
I have included the Docker container logs.
I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.
Expected Behavior:
When calling the Open-webUI API with tools that need arguments and an expected tool call is expected, the model answer with a tool call with arguments
Actual Behavior:
The tool call answered has the arguments not correctly serialized
Description
Bug Summary:
The JSON representazion of the arguments in the tool beign called seem a standard python representation of a dictionary and not a full serialized json.
Originally created by @Seniorsimo on GitHub (Feb 10, 2025).
# Bug Report
## Installation Method
Docker
## Environment
- **Open WebUI Version:** v0.5.10
- **Ollama (if applicable):** 0.5.7-0-ga420a45-dirty
- **Operating System:** Windows 11
**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:
When calling the Open-webUI API with tools that need arguments and an expected tool call is expected, the model answer with a tool call with arguments
## Actual Behavior:
The tool call answered has the arguments not correctly serialized
## Description
**Bug Summary:**
The JSON representazion of the arguments in the tool beign called seem a standard python representation of a dictionary and not a full serialized json.
A sample tool call returned by Open-webUI
```json
"tool_calls": [
{
"index": 0,
"id": "call_df2ee15e-e8ee-4709-b179-e0f2df19fa91",
"type": "function",
"function": {
"name": "weather",
"arguments": "{'city': 'New York'}"
}
}
]
```
A sample tool call returned by OpenAI
```json
"tool_calls":[
{
"index":0,
"id":"call_Gs5yB8tdaYWth1RFMbeIEVDU",
"type":"function",
"function":{
"name":"weather",
"arguments":"{\"city\":\"New York\"}"
}
}
]
```
In the Open-webUI the arguments is not a well-formed JSON: `'` should be replaced by `\"`.
## Reproduction Details
**Steps to Reproduce:**
*Open-webui*
Request
```bash
curl -XPOST -H 'Authorization: Bearer sk-YOUR-API-KEY' -H "Content-type: application/json" -d '{
"messages": [
{
"content": "You are a helpful assistant",
"role": "system"
}, {
"content": "It feels so cold today in NY.",
"role": "user"
}
],
"model": "pc.qwen2.5:14b",
"n": 1,
"stream": true,
"temperature": 0.7,
"tools": [
{
"type": "function",
"function": {
"name": "weather",
"description": "Retrieve the weather for a city.",
"parameters": {
"properties": {
"city": {
"description": "The city to inspect current weather",
"type": "string"
}
},
"required": ["city"],
"type": "object"
}
}
}
]
}' 'http://localhost:8080/api/chat/completions'
```
Response
```json
{
"id": "qwen2.5:14b-92f77e7e-baa5-454a-aa84-4a8647ef3044",
"created": 1739210359,
"model": "qwen2.5:14b",
"choices": [
{
"index": 0,
"logprobs": null,
"finish_reason": null,
"delta": {
"tool_calls": [
{
"index": 0,
"id": "call_df2ee15e-e8ee-4709-b179-e0f2df19fa91",
"type": "function",
"function": {
"name": "weather",
"arguments": "{'city': 'New York'}"
}
}
]
}
}
],
"object": "chat.completion.chunk"
}
```
*OpenAI*
Request
```bash
curl -XPOST -H 'Authorization: Bearer sk-YOUR-API-KEY' -H "Content-type: application/json" -d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"content": "You are a helpful assistant",
"role": "system"
}, {
"content": "It feels so cold today in NY.",
"role": "user"
}
],
"stream": true,
"temperature": 0.7,
"tools": [
{
"type": "function",
"function": {
"name": "weather",
"description": "Retrieve the weather for a city.",
"parameters": {
"properties": {
"city": {
"description": "The city to inspect current weather",
"type": "string"
}
},
"required": ["city"],
"type": "object"
}
}
}
]
}' 'https://api.openai.com/v1/chat/completions'
```
Response
```json
{
"id":"chatcmpl-AzA1wy4pXHFTtPGVjcZ4F04XUAfK0",
"object":"chat.completion.chunk",
"created":1739139928,
"model":"gpt-3.5-turbo-0125",
"service_tier":"default",
"system_fingerprint":null,
"choices":[
{
"index":0,
"delta":{
"role":"assistant",
"content":null,
"tool_calls":[
{
"index":0,
"id":"call_Gs5yB8tdaYWth1RFMbeIEVDU",
"type":"function",
"function":{
"name":"weather",
"arguments":"{\"city\":\"New York\"}"
}
}
]
},
"logprobs":null,
"finish_reason":null
}
]
}
```
## Logs and Screenshots
**Browser Console Logs:**
not applicable
**Docker Container Logs:**
INFO: 10.88.5.1:0 - "POST /api/chat/completions HTTP/1.1" 200 OK
**Screenshots/Screen Recordings (if applicable):**
not applicable
## Additional Information
I have tried to solve this locally in a fork and seems working now.
Just replaced tis line:
```python
"arguments": f"{tool_call.get('function', {}).get('arguments', {})}",
```
with this one:
```python
"arguments": json.dumps(tool_call.get('function', {}).get('arguments', {})),
```
The related commit:
https://github.com/open-webui/open-webui/commit/2c04be429a720b6d4921c73ef944fa4067cabad1
Let me know if some other info is needed.
Great work !!!
How could it be model-dependent? I've tried multiple models:
qwen2.5:14b (the one I posted)
llama3.2:latest
Even gpt-3.5-tbo using OpenWebUI as a proxy
In all cases, the results were identical.
From the code in my bug report, you can see that the current implementation is printing a dictionary instead of properly JSON serializing it. The method in question is called "ollama_to_openai," which suggests its purpose should be to convert Ollama responses into OpenAI-compatible standards.
If the API being exposed must be compatible with OpenAI, shouldn't I expect consistent results regardless of the model used? Additionally, even if a different model is employed, shouldn’t its response be converted to adhere to the OpenAI standard?
This fix literally 10 seconds to implement:
@Seniorsimo commented on GitHub (Feb 10, 2025):
How could it be model-dependent? I've tried multiple models:
qwen2.5:14b (the one I posted)
llama3.2:latest
Even gpt-3.5-tbo using OpenWebUI as a proxy
In all cases, the results were identical.
From the code in my bug report, you can see that the current implementation is printing a dictionary instead of properly JSON serializing it. The method in question is called "ollama_to_openai," which suggests its purpose should be to convert Ollama responses into OpenAI-compatible standards.
If the API being exposed must be compatible with OpenAI, shouldn't I expect consistent results regardless of the model used? Additionally, even if a different model is employed, shouldn’t its response be converted to adhere to the OpenAI standard?
This fix literally 10 seconds to implement:
I confirm that I have experienced the same bug and that the suggested fix worked for me!
It's just a "parsing" bug, not a model problem.
Using <json.dumps> instead of a simple string f“” can easily solve the bug.
Thanks @Seniorsimo for the solution.
@gmammolo commented on GitHub (Feb 10, 2025):
Hi @tjbck,
I confirm that I have experienced the same bug and that the suggested fix worked for me!
It's just a "parsing" bug, not a model problem.
Using <json.dumps> instead of a simple string f“” can easily solve the bug.
Thanks @Seniorsimo for the solution.
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 @Seniorsimo on GitHub (Feb 10, 2025).
Bug Report
Installation Method
Docker
Environment
Open WebUI Version: v0.5.10
Ollama (if applicable): 0.5.7-0-ga420a45-dirty
Operating System: Windows 11
Confirmation:
Expected Behavior:
When calling the Open-webUI API with tools that need arguments and an expected tool call is expected, the model answer with a tool call with arguments
Actual Behavior:
The tool call answered has the arguments not correctly serialized
Description
Bug Summary:
The JSON representazion of the arguments in the tool beign called seem a standard python representation of a dictionary and not a full serialized json.
A sample tool call returned by Open-webUI
A sample tool call returned by OpenAI
In the Open-webUI the arguments is not a well-formed JSON:
'should be replaced by\".Reproduction Details
Steps to Reproduce:
Open-webui
Request
Response
OpenAI
Request
Response
Logs and Screenshots
Browser Console Logs:
not applicable
Docker Container Logs:
INFO: 10.88.5.1:0 - "POST /api/chat/completions HTTP/1.1" 200 OK
Screenshots/Screen Recordings (if applicable):
not applicable
Additional Information
I have tried to solve this locally in a fork and seems working now.
Just replaced tis line:
with this one:
The related commit:
https://github.com/open-webui/open-webui/commit/2c04be429a720b6d4921c73ef944fa4067cabad1
Let me know if some other info is needed.
Great work !!!
@tjbck commented on GitHub (Feb 10, 2025):
This is model dependent and out of scope of Open WebUI.
@Seniorsimo commented on GitHub (Feb 10, 2025):
How could it be model-dependent? I've tried multiple models:
qwen2.5:14b (the one I posted)
llama3.2:latest
Even gpt-3.5-tbo using OpenWebUI as a proxy
In all cases, the results were identical.
From the code in my bug report, you can see that the current implementation is printing a dictionary instead of properly JSON serializing it. The method in question is called "ollama_to_openai," which suggests its purpose should be to convert Ollama responses into OpenAI-compatible standards.
If the API being exposed must be compatible with OpenAI, shouldn't I expect consistent results regardless of the model used? Additionally, even if a different model is employed, shouldn’t its response be converted to adhere to the OpenAI standard?
This fix literally 10 seconds to implement:
@gmammolo commented on GitHub (Feb 10, 2025):
Hi @tjbck,
I confirm that I have experienced the same bug and that the suggested fix worked for me!
It's just a "parsing" bug, not a model problem.
Using <json.dumps> instead of a simple string f“” can easily solve the bug.
Thanks @Seniorsimo for the solution.
@tjbck commented on GitHub (Feb 10, 2025):
Addressed with
0f12c4d14f, Misread your issue post!