Sidebar
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ from e2bqwen import QwenVLAPIModel, E2BVisionAgent
|
|
| 19 |
E2B_API_KEY = os.getenv("E2B_API_KEY")
|
| 20 |
SANDBOXES = {}
|
| 21 |
SANDBOX_METADATA = {}
|
| 22 |
-
SANDBOX_TIMEOUT =
|
| 23 |
WIDTH = 1280
|
| 24 |
HEIGHT = 960
|
| 25 |
TMP_DIR = './tmp/'
|
|
@@ -70,6 +70,11 @@ custom_css = """
|
|
| 70 |
transform: scale(0.65);
|
| 71 |
}
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
/* Status indicator light */
|
| 74 |
.status-indicator {
|
| 75 |
position: absolute;
|
|
@@ -512,7 +517,7 @@ class EnrichedGradioUI(GradioUI):
|
|
| 512 |
""")
|
| 513 |
|
| 514 |
try:
|
| 515 |
-
messages.append(gr.ChatMessage(role="user", content=
|
| 516 |
yield messages
|
| 517 |
|
| 518 |
for msg in stream_to_gradio(session_state["agent"], task=full_task, reset_agent_memory=False):
|
|
@@ -534,36 +539,50 @@ class EnrichedGradioUI(GradioUI):
|
|
| 534 |
|
| 535 |
|
| 536 |
# Create a Gradio app with Blocks
|
| 537 |
-
with gr.Blocks(css=custom_css, js=custom_js) as demo:
|
| 538 |
#Storing session hash in a state variable
|
| 539 |
session_hash_state = gr.State(None)
|
| 540 |
|
| 541 |
-
gr.Markdown("# GUI Agent assistant")
|
| 542 |
|
| 543 |
-
sandbox_html = gr.HTML(
|
| 544 |
-
value=sandbox_html_template.format(
|
| 545 |
-
stream_url="",
|
| 546 |
-
status_class="status-interactive",
|
| 547 |
-
status_text="Interactive"
|
| 548 |
-
),
|
| 549 |
-
label="Output"
|
| 550 |
-
)
|
| 551 |
with gr.Row():
|
| 552 |
-
|
| 553 |
-
value=
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
"Check the commuting time between Bern and Zurich",
|
| 560 |
-
"Write 'Hello World' in a text editor",
|
| 561 |
-
"Search a flight Paris - Berlin for tomorrow"
|
| 562 |
-
],
|
| 563 |
-
inputs = task_input,
|
| 564 |
-
label= "Example Tasks",
|
| 565 |
-
examples_per_page=4
|
| 566 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
|
| 568 |
# with gr.Group(visible=True) as terminal_container:
|
| 569 |
|
|
@@ -576,20 +595,6 @@ with gr.Blocks(css=custom_css, js=custom_js) as demo:
|
|
| 576 |
#)
|
| 577 |
|
| 578 |
|
| 579 |
-
# Hidden refresh button
|
| 580 |
-
refresh_btn = gr.Button("Refresh", visible=False, elem_id="refresh-log-btn")
|
| 581 |
-
|
| 582 |
-
session_state = gr.State({})
|
| 583 |
-
stored_messages = gr.State([])
|
| 584 |
-
|
| 585 |
-
with gr.Group(visible=False) as results_container:
|
| 586 |
-
results_output = gr.Textbox(
|
| 587 |
-
label="Results",
|
| 588 |
-
interactive=False,
|
| 589 |
-
elem_id="results-output"
|
| 590 |
-
)
|
| 591 |
-
|
| 592 |
-
update_btn = gr.Button("Let's go!")
|
| 593 |
|
| 594 |
chatbot = gr.Chatbot(
|
| 595 |
label="Agent's execution logs",
|
|
|
|
| 19 |
E2B_API_KEY = os.getenv("E2B_API_KEY")
|
| 20 |
SANDBOXES = {}
|
| 21 |
SANDBOX_METADATA = {}
|
| 22 |
+
SANDBOX_TIMEOUT = 600
|
| 23 |
WIDTH = 1280
|
| 24 |
HEIGHT = 960
|
| 25 |
TMP_DIR = './tmp/'
|
|
|
|
| 70 |
transform: scale(0.65);
|
| 71 |
}
|
| 72 |
|
| 73 |
+
.primary-color-label label span {
|
| 74 |
+
font-weight: bold;
|
| 75 |
+
color: var(--button-primary-border-color);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
/* Status indicator light */
|
| 79 |
.status-indicator {
|
| 80 |
position: absolute;
|
|
|
|
| 517 |
""")
|
| 518 |
|
| 519 |
try:
|
| 520 |
+
messages.append(gr.ChatMessage(role="user", content=task_input))
|
| 521 |
yield messages
|
| 522 |
|
| 523 |
for msg in stream_to_gradio(session_state["agent"], task=full_task, reset_agent_memory=False):
|
|
|
|
| 539 |
|
| 540 |
|
| 541 |
# Create a Gradio app with Blocks
|
| 542 |
+
with gr.Blocks(css=custom_css, js=custom_js, fill_width=True) as demo:
|
| 543 |
#Storing session hash in a state variable
|
| 544 |
session_hash_state = gr.State(None)
|
| 545 |
|
| 546 |
+
gr.Markdown("# GUI Agent - Input your task and run your personal assistant!")
|
| 547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
with gr.Row():
|
| 549 |
+
sandbox_html = gr.HTML(
|
| 550 |
+
value=sandbox_html_template.format(
|
| 551 |
+
stream_url="",
|
| 552 |
+
status_class="status-interactive",
|
| 553 |
+
status_text="Interactive"
|
| 554 |
+
),
|
| 555 |
+
label="Output"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
)
|
| 557 |
+
with gr.Sidebar(position="left"):
|
| 558 |
+
task_input = gr.Textbox(
|
| 559 |
+
value="Find picture of cute puppies",
|
| 560 |
+
label="Enter your task below:",
|
| 561 |
+
elem_classes="primary-color-label"
|
| 562 |
+
)
|
| 563 |
+
|
| 564 |
+
gr.Examples(
|
| 565 |
+
examples=[
|
| 566 |
+
"Check the commuting time between Bern and Zurich",
|
| 567 |
+
"Write 'Hello World' in a text editor",
|
| 568 |
+
"Search a flight Paris - Berlin for tomorrow"
|
| 569 |
+
],
|
| 570 |
+
inputs = task_input,
|
| 571 |
+
label= "Example Tasks",
|
| 572 |
+
examples_per_page=4
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
session_state = gr.State({})
|
| 576 |
+
stored_messages = gr.State([])
|
| 577 |
+
|
| 578 |
+
with gr.Group(visible=False) as results_container:
|
| 579 |
+
results_output = gr.Textbox(
|
| 580 |
+
label="Results",
|
| 581 |
+
interactive=False,
|
| 582 |
+
elem_id="results-output"
|
| 583 |
+
)
|
| 584 |
+
|
| 585 |
+
update_btn = gr.Button("Let's go!", variant="primary")
|
| 586 |
|
| 587 |
# with gr.Group(visible=True) as terminal_container:
|
| 588 |
|
|
|
|
| 595 |
#)
|
| 596 |
|
| 597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
|
| 599 |
chatbot = gr.Chatbot(
|
| 600 |
label="Agent's execution logs",
|