Update app.py
Browse files
app.py
CHANGED
|
@@ -18,16 +18,16 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
|
|
| 18 |
str: The answer to the question
|
| 19 |
"""
|
| 20 |
if not question:
|
| 21 |
-
raise gr.
|
| 22 |
|
| 23 |
if not openai_api_key:
|
| 24 |
-
raise gr.
|
| 25 |
|
| 26 |
if not gemini_api_key:
|
| 27 |
-
raise gr.
|
| 28 |
|
| 29 |
if not anthropic_api_key:
|
| 30 |
-
raise gr.
|
| 31 |
|
| 32 |
if file_name:
|
| 33 |
file_name = f"data/{file_name}"
|
|
@@ -44,7 +44,7 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
|
|
| 44 |
|
| 45 |
answer = run_crew(question, file_name)
|
| 46 |
except Exception as e:
|
| 47 |
-
raise gr.
|
| 48 |
finally:
|
| 49 |
del os.environ["OPENAI_API_KEY"]
|
| 50 |
del os.environ["GEMINI_API_KEY"]
|
|
|
|
| 18 |
str: The answer to the question
|
| 19 |
"""
|
| 20 |
if not question:
|
| 21 |
+
raise gr.Warning("Question is required.")
|
| 22 |
|
| 23 |
if not openai_api_key:
|
| 24 |
+
raise gr.Warning("OpenAI API Key is required.")
|
| 25 |
|
| 26 |
if not gemini_api_key:
|
| 27 |
+
raise gr.Warning("Gemini API Key is required.")
|
| 28 |
|
| 29 |
if not anthropic_api_key:
|
| 30 |
+
raise gr.Warning("Anthropic API Key is required.")
|
| 31 |
|
| 32 |
if file_name:
|
| 33 |
file_name = f"data/{file_name}"
|
|
|
|
| 44 |
|
| 45 |
answer = run_crew(question, file_name)
|
| 46 |
except Exception as e:
|
| 47 |
+
raise gr.Warning(e)
|
| 48 |
finally:
|
| 49 |
del os.environ["OPENAI_API_KEY"]
|
| 50 |
del os.environ["GEMINI_API_KEY"]
|