Update app.py
Browse files
app.py
CHANGED
@@ -6,24 +6,18 @@ from helper import get_questions
|
|
6 |
|
7 |
lock = threading.Lock()
|
8 |
|
9 |
-
def invoke(
|
10 |
-
if not level:
|
11 |
-
raise gr.Error("Level is required.")
|
12 |
-
|
13 |
if not question:
|
14 |
raise gr.Error("Question is required.")
|
15 |
-
|
16 |
-
if not ground_truth:
|
17 |
-
raise gr.Error("Ground Truth is required.")
|
18 |
-
|
19 |
if not openai_api_key:
|
20 |
raise gr.Error("OpenAI API Key is required.")
|
21 |
|
22 |
with lock:
|
23 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
24 |
-
answer
|
25 |
del os.environ["OPENAI_API_KEY"]
|
26 |
-
return answer
|
27 |
|
28 |
gr.close_all()
|
29 |
|
@@ -33,9 +27,7 @@ demo = gr.Interface(fn = invoke,
|
|
33 |
gr.Textbox(label = "File Name"),
|
34 |
gr.Textbox(label = "Ground Truth"),
|
35 |
gr.Textbox(label = "OpenAI API Key", type = "password")],
|
36 |
-
outputs = [gr.Textbox(label = "Answer", lines = 1, interactive = False),
|
37 |
-
gr.Textbox(label = "Final Answer", lines = 1, interactive = False),
|
38 |
-
gr.Radio(["True", "False"], label = "Matches Ground Truth", interactive = False)],
|
39 |
title = "General AI Assistant (GAIA)",
|
40 |
description = os.environ["DESCRIPTION"],
|
41 |
examples = get_questions(),
|
|
|
6 |
|
7 |
lock = threading.Lock()
|
8 |
|
9 |
+
def invoke(question, file_name, openai_api_key):
|
|
|
|
|
|
|
10 |
if not question:
|
11 |
raise gr.Error("Question is required.")
|
12 |
+
|
|
|
|
|
|
|
13 |
if not openai_api_key:
|
14 |
raise gr.Error("OpenAI API Key is required.")
|
15 |
|
16 |
with lock:
|
17 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
18 |
+
answer = run_agent(question, file_name)
|
19 |
del os.environ["OPENAI_API_KEY"]
|
20 |
+
return answer
|
21 |
|
22 |
gr.close_all()
|
23 |
|
|
|
27 |
gr.Textbox(label = "File Name"),
|
28 |
gr.Textbox(label = "Ground Truth"),
|
29 |
gr.Textbox(label = "OpenAI API Key", type = "password")],
|
30 |
+
outputs = [gr.Textbox(label = "Answer", lines = 1, interactive = False)],
|
|
|
|
|
31 |
title = "General AI Assistant (GAIA)",
|
32 |
description = os.environ["DESCRIPTION"],
|
33 |
examples = get_questions(),
|