[GH-ISSUE #5704] Form structure for /ollama/api/embed is incorrect #68697

Closed
opened 2026-05-13 01:03:08 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Garethp on GitHub (Sep 25, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/5704

Bug Report

Installation Method

Installed with the main docker tag

Environment

  • Open WebUI Version: v0.3.29
  • Ollama (if applicable): v0.3.12
  • Operating System: Ubuntu

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 Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

When posting against /ollama/api/embed, I should be able to pass in the chunks to be embedded through the input field.

Actual Behavior:

Attempting to do the above will result in the response

{"detail":[{"type":"missing","loc":["body","prompt"],"msg":"Field required","input":{"model":"nomic-embed-text","input":"test"}}]}

Description

Bug Summary:
The GenerateEmbeddingsForm for Ollama is being used for both /api/embed and /api/embeddings, but those endpoints take different JSON structures. GenerateEmbeddingsForm requires a prompt field, however the typings in Ollama expect the chunks to be in the input field instead.

There should be a separate GenerateEmbedForm and GenerateEmbeddingsForm to match the fact that Ollama has a separate EmbedRequest and EmbeddingRequest structure.

Reproduction Details

Steps to Reproduce:
The following will produce an error:

curl -X POST https://open-web-ui/ollama/api/embed \
	-H 'accept: application/json' \
	-H 'Authorization: Bearer jwt-token' \
	-H 'Content-Type: application/json' \
	-d '{
		"model": "nomic-embed-text",
		"input": "test"
	}'

Whereas the following will return an empty response instead of the embeddings

curl -X POST https://open-web-ui/ollama/api/embed \
	-H 'accept: application/json' \
	-H 'Authorization: Bearer jwt-token' \
	-H 'Content-Type: application/json' \
	-d '{
		"model": "nomic-embed-text",
		"prompt": "test"
	}'

Logs and Screenshots

Docker Container Logs:
When posting with input, the only relevant line in the Docker logs is as follows:

INFO:     10.64.84.86:0 - "POST /ollama/api/embed HTTP/1.1" 422 Unprocessable Entity

Additional Information

As you can see, I've linked to code in Open WebUI's dev branch to show that this error is present in dev

Originally created by @Garethp on GitHub (Sep 25, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/5704 # Bug Report ## Installation Method Installed with the `main` docker tag ## Environment - **Open WebUI Version:** v0.3.29 - **Ollama (if applicable):** v0.3.12 - **Operating System:** Ubuntu **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. - [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: When posting against `/ollama/api/embed`, I should be able to pass in the chunks to be embedded through the `input` field. ## Actual Behavior: Attempting to do the above will result in the response ```json {"detail":[{"type":"missing","loc":["body","prompt"],"msg":"Field required","input":{"model":"nomic-embed-text","input":"test"}}]} ``` ## Description **Bug Summary:** The [`GenerateEmbeddingsForm`](https://github.com/open-webui/open-webui/blob/dev/backend/open_webui/apps/ollama/main.py#L539) for Ollama is being used for both `/api/embed` and `/api/embeddings`, but those endpoints take different JSON structures. `GenerateEmbeddingsForm` requires a `prompt` field, however the [typings in Ollama](https://github.com/ollama/ollama/blob/main/api/types.go#L253) expect the chunks to be in the `input` field instead. There should be a separate `GenerateEmbedForm` and `GenerateEmbeddingsForm` to match the fact that Ollama has a separate [`EmbedRequest`](https://github.com/ollama/ollama/blob/main/api/types.go#L248) and [`EmbeddingRequest`](https://github.com/ollama/ollama/blob/main/api/types.go#L276) structure. ## Reproduction Details **Steps to Reproduce:** The following will produce an error: ```sh curl -X POST https://open-web-ui/ollama/api/embed \ -H 'accept: application/json' \ -H 'Authorization: Bearer jwt-token' \ -H 'Content-Type: application/json' \ -d '{ "model": "nomic-embed-text", "input": "test" }' ``` Whereas the following will return an empty response instead of the embeddings ```sh curl -X POST https://open-web-ui/ollama/api/embed \ -H 'accept: application/json' \ -H 'Authorization: Bearer jwt-token' \ -H 'Content-Type: application/json' \ -d '{ "model": "nomic-embed-text", "prompt": "test" }' ``` ## Logs and Screenshots **Docker Container Logs:** When posting with `input`, the only relevant line in the Docker logs is as follows: ``` INFO: 10.64.84.86:0 - "POST /ollama/api/embed HTTP/1.1" 422 Unprocessable Entity ``` ## Additional Information As you can see, I've linked to code in Open WebUI's dev branch to show that this error is present in dev
Author
Owner

@tjbck commented on GitHub (Sep 25, 2024):

Fixed in dev!

<!-- gh-comment-id:2375202541 --> @tjbck commented on GitHub (Sep 25, 2024): Fixed in dev!
Author
Owner

@Garethp commented on GitHub (Sep 26, 2024):

Thanks for the quick turnaround, but unfortunately it's still not fixed. If I try to run on 0.3.30

curl -X POST https://open-web-ui/ollama/api/embed \
	-H 'accept: application/json' \
	-H 'Authorization: Bearer jwt-token' \
	-H 'Content-Type: application/json' \
	-d '{
		"model": "nomic-embed-text",
		"input": "test"
	}'

I get the following error:

{"detail":[{"type":"missing","loc":["body","truncate"],"msg":"Field required","input":{"model":"nomic-embed-text","input":"test"}}]}%

Where as putting that same request against Ollama directly results in a successful response. I can see that you've made truncate optional in the GenerateEmbedForm but it doesn't appear to making that parameter optional.

<!-- gh-comment-id:2376591995 --> @Garethp commented on GitHub (Sep 26, 2024): Thanks for the quick turnaround, but unfortunately it's still not fixed. If I try to run on `0.3.30` ```sh curl -X POST https://open-web-ui/ollama/api/embed \ -H 'accept: application/json' \ -H 'Authorization: Bearer jwt-token' \ -H 'Content-Type: application/json' \ -d '{ "model": "nomic-embed-text", "input": "test" }' ``` I get the following error: ``` {"detail":[{"type":"missing","loc":["body","truncate"],"msg":"Field required","input":{"model":"nomic-embed-text","input":"test"}}]}% ``` Where as putting that same request against Ollama directly results in a successful response. I can see that you've made `truncate` optional in the `GenerateEmbedForm` but it doesn't appear to making that parameter optional.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#68697