Fix some errors found in thunderbird examples
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import ctypes
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import func_timeout
|
||||
|
||||
from desktop_env.envs.desktop_env import DesktopEnv
|
||||
from mm_agents.gpt_4v_agent import GPT4v_Agent
|
||||
@@ -104,28 +104,10 @@ def run_one_example(example, agent, max_steps=10, example_trajectory_dir="exp_tr
|
||||
except Exception as e:
|
||||
print(f"An error occurred while stopping the recording: {e}")
|
||||
|
||||
# Run the `record` function in a separate thread
|
||||
recording_thread = threading.Thread(target=stop_recording())
|
||||
recording_thread.start()
|
||||
|
||||
# Start a timer for your timeout length (in this case, 60 seconds)
|
||||
timeout = 60 # seconds
|
||||
start_time = time.time()
|
||||
|
||||
# The main thread will wait for the set timeout period or until the recording is done
|
||||
while recording_thread.is_alive():
|
||||
elapsed_time = time.time() - start_time
|
||||
if elapsed_time >= timeout:
|
||||
print("Timeout reached. Stopping recording.")
|
||||
break
|
||||
time.sleep(0.1) # Sleep for a short time to prevent this loop from using too much CPU
|
||||
|
||||
# kill the recording thread if it is still alive
|
||||
if recording_thread.is_alive():
|
||||
recording_thread.kill()
|
||||
|
||||
# Wait for the recording thread to finish before exiting
|
||||
recording_thread.join()
|
||||
try:
|
||||
func_timeout.func_timeout(30, stop_recording)
|
||||
except func_timeout.exceptions.FunctionTimedOut:
|
||||
logger.info("Recording timed out.")
|
||||
|
||||
result = env.evaluate()
|
||||
logger.info("Result: %.2f", result)
|
||||
@@ -147,7 +129,7 @@ def main(example_class, example_id):
|
||||
|
||||
with open(f"evaluation_examples/examples/{example_class}/{example_id}.json", "r", encoding="utf-8") as f:
|
||||
example = json.load(f)
|
||||
example["snapshot"] = "exp_chrome"
|
||||
example["snapshot"] = "exp_v1"
|
||||
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
agent = GPT4v_Agent(api_key=api_key, model=gpt4_model, instruction=example['instruction'],
|
||||
|
||||
Reference in New Issue
Block a user