mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[PR #22702] [CLOSED] fix: handle ollama embedding errors for bge-m3 and similar models #114132
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22702
Author: @mvanhorn
Created: 3/15/2026
Status: ❌ Closed
Base:
main← Head:osc/22671-ollama-rag-embedding-500📝 Commits (1)
f697266fix: handle ollama embedding response format for bge-m3📊 Changes
1 file changed (+30 additions, -4 deletions)
View changed files
📝
backend/open_webui/retrieval/utils.py(+30 -4)📄 Description
Summary
truncate: truein ollama/api/embedrequests to ensure input is truncated to fit the model's context length, preventing HTTP 500 errors with models like bge-m3 that have limited context windows (num_ctx=4096)raise_for_status()with error response body parsing in both sync and async ollama embedding functions, so the actual ollama error message is logged instead of a generic "500 Internal Server Error"Noneguards ingenerate_embeddingsto preventTypeError: 'NoneType' object is not subscriptablewhen an upstream embedding call fails and returnsNoneRoot cause
When using
RAG_EMBEDDING_ENGINE=ollamawithRAG_EMBEDDING_MODEL=bge-m3, ollama can return HTTP 500 if the input text exceeds the model's context length. While ollama's API documentstruncateas defaulting totrue, certain model/version combinations (bge-m3 on ollama 0.18.0) fail without it being explicitly set. The error was further obscured becauseraise_for_status()discarded ollama's error response body, and theNonereturn from the embedding function caused a cascadingTypeError.Test plan
RAG_EMBEDDING_ENGINE=ollamaandRAG_EMBEDDING_MODEL=bge-m3Fixes #22671
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.