def get_context_generator( override_opt: Optional[Dict[str, Any]] = None, task: Optional[str] = 'blended_skill_talk', **kwargs, ) -> ContextGenerator: """ Return an object to return BlendedSkillTalk-style context info (personas, etc.). """ argparser = ParlaiParser(False, False) argparser.add_parlai_data_path() if override_opt is not None: argparser.set_params(**override_opt) opt = argparser.parse_args([]) task_module = load_task_module(task) context_generator_class = getattr(task_module, 'ContextGenerator', None) context_generator = context_generator_class(opt, datatype='test', seed=0, **kwargs) # We pull from the test set so that the model can't regurgitate # memorized conversations return context_generator
def _create_task_agents(opt: Opt): """ Create task agent(s) for the given task name. It does this by calling the create_agent function in agents.py of the given task. If create_agents function does not exist, it just looks for the teacher (agent) class defined by the task name directly. (This saves the task creator bothering to define the create_agents function when it is not needed.) """ my_module = load_task_module(opt['task']) try: # Tries to call the create_agent function in agents.py task_agents = my_module.create_agents(opt) # type: ignore except AttributeError: # Create_agent not found, so try to create the teacher directly. return create_task_agent_from_taskname(opt) if type(task_agents) != list: task_agents = [task_agents] return task_agents
def _create_task_agents(opt: Opt): """ Create task agent(s) for the given task name. It does this by calling the create_agent function in agents.py of the given task. If create_agents function does not exist, it just looks for the teacher (agent) class defined by the task name directly. (This saves the task creator bothering to define the create_agents function when it is not needed.) """ if opt.get('interactive_task', False) or opt.get('selfchat_task', False): # do not need task agents in interactive or self chat settings return [] try: # Tries to call the create_agent function in agents.py my_module = load_task_module(opt['task']) task_agents = my_module.create_agents(opt) # type: ignore except (ModuleNotFoundError, AttributeError): # Create_agent not found, so try to create the teacher directly. return create_task_agent_from_taskname(opt) if type(task_agents) != list: task_agents = [task_agents] return task_agents
def test_load_task(self): task_module = load_task_module(OPTIONS['task']) self.assertEqual(task_module, c2agents)