56 class Valves(BaseModel):57 58 SET_TEMP_TO_ZERO: bool = Field(59 default=False,60 description="""Decide if you want to set the temperature to 0 for grounded answers,61 Google reccomends it in their docs.""",62 )63 GROUNDING_DYNAMIC_RETRIEVAL_THRESHOLD: float | None = Field(64 default=None,65 description="""See https://ai.google.dev/gemini-api/docs/grounding?lang=python#dynamic-threshold for more information.66 Only supported for 1.0 and 1.5 models""",67 ) gemini_manifold_companion.py - Detailed Documentation
This document provides a comprehensive overview of the gemini_manifold_companion.py Open WebUI filter, designed as a companion to the gemini_manifold.py pipe.
Description
The gemini_manifold_companion.py filter enhances the functionality of the "Gemini Manifold google_genai" pipe within Open WebUI. Its primary function is to intercept and modify requests to enable Google Search grounding, code execution, and backend RAG bypass with compatible Gemini models. It also adds citation markers and source information to grounded responses. It's a separate, complementary component in the Open WebUI plugin system.
Features
Implemented Features:
- Google Search Grounding: Enables Google Search grounding for supported Gemini models. Intercepts the Open WebUI's built-in search feature, disables it, and passes custom values to
gemini_manifold.pyto trigger grounding. - Google Code Execution: Intercepts Open WebUI's code interpreter feature, disables it, and signals
gemini_manifold.pyto use Google's code execution tool via the Gemini API. - Backend RAG Bypass: Allows bypassing Open WebUI's built-in RAG pipeline and sending uploaded documents directly to the Gemini API via
gemini_manifold.pyfor native processing. - Citation Marker Addition & Source Emission: Adds
[index]style citation markers to the model's response text based on grounding metadata and emits separate events for the UI to display source information (resolved URLs) and search queries. - Configurable Valves: Offers configurable settings to control grounding behavior, RAG bypass, permissive safety settings, and logging verbosity.
Planned Features:
- Citation marker removal (from input prompt).
Installation
- Install and configure
gemini_manifold.py, see it's docs. - Install the filter within Open WebUI. You can get it from Open WebUI Community.
- Enable the filter globally, or on specific models that support the desired features (grounding, code execution, RAG bypass). This can be done through Open WebUI's plugin management interface.
Configuration
The filter is configured via a "Valves" settings menu accessible by clicking the gear icon associated with the filter in Open WebUI. The following settings are available:
- Set Temp To Zero: (Enabled/Disabled) When enabled, the filter will override the temperature setting and set it to
0for grounded answers, as recommended by Google. - Grounding Dynamic Retrieval Threshold: (Default/Custom) This setting controls the dynamic retrieval threshold for Google Search grounding.
- Default: Uses Google's default threshold value. Refer to the Google Gemini API documentation on grounding for more information.
- Custom: Allows specifying a custom threshold value. Consult the Google documentation for information on acceptable values and their impact. This setting is only supported for Gemini 1.0 and 1.5 models.
- USE_PERMISSIVE_SAFETY: (Enabled/Disabled) When enabled, the filter will add permissive safety settings to the request payload, potentially allowing the model to generate responses that might otherwise be blocked by default safety filters. Refer to Google's safety settings documentation for details.
- BYPASS_BACKEND_RAG: (Enabled/Disabled) When enabled, the filter intercepts document uploads, prevents Open WebUI's backend RAG from processing them, and signals the
gemini_manifold.pypipe to handle the raw documents directly with the Gemini API. Note: This feature is not supported in temporary ('local') chats. - LOG_LEVEL: (TRACE/DEBUG/INFO/SUCCESS/WARNING/ERROR/CRITICAL) Controls the logging verbosity of this specific filter. Use
docker logs -f open-webuito view logs.
Usage
Once installed and configured, the filter automatically modifies requests for models registered by gemini_manifold.py and listed in ALLOWED_GROUNDING_MODELS or ALLOWED_CODE_EXECUTION_MODELS (defined in the filter's code) when the user enables web search or code interpreter in the Open WebUI chat interface, or when documents are uploaded to a persistent chat (and BYPASS_BACKEND_RAG is enabled).
The filter checks for the gemini_manifold_google_genai. prefix in the model name (or its base model ID) to ensure it's interacting with a model managed by the gemini_manifold.py pipe.
Data Pipeline
The filter's operation can be summarized as follows:
-
inlet(body: dict, __metadata__: dict[str, Any]) -> dict: This function modifies the incoming request payload (body) before it's sent to thegemini_manifold.pypipe.- It checks if the model is a supported Gemini model for grounding or code execution using the
gemini_manifold_google_genai.prefix and internal model lists (ALLOWED_GROUNDING_MODELS,ALLOWED_CODE_EXECUTION_MODELS). - If web search is enabled in the request's
featuresdictionary and the model supports grounding, it disables the defaultweb_searchfeature. It then adds custom features (google_search_retrievalfor 1.0/1.5 models,google_search_toolfor >=2.0 models) tobody["metadata"]["features"]to signal the pipe to use Google Search grounding. If the "Set Temp To Zero" valve is enabled, it overwrites thetemperaturevalue with0. - If code interpreter is enabled in the request's
featuresdictionary and the model supports code execution, it disables the defaultcode_interpreterfeature. It then adds the custom featuregoogle_code_executiontobody["metadata"]["features"]to signal the pipe to use Google's code execution tool. - If the
BYPASS_BACKEND_RAGvalve is enabled and documents are present inbody["files"](and the chat is not temporary), it clears thebody["files"]list to prevent Open WebUI's backend RAG from processing them. It then addsupload_documents: truetobody["metadata"]["features"]to signal the pipe to handle the raw documents directly with the Gemini API. If the valve is disabled or it's a temporary chat,upload_documents: falseis added. - If the
USE_PERMISSIVE_SAFETYvalve is enabled, it adds permissive safety settings tobody["metadata"]["safety_settings"]. - It ensures the necessary
metadataandmetadata.featuresstructures exist in thebody.
- It checks if the model is a supported Gemini model for grounding or code execution using the
-
stream(event: dict) -> dict: This function currently performs no modifications on the streaming response from the LLM. It's included for potential future use. -
outlet(body: dict, __request__: Request, __metadata__: dict[str, Any], __event_emitter__: Callable[["Event"], Awaitable[None]], **kwargs) -> dict: This function processes the complete response payload after it's received from thegemini_manifold.pypipe.- It checks for
GroundingMetadatathat the pipe may have stored in the request state (__request__.app.state). - If grounding metadata is found (indicating the response was grounded), it processes the model's response text to add
[index]style citation markers based on thegrounding_supportsandgrounding_chunksinformation provided by the API. The response text inbody["messages"][-1]["content"]is updated with these markers. - It initiates a background task to resolve the original source URLs (e.g., following redirects) found in the grounding metadata. Once resolved, it emits a
chat:completionevent containing the resolved source information for display in the UI's source panel. - It emits a
statusevent containing the actual Google search queries used by the model, often including links to the search results pages. - The original
TODOregarding citation marker removal from the input prompt remains a separate potential future feature.
- It checks for
Dependencies
This filter is designed to work exclusively with the gemini_manifold.py pipe. It has no external dependencies beyond the standard Open WebUI environment and the google-genai library (which is a dependency of the pipe). The gemini_manifold.py function handles the actual interaction with the Google Gemini API. The filter is designed to fail gracefully if the "Gemini Manifold google_genai" pipe function is not properly configured or is unavailable, by skipping all modifications.
Troubleshooting
If features are not working as expected, check the following:
- Ensure the filter is enabled globally or for the specific model being used.
- Verify that the model name includes the
gemini_manifold_google_genai.prefix and is present in the relevantALLOWED_GROUNDING_MODELSorALLOWED_CODE_EXECUTION_MODELSlist within the filter's code. - For Grounding: Ensure web search is enabled in the Open WebUI chat interface.
- For Code Execution: Ensure the code interpreter feature is enabled in the Open WebUI chat interface.
- For RAG Bypass: Ensure the
BYPASS_BACKEND_RAGvalve is enabled for the filter. Verify you are using a persistent chat (not a temporary 'local' chat). Check if the documents are actually being included in the initial request payload sent by the UI. - Consult the Open WebUI logs (using
docker logs -f open-webui) for any error messages related to the filter. Adjust theLOG_LEVELvalve for more detailed output if needed.
License
MIT License. See the LICENSE file for details.
gemini_manifold_companion.py - Detailed Documentation
This document provides a comprehensive overview of the gemini_manifold_companion.py Open WebUI filter, designed as a companion to the gemini_manifold.py pipe.
Description
The gemini_manifold_companion.py filter enhances the functionality of the "Gemini Manifold google_genai" pipe within Open WebUI. Its primary function is to intercept and modify requests to enable Google Search grounding, code execution, and backend RAG bypass with compatible Gemini models. It also adds citation markers and source information to grounded responses. It's a separate, complementary component in the Open WebUI plugin system.
Features
Implemented Features:
- Google Search Grounding: Enables Google Search grounding for supported Gemini models. Intercepts the Open WebUI's built-in search feature, disables it, and passes custom values to
gemini_manifold.pyto trigger grounding. - Google Code Execution: Intercepts Open WebUI's code interpreter feature, disables it, and signals
gemini_manifold.pyto use Google's code execution tool via the Gemini API. - Backend RAG Bypass: Allows bypassing Open WebUI's built-in RAG pipeline and sending uploaded documents directly to the Gemini API via
gemini_manifold.pyfor native processing. - Citation Marker Addition & Source Emission: Adds
[index]style citation markers to the model's response text based on grounding metadata and emits separate events for the UI to display source information (resolved URLs) and search queries. - Configurable Valves: Offers configurable settings to control grounding behavior, RAG bypass, permissive safety settings, and logging verbosity.
Planned Features:
- Citation marker removal (from input prompt).
Installation
- Install and configure
gemini_manifold.py, see it's docs. - Install the filter within Open WebUI. You can get it from Open WebUI Community.
- Enable the filter globally, or on specific models that support the desired features (grounding, code execution, RAG bypass). This can be done through Open WebUI's plugin management interface.
Configuration
The filter is configured via a "Valves" settings menu accessible by clicking the gear icon associated with the filter in Open WebUI. The following settings are available:
- Set Temp To Zero: (Enabled/Disabled) When enabled, the filter will override the temperature setting and set it to
0for grounded answers, as recommended by Google. - Grounding Dynamic Retrieval Threshold: (Default/Custom) This setting controls the dynamic retrieval threshold for Google Search grounding.
- Default: Uses Google's default threshold value. Refer to the Google Gemini API documentation on grounding for more information.
- Custom: Allows specifying a custom threshold value. Consult the Google documentation for information on acceptable values and their impact. This setting is only supported for Gemini 1.0 and 1.5 models.
- USE_PERMISSIVE_SAFETY: (Enabled/Disabled) When enabled, the filter will add permissive safety settings to the request payload, potentially allowing the model to generate responses that might otherwise be blocked by default safety filters. Refer to Google's safety settings documentation for details.
- BYPASS_BACKEND_RAG: (Enabled/Disabled) When enabled, the filter intercepts document uploads, prevents Open WebUI's backend RAG from processing them, and signals the
gemini_manifold.pypipe to handle the raw documents directly with the Gemini API. Note: This feature is not supported in temporary ('local') chats. - LOG_LEVEL: (TRACE/DEBUG/INFO/SUCCESS/WARNING/ERROR/CRITICAL) Controls the logging verbosity of this specific filter. Use
docker logs -f open-webuito view logs.
Usage
Once installed and configured, the filter automatically modifies requests for models registered by gemini_manifold.py and listed in ALLOWED_GROUNDING_MODELS or ALLOWED_CODE_EXECUTION_MODELS (defined in the filter's code) when the user enables web search or code interpreter in the Open WebUI chat interface, or when documents are uploaded to a persistent chat (and BYPASS_BACKEND_RAG is enabled).
The filter checks for the gemini_manifold_google_genai. prefix in the model name (or its base model ID) to ensure it's interacting with a model managed by the gemini_manifold.py pipe.
Data Pipeline
The filter's operation can be summarized as follows:
-
inlet(body: dict, __metadata__: dict[str, Any]) -> dict: This function modifies the incoming request payload (body) before it's sent to thegemini_manifold.pypipe.- It checks if the model is a supported Gemini model for grounding or code execution using the
gemini_manifold_google_genai.prefix and internal model lists (ALLOWED_GROUNDING_MODELS,ALLOWED_CODE_EXECUTION_MODELS). - If web search is enabled in the request's
featuresdictionary and the model supports grounding, it disables the defaultweb_searchfeature. It then adds custom features (google_search_retrievalfor 1.0/1.5 models,google_search_toolfor >=2.0 models) tobody["metadata"]["features"]to signal the pipe to use Google Search grounding. If the "Set Temp To Zero" valve is enabled, it overwrites thetemperaturevalue with0. - If code interpreter is enabled in the request's
featuresdictionary and the model supports code execution, it disables the defaultcode_interpreterfeature. It then adds the custom featuregoogle_code_executiontobody["metadata"]["features"]to signal the pipe to use Google's code execution tool. - If the
BYPASS_BACKEND_RAGvalve is enabled and documents are present inbody["files"](and the chat is not temporary), it clears thebody["files"]list to prevent Open WebUI's backend RAG from processing them. It then addsupload_documents: truetobody["metadata"]["features"]to signal the pipe to handle the raw documents directly with the Gemini API. If the valve is disabled or it's a temporary chat,upload_documents: falseis added. - If the
USE_PERMISSIVE_SAFETYvalve is enabled, it adds permissive safety settings tobody["metadata"]["safety_settings"]. - It ensures the necessary
metadataandmetadata.featuresstructures exist in thebody.
- It checks if the model is a supported Gemini model for grounding or code execution using the
-
stream(event: dict) -> dict: This function currently performs no modifications on the streaming response from the LLM. It's included for potential future use. -
outlet(body: dict, __request__: Request, __metadata__: dict[str, Any], __event_emitter__: Callable[["Event"], Awaitable[None]], **kwargs) -> dict: This function processes the complete response payload after it's received from thegemini_manifold.pypipe.- It checks for
GroundingMetadatathat the pipe may have stored in the request state (__request__.app.state). - If grounding metadata is found (indicating the response was grounded), it processes the model's response text to add
[index]style citation markers based on thegrounding_supportsandgrounding_chunksinformation provided by the API. The response text inbody["messages"][-1]["content"]is updated with these markers. - It initiates a background task to resolve the original source URLs (e.g., following redirects) found in the grounding metadata. Once resolved, it emits a
chat:completionevent containing the resolved source information for display in the UI's source panel. - It emits a
statusevent containing the actual Google search queries used by the model, often including links to the search results pages. - The original
TODOregarding citation marker removal from the input prompt remains a separate potential future feature.
- It checks for
Dependencies
This filter is designed to work exclusively with the gemini_manifold.py pipe. It has no external dependencies beyond the standard Open WebUI environment and the google-genai library (which is a dependency of the pipe). The gemini_manifold.py function handles the actual interaction with the Google Gemini API. The filter is designed to fail gracefully if the "Gemini Manifold google_genai" pipe function is not properly configured or is unavailable, by skipping all modifications.
Troubleshooting
If features are not working as expected, check the following:
- Ensure the filter is enabled globally or for the specific model being used.
- Verify that the model name includes the
gemini_manifold_google_genai.prefix and is present in the relevantALLOWED_GROUNDING_MODELSorALLOWED_CODE_EXECUTION_MODELSlist within the filter's code. - For Grounding: Ensure web search is enabled in the Open WebUI chat interface.
- For Code Execution: Ensure the code interpreter feature is enabled in the Open WebUI chat interface.
- For RAG Bypass: Ensure the
BYPASS_BACKEND_RAGvalve is enabled for the filter. Verify you are using a persistent chat (not a temporary 'local' chat). Check if the documents are actually being included in the initial request payload sent by the UI. - Consult the Open WebUI logs (using
docker logs -f open-webui) for any error messages related to the filter. Adjust theLOG_LEVELvalve for more detailed output if needed.
License
MIT License. See the LICENSE file for details.

