mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
fix(prompt): preserve non-ASCII characters in tool specs serialization (#19942)
Use json.dumps with ensure_ascii=False to avoid converting Chinese descriptions into Unicode escape sequences. This makes logs easier to read and significantly improves LLM tool selection accuracy (from ~48% to ~67%) by preserving the original natural language context.
This commit is contained in:
@@ -345,7 +345,7 @@ async def chat_completion_tools_handler(
|
|||||||
sources = []
|
sources = []
|
||||||
|
|
||||||
specs = [tool["spec"] for tool in tools.values()]
|
specs = [tool["spec"] for tool in tools.values()]
|
||||||
tools_specs = json.dumps(specs)
|
tools_specs = json.dumps(specs, ensure_ascii=False)
|
||||||
|
|
||||||
if request.app.state.config.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE != "":
|
if request.app.state.config.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE != "":
|
||||||
template = request.app.state.config.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
|
template = request.app.state.config.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
|
||||||
|
|||||||
Reference in New Issue
Block a user