From c6b051d65fda96b8e639aff6565919a06df4fcd1 Mon Sep 17 00:00:00 2001 From: Sunan Xiang Date: Fri, 28 Nov 2025 18:25:21 -0800 Subject: [PATCH] Appworld integration env setup guide --- examples/appworld/README.md | 35 +++++++ scripts/agent/appworld/install_env_cpu.sh | 81 ++++++++++++++++ scripts/agent/appworld/install_env_gpu.sh | 109 ++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 examples/appworld/README.md create mode 100644 scripts/agent/appworld/install_env_cpu.sh create mode 100755 scripts/agent/appworld/install_env_gpu.sh diff --git a/examples/appworld/README.md b/examples/appworld/README.md new file mode 100644 index 000000000..8272df182 --- /dev/null +++ b/examples/appworld/README.md @@ -0,0 +1,35 @@ +# AppWorld Agent Examples + +Examples for training and running AppWorld agents using rLLM. AppWorld provides a multi-application environment with 9 applications (Spotify, Gmail, Calendar, etc.) and 457 APIs. + +## Quick Start + +### 1. Environment Setup + +```bash +# CPU-only (for local development/testing) +bash scripts/agent/appworld/install_env_cpu.sh + +# GPU (for training/production) +bash scripts/agent/appworld/install_env_gpu.sh +``` + +**Note**: For GPU setup, adjust CUDA version in the script if needed. + +### 2. Install AppWorld + +After setting up the environment: + +```bash +conda activate rllm_py311 # or rllm_py311_gpu +pip install git+https://github.com/StonyBrookNLP/appworld.git +appworld install +appworld download data --root /path/to/your/data/directory +appworld verify tasks +``` + + +## References + +- [AppWorld GitHub](https://github.com/StonyBrookNLP/appworld) +- [rLLM Documentation](../../docs/) diff --git a/scripts/agent/appworld/install_env_cpu.sh b/scripts/agent/appworld/install_env_cpu.sh new file mode 100644 index 000000000..48e3df12e --- /dev/null +++ b/scripts/agent/appworld/install_env_cpu.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# AppWorld Environment Setup Script (CPU Version) +# This script sets up the rLLM environment for AppWorld (with CPU for quick support) + +conda create -n rllm_py311 python=3.11 -y +conda activate rllm_py311 + +# first cpuonly(from pytorch channel) +conda install -c pytorch cpuonly -y + +# install pytorch 2.7.0(from conda-forge) +conda install -c conda-forge pytorch=2.7.0 torchvision torchaudio libtorch -y + +# verify PyTorch +python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA available:', torch.cuda.is_available())" + +# ========== Step 3: install main packages ========== +conda install -c conda-forge \ + numpy scipy pandas pyarrow \ + scikit-learn nltk pyyaml pydantic \ + pytest gymnasium -y + +# ========== Step 4: install API pacakges ========== +conda install -c conda-forge \ + httpx openai tabulate fire -y + +# ========== Step 5: install ML related packaged========== +conda install -c conda-forge \ + transformers datasets polars -y + +python -m pip install -e . + +python -c " +import sys +import torch +import numpy as np +import transformers +import openai +from rllm.agents.appworld_react_agents import AppWorldReactAgent +from rllm.engine.agent_execution_engine import AgentExecutionEngine +from rllm.environments.appworld.appworld_env import AppWorldEnv + +print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━') +print('✅ Python:', sys.version.split()[0]) +print('✅ PyTorch:', torch.__version__) +print('✅ CUDA:', torch.cuda.is_available()) +print('✅ NumPy:', np.__version__) +print('✅ Transformers:', transformers.__version__) +print('✅ OpenAI:', openai.__version__) +print('✅ rLLM all packaged installed') +print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━') +" + + +python -m pip install git+https://github.com/StonyBrookNLP/appworld.git + +python -c "import appworld; print(f'✅ AppWorld version: {appworld.__version__}'); print(f'✅ Python version: {__import__(\"sys\").version.split()[0]}')" + + +appworld install +# Note: typer and click version should be compatible +appworld download data --root {path} + +# verify the tasks are downloaded +appworld verify tasks + +# below are for debugging +# print the available functions +python -c "import appworld; help(appworld); print('Available functions:'); print([x for x in dir(appworld) if not x.startswith('_')])" +python -c "import inspect;from appworld import load_task_ids; print(inspect.getsource(load_task_ids)); print(appworld.__file__)" +print(inspect.getsource(load_task_ids)) + +python -c "from appworld import load_task_ids, AppWorld; task_id = load_task_ids('dev')[0]; app = AppWorld(task_id=task_id); print('Task attributes:'); print([x for x in dir(app.task) if not x.startswith('_')][:20]); print(f'\\nInstruction: {app.task.instruction}')" + +import inspect +from appworld import AppWorld +app = AppWorld(task_id="50e1ac9_2") +ev = app.evaluate() +print(dir(ev)) +print(inspect.getdoc(ev)) +print(inspect.getmembers(ev, predicate=inspect.ismethod)) \ No newline at end of file diff --git a/scripts/agent/appworld/install_env_gpu.sh b/scripts/agent/appworld/install_env_gpu.sh new file mode 100755 index 000000000..f4199acea --- /dev/null +++ b/scripts/agent/appworld/install_env_gpu.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# AppWorld Environment Setup Script (GPU Version) +# This script sets up the rLLM environment with GPU support for AppWorld + +set -e # Exit on error + +echo "==========================================" +echo "AppWorld GPU Environment Setup" +echo "==========================================" + +# ========== Step 1: Create conda environment ========== +echo "Step 1: Creating conda environment..." +conda create -n rllm_py311_gpu python=3.11 -y +conda activate rllm_py311_gpu + +# ========== Step 2: Install PyTorch (GPU version) ========== +echo "Step 2: Installing PyTorch with CUDA support..." +# Use PyTorch 2.7.0 + CUDA 12.1 (adjust according to your CUDA version) +# If your CUDA version is 11.8, change to pytorch-cuda=11.8 +conda install pytorch=2.7.0 torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y + +# Verify PyTorch and CUDA +echo "Verifying PyTorch installation..." +python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA available:', torch.cuda.is_available()); print('CUDA version:', torch.version.cuda if torch.cuda.is_available() else 'N/A'); print('GPU count:', torch.cuda.device_count() if torch.cuda.is_available() else 0)" + +# ========== Step 3: Install other core packages (conda) ========== +echo "Step 3: Installing core packages..." +conda install -c conda-forge \ + numpy scipy pandas pyarrow \ + scikit-learn nltk pyyaml pydantic \ + pytest gymnasium -y + +# ========== Step 4: Install API and utility packages (conda) ========== +echo "Step 4: Installing API and utility packages..." +conda install -c conda-forge \ + httpx openai tabulate fire -y + +# ========== Step 5: Install ML packages (use conda when available) ========== +echo "Step 5: Installing ML packages..." +conda install -c conda-forge \ + transformers datasets polars -y + +# ========== Step 6: Install rLLM ========== +echo "Step 6: Installing rLLM..." +python -m pip install -e . + +# Verify rLLM installation +echo "Verifying rLLM installation..." +python -c " +import sys +import torch +import numpy as np +import transformers +import openai +from rllm.agents.appworld_react_agents import AppWorldReactAgent +from rllm.engine.agent_execution_engine import AgentExecutionEngine +from rllm.environments.appworld.appworld_env import AppWorldEnv + +print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━') +print('✅ Python:', sys.version.split()[0]) +print('✅ PyTorch:', torch.__version__) +print('✅ CUDA Available:', torch.cuda.is_available()) +if torch.cuda.is_available(): + print('✅ CUDA Version:', torch.version.cuda) + print('✅ GPU Count:', torch.cuda.device_count()) + print('✅ GPU Name:', torch.cuda.get_device_name(0)) +print('✅ NumPy:', np.__version__) +print('✅ Transformers:', transformers.__version__) +print('✅ OpenAI:', openai.__version__) +print('✅ All rLLM components imported successfully!') +print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━') +" + +# ========== Step 7: Install AppWorld ========== +echo "Step 7: Installing AppWorld..." +python -m pip install git+https://github.com/StonyBrookNLP/appworld.git + +# Verify AppWorld +echo "Verifying AppWorld installation..." +python -c "import appworld; print(f'✅ AppWorld version: {appworld.__version__}'); print(f'✅ Python version: {__import__(\"sys\").version.split()[0]}')" + +# ========== Step 8: Configure AppWorld data ========== +echo "Step 8: Setting up AppWorld data..." +echo "Running: appworld install" +appworld install + +echo "" +echo "NOTE: Please manually run the following command to download data (specify path):" +echo " appworld download data --root /path/to/your/data/directory" +echo "" +echo "Then verify task data:" +echo " appworld verify tasks" + +# ========== Optional: Debugging commands ========== +echo "" +echo "==========================================" +echo "Installation completed!" +echo "==========================================" +echo "" +echo "To activate this environment in the future, run:" +echo " conda activate rllm_py311_gpu" +echo "" +echo "Optional: Run the following for debugging:" +echo " # Print available AppWorld functions" +echo " python -c \"import appworld; print([x for x in dir(appworld) if not x.startswith('_')])\"" +echo "" +echo " # Test loading a task" +echo " python -c \"from appworld import load_task_ids, AppWorld; task_id = load_task_ids('dev')[0]; app = AppWorld(task_id=task_id); print(f'Instruction: {app.task.instruction}')\"" +