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:
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
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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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
maindocker tagEnvironment
Confirmation:
Expected Behavior:
When posting against
/ollama/api/embed, I should be able to pass in the chunks to be embedded through theinputfield.Actual Behavior:
Attempting to do the above will result in the response
Description
Bug Summary:
The
GenerateEmbeddingsFormfor Ollama is being used for both/api/embedand/api/embeddings, but those endpoints take different JSON structures.GenerateEmbeddingsFormrequires apromptfield, however the typings in Ollama expect the chunks to be in theinputfield instead.There should be a separate
GenerateEmbedFormandGenerateEmbeddingsFormto match the fact that Ollama has a separateEmbedRequestandEmbeddingRequeststructure.Reproduction Details
Steps to Reproduce:
The following will produce an error:
Whereas the following will return an empty response instead of the embeddings
Logs and Screenshots
Docker Container Logs:
When posting with
input, the only relevant line in the Docker logs is as follows: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
@tjbck commented on GitHub (Sep 25, 2024):
Fixed in dev!
@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.30I get the following error:
Where as putting that same request against Ollama directly results in a successful response. I can see that you've made
truncateoptional in theGenerateEmbedFormbut it doesn't appear to making that parameter optional.