Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,7 @@ import base64
|
|
7 |
import os
|
8 |
|
9 |
# Initialize the Google Generative AI client with the API key from environment variables
|
10 |
-
|
11 |
-
genai.configure(api_key=api_key)
|
12 |
-
|
13 |
-
# Initialize the Gemini model for text generation
|
14 |
-
gemini_model = genai.GenerativeModel('gemini-2.5-flash-preview-04-17')
|
15 |
|
16 |
def generate_item(tag):
|
17 |
"""
|
@@ -25,11 +21,11 @@ def generate_item(tag):
|
|
25 |
"""
|
26 |
# Generate text using Gemini LLM
|
27 |
prompt = f"Generate a short, engaging post about {tag} in the style of a TikTok caption."
|
28 |
-
text_response =
|
29 |
text = text_response.text.strip()
|
30 |
|
31 |
# Generate an image using Imagen based on the generated text
|
32 |
-
image_response =
|
33 |
model='imagen-3.0-generate-002',
|
34 |
prompt=text,
|
35 |
config=types.GenerateImagesConfig(
|
|
|
7 |
import os
|
8 |
|
9 |
# Initialize the Google Generative AI client with the API key from environment variables
|
10 |
+
client = genai.Client(api_key='GEMINI_API_KEY')
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def generate_item(tag):
|
13 |
"""
|
|
|
21 |
"""
|
22 |
# Generate text using Gemini LLM
|
23 |
prompt = f"Generate a short, engaging post about {tag} in the style of a TikTok caption."
|
24 |
+
text_response = client.models.generate_content(model='gemini-2.5-flash-preview-04-17',prompt)
|
25 |
text = text_response.text.strip()
|
26 |
|
27 |
# Generate an image using Imagen based on the generated text
|
28 |
+
image_response = client.models.generate_images(
|
29 |
model='imagen-3.0-generate-002',
|
30 |
prompt=text,
|
31 |
config=types.GenerateImagesConfig(
|