JLeine / open-webui

This is a repo for open-webui extensions such as tools etc
MIT License
2 stars 0 forks source link

Unsupported JSON schema type: optional #8

Open codingstube opened 2 weeks ago

codingstube commented 2 weeks ago

Hi,

thanks for your cool Tool for Open-Webui. I've tried to use it, but it starts always with the following error and I did not receive any documents. URL and Token is set.

Thanks for your help. I use llama3.1 as Model.

DEBUG [main] tool_ids=['paperless'] ERROR [main] Unsupported JSON schema type: optional Traceback (most recent call last): File "/app/backend/main.py", line 570, 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 name: json_schema_to_pydantic_field(name, prop, schema.get("required", [])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydanticfield type = json_schema_to_pydantic_type(json_schema) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantictype raise ValueError(f"Unsupported JSON schema type: {type}") ValueError: Unsupported JSON schema type: optional

oschmidteu commented 2 weeks ago

Hey Jonas,

thank you for your tool. I have to same problem as @codingstube

2024-08-28T08:00:08.989101430Z INFO:     172.17.0.1:46008 - "POST /api/chat/completions HTTP/1.1" 200 OK
2024-08-28T08:00:09.956506459Z User: {'id': '34e4a6a5-ff45-4782-bcb4-907d6fdea284', 'email': ', 'name': '', 'role': 'admin'}
2024-08-28T08:00:08.471470689Z ValueError: Unsupported JSON schema type: optional
2024-08-28T08:00:08.470959083Z   File "/app/backend/utils/schemas.py", line 21, in json_schema_to_model
2024-08-28T08:00:08.471219016Z   File "/app/backend/utils/schemas.py", line 45, in json_schema_to_pydantic_field
2024-08-28T08:00:08.470998184Z     field_definitions = {
2024-08-28T08:00:08.471041974Z                         ^
2024-08-28T08:00:08.471075954Z   File "/app/backend/utils/schemas.py", line 22, in <dictcomp>
2024-08-28T08:00:08.471182476Z           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-28T08:00:08.471269827Z     type_ = json_schema_to_pydantic_type(json_schema)
2024-08-28T08:00:08.471313077Z             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-28T08:00:08.471357078Z   File "/app/backend/utils/schemas.py", line 104, in json_schema_to_pydantic_type
2024-08-28T08:00:08.471413138Z     raise ValueError(f"Unsupported JSON schema type: {type_}")
2024-08-28T08:00:09.971175066Z INFO:     172.17.0.1:46008 - "POST /api/chat/completed HTTP/1.1" 200 OK
2024-08-28T08:00:08.471130835Z     name: json_schema_to_pydantic_field(name, prop, schema.get("required", []))
2024-08-28T08:00:08.470913883Z                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-28T08:00:08.470851852Z     "pydantic_model": json_schema_to_model(spec),
2024-08-28T08:00:08.470693080Z   File "/app/backend/utils/tools.py", line 75, in get_tools
2024-08-28T08:00:08.470657070Z             ^^^^^^^^^^
2024-08-28T08:00:08.470601029Z     tools = get_tools(
2024-08-28T08:00:08.470542248Z   File "/app/backend/main.py", line 377, in chat_completion_tools_handler
2024-08-28T08:00:08.470505498Z                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-28T08:00:08.470440107Z     body, flags = await chat_completion_tools_handler(body, user, extra_params)
2024-08-28T08:00:08.470354566Z   File "/app/backend/main.py", line 562, in dispatch
2024-08-28T08:00:08.470291205Z Traceback (most recent call last):
2024-08-28T08:00:08.470095773Z ERROR [main] Unsupported JSON schema type: optional

OpenWebUI Version: v0.3.16 Paperless NGX Version: [Paperless-ngx 2.11.6]

I don't think its modell relatet but just in case: I was using chatgpt-4o-latest