issue: API Requests involving tools fail with 400 due to validation error #4743

Closed
opened 2025-11-11 16:01:52 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @CooperCorona on GitHub (Apr 6, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.5.16

Ollama Version (if applicable)

0.6.1

Operating System

Ubuntu 20.04.6

Browser (if applicable)

Chrome Version 134.0.6998.166

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using 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 listed steps to reproduce the bug in detail.

Expected Behavior

OpenWebUI will successfully interpret API requests (via the Ollama endpoint) that involve tool calling, specifically the Goose agent (see also the bug I filed against Goose; I'm not sure what program the bug is in).

Actual Behavior

OpenWebUI fails with Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict]

Steps to Reproduce

  1. Install Goose
  2. Run goose configure. Select OpenAI and
    a. Configure the host to be your OpenWebUI instance.
    b. Configure the base path to be ollama/v1/chat/completions.
    c. Select qwen2.5-coder:1.5b as the model.
  3. Run goose session
  4. Perform any command. Either immediately or after one or two commands, Goose will start failing due to 400 bad request errors. Every subsequent command will cause the same error. The only fix is to start a new session.

Logs & Screenshots

Docker logs:

[GIN] 2025/04/06 - 17:13:18 | 200 |  110.334241ms |       127.0.0.1 | POST     "/v1/chat/completions"
INFO:     50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 200 OK
time=2025-04-06T17:13:18.192Z level=WARN source=runner.go:129 msg="truncating input prompt" limit=2048 prompt=2171 keep=4 new=2048
[GIN] 2025/04/06 - 17:13:18 | 200 |  391.436266ms |       127.0.0.1 | POST     "/v1/chat/completions"
INFO:     50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 200 OK
ERROR [open_webui.routers.ollama] 1 validation error for OpenAIChatCompletionForm
messages.2.content
  Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missing
Traceback (most recent call last):
  File "/app/backend/open_webui/routers/ollama.py", line 1179, in generate_openai_chat_completion
    completion_form = OpenAIChatCompletionForm(**form_data)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for OpenAIChatCompletionForm
messages.2.content
  Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missing
INFO:     50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 400 Bad Request

Additional Information

When I use Goose via Ollama directly (on the same machine that Goose is running, as opposed to the different machine on which OpenWebUI is running, with its own instance of Ollama), everything works. This is why I believe it may be a bug in OpenWebUI, not Goose.

Originally created by @CooperCorona on GitHub (Apr 6, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.5.16 ### Ollama Version (if applicable) 0.6.1 ### Operating System Ubuntu 20.04.6 ### Browser (if applicable) Chrome Version 134.0.6998.166 ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using 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 listed steps to reproduce the bug in detail. ### Expected Behavior OpenWebUI will successfully interpret API requests (via the Ollama endpoint) that involve tool calling, specifically the [Goose agent](https://github.com/block/goose) (see also the [bug I filed against Goose](https://github.com/block/goose/issues/2053); I'm not sure what program the bug is in). ### Actual Behavior OpenWebUI fails with `Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict]` ### Steps to Reproduce 1. [Install Goose](https://block.github.io/goose/docs/quickstart) 2. Run `goose configure`. Select OpenAI and a. Configure the host to be your OpenWebUI instance. b. Configure the base path to be `ollama/v1/chat/completions`. c. Select `qwen2.5-coder:1.5b` as the model. 3. Run `goose session` 4. Perform any command. Either immediately or after one or two commands, Goose will start failing due to 400 bad request errors. Every subsequent command will cause the same error. The only fix is to start a new session. ### Logs & Screenshots Docker logs: ``` [GIN] 2025/04/06 - 17:13:18 | 200 | 110.334241ms | 127.0.0.1 | POST "/v1/chat/completions" INFO: 50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 200 OK time=2025-04-06T17:13:18.192Z level=WARN source=runner.go:129 msg="truncating input prompt" limit=2048 prompt=2171 keep=4 new=2048 [GIN] 2025/04/06 - 17:13:18 | 200 | 391.436266ms | 127.0.0.1 | POST "/v1/chat/completions" INFO: 50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 200 OK ERROR [open_webui.routers.ollama] 1 validation error for OpenAIChatCompletionForm messages.2.content Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/missing Traceback (most recent call last): File "/app/backend/open_webui/routers/ollama.py", line 1179, in generate_openai_chat_completion completion_form = OpenAIChatCompletionForm(**form_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 214, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 1 validation error for OpenAIChatCompletionForm messages.2.content Field required [type=missing, input_value={'role': 'assistant', 'to...', 'type': 'function'}]}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/missing INFO: 50.209.174.90:0 - "POST /ollama/v1/chat/completions HTTP/1.0" 400 Bad Request ``` ### Additional Information When I use Goose via Ollama directly (on the same machine that Goose is running, as opposed to the different machine on which OpenWebUI is running, with its own instance of Ollama), everything works. This is why I believe it may be a bug in OpenWebUI, not Goose.
GiteaMirror added the bug label 2025-11-11 16:01:52 -06:00
Author
Owner

@tjbck commented on GitHub (Apr 6, 2025):

Ollama endpoint will only support Ollama, please use OpenAI connections for other inference services.

@tjbck commented on GitHub (Apr 6, 2025): Ollama endpoint will only support Ollama, please use OpenAI connections for other inference services.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#4743