Skip to content

Commit 92eef44

Browse files
authored
Update ai.py
1 parent decc6d7 commit 92eef44

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

helpers/ai.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
ENGINE_ID= "stable-diffusion-v1-6"
1919

2020
genai.configure(api_key=GEMINI_API_KEY)
21-
2221
generation_config = {
2322
"temperature": 1,
2423
"top_p": 0.95,
2524
"top_k": 64,
2625
"max_output_tokens": 8192,
2726
"response_mime_type": "text/plain",
2827
}
29-
3028
model = genai.GenerativeModel(
3129
model_name="gemini-1.5-flash",
3230
generation_config=generation_config,
@@ -107,13 +105,8 @@ def edit_image(image_bytes, prompt):
107105

108106
response.raise_for_status()
109107
data = response.json()
110-
images = data.get("artifacts", [])
111-
112-
if not images:
113-
raise Exception("No images generated.")
114-
115-
return [base64.b64decode(image["base64"]) for image in images]
116-
108+
image_data = data["artifacts"][0]["base64"]
109+
return base64.b64decode(image_data)
117110
except Exception as e:
118111
print(f"Error in edit_image: {e}")
119-
return None
112+
return None

0 commit comments

Comments
 (0)