-
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathgoogle_search_tool.py
More file actions
33 lines (27 loc) · 1.23 KB
/
google_search_tool.py
File metadata and controls
33 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
title: Google Search Tool Filter for https://github.com/owndev/Open-WebUI-Functions/blob/main/pipelines/google/google_gemini.py
author: owndev, olivier-lacroix
author_url: https://github.com/owndev/
project_url: https://github.com/owndev/Open-WebUI-Functions
funding_url: https://github.com/sponsors/owndev
version: 1.0.0
license: Apache License 2.0
requirements:
- https://github.com/owndev/Open-WebUI-Functions/blob/main/pipelines/google/google_gemini.py
description: Replacing web_search tool with google search grounding
"""
import logging
from open_webui.env import SRC_LOG_LEVELS
class Filter:
def __init__(self):
self.log = logging.getLogger("google_ai.pipe")
self.log.setLevel(SRC_LOG_LEVELS.get("OPENAI", logging.INFO))
def inlet(self, body: dict) -> dict:
features = body.get("features", {})
# Ensure metadata structure exists and add new feature
metadata = body.setdefault("metadata", {})
metadata_features = metadata.setdefault("features", {})
if features.pop("web_search"):
self.log.debug("Replacing web_search tool with google search grounding")
metadata_features["google_search_tool"] = True
return body