File size: 700 Bytes
43c34cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ..config import EnvironmentConfig
from .base import Environment, TimeStep
from .conversation import Conversation, ModeratedConversation
from .paper_review import PaperReview
from .paper_decision import PaperDecision

ALL_ENVIRONMENTS = [
    Conversation,
    ModeratedConversation,
    PaperReview,
    PaperDecision,
]

ENV_REGISTRY = {env.type_name: env for env in ALL_ENVIRONMENTS}


# Load an environment from a config dictionary
def load_environment(config: EnvironmentConfig):
    try:
        env_cls = ENV_REGISTRY[config["env_type"]]
    except KeyError:
        raise ValueError(f"Unknown environment type: {config['env_type']}")

    env = env_cls.from_config(config)
    return env