[GH-ISSUE #4793] list parameters broken in tools #117044

Closed
opened 2026-05-20 18:45:36 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @gkns1 on GitHub (Aug 21, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4793

Bug Report

Installation Method

docker

Environment

Open WebUI v0.3.14

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:

Tools work as before.

Actual Behavior:

Tool errors out with list parameter type.

Description

Bug Summary:
This might be related to this file.
50d53c6f8d/backend/utils/schemas.py (L86)

Since updating to today's release, my tools stopped working. If the commit from 2 days ago is in the release, I'm guessing line 86 breaks list parameters in tools. changing "array" to "list" and restarting the backend fixes it for me.

Reproduction Details

Steps to Reproduce:
use "list" or "List[str]" as the type of a param in a tool.
e.g.

    async def send_data(
        self,
        filename: str,
        models: List[str],
        system: str,
        __event_emitter__: Callable[[dict], Awaitable[None]],)

Logs and Screenshots

ERROR [main] Unsupported JSON schema type: list
Traceback (most recent call last):
  File "/app/backend/main.py", line 564, in dispatch
    body, flags = await chat_completion_tools_handler(body, user, extra_params)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/main.py", line 393, in chat_completion_tools_handler
    tools = get_tools(webui_app, tool_ids, user, custom_params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/tools.py", line 75, in get_tools
    "pydantic_model": json_schema_to_model(spec),
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 21, in json_schema_to_model
    field_definitions = {
                        ^
  File "/app/backend/utils/schemas.py", line 22, in <dictcomp>
    name: json_schema_to_pydantic_field(name, prop, schema.get("required", []))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydantic_field
    type_ = json_schema_to_pydantic_type(json_schema)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantic_type
    raise ValueError(f"Unsupported JSON schema type: {type_}")
ValueError: Unsupported JSON schema type: list

Docker Container Logs:
See above

Additional Information

Originally created by @gkns1 on GitHub (Aug 21, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4793 # Bug Report ## Installation Method docker ## Environment Open WebUI v0.3.14 **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. - [ ] 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: Tools work as before. ## Actual Behavior: Tool errors out with list parameter type. ## Description **Bug Summary:** This might be related to this file. https://github.com/open-webui/open-webui/blame/50d53c6f8db70f8325663ac3b7142428dc8dec22/backend/utils/schemas.py#L86 Since updating to today's release, my tools stopped working. If the commit from 2 days ago is in the release, I'm guessing line 86 breaks list parameters in tools. changing "array" to "list" and restarting the backend fixes it for me. ## Reproduction Details **Steps to Reproduce:** use "list" or "List[str]" as the type of a param in a tool. e.g. ``` async def send_data( self, filename: str, models: List[str], system: str, __event_emitter__: Callable[[dict], Awaitable[None]],) ``` ## Logs and Screenshots ``` ERROR [main] Unsupported JSON schema type: list Traceback (most recent call last): File "/app/backend/main.py", line 564, in dispatch body, flags = await chat_completion_tools_handler(body, user, extra_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/main.py", line 393, in chat_completion_tools_handler tools = get_tools(webui_app, tool_ids, user, custom_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/tools.py", line 75, in get_tools "pydantic_model": json_schema_to_model(spec), ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 21, in json_schema_to_model field_definitions = { ^ File "/app/backend/utils/schemas.py", line 22, in <dictcomp> name: json_schema_to_pydantic_field(name, prop, schema.get("required", [])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydantic_field type_ = json_schema_to_pydantic_type(json_schema) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantic_type raise ValueError(f"Unsupported JSON schema type: {type_}") ValueError: Unsupported JSON schema type: list ``` **Docker Container Logs:** See above ## Additional Information
Author
Owner

@justinh-rahb commented on GitHub (Aug 21, 2024):

Duplicate:

<!-- gh-comment-id:2302859541 --> @justinh-rahb commented on GitHub (Aug 21, 2024): Duplicate: - #4791
Author
Owner

@gkns1 commented on GitHub (Aug 26, 2024):

@justinh-rahb Still getting the error after updating to v0.3.15 with watchtower. My modification makes it go away.

<!-- gh-comment-id:2310681383 --> @gkns1 commented on GitHub (Aug 26, 2024): @justinh-rahb Still getting the error after updating to v0.3.15 with watchtower. My modification makes it go away.
Author
Owner

@justinh-rahb commented on GitHub (Aug 26, 2024):

Tools are generally working on my end. Git commit hash e2b7296

Screenshot 2024-08-26 at 4 16 13 PM

<!-- gh-comment-id:2311008191 --> @justinh-rahb commented on GitHub (Aug 26, 2024): Tools are generally working on my end. Git commit hash [e2b7296](https://github.com/open-webui/open-webui/commit/e2b7296786053dfc77f6ae0205a1b195e05a712c) ![Screenshot 2024-08-26 at 4 16 13 PM](https://github.com/user-attachments/assets/b563e511-a815-40b8-9469-c87a371ef6be)
Author
Owner

@gkns1 commented on GitHub (Aug 27, 2024):

Watchtower updated to 0.3.16 today and the error came back. The tools where I don't use list/List[str] work fine.
I made a simple example that triggers the error for me.

What I didn't mention and it may matter - I'm testing this with 4o mini through litellm proxy connection.

"""
title: list test
author: KG
author_url: 
funding_url: 
version: 0.1.0
"""

from typing import List


class Tools:
    async def print_list(
        self,
        to_print: List[str],
    ) -> str:
        """
        Print back a list of strings.

        :param to_print: A list of words to print.
        :return: A list of words to return to the user.
        """
        return f"{to_print}"

prompt with the tool manually selected:
Print back a list of those strings: 1, 2, something, whatever
log:

ERROR [main] Unsupported JSON schema type: list
Traceback (most recent call last):
  File "/app/backend/main.py", line 562, in dispatch
    body, flags = await chat_completion_tools_handler(body, user, extra_params)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/main.py", line 377, in chat_completion_tools_handler
    tools = get_tools(
            ^^^^^^^^^^
  File "/app/backend/utils/tools.py", line 75, in get_tools
    "pydantic_model": json_schema_to_model(spec),
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 21, in json_schema_to_model
    field_definitions = {
                        ^
  File "/app/backend/utils/schemas.py", line 22, in <dictcomp>
    name: json_schema_to_pydantic_field(name, prop, schema.get("required", []))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydantic_field
    type_ = json_schema_to_pydantic_type(json_schema)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantic_type
    raise ValueError(f"Unsupported JSON schema type: {type_}")
ValueError: Unsupported JSON schema type: list

The log after modification, restart and using the same tool+prompt:

INFO  [main] tools={'print_list': {'toolkit_id': 'list_test', 'callable': <function apply_extra_params_to_tool_function.<locals>.new_function at 0x7f241716d1c0>, 'spec': {'name': 'print_list', 'description': 'Sends activity data from a specified file to an API.', 'parameters': {'type': 'object', 'properties': {'to_print': {'type': 'list', 'enum': "(<class 'str'>,)", 'description': 'A list of words to print.'}}, 'required': ['to_print']}}, 'pydantic_model': <class 'utils.schemas.print_list'>, 'file_handler': False, 'citation': False}}
INFO  [main] tools_function_calling_prompt='Tools: [{"name": "print_list", "description": "Sends activity data from a specified file to an API.", "parameters": {"type": "object", "properties": {"to_print": {"type": "list", "enum": "(<class \'str\'>,)", "description": "A list of words to print."}}, "required": ["to_print"]}}]\nIf a function tool doesn\'t match the query, return an empty string. Else, pick a function tool, fill in the parameters from the function tool\'s schema, and return it in the format { "name": "functionName", "parameters": { "key": "value" } }. Only pick a function if the user asks.  Only return the object. Do not return any other text.'

response
Screenshot 2024-08-27 at 16 04 08

edit: Worth mentioning maybe - I also have the context clip filter turned on globally. (from the community functions)

<!-- gh-comment-id:2313408739 --> @gkns1 commented on GitHub (Aug 27, 2024): Watchtower updated to 0.3.16 today and the error came back. The tools where I don't use list/List[str] work fine. I made a simple example that triggers the error for me. What I didn't mention and it may matter - I'm testing this with 4o mini through litellm proxy connection. ``` """ title: list test author: KG author_url: funding_url: version: 0.1.0 """ from typing import List class Tools: async def print_list( self, to_print: List[str], ) -> str: """ Print back a list of strings. :param to_print: A list of words to print. :return: A list of words to return to the user. """ return f"{to_print}" ``` prompt with the tool manually selected: `Print back a list of those strings: 1, 2, something, whatever` log: ``` ERROR [main] Unsupported JSON schema type: list Traceback (most recent call last): File "/app/backend/main.py", line 562, in dispatch body, flags = await chat_completion_tools_handler(body, user, extra_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/main.py", line 377, in chat_completion_tools_handler tools = get_tools( ^^^^^^^^^^ File "/app/backend/utils/tools.py", line 75, in get_tools "pydantic_model": json_schema_to_model(spec), ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 21, in json_schema_to_model field_definitions = { ^ File "/app/backend/utils/schemas.py", line 22, in <dictcomp> name: json_schema_to_pydantic_field(name, prop, schema.get("required", [])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydantic_field type_ = json_schema_to_pydantic_type(json_schema) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantic_type raise ValueError(f"Unsupported JSON schema type: {type_}") ValueError: Unsupported JSON schema type: list ``` The log after modification, restart and using the same tool+prompt: ``` INFO [main] tools={'print_list': {'toolkit_id': 'list_test', 'callable': <function apply_extra_params_to_tool_function.<locals>.new_function at 0x7f241716d1c0>, 'spec': {'name': 'print_list', 'description': 'Sends activity data from a specified file to an API.', 'parameters': {'type': 'object', 'properties': {'to_print': {'type': 'list', 'enum': "(<class 'str'>,)", 'description': 'A list of words to print.'}}, 'required': ['to_print']}}, 'pydantic_model': <class 'utils.schemas.print_list'>, 'file_handler': False, 'citation': False}} INFO [main] tools_function_calling_prompt='Tools: [{"name": "print_list", "description": "Sends activity data from a specified file to an API.", "parameters": {"type": "object", "properties": {"to_print": {"type": "list", "enum": "(<class \'str\'>,)", "description": "A list of words to print."}}, "required": ["to_print"]}}]\nIf a function tool doesn\'t match the query, return an empty string. Else, pick a function tool, fill in the parameters from the function tool\'s schema, and return it in the format { "name": "functionName", "parameters": { "key": "value" } }. Only pick a function if the user asks. Only return the object. Do not return any other text.' ``` response ![Screenshot 2024-08-27 at 16 04 08](https://github.com/user-attachments/assets/68d2a815-4084-438f-b954-6c73f3189a99) edit: Worth mentioning maybe - I also have the context clip filter turned on globally. (from the community functions)
Author
Owner

@robert-mcdermott commented on GitHub (Aug 27, 2024):

I'm having this exact error, my functions stopped working, running v0.3.15

<!-- gh-comment-id:2313672681 --> @robert-mcdermott commented on GitHub (Aug 27, 2024): I'm having this exact error, my functions stopped working, running v0.3.15
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#117044