Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
# Log the response text (optional, for server-side debugging)
|
197 |
-
logging.info(f"Gemini API call successful. Prompt:
|
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:
|