[PR #16022] [CLOSED] feat: Add Google embeddings support #24007

Closed
opened 2026-04-20 05:10:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/16022
Author: @ipapapa
Created: 7/25/2025
Status: Closed

Base: devHead: fix-google-embeddings


📝 Commits (4)

  • ffff6fa feat: Add Google embeddings support
  • b8da4a8 refac
  • d7262aa Merge branch 'open-webui:main' into fix-google-embeddings
  • b21509d feat: Add Google embeddings support with migration guidance

📊 Changes

6 files changed (+190 additions, -19 deletions)

View changed files

📝 README.md (+41 -0)
📝 backend/open_webui/config.py (+0 -6)
📝 backend/open_webui/env.py (+29 -0)
📝 backend/open_webui/main.py (+1 -1)
📝 backend/open_webui/retrieval/utils.py (+64 -1)
📝 backend/open_webui/utils/auth.py (+55 -11)

📄 Description

Add Google embeddings support

Summary

This PR adds support for Google's embedding models (Gemini) to Open WebUI's RAG functionality. Previously, users trying to use Google embeddings would encounter "Unknown embedding engine: google" errors.

Changes Made

Core Implementation

  • Added google to the supported embedding engines list in get_embedding_function()
  • Implemented generate_google_batch_embeddings() function following Google's API specification
  • Added proper error handling and logging for Google embedding requests

Technical Details

  • Endpoint: Uses Google's native models/{model}:batchEmbedContents API endpoint
  • Authentication: Supports x-goog-api-key header format
  • Request Format: Handles Google's specific request structure with requests array
  • Response Parsing: Extracts embeddings from Google's {"embeddings": [{"values": [...]}]} response format

Testing

API Verification: Direct API calls to Google's embedding service succeed
Integration Testing: Open WebUI starts successfully with RAG_EMBEDDING_ENGINE=google
Error Resolution: No more "Unknown embedding engine" errors
Model Recognition: Properly recognizes models like text-embedding-004

Configuration Example

environment:
  - RAG_EMBEDDING_ENGINE=google
  - RAG_EMBEDDING_MODEL=text-embedding-004
  - OPENAI_API_KEY=${GOOGLE_API_KEY}  # Use Google API key

Discussion: https://github.com/open-webui/open-webui/discussions/16043
Closes #11714

Benefits

  • Enables RAG functionality with Google's multilingual embedding models
  • Supports Google's latest text-embedding-004 model (768 dimensions)
  • Maintains compatibility with existing OpenAI/Ollama/Azure implementations
  • Provides proper error handling and logging

Backwards Compatibility

This change is fully backwards compatible. Existing configurations continue to work unchanged.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have tested my changes locally
  • The changes have been tested with actual Google API keys

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/16022 **Author:** [@ipapapa](https://github.com/ipapapa) **Created:** 7/25/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-google-embeddings` --- ### 📝 Commits (4) - [`ffff6fa`](https://github.com/open-webui/open-webui/commit/ffff6fa23af9288a6e669129000600a86de3032c) feat: Add Google embeddings support - [`b8da4a8`](https://github.com/open-webui/open-webui/commit/b8da4a8cd8257d4846f3608e299618a0b4f185ed) refac - [`d7262aa`](https://github.com/open-webui/open-webui/commit/d7262aa2c9f2f38eaedd7bf44ad5ae2c1ad306c1) Merge branch 'open-webui:main' into fix-google-embeddings - [`b21509d`](https://github.com/open-webui/open-webui/commit/b21509d445c2005f662ca6fd46ec0ddee260cd2e) feat: Add Google embeddings support with migration guidance ### 📊 Changes **6 files changed** (+190 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+41 -0) 📝 `backend/open_webui/config.py` (+0 -6) 📝 `backend/open_webui/env.py` (+29 -0) 📝 `backend/open_webui/main.py` (+1 -1) 📝 `backend/open_webui/retrieval/utils.py` (+64 -1) 📝 `backend/open_webui/utils/auth.py` (+55 -11) </details> ### 📄 Description # Add Google embeddings support ## Summary This PR adds support for Google's embedding models (Gemini) to Open WebUI's RAG functionality. Previously, users trying to use Google embeddings would encounter "Unknown embedding engine: google" errors. ## Changes Made ### Core Implementation - Added `google` to the supported embedding engines list in `get_embedding_function()` - Implemented `generate_google_batch_embeddings()` function following Google's API specification - Added proper error handling and logging for Google embedding requests ### Technical Details - **Endpoint**: Uses Google's native `models/{model}:batchEmbedContents` API endpoint - **Authentication**: Supports `x-goog-api-key` header format - **Request Format**: Handles Google's specific request structure with `requests` array - **Response Parsing**: Extracts embeddings from Google's `{"embeddings": [{"values": [...]}]}` response format ## Testing ✅ **API Verification**: Direct API calls to Google's embedding service succeed ✅ **Integration Testing**: Open WebUI starts successfully with `RAG_EMBEDDING_ENGINE=google` ✅ **Error Resolution**: No more "Unknown embedding engine" errors ✅ **Model Recognition**: Properly recognizes models like `text-embedding-004` ## Configuration Example ```yaml environment: - RAG_EMBEDDING_ENGINE=google - RAG_EMBEDDING_MODEL=text-embedding-004 - OPENAI_API_KEY=${GOOGLE_API_KEY} # Use Google API key ``` ## Related Issues Discussion: https://github.com/open-webui/open-webui/discussions/16043 Closes #11714 ## Benefits - Enables RAG functionality with Google's multilingual embedding models - Supports Google's latest text-embedding-004 model (768 dimensions) - Maintains compatibility with existing OpenAI/Ollama/Azure implementations - Provides proper error handling and logging ## Backwards Compatibility This change is fully backwards compatible. Existing configurations continue to work unchanged. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] My changes generate no new warnings - [x] I have tested my changes locally - [x] The changes have been tested with actual Google API keys ## 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-04-20 05:10:49 -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#24007