Commit fd20c57d authored by YaningGao's avatar YaningGao
Browse files

update alfworld

parent 581e5281
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -31,3 +31,19 @@ pip install --upgrade mani_skill
python -m mani_skill.utils.download_asset "PickSingleYCB-v1"
python -m mani_skill.utils.download_asset partnet_mobility_cabinet
```

### ALFWorld
```
pip install ai2thor==2.1.0
pip install alfworld==0.3.2
pip3 install numpy==1.23.5
pip3 install protobuf==3.20.3
pip3 install pydantic==1.10.14
pip3 install pydantic-core==2.16.3
pip3 uninstall frozenlist gradio murmurhash preshed spacy srsly thinc weasel aiosignal annotated-types blis catalogue cloudpathlib cymem

# Set the data path and download before running the server
export ALFWORLD_DATA=<storage_path>
alfworld-download
python vagen/env/server.py
```
+3 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ from .frozenlake import FrozenLakeEnv,FrozenLakeEnvConfig, FrozenLakeService
# from .navigation import NavigationEnv, NavigationEnvConfig, NavigationServiceConfig, NavigationService
# from .svg import SVGEnv, SvgEnvConfig, SVGService, SVGServiceConfig
# from .primitive_skill import PrimitiveSkillEnv, PrimitiveSkillEnvConfig, PrimitiveSkillService, PrimitiveSkillConfig
from .alfworld import ALFWorldEnv, ALFWorldEnvConfig
from .alfworld import ALFWorldEnv, ALFWorldEnvConfig, ALFWorldService, ALFWorldServiceConfig
REGISTERED_ENV = {
    "sokoban": {
        "env_cls": SokobanEnv,
@@ -35,5 +35,7 @@ REGISTERED_ENV = {
    "alfworld": {
        "env_cls": ALFWorldEnv,
        "config_cls": ALFWorldEnvConfig,
        "service_cls": ALFWorldService,
        "service_config_cls": ALFWorldServiceConfig
    },
}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
from .env import ALFWorldEnv
from .env_config import ALFWorldEnvConfig
from .service import ALFWorldService
from .service_config import ALFWorldServiceConfig
+0 −13
Original line number Diff line number Diff line
@@ -205,19 +205,6 @@ class ALFWorldEnv(BaseEnv):
                reward=self.total_reward
            )
        
        # Add response format instructions based on config
        if not self.config.action_only_prompt:
            obs_str += (
                "\nYour response should be a valid JSON: \n{\n"
                "\"thoughts\": \"your reasoning\", \n"
                "\"action\": \"chosen_action\"\n}"
            )
        else:
            obs_str += (
                "\nYour response should be a valid JSON: \n{\n"
                "\"action\": \"chosen_action\"\n}"
            )
        
        # For text mode, just return the observation string
        if self.config.render_mode == "text":
            return {
+14 −2
Original line number Diff line number Diff line
from vagen.env.base.base_env_config import BaseEnvConfig
from dataclasses import dataclass, field, fields
from typing import Optional, List
import os

@dataclass
class ALFWorldEnvConfig(BaseEnvConfig):
@@ -10,9 +11,20 @@ class ALFWorldEnvConfig(BaseEnvConfig):
    action_only_prompt: bool = False
    render_mode: str = "text"  # @TODO Only "text" mode is supported for now

    def __post_init__(self):
        # Expand any ${env:VAR} or $VAR references in the path
        raw = self.alf_config_path
        # Convert Hydra-style ${env:VAR} to shell-style $VAR
        raw = raw.replace('${env:', '$').replace('}', '')
        # Expand environment variables
        self.alf_config_path = os.path.expandvars(raw)

    def config_id(self) -> str:
        """Generate a unique identifier for this configuration."""
        id_fields = ["alf_config_path", "render_mode", "action_only_prompt", "max_actions_per_step"]
        id_str = ",".join([f"{field.name}={getattr(self, field.name)}" for field in fields(self) 
                          if field.name in id_fields])
        id_str = ",".join([
            f"{field.name}={getattr(self, field.name)}"
            for field in fields(self)
            if field.name in id_fields
        ])
        return f"ALFWorldEnvConfig({id_str})"
Loading