mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-05 07:26:39 +08:00
Implement base64 fallback for image handling when no uploader is configured (#1)
* Initial plan * Implement base64 fallback for image handling when no uploader configured Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com>
This commit is contained in:
committed by
bbbugg
co-authored by
bbbugg
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent
4af17ce55d
commit
bb6c629aef
@@ -10,6 +10,7 @@ from app.core.constants import VALID_IMAGE_RATIOS
|
||||
from app.domain.openai_models import ImageGenerationRequest
|
||||
from app.log.logger import get_image_create_logger
|
||||
from app.utils.uploader import ImageUploaderFactory
|
||||
from app.utils.helpers import is_image_upload_configured
|
||||
|
||||
logger = get_image_create_logger()
|
||||
|
||||
@@ -97,12 +98,15 @@ class ImageCreateService:
|
||||
image_data = generated_image.image.image_bytes
|
||||
image_uploader = None
|
||||
|
||||
if request.response_format == "b64_json":
|
||||
# Return base64 if explicitly requested or if no uploader is configured
|
||||
if request.response_format == "b64_json" or not is_image_upload_configured():
|
||||
base64_image = base64.b64encode(image_data).decode("utf-8")
|
||||
images_data.append(
|
||||
{"b64_json": base64_image, "revised_prompt": request.prompt}
|
||||
)
|
||||
continue
|
||||
else:
|
||||
# Upload to configured provider
|
||||
current_date = time.strftime("%Y/%m/%d")
|
||||
filename = f"{current_date}/{uuid.uuid4().hex[:8]}.png"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user