Spaces:
Sleeping
Sleeping
Add run_test (#1)
Browse files- Add run_test (0bac53081783fa9a1f77b98ac8ee22cae45d19e0)
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -19,6 +20,24 @@ class BasicAgent:
|
|
19 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
20 |
return fixed_answer
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
24 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
@@ -40,7 +59,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
40 |
|
41 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
42 |
try:
|
43 |
-
agent =
|
44 |
except Exception as e:
|
45 |
print(f"Error instantiating agent: {e}")
|
46 |
return f"Error initializing agent: {e}", None
|
@@ -161,6 +180,7 @@ with gr.Blocks() as demo:
|
|
161 |
gr.LoginButton()
|
162 |
|
163 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
|
|
164 |
|
165 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
166 |
# Removed max_rows=10 from DataFrame constructor
|
@@ -171,6 +191,11 @@ with gr.Blocks() as demo:
|
|
171 |
outputs=[status_output, results_table]
|
172 |
)
|
173 |
|
|
|
|
|
|
|
|
|
|
|
174 |
if __name__ == "__main__":
|
175 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
176 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
import agent.py as ag
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
|
|
20 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
21 |
return fixed_answer
|
22 |
|
23 |
+
def run_test( profile: gr.OAuthProfile | None):
|
24 |
+
"""
|
25 |
+
Used only during development for test purpose.
|
26 |
+
"""
|
27 |
+
# 1. Instantiate Agent
|
28 |
+
try:
|
29 |
+
agent = ag.QAgent()
|
30 |
+
except Exception as e:
|
31 |
+
print(f"Error instantiating agent: {e}")
|
32 |
+
return f"Error initializing agent: {e}", None
|
33 |
+
|
34 |
+
try:
|
35 |
+
answer = agent("What kind of techno is Kyber, from former lead developer of VLC ?")
|
36 |
+
except Exception as e:
|
37 |
+
print(f"Error running agent a test run: {e}")
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
42 |
"""
|
43 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
59 |
|
60 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
61 |
try:
|
62 |
+
agent = ag.QAgent()
|
63 |
except Exception as e:
|
64 |
print(f"Error instantiating agent: {e}")
|
65 |
return f"Error initializing agent: {e}", None
|
|
|
180 |
gr.LoginButton()
|
181 |
|
182 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
183 |
+
run_test_button = gr.Button("Run test")
|
184 |
|
185 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
186 |
# Removed max_rows=10 from DataFrame constructor
|
|
|
191 |
outputs=[status_output, results_table]
|
192 |
)
|
193 |
|
194 |
+
run_test_button.click(
|
195 |
+
fn=run_test,
|
196 |
+
outputs=[status_output, results_table]
|
197 |
+
)
|
198 |
+
|
199 |
if __name__ == "__main__":
|
200 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
201 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|