Spaces:
Build error
Build error
test_app.py
Browse files- test_app.py +97 -0
test_app.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from agent import BasicAgent
|
| 3 |
+
|
| 4 |
+
agent = BasicAgent()
|
| 5 |
+
|
| 6 |
+
def run_agent(question):
|
| 7 |
+
return agent(question)
|
| 8 |
+
|
| 9 |
+
with gr.Blocks() as demo:
|
| 10 |
+
gr.Markdown("# Agent Tool Tester")
|
| 11 |
+
|
| 12 |
+
with gr.Row():
|
| 13 |
+
question_input = gr.Textbox(label="Question")
|
| 14 |
+
run_button = gr.Button("Run Agent")
|
| 15 |
+
|
| 16 |
+
output = gr.Textbox(label="Agent Output")
|
| 17 |
+
|
| 18 |
+
run_button.click(fn=run_agent, inputs=question_input, outputs=output)
|
| 19 |
+
|
| 20 |
+
gr.Markdown("## Pre-defined Questions")
|
| 21 |
+
|
| 22 |
+
with gr.Accordion("Python Interpreter"):
|
| 23 |
+
gr.Examples(
|
| 24 |
+
examples=[
|
| 25 |
+
"What is 2 + 2?",
|
| 26 |
+
"What is the square root of 144?",
|
| 27 |
+
],
|
| 28 |
+
inputs=question_input
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
with gr.Accordion("DuckDuckGo Search"):
|
| 32 |
+
gr.Examples(
|
| 33 |
+
examples=[
|
| 34 |
+
"What is the capital of France?",
|
| 35 |
+
"Who is the current president of the United States?",
|
| 36 |
+
],
|
| 37 |
+
inputs=question_input
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
with gr.Accordion("File Reader from URL"):
|
| 41 |
+
gr.Examples(
|
| 42 |
+
examples=[
|
| 43 |
+
"Read the first 5 rows of this CSV file: https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv",
|
| 44 |
+
],
|
| 45 |
+
inputs=question_input
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
with gr.Accordion("Wikipedia"):
|
| 49 |
+
gr.Examples(
|
| 50 |
+
examples=[
|
| 51 |
+
"Tell me about the Eiffel Tower.",
|
| 52 |
+
],
|
| 53 |
+
inputs=question_input
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
with gr.Accordion("YouTube Transcript Reader"):
|
| 57 |
+
gr.Examples(
|
| 58 |
+
examples=[
|
| 59 |
+
"What is the summary of the video https://www.youtube.com/watch?v=dQw4w9WgXcQ?",
|
| 60 |
+
],
|
| 61 |
+
inputs=question_input
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
with gr.Accordion("Web Page Reader"):
|
| 65 |
+
gr.Examples(
|
| 66 |
+
examples=[
|
| 67 |
+
"Read the content of the page https://en.wikipedia.org/wiki/Main_Page",
|
| 68 |
+
],
|
| 69 |
+
inputs=question_input
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
with gr.Accordion("Audio Analyzer"):
|
| 73 |
+
gr.Examples(
|
| 74 |
+
examples=[
|
| 75 |
+
"Transcribe the audio from this URL: https://www.kozco.com/tech/piano2-CoolEdit.mp3",
|
| 76 |
+
],
|
| 77 |
+
inputs=question_input
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
with gr.Accordion("Video Analyzer"):
|
| 81 |
+
gr.Examples(
|
| 82 |
+
examples=[
|
| 83 |
+
"Transcribe the audio from this video: https://www.w3schools.com/html/mov_bbb.mp4",
|
| 84 |
+
],
|
| 85 |
+
inputs=question_input
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
with gr.Accordion("Image Analyzer"):
|
| 89 |
+
gr.Examples(
|
| 90 |
+
examples=[
|
| 91 |
+
"What is in this image? https://www.w3schools.com/html/img_chania.jpg",
|
| 92 |
+
],
|
| 93 |
+
inputs=question_input
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
if __name__ == "__main__":
|
| 97 |
+
demo.launch()
|