[PR #18014] [CLOSED] feat: add filter processing to ollama and openai embedding endpoints #63495

Closed
opened 2026-05-06 08:18:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/18014
Author: @Simon-Stone
Created: 10/2/2025
Status: Closed

Base: devHead: apply-filters-to-embedding-requests


📝 Commits (1)

  • 73767fd feat: add filter processing to ollama and openai embedding endpoints

📊 Changes

2 files changed (+134 additions, -0 deletions)

View changed files

📝 backend/open_webui/routers/ollama.py (+98 -0)
📝 backend/open_webui/routers/openai.py (+36 -0)

📄 Description

feat: Add inlet filter support to embedding endpoints

Before submitting, make sure you've checked the following:

  • Target branch: Pull request targets the dev branch
  • Description: Concise description provided below
  • Changelog: Changelog entry added at the bottom
  • Documentation: No documentation changes required (internal API change)
  • Dependencies: No new dependencies added
  • Testing: Changes tested with embedding endpoints
  • Code review: Self-review performed
  • Prefix: feat - Introduces new feature (inlet filter support for embeddings)

Changelog Entry

Description

This PR adds inlet filter support to embedding endpoints, ensuring that embedding requests go through attached inlet filters just like completion endpoints do. Previously, requests to /api/embed, /api/embeddings, and OpenAI-compatible embedding endpoints bypassed pipeline inlet filters, preventing filters from intercepting, modifying, logging, or validating embedding requests.

Potential use-cases for this:

  • Injection of the user ID for upstream usage tracking, for example via LiteLLM.
  • Guardrailing to enforce policy-compliant use of not just chat completion but also embeddings.

The implementation includes:

  • Integration of process_filter_functions() into all embedding endpoints

Added

Security

  • Embedding endpoints now properly enforce pipeline inlet filters, allowing administrators to validate, log, or modify embedding requests through filter pipelines

Additional Information

Technical Details:

The implementation follows the same pattern used in tasks.py for completion endpoints.

Testing:

To verify the changes work correctly:

  1. Set up a pipeline inlet filter configured to intercept embedding requests
  2. Send requests to /api/embed, /api/embeddings, or OpenAI-compatible embedding endpoints
  3. Verify that the filter receives and can process the embedding request payload
  4. Confirm that modifications made by the filter are applied to the actual embedding request

Related Issues:

This change ensures consistent behavior between completion and embedding endpoints, allowing administrators to apply the same filtering, logging, and validation logic to all API requests.


Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/18014 **Author:** [@Simon-Stone](https://github.com/Simon-Stone) **Created:** 10/2/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `apply-filters-to-embedding-requests` --- ### 📝 Commits (1) - [`73767fd`](https://github.com/open-webui/open-webui/commit/73767fddf4cbf949843e90af36d22d360e0226bd) feat: add filter processing to ollama and openai embedding endpoints ### 📊 Changes **2 files changed** (+134 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/ollama.py` (+98 -0) 📝 `backend/open_webui/routers/openai.py` (+36 -0) </details> ### 📄 Description # feat: Add inlet filter support to embedding endpoints **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Pull request targets the `dev` branch - [x] **Description:** Concise description provided below - [x] **Changelog:** Changelog entry added at the bottom - [x] **Documentation:** No documentation changes required (internal API change) - [x] **Dependencies:** No new dependencies added - [x] **Testing:** Changes tested with embedding endpoints - [x] **Code review:** Self-review performed - [x] **Prefix:** `feat` - Introduces new feature (inlet filter support for embeddings) --- # Changelog Entry ### Description This PR adds inlet filter support to embedding endpoints, ensuring that embedding requests go through attached inlet filters just like completion endpoints do. Previously, requests to `/api/embed`, `/api/embeddings`, and OpenAI-compatible embedding endpoints bypassed pipeline inlet filters, preventing filters from intercepting, modifying, logging, or validating embedding requests. Potential use-cases for this: - Injection of the user ID for upstream usage tracking, for example via LiteLLM. - Guardrailing to enforce policy-compliant use of not just chat completion but also embeddings. The implementation includes: - Integration of `process_filter_functions()` into all embedding endpoints ### Added - Inlet filter processing for Ollama `/api/embed` endpoint ([`ollama.py:1067-1098`](backend/open_webui/routers/ollama.py)) - Inlet filter processing for Ollama `/api/embeddings` endpoint ([`ollama.py:1192-1220`](backend/open_webui/routers/ollama.py)) - Inlet filter processing for OpenAI-compatible `embeddings()` function ([`openai.py:1009-1027`](backend/open_webui/routers/openai.py)) ### Security - Embedding endpoints now properly enforce pipeline inlet filters, allowing administrators to validate, log, or modify embedding requests through filter pipelines --- ### Additional Information **Technical Details:** The implementation follows the same pattern used in [`tasks.py`](backend/open_webui/routers/tasks.py:228) for completion endpoints. **Testing:** To verify the changes work correctly: 1. Set up a pipeline inlet filter configured to intercept embedding requests 2. Send requests to `/api/embed`, `/api/embeddings`, or OpenAI-compatible embedding endpoints 3. Verify that the filter receives and can process the embedding request payload 4. Confirm that modifications made by the filter are applied to the actual embedding request **Related Issues:** This change ensures consistent behavior between completion and embedding endpoints, allowing administrators to apply the same filtering, logging, and validation logic to all API requests. --- ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 08:18:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#63495