Spaces:
Runtime error
Runtime error
Commit
·
6a322e7
1
Parent(s):
6db991a
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,23 @@ genai.configure(api_key=GOOGLE_AI_STUDIO)
|
|
10 |
model = genai.GenerativeModel('gemini-pro')
|
11 |
|
12 |
def get_response(query):
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Gradio interface
|
17 |
iface = gr.Interface(
|
|
|
10 |
model = genai.GenerativeModel('gemini-pro')
|
11 |
|
12 |
def get_response(query):
|
13 |
+
"""
|
14 |
+
Searches for content based on the provided query using the Gemini model.
|
15 |
+
Handles DeadlineExceeded exceptions from the Google API.
|
16 |
+
Args:
|
17 |
+
query (str): The search query.
|
18 |
+
Returns:
|
19 |
+
str: The response text from the Gemini model or an error message.
|
20 |
+
"""
|
21 |
+
try:
|
22 |
+
response = model.generate_content(query)
|
23 |
+
return response.text
|
24 |
+
except exceptions.DeadlineExceeded as e:
|
25 |
+
# Handle the DeadlineExceeded exception here
|
26 |
+
print("Error: Deadline Exceeded -", str(e))
|
27 |
+
# You can return a custom message or take other appropriate actions
|
28 |
+
return "Error: The request timed out. Please try again later."
|
29 |
+
|
30 |
|
31 |
# Gradio interface
|
32 |
iface = gr.Interface(
|