GuglielmoTor commited on
Commit
ec488c8
·
verified ·
1 Parent(s): c6c5351

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -180,21 +180,18 @@ def call_gemini_api_direct_with_prompt(user_prompt):
180
 
181
  try:
182
  # Configure the genai library with the API key
183
- # This needs to be done once, but doing it per call is fine for this simple test
184
- genai.configure(api_key=api_key)
185
 
186
  # Specify the model name as requested
187
  model_name = "gemini-2.5-flash-preview-05-20"
188
 
189
- # Create a GenerativeModel instance
190
- model = genai.GenerativeModel(model_name)
191
-
192
- # Generate content based on the user's prompt
193
- # Direct execution of the API call
194
- response = model.generate_content(user_prompt)
195
-
196
  # Log the response text (optional, for server-side debugging)
197
- logging.info(f"Gemini API call successful. Prompt: '{user_prompt}'. Response: '{response.text[:100]}...'")
198
 
199
  return response.text
200
  except Exception as e:
 
180
 
181
  try:
182
  # Configure the genai library with the API key
 
 
183
 
184
  # Specify the model name as requested
185
  model_name = "gemini-2.5-flash-preview-05-20"
186
 
187
+ client = genai.Client(api_key="AIzaSyCSfIw2kWWO1c_oa7WQ33h11O6N8egNoqk")
188
+
189
+ response = client.models.generate_content(
190
+ model=model_name, contents="Explain how AI works in a few words"
191
+ )
192
+
 
193
  # Log the response text (optional, for server-side debugging)
194
+ logging.info(f"Gemini API call successful. Prompt: . Response: '{response.text[:100]}...'")
195
 
196
  return response.text
197
  except Exception as e: