Beispiel #1
0
def _get_task_world(opt, user_agents):
    task_agents = _create_task_agents(opt)
    sp = opt['task'].strip().split(':')
    if '.' in sp[0]:
        # The case of opt['task'] = 'parlai.tasks.squad.agents:DefaultTeacher'
        # (i.e. specifying your own path directly, assumes DialogPartnerWorld)
        if len(task_agents + user_agents) == 2:
            world_class = DialogPartnerWorld
        else:
            world_class = MultiAgentDialogWorld
    else:
        task = sp[0].lower()
        if len(sp) > 1:
            sp[1] = sp[1][0].upper() + sp[1][1:]
            world_name = sp[1] + "World"
        else:
            world_name = "DefaultWorld"
        module_name = "parlai.tasks.%s.worlds" % (task)
        try:
            my_module = importlib.import_module(module_name)
            world_class = getattr(my_module, world_name)
        except Exception:
            # Defaults to this if you did not specify a world for your task.
            if len(task_agents + user_agents) == 2:
                world_class = DialogPartnerWorld
            else:
                world_class = MultiAgentDialogWorld
    return world_class, task_agents
def create_selfplay_world(opt, user_agents):
    """API compatible for various selfplay task"""
    # TODO: tasks.convai2.agents.OriginalPersonaTeacher, add more teachers
    if ',' in opt['task']:
        tasks = opt['task'].split(',')
        teacher_agents = []
        for task in tasks:
            opt['task'] = task
            teacher_agents.append(_create_task_agents(opt)[0])
    else:
        teacher_agents = [_create_task_agents(opt)[0]]

    agents = [user_agents[0], user_agents[1]]
    agents.extend(teacher_agents)
    world = SelfPlayWorld(opt, agents=agents, shared=None)
    return world
Beispiel #3
0
def _get_task_world(opt, user_agents):
    task_agents = _create_task_agents(opt)
    sp = opt['task'].strip().split(':')
    if '.' in sp[0]:
        # The case of opt['task'] = 'parlai.tasks.squad.agents:DefaultTeacher'
        # (i.e. specifying your own path directly, assumes DialogPartnerWorld)
        if len(task_agents + user_agents) == 2:
            world_class = DialogPartnerWorld
        else:
            world_class = MultiAgentDialogWorld
    else:
        task = sp[0].lower()
        if len(sp) > 1:
            sp[1] = sp[1][0].upper() + sp[1][1:]
            world_name = sp[1] + "World"
        else:
            world_name = "DefaultWorld"
        module_name = "parlai.tasks.%s.worlds" % (task)
        try:
            my_module = importlib.import_module(module_name)
            world_class = getattr(my_module, world_name)
        except Exception:
            # Defaults to this if you did not specify a world for your task.
            if len(task_agents + user_agents) == 2:
                world_class = DialogPartnerWorld
            else:
                world_class = MultiAgentDialogWorld
    return world_class, task_agents
Beispiel #4
0
def create_task_world(opt, active_agent, static_agent):
    teacher = _create_task_agents(opt)
    return RLDialogWorld(opt, active_agent, static_agent, teacher)