saq1b commited on
Commit
d0bb969
1 Parent(s): 7733b7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -253,7 +253,15 @@ Follow this example structure:
253
  system_instruction=system_prompt
254
  )
255
 
256
- response = await model.generate_content_async(messages)
 
 
 
 
 
 
 
 
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