(args: argparse.Namespace)
| 203 | |
| 204 | |
| 205 | def construct_agent(args: argparse.Namespace) -> Agent: |
| 206 | llm_config = lm_config.construct_llm_config(args) |
| 207 | |
| 208 | agent: Agent |
| 209 | if args.agent_type == "teacher_forcing": |
| 210 | agent = TeacherForcingAgent() |
| 211 | elif args.agent_type == "prompt": |
| 212 | with open(args.instruction_path) as f: |
| 213 | constructor_type = json.load(f)["meta_data"]["prompt_constructor"] |
| 214 | tokenizer = Tokenizer(args.provider, args.model) |
| 215 | prompt_constructor = eval(constructor_type)( |
| 216 | args.instruction_path, lm_config=llm_config, tokenizer=tokenizer |
| 217 | ) |
| 218 | agent = PromptAgent( |
| 219 | action_set_tag=args.action_set_tag, |
| 220 | lm_config=llm_config, |
| 221 | prompt_constructor=prompt_constructor, |
| 222 | ) |
| 223 | else: |
| 224 | raise NotImplementedError( |
| 225 | f"agent type {args.agent_type} not implemented" |
| 226 | ) |
| 227 | return agent |
no test coverage detected