Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -253,7 +253,15 @@ Follow this example structure:
|
|
253 |
system_instruction=system_prompt
|
254 |
)
|
255 |
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
print(f"Generated podcast script:\n{response.text}")
|
259 |
|
|
|
253 |
system_instruction=system_prompt
|
254 |
)
|
255 |
|
256 |
+
try:
|
257 |
+
response = await model.generate_content_async(messages)
|
258 |
+
except Exception as e:
|
259 |
+
if "API key not valid" in str(e):
|
260 |
+
gr.Error("Invalid API key. Please provide a valid Gemini API key.")
|
261 |
+
raise ValueError("Invalid API key. Please provide a valid Gemini API key.")
|
262 |
+
else:
|
263 |
+
gr.Error(f"Failed to generate podcast script: {e}")
|
264 |
+
raise e
|
265 |
|
266 |
print(f"Generated podcast script:\n{response.text}")
|
267 |
|