fromtypingimportAny,Listfromlangchain_core.promptsimportPromptTemplatefromlangchain.agentsimportAgentExecutor,create_tool_calling_agent,create_structured_chat_agentfromlangchain.toolsimportBaseToolfromlanggraph.prebuiltimportcreate_react_agentclassAgent:def__init__(self,llm,tools:List[BaseTool],prompt:PromptTemplate=None,verbose:bool=False):self.llm=llmself.tools=toolsself.prompt=promptifnotprompt:agent=create_react_agent(llm,tools,debug=verbose)self.agent_executor=agentelse:agent=create_structured_chat_agent(llm,tools,prompt)self.agent_executor=AgentExecutor(agent=agent,tools=tools,verbose=verbose)defexec(self,prompt_args:dict={},stream:bool=False):# if stream:# for step in self.agent_executor.stream(prompt_args):# yield step returnself.agent_executor.invoke(input=prompt_args)