Repair second task
Browse files- app.py +9 -7
- e2bqwen.py +4 -4
app.py
CHANGED
|
@@ -118,6 +118,7 @@ custom_css = """
|
|
| 118 |
|
| 119 |
.logo-container {
|
| 120 |
display: flex;
|
|
|
|
| 121 |
justify-content: space-between;
|
| 122 |
align-items: center;
|
| 123 |
width: 100%;
|
|
@@ -386,8 +387,9 @@ def get_or_create_sandbox(session_hash):
|
|
| 386 |
print(f"Creating new sandbox for session {session_hash}")
|
| 387 |
desktop = Sandbox(api_key=E2B_API_KEY, resolution=(WIDTH, HEIGHT), dpi=96, timeout=SANDBOX_TIMEOUT)
|
| 388 |
desktop.stream.start(require_auth=True)
|
| 389 |
-
|
| 390 |
-
|
|
|
|
| 391 |
|
| 392 |
# Store sandbox with metadata
|
| 393 |
SANDBOXES[session_hash] = desktop
|
|
@@ -591,7 +593,6 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, fill_width=True) as de
|
|
| 591 |
<style>
|
| 592 |
:root {
|
| 593 |
--body-background-fill: black!important;
|
| 594 |
-
--background-fill-secondary: #fad391!important;
|
| 595 |
--body-text-color: #f59e0b!important;
|
| 596 |
--block-text-color: #f59e0b!important;
|
| 597 |
--font: Oxanium;
|
|
@@ -641,6 +642,11 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, fill_width=True) as de
|
|
| 641 |
outputs=[theme_styles]
|
| 642 |
)
|
| 643 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
chatbot_display = gr.Chatbot(
|
| 645 |
label="Agent's execution logs",
|
| 646 |
type="messages",
|
|
@@ -652,10 +658,6 @@ with gr.Blocks(theme=theme, css=custom_css, js=custom_js, fill_width=True) as de
|
|
| 652 |
scale=1,
|
| 653 |
)
|
| 654 |
|
| 655 |
-
footer_html = gr.HTML(
|
| 656 |
-
value=footer_html,
|
| 657 |
-
label="Header"
|
| 658 |
-
)
|
| 659 |
agent_ui = EnrichedGradioUI(CodeAgent(tools=[], model=None, name="ok", description="ok"))
|
| 660 |
|
| 661 |
def read_log_content(log_file, tail=4):
|
|
|
|
| 118 |
|
| 119 |
.logo-container {
|
| 120 |
display: flex;
|
| 121 |
+
flex-direction: column;
|
| 122 |
justify-content: space-between;
|
| 123 |
align-items: center;
|
| 124 |
width: 100%;
|
|
|
|
| 387 |
print(f"Creating new sandbox for session {session_hash}")
|
| 388 |
desktop = Sandbox(api_key=E2B_API_KEY, resolution=(WIDTH, HEIGHT), dpi=96, timeout=SANDBOX_TIMEOUT)
|
| 389 |
desktop.stream.start(require_auth=True)
|
| 390 |
+
setup_cmd = """sudo mkdir -p /usr/lib/firefox-esr/distribution && echo '{"policies":{"OverrideFirstRunPage":"","OverridePostUpdatePage":"","DisableProfileImport":true,"DontCheckDefaultBrowser":true}}'
|
| 391 |
+
sudo tee /usr/lib/firefox-esr/distribution/policies.json > /dev/null"""
|
| 392 |
+
desktop.commands.run(setup_cmd)
|
| 393 |
|
| 394 |
# Store sandbox with metadata
|
| 395 |
SANDBOXES[session_hash] = desktop
|
|
|
|
| 593 |
<style>
|
| 594 |
:root {
|
| 595 |
--body-background-fill: black!important;
|
|
|
|
| 596 |
--body-text-color: #f59e0b!important;
|
| 597 |
--block-text-color: #f59e0b!important;
|
| 598 |
--font: Oxanium;
|
|
|
|
| 642 |
outputs=[theme_styles]
|
| 643 |
)
|
| 644 |
|
| 645 |
+
footer = gr.HTML(
|
| 646 |
+
value=footer_html,
|
| 647 |
+
label="Header"
|
| 648 |
+
)
|
| 649 |
+
|
| 650 |
chatbot_display = gr.Chatbot(
|
| 651 |
label="Agent's execution logs",
|
| 652 |
type="messages",
|
|
|
|
| 658 |
scale=1,
|
| 659 |
)
|
| 660 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
agent_ui = EnrichedGradioUI(CodeAgent(tools=[], model=None, name="ok", description="ok"))
|
| 662 |
|
| 663 |
def read_log_content(log_file, tail=4):
|
e2bqwen.py
CHANGED
|
@@ -258,7 +258,7 @@ class E2BVisionAgent(CodeAgent):
|
|
| 258 |
"""
|
| 259 |
Waits for the specified number of seconds. Very useful in case the prior order is still executing (for example starting very heavy applications like browsers or office apps)
|
| 260 |
Args:
|
| 261 |
-
seconds: Number of seconds to wait
|
| 262 |
"""
|
| 263 |
time.sleep(seconds)
|
| 264 |
self.logger.log(self.log_path, f"Waited for {seconds} seconds")
|
|
@@ -336,8 +336,8 @@ class E2BVisionAgent(CodeAgent):
|
|
| 336 |
previous_memory_step.observations_images = None
|
| 337 |
|
| 338 |
# Add to the current memory step
|
| 339 |
-
|
| 340 |
-
memory_step.observations_images = [screenshot_path]
|
| 341 |
|
| 342 |
#Storing memory and metadata to file:
|
| 343 |
self.store_metadata_to_file(agent)
|
|
@@ -441,7 +441,7 @@ class QwenVLAPIModel(Model):
|
|
| 441 |
base64_image = base64.b64encode(image_file.read()).decode("utf-8")
|
| 442 |
else:
|
| 443 |
# Image is a PIL image or similar object
|
| 444 |
-
img_byte_arr =
|
| 445 |
item["image"].save(img_byte_arr, format="PNG")
|
| 446 |
base64_image = base64.b64encode(img_byte_arr.getvalue()).decode("utf-8")
|
| 447 |
|
|
|
|
| 258 |
"""
|
| 259 |
Waits for the specified number of seconds. Very useful in case the prior order is still executing (for example starting very heavy applications like browsers or office apps)
|
| 260 |
Args:
|
| 261 |
+
seconds: Number of seconds to wait, generally 3 is enough.
|
| 262 |
"""
|
| 263 |
time.sleep(seconds)
|
| 264 |
self.logger.log(self.log_path, f"Waited for {seconds} seconds")
|
|
|
|
| 336 |
previous_memory_step.observations_images = None
|
| 337 |
|
| 338 |
# Add to the current memory step
|
| 339 |
+
memory_step.observations_images = [image.copy()] # This takes the original image directly.
|
| 340 |
+
# memory_step.observations_images = [screenshot_path] # IF YOU USE THIS INSTEAD OF ABOVE, LAUNCHING A SECOND TASK BREAKS
|
| 341 |
|
| 342 |
#Storing memory and metadata to file:
|
| 343 |
self.store_metadata_to_file(agent)
|
|
|
|
| 441 |
base64_image = base64.b64encode(image_file.read()).decode("utf-8")
|
| 442 |
else:
|
| 443 |
# Image is a PIL image or similar object
|
| 444 |
+
img_byte_arr = BytesIO()
|
| 445 |
item["image"].save(img_byte_arr, format="PNG")
|
| 446 |
base64_image = base64.b64encode(img_byte_arr.getvalue()).decode("utf-8")
|
| 447 |
|