Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,13 @@ from util import get_questions
|
|
| 5 |
|
| 6 |
QUESTION_FILE_PATH = "data/gaia_validation_20.jsonl"
|
| 7 |
|
| 8 |
-
def invoke(level, question, file_name, ground_truth, google_api_key):
|
| 9 |
if not question:
|
| 10 |
raise gr.Error("Question is required.")
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
if not google_api_key:
|
| 13 |
raise gr.Error("Google API Key is required.")
|
| 14 |
|
|
@@ -21,12 +24,14 @@ def invoke(level, question, file_name, ground_truth, google_api_key):
|
|
| 21 |
answer = ""
|
| 22 |
|
| 23 |
try:
|
|
|
|
| 24 |
os.environ["GOOGLE_API_KEY"] = google_api_key
|
| 25 |
|
| 26 |
answer = run_crew(question, file_name)
|
| 27 |
except Exception as e:
|
| 28 |
raise gr.Error(e)
|
| 29 |
finally:
|
|
|
|
| 30 |
del os.environ["GOOGLE_API_KEY"]
|
| 31 |
|
| 32 |
return answer
|
|
@@ -38,6 +43,7 @@ demo = gr.Interface(fn=invoke,
|
|
| 38 |
gr.Markdown(label="Question"),
|
| 39 |
gr.Textbox(label="File Name"),
|
| 40 |
gr.Textbox(label="Ground Truth"),
|
|
|
|
| 41 |
gr.Textbox(label="Google API Key", type="password")],
|
| 42 |
outputs=[gr.Textbox(label="Answer", lines=1, interactive=False)],
|
| 43 |
title="General AI Assistant (GAIA) 🤖🤝🤖",
|
|
|
|
| 5 |
|
| 6 |
QUESTION_FILE_PATH = "data/gaia_validation_20.jsonl"
|
| 7 |
|
| 8 |
+
def invoke(level, question, file_name, ground_truth, openai_api_key, google_api_key):
|
| 9 |
if not question:
|
| 10 |
raise gr.Error("Question is required.")
|
| 11 |
+
|
| 12 |
+
if not openai_api_key:
|
| 13 |
+
raise gr.Error("OpenAI API Key is required.")
|
| 14 |
+
|
| 15 |
if not google_api_key:
|
| 16 |
raise gr.Error("Google API Key is required.")
|
| 17 |
|
|
|
|
| 24 |
answer = ""
|
| 25 |
|
| 26 |
try:
|
| 27 |
+
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 28 |
os.environ["GOOGLE_API_KEY"] = google_api_key
|
| 29 |
|
| 30 |
answer = run_crew(question, file_name)
|
| 31 |
except Exception as e:
|
| 32 |
raise gr.Error(e)
|
| 33 |
finally:
|
| 34 |
+
del os.environ["OPENAI_API_KEY"]
|
| 35 |
del os.environ["GOOGLE_API_KEY"]
|
| 36 |
|
| 37 |
return answer
|
|
|
|
| 43 |
gr.Markdown(label="Question"),
|
| 44 |
gr.Textbox(label="File Name"),
|
| 45 |
gr.Textbox(label="Ground Truth"),
|
| 46 |
+
gr.Textbox(label="OpenAI API Key", type="password")],
|
| 47 |
gr.Textbox(label="Google API Key", type="password")],
|
| 48 |
outputs=[gr.Textbox(label="Answer", lines=1, interactive=False)],
|
| 49 |
title="General AI Assistant (GAIA) 🤖🤝🤖",
|