Skip to content

Commit 7a86580

Browse files
author
katiue
committed
optimize code
1 parent 808d40c commit 7a86580

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

webui.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def run_browser_agent(
8686
)
8787

8888
if agent_type == "org":
89-
final_result, errors, model_actions, model_thoughts, recorded_files, trace_file = await run_org_agent(
89+
final_result, errors, model_actions, model_thoughts = await run_org_agent(
9090
llm=llm,
9191
headless=headless,
9292
disable_security=disable_security,
@@ -158,19 +158,21 @@ async def run_org_agent(
158158
trace_path=save_trace_path if save_trace_path else None,
159159
save_recording_path=save_recording_path if save_recording_path else None,
160160
no_viewport=False,
161-
browser_window_size=BrowserContextWindowSize(width=window_w, height=window_h),
161+
browser_window_size=BrowserContextWindowSize(
162+
width=window_w, height=window_h
163+
),
162164
)
163165
) as browser_context:
164166
agent = Agent(
165167
task=task,
166168
llm=llm,
167169
use_vision=use_vision,
168-
max_actions_per_step=max_actions_per_step,
169-
tool_call_in_content=tool_call_in_content,
170170
browser_context=browser_context,
171+
max_actions_per_step=max_actions_per_step,
172+
tool_call_in_content=tool_call_in_content
171173
)
172174
history = await agent.run(max_steps=max_steps)
173-
175+
174176
final_result = history.final_result()
175177
errors = history.errors()
176178
model_actions = history.model_actions()
@@ -196,7 +198,7 @@ async def run_custom_agent(
196198
max_steps,
197199
use_vision,
198200
max_actions_per_step,
199-
tool_call_in_content,
201+
tool_call_in_content
200202
):
201203
global _global_browser, _global_browser_context, _global_playwright
202204

@@ -636,22 +638,22 @@ def create_ui(theme_name="Ocean"):
636638
)
637639

638640
with gr.TabItem("🤖 Run Agent", id=4):
639-
task = gr.Textbox(
640-
lines=4,
641-
value="go to google.com and type 'OpenAI' click search and give me the first url",
642-
info="Describe what you want the agent to do",
643-
)
644-
add_infos = gr.Textbox(lines=3, label="Additional Information")
641+
task = gr.Textbox(
642+
lines=4,
643+
value="go to google.com and type 'OpenAI' click search and give me the first url",
644+
info="Describe what you want the agent to do",
645+
)
646+
add_infos = gr.Textbox(lines=3, label="Additional Information")
647+
648+
with gr.Row():
649+
run_button = gr.Button("▶️ Run Agent", variant="primary", scale=2)
650+
stop_button = gr.Button("⏹️ Stop", variant="stop", scale=1)
645651

646-
with gr.Row():
647-
run_button = gr.Button("▶️ Run Agent", variant="primary", scale=2)
648-
stop_button = gr.Button("⏹️ Stop", variant="stop", scale=1)
649-
650-
with gr.Row():
651-
browser_view = gr.HTML(
652-
value="<div>Waiting for browser session...</div>",
653-
label="Live Browser View",
654-
)
652+
with gr.Row():
653+
browser_view = gr.HTML(
654+
value="<div>Waiting for browser session...</div>",
655+
label="Live Browser View",
656+
)
655657

656658
with gr.TabItem("📊 Results", id=5):
657659
with gr.Group():

0 commit comments

Comments
 (0)