Skip to content

Commit 5c07c47

Browse files
authored
docs: Update documentation for Google Gemini
1 parent 287af18 commit 5c07c47

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Pipelines are processing functions that extend Open WebUI with **custom AI model
130130
- **Advanced Image Processing**: Optimized image handling with configurable compression, resizing, and quality settings.
131131
- **Configurable Parameters**: Environment variables for image optimization (quality, max dimensions, format conversion).
132132
- Grounding with Google search with [google_search_tool.py filter](./filters/google_search_tool.py)
133+
- Ability to forward User Headers and change gemini base url
133134
- Native tool calling support
134135

135136
🔗 [Google Gemini Pipeline in Open WebUI](https://openwebui.com/f/owndev/google_gemini)

docs/google-gemini-integration.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ This integration enables **Open WebUI** to interact with **Google Gemini** model
5252
- **Grounding with Google search**
5353
Improve the accuracy and recency of Gemini responses with Google search grounding.
5454

55-
- **Native tool calling support**
55+
- **Ability to forward User Headers and change gemini base url**
56+
Forward user information headers (like Name, Id, Email and Role) to Google API or LiteLLM for better context and analytics. Also, change the base URL for the Google Generative AI API if needed.
57+
58+
- **Native tool calling support**
5659
Leverage Google genai native function calling to orchestrate the use of tools
5760

5861
## Environment Variables

pipelines/google/google_gemini.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,20 @@ class Pipe:
150150
# Configuration valves for the pipeline
151151
class Valves(BaseModel):
152152
BASE_URL: str = Field(
153-
default=os.getenv("GOOGLE_GENAI_BASE_URL", "https://generativelanguage.googleapis.com/"),
153+
default=os.getenv(
154+
"GOOGLE_GENAI_BASE_URL", "https://generativelanguage.googleapis.com/"
155+
),
154156
description="Base URL for the Google Generative AI API.",
155157
)
156-
ENABLE_FORWARD_USER_INFO_HEADERS: bool = Field(
157-
default=os.getenv("ENABLE_FORWARD_USER_INFO_HEADERS", "false").lower() == "true",
158-
description="Whether to forward user information headers.",
159-
)
160158
GOOGLE_API_KEY: EncryptedStr = Field(
161159
default=os.getenv("GOOGLE_API_KEY", ""),
162160
description="API key for Google Generative AI (used if USE_VERTEX_AI is false).",
163161
)
162+
ENABLE_FORWARD_USER_INFO_HEADERS: bool = Field(
163+
default=os.getenv("ENABLE_FORWARD_USER_INFO_HEADERS", "false").lower()
164+
== "true",
165+
description="Whether to forward user information headers.",
166+
)
164167
USE_VERTEX_AI: bool = Field(
165168
default=os.getenv("GOOGLE_GENAI_USE_VERTEXAI", "false").lower() == "true",
166169
description="Whether to use Google Cloud Vertex AI instead of the Google Generative AI API.",
@@ -450,7 +453,7 @@ def __init__(self):
450453
"""Initializes the Pipe instance and configures the genai library."""
451454
self.valves = self.Valves()
452455
self.name: str = "Google Gemini: "
453-
456+
454457
# Setup logging
455458
self.log = logging.getLogger("google_ai.pipe")
456459
self.log.setLevel(SRC_LOG_LEVELS.get("OPENAI", logging.INFO))
@@ -477,14 +480,20 @@ def _get_client(self) -> genai.Client:
477480
else:
478481
self.log.debug("Initializing Google Generative AI client with API Key")
479482
headers = {}
480-
if self.valves.ENABLE_FORWARD_USER_INFO_HEADERS and hasattr(self, 'user') and self.user:
483+
if (
484+
self.valves.ENABLE_FORWARD_USER_INFO_HEADERS
485+
and hasattr(self, "user")
486+
and self.user
487+
):
481488
headers = {
482489
"X-OpenWebUI-User-Name": self.user.name,
483490
"X-OpenWebUI-User-Id": self.user.id,
484491
"X-OpenWebUI-User-Email": self.user.email,
485492
"X-OpenWebUI-User-Role": self.user.role,
486493
}
487-
options = types.HttpOptions(api_version='v1alpha', base_url=self.valves.BASE_URL, headers=headers)
494+
options = types.HttpOptions(
495+
api_version="v1alpha", base_url=self.valves.BASE_URL, headers=headers
496+
)
488497
return genai.Client(
489498
api_key=self.valves.GOOGLE_API_KEY.get_decrypted(), http_options=options
490499
)

0 commit comments

Comments
 (0)