MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / construct_agent

Function construct_agent

webarena/agent/agent.py:205–227  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

203
204
205def 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

Callers 1

run.pyFile · 0.90

Calls 3

TokenizerClass · 0.90
TeacherForcingAgentClass · 0.85
PromptAgentClass · 0.85

Tested by

no test coverage detected