Skip to content

Commit 824373e

Browse files
authored
Merge pull request #118 from ShirasawaSama/patch-1
fix: fix the incorrect file retrieval method to obtain files from S3
2 parents 2477bb4 + cc4c1fe commit 824373e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

pipelines/google/google_gemini.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
author_url: https://github.com/owndev/
55
project_url: https://github.com/owndev/Open-WebUI-Functions
66
funding_url: https://github.com/sponsors/owndev
7-
version: 1.9.1
7+
version: 1.9.2
88
required_open_webui_version: 0.6.26
99
license: Apache License 2.0
1010
description: Highly optimized Google Gemini pipeline with advanced image generation capabilities, intelligent compression, and streamlined processing workflows.
@@ -1359,15 +1359,20 @@ async def _fetch_file_as_base64(self, file_url: str) -> Optional[str]:
13591359
else:
13601360
fid = file_url.split("/files/")[-1].split("/")[0].split("?")[0]
13611361

1362+
from pathlib import Path
13621363
from open_webui.models.files import Files
1364+
from open_webui.storage.provider import Storage
13631365

13641366
file_obj = Files.get_file_by_id(fid)
13651367
if file_obj and file_obj.path:
1366-
async with aiofiles.open(file_obj.path, "rb") as fp:
1367-
raw = await fp.read()
1368-
enc = base64.b64encode(raw).decode()
1369-
mime = file_obj.meta.get("content_type", "image/png")
1370-
return f"data:{mime};base64,{enc}"
1368+
file_path = Storage.get_file(file_obj.path)
1369+
file_path = Path(file_path)
1370+
if file_path.is_file():
1371+
async with aiofiles.open(file_path, "rb") as fp:
1372+
raw = await fp.read()
1373+
enc = base64.b64encode(raw).decode()
1374+
mime = file_obj.meta.get("content_type", "image/png")
1375+
return f"data:{mime};base64,{enc}"
13711376
except Exception as e:
13721377
self.log.warning(f"Could not fetch file {file_url}: {e}")
13731378
return None

0 commit comments

Comments
 (0)