From 4cbb0e7091e80a500473d9b93b20a7cb146da6b3 Mon Sep 17 00:00:00 2001 From: Shirasawa <764798966@qq.com> Date: Fri, 5 Dec 2025 15:29:12 +0800 Subject: [PATCH 1/2] fix: fix the incorrect file retrieval method to obtain files from S3 Refactor file reading logic to use Storage provider and pathlib for file path handling. Signed-off-by: Shirasawa <764798966@qq.com> --- pipelines/google/google_gemini.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pipelines/google/google_gemini.py b/pipelines/google/google_gemini.py index 90fbcd0..2c12bf5 100644 --- a/pipelines/google/google_gemini.py +++ b/pipelines/google/google_gemini.py @@ -1358,15 +1358,20 @@ async def _fetch_file_as_base64(self, file_url: str) -> Optional[str]: else: fid = file_url.split("/files/")[-1].split("/")[0].split("?")[0] + from pathlib import Path from open_webui.models.files import Files + from open_webui.storage.provider import Storage file_obj = Files.get_file_by_id(fid) if file_obj and file_obj.path: - async with aiofiles.open(file_obj.path, "rb") as fp: - raw = await fp.read() - enc = base64.b64encode(raw).decode() - mime = file_obj.meta.get("content_type", "image/png") - return f"data:{mime};base64,{enc}" + file_path = Storage.get_file(file_obj.path) + file_path = Path(file_path) + if file_path.is_file(): + async with aiofiles.open(file_path, "rb") as fp: + raw = await fp.read() + enc = base64.b64encode(raw).decode() + mime = file_obj.meta.get("content_type", "image/png") + return f"data:{mime};base64,{enc}" except Exception as e: self.log.warning(f"Could not fetch file {file_url}: {e}") return None From cc4c1fef56b6e39dd62b32919ec3592bd5d412f8 Mon Sep 17 00:00:00 2001 From: owndev <69784886+owndev@users.noreply.github.com> Date: Mon, 8 Dec 2025 08:55:02 +0100 Subject: [PATCH 2/2] fix(google_gemini.py): increment version to 1.9.2 --- pipelines/google/google_gemini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/google/google_gemini.py b/pipelines/google/google_gemini.py index dd98a6a..4df6cec 100644 --- a/pipelines/google/google_gemini.py +++ b/pipelines/google/google_gemini.py @@ -4,7 +4,7 @@ author_url: https://github.com/owndev/ project_url: https://github.com/owndev/Open-WebUI-Functions funding_url: https://github.com/sponsors/owndev -version: 1.9.1 +version: 1.9.2 required_open_webui_version: 0.6.26 license: Apache License 2.0 description: Highly optimized Google Gemini pipeline with advanced image generation capabilities, intelligent compression, and streamlined processing workflows.