Spaces:
Runtime error
Runtime error
eaglelandsonce
commited on
Commit
·
bd5f25e
1
Parent(s):
0feca4f
Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,15 @@ genai.configure(api_key=GOOGLE_AI_STUDIO)
|
|
14 |
model = genai.GenerativeModel('gemini-pro')
|
15 |
|
16 |
def generate_response(query):
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text", title="Generative AI Query Response")
|
21 |
iface.launch()
|
|
|
14 |
model = genai.GenerativeModel('gemini-pro')
|
15 |
|
16 |
def generate_response(query):
|
17 |
+
try:
|
18 |
+
response = model.generate_content(query)
|
19 |
+
return response.text
|
20 |
+
except exceptions.DeadlineExceeded as e:
|
21 |
+
print("Deadline Exceeded Error: ", e)
|
22 |
+
return "Error: Deadline Exceeded"
|
23 |
+
except Exception as e:
|
24 |
+
print("An unexpected error occurred: ", e)
|
25 |
+
return "Error: An unexpected error occurred"
|
26 |
|
27 |
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text", title="Generative AI Query Response")
|
28 |
iface.launch()
|