catch exception
This commit is contained in:
@@ -7,6 +7,7 @@ from PIL import Image
|
||||
from google import genai
|
||||
from google.genai import types
|
||||
|
||||
from adapters.Exception import GoogleGenerationException
|
||||
from models.enums import AspectRatios, Quality
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -85,6 +86,8 @@ class GoogleAdapter:
|
||||
),
|
||||
)
|
||||
)
|
||||
if response.parts is None and response.candidates[0].finish_reason is not None:
|
||||
raise GoogleGenerationException(f"Generation blocked in cause of {response.candidates[0].finish_reason.value}")
|
||||
|
||||
generated_images = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user