Remove session hash logging
Browse files
app.py
CHANGED
|
@@ -366,14 +366,6 @@ def cleanup_sandboxes():
|
|
| 366 |
|
| 367 |
def get_or_create_sandbox(session_hash):
|
| 368 |
current_time = time.time()
|
| 369 |
-
print("======")
|
| 370 |
-
print(":=======")
|
| 371 |
-
print("Session hash:", session_hash)
|
| 372 |
-
print("Sandboxes:", SANDBOXES.keys())
|
| 373 |
-
print("Session hash in SANDBOXES:", session_hash in SANDBOXES)
|
| 374 |
-
print("Session hash in SANDBOX_METADATA:", session_hash in SANDBOX_METADATA)
|
| 375 |
-
if session_hash in SANDBOX_METADATA:
|
| 376 |
-
print("Session not timeout:", current_time - SANDBOX_METADATA[session_hash]['created_at'] < SANDBOX_TIMEOUT)
|
| 377 |
|
| 378 |
# Check if sandbox exists and is still valid
|
| 379 |
if (session_hash in SANDBOXES and
|
|
@@ -489,6 +481,11 @@ def create_agent(data_dir, desktop):
|
|
| 489 |
planning_interval=10,
|
| 490 |
)
|
| 491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
|
| 493 |
class EnrichedGradioUI(GradioUI):
|
| 494 |
def log_user_message(self, text_input):
|
|
@@ -514,11 +511,6 @@ class EnrichedGradioUI(GradioUI):
|
|
| 514 |
session_state["agent"].data_dir = data_dir # Update data dir to new interaction
|
| 515 |
else:
|
| 516 |
session_state["agent"] = create_agent(data_dir=data_dir, desktop=desktop)
|
| 517 |
-
|
| 518 |
-
if "replay_log" in session_state and session_state["replay_log"] is not None:
|
| 519 |
-
original_model = session_state["agent"].model
|
| 520 |
-
session_state["agent"].model = FakeModelReplayLog(session_state["replay_log"])
|
| 521 |
-
|
| 522 |
|
| 523 |
try:
|
| 524 |
stored_messages.append(gr.ChatMessage(role="user", content=task_input))
|
|
@@ -533,27 +525,19 @@ class EnrichedGradioUI(GradioUI):
|
|
| 533 |
stored_messages.append(msg)
|
| 534 |
yield stored_messages
|
| 535 |
|
| 536 |
-
yield stored_messages
|
| 537 |
# THIS ERASES IMAGES FROM MEMORY, USE WITH CAUTION
|
| 538 |
-
|
| 539 |
-
for memory_step in memory.steps:
|
| 540 |
-
if getattr(memory_step, "observations_images", None):
|
| 541 |
-
memory_step.observations_images = None
|
| 542 |
-
summary = memory.get_succinct_steps()
|
| 543 |
save_final_status(data_dir, "completed", summary = summary)
|
|
|
|
| 544 |
|
| 545 |
-
# # TODO: uncomment below after testing
|
| 546 |
except Exception as e:
|
| 547 |
error_message=f"Error in interaction: {str(e)}"
|
| 548 |
stored_messages.append(gr.ChatMessage(role="assistant", content=error_message))
|
|
|
|
|
|
|
| 549 |
yield stored_messages
|
| 550 |
raise e
|
| 551 |
-
save_final_status(data_dir, "failed", summary=[], error_message=error_message)
|
| 552 |
-
|
| 553 |
finally:
|
| 554 |
-
if "replay_log" in session_state and session_state["replay_log"] is not None: # Replace the model with original model
|
| 555 |
-
session_state["agent"].model = original_model
|
| 556 |
-
session_state["replay_log"] = None
|
| 557 |
upload_to_hf_and_remove(data_dir)
|
| 558 |
|
| 559 |
theme = gr.themes.Default(font=["Oxanium", "sans-serif"], primary_hue="amber", secondary_hue="blue")
|
|
|
|
| 366 |
|
| 367 |
def get_or_create_sandbox(session_hash):
|
| 368 |
current_time = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
# Check if sandbox exists and is still valid
|
| 371 |
if (session_hash in SANDBOXES and
|
|
|
|
| 481 |
planning_interval=10,
|
| 482 |
)
|
| 483 |
|
| 484 |
+
def get_agent_summary_erase_images(agent):
|
| 485 |
+
for memory_step in agent.memory.steps:
|
| 486 |
+
if getattr(memory_step, "observations_images", None):
|
| 487 |
+
memory_step.observations_images = None
|
| 488 |
+
return agent.memory.get_succinct_steps()
|
| 489 |
|
| 490 |
class EnrichedGradioUI(GradioUI):
|
| 491 |
def log_user_message(self, text_input):
|
|
|
|
| 511 |
session_state["agent"].data_dir = data_dir # Update data dir to new interaction
|
| 512 |
else:
|
| 513 |
session_state["agent"] = create_agent(data_dir=data_dir, desktop=desktop)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
try:
|
| 516 |
stored_messages.append(gr.ChatMessage(role="user", content=task_input))
|
|
|
|
| 525 |
stored_messages.append(msg)
|
| 526 |
yield stored_messages
|
| 527 |
|
|
|
|
| 528 |
# THIS ERASES IMAGES FROM MEMORY, USE WITH CAUTION
|
| 529 |
+
summary = get_agent_summary_erase_images(session_state["agent"])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
save_final_status(data_dir, "completed", summary = summary)
|
| 531 |
+
yield stored_messages
|
| 532 |
|
|
|
|
| 533 |
except Exception as e:
|
| 534 |
error_message=f"Error in interaction: {str(e)}"
|
| 535 |
stored_messages.append(gr.ChatMessage(role="assistant", content=error_message))
|
| 536 |
+
summary = get_agent_summary_erase_images(session_state["agent"])
|
| 537 |
+
save_final_status(data_dir, "failed", summary=summary, error_message=error_message)
|
| 538 |
yield stored_messages
|
| 539 |
raise e
|
|
|
|
|
|
|
| 540 |
finally:
|
|
|
|
|
|
|
|
|
|
| 541 |
upload_to_hf_and_remove(data_dir)
|
| 542 |
|
| 543 |
theme = gr.themes.Default(font=["Oxanium", "sans-serif"], primary_hue="amber", secondary_hue="blue")
|