Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -206,21 +206,47 @@ if __name__ == "__main__":
|
|
| 206 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 207 |
|
| 208 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 209 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
-
|
|
|
|
| 212 |
free_question = gr.Textbox(label="Ask your own question")
|
| 213 |
free_response = gr.Textbox(label="Agent's Response", interactive=False)
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
return test_agent(q)
|
| 220 |
|
| 221 |
free_question.submit(fn=run_custom_query, inputs=free_question, outputs=free_response)
|
| 222 |
|
| 223 |
|
| 224 |
|
|
|
|
| 225 |
|
| 226 |
demo.launch(debug=True, share=False)
|
|
|
|
| 206 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 207 |
|
| 208 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 209 |
+
with gr.Blocks() as demo:
|
| 210 |
+
gr.Markdown("# Basic Agent Evaluation Runner")
|
| 211 |
+
gr.Markdown(
|
| 212 |
+
"""
|
| 213 |
+
**Instructions:**
|
| 214 |
+
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 215 |
+
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 216 |
+
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
| 217 |
+
---
|
| 218 |
+
**Disclaimers:**
|
| 219 |
+
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|
| 220 |
+
This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
|
| 221 |
+
"""
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
gr.LoginButton()
|
| 225 |
+
|
| 226 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 227 |
+
|
| 228 |
+
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 229 |
+
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 230 |
+
|
| 231 |
+
run_button.click(
|
| 232 |
+
fn=run_and_submit_all,
|
| 233 |
+
outputs=[status_output, results_table]
|
| 234 |
+
)
|
| 235 |
|
| 236 |
+
# β
Manual Test Interface (Put inside Blocks!)
|
| 237 |
+
gr.Markdown("## Ask your Agent Any Question (Manual Test)")
|
| 238 |
free_question = gr.Textbox(label="Ask your own question")
|
| 239 |
free_response = gr.Textbox(label="Agent's Response", interactive=False)
|
| 240 |
+
|
| 241 |
+
test_agent = BasicAgent()
|
| 242 |
+
|
| 243 |
+
def run_custom_query(q):
|
| 244 |
+
return test_agent(q)
|
|
|
|
| 245 |
|
| 246 |
free_question.submit(fn=run_custom_query, inputs=free_question, outputs=free_response)
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
+
|
| 251 |
|
| 252 |
demo.launch(debug=True, share=False)
|