mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[GH-ISSUE #9768] API Tool arguments formatting issue #86379
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 @Seniorsimo on GitHub (Feb 10, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/9768
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:
2c04be429aLet 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!