Add quickstart script and update README (#325)

Co-authored-by: Aneesh Prasad <aneeshprasad@Aneeshs-MacBook-Pro.local>
This commit is contained in:
aneeshprasad1
2025-09-01 08:14:24 -07:00
committed by GitHub
parent 756e006af6
commit 8513e8c89e
2 changed files with 68 additions and 37 deletions

View File

@@ -106,45 +106,13 @@ We are working on supporting more 👷. Please hold tight!
## 🚀 Quick Start
Run the following minimal example to interact with the environment:
```python
from desktop_env.desktop_env import DesktopEnv
```bash
# Basic usage with default settings
python quickstart.py
example = {
"id": "94d95f96-9699-4208-98ba-3c3119edf9c2",
"instruction": "I want to install Spotify on my current system. Could you please help me?",
"config": [
{
"type": "execute",
"parameters": {
"command": [
"python",
"-c",
"import pyautogui; import time; pyautogui.click(960, 540); time.sleep(0.5);"
]
}
}
],
"evaluator": {
"func": "check_include_exclude",
"result": {
"type": "vm_command_line",
"command": "which spotify"
},
"expected": {
"type": "rule",
"rules": {
"include": ["spotify"],
"exclude": ["not found"]
}
}
}
}
# Customize provider and VM path
python quickstart.py --provider_name vmware --path_to_vm "path/to/your/vm.vmx"
env = DesktopEnv(action_space="pyautogui")
obs = env.reset(task_config=example)
obs, reward, done, info = env.step("pyautogui.rightClick()")
```
You will see all the logs of the system running normally, including the successful creation of the environment, completion of setup, and successful execution of actions. In the end, you will observe a successful right-click on the screen, which means you are ready to go.
## 🧪 Experiments

63
quickstart.py Normal file
View File

@@ -0,0 +1,63 @@
from desktop_env.desktop_env import DesktopEnv
import argparse
example = {
"id": "94d95f96-9699-4208-98ba-3c3119edf9c2",
"instruction": "I want to install Spotify on my current system. Could you please help me?",
"config": [
{
"type": "execute",
"parameters": {
"command": [
"python",
"-c",
"import pyautogui; import time; pyautogui.click(960, 540); time.sleep(0.5);"
]
}
}
],
"evaluator": {
"func": "check_include_exclude",
"result": {
"type": "vm_command_line",
"command": "which spotify"
},
"expected": {
"type": "rule",
"rules": {
"include": ["spotify"],
"exclude": ["not found"]
}
}
}
}
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--provider_name", type=str, default="vmware")
parser.add_argument("--path_to_vm", type=str, default="vmware_vm_data/Ubuntu-arm/Ubuntu.vmx")
parser.add_argument("--os_type", type=str, default="Ubuntu")
parser.add_argument("--action_space", type=str, default="pyautogui")
parser.add_argument("--headless", type=bool, default=False) # Set to True if you want to run without GUI
args = parser.parse_args()
# Initialize DesktopEnv
env = DesktopEnv(
provider_name=args.provider_name,
path_to_vm=args.path_to_vm,
os_type=args.os_type,
action_space=args.action_space,
headless=args.headless
)
print("Starting OSWorld environment...")
obs = env.reset(task_config=example)
print("Environment reset complete!")
print("Executing action: pyautogui.rightClick()")
obs, reward, done, info = env.step("pyautogui.rightClick()")
print("Action executed successfully!")
# Clean up
env.close()
print("Environment closed.")