codelion commited on
Commit
d6f0f11
·
verified ·
1 Parent(s): 279374e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
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
- api_key = os.getenv("GEMINI_API_KEY")
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 = gemini_model.generate_content(prompt)
29
  text = text_response.text.strip()
30
 
31
  # Generate an image using Imagen based on the generated text
32
- image_response = genai.generate_images(
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(