code: #import os
  
  from dotenv import load_dotenv, find_dotenv
  _ = load_dotenv(find_dotenv())  # read local .env file
  
  import warnings
  warnings.filterwarnings("ignore")
  
  from langchain.agents.agent_toolkits import create_python_agent
  from langchain.agents import load_tools, initialize_agent
  from langchain.agents import AgentType
  from langchain.tools.python.tool import PythonREPLTool
  #from langchain.python import PythonREPL
  from langchain.chat_models import ChatOpenAI
  import langchain
  
  llm = ChatOpenAI(temperature=0)
  tools = load_tools(["llm-math", "wikipedia"], llm=llm)
  
  customer_list = [["Harrison", "Chase"], 
                   ["Lang", "Chain"],
                   ["Dolly", "Too"],
                   ["Elle", "Elem"], 
                   ["Geoff", "Fusion"], 
                   ["Trance", "Former"],
                   ["Jen", "Ayai"]]
  
  def do_answer1():
      langchain.debug = True
      agent = create_python_agent(
          llm,
          tool=PythonREPLTool(),
          verbose=True
      )
  
      answer = agent.run(f"""Sort these customers by \
      last name and then first name \
      and print the output: {customer_list}""") 
      print(answer)
      langchain.debug = False
  
  
  def do_answer2():
      from langchain.agents import tool
      from datetime import date 
      langchain.debug = True 
  
      @tool
      def time(text: str) -> str:
          """Returns todays date, use this for any \
          questions related to knowing todays date. \
          The input should always be an empty string, \
          and this function will always return todays \
          date - any date mathmatics should occur \
          outside this function."""
          return str(date.today()) 
  
      agent = initialize_agent(
          tools + [time], 
          llm, 
          agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
          handle_parsing_errors=True,
          verbose = True)  
      
      try:
          result = agent("whats the date today?") 
      except: # noqa
          print("exception on external access")
      print(result)
      langchain.debug = False
  
  if __name__ == "__main__":
      #do_answer1()
      do_answer2()
  
apis: langchain.tools.python.tool.PythonREPLTool langchain.agents.load_tools langchain.agents.initialize_agent langchain.chat_models.ChatOpenAI
extract_api: [((128, 161), 'warnings.filterwarnings', 'warnings.filterwarnings', (['"""ignore"""'], {}), "('ignore')\n", (151, 161), False, 'import warnings\n'), ((489, 514), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'temperature': '(0)'}), '(temperature=0)\n', (499, 514), False, 'from langchain.chat_models import ChatOpenAI\n'), ((523, 569), 'langchain.agents.load_tools', 'load_tools', (["['llm-math', 'wikipedia']"], {'llm': 'llm'}), "(['llm-math', 'wikipedia'], llm=llm)\n", (533, 569), False, 'from langchain.agents import load_tools, initialize_agent\n'), ((72, 85), 'dotenv.find_dotenv', 'find_dotenv', ([], {}), '()\n', (83, 85), False, 'from dotenv import load_dotenv, find_dotenv\n'), ((1666, 1800), 'langchain.agents.initialize_agent', 'initialize_agent', (['(tools + [time])', 'llm'], {'agent': 'AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION', 'handle_parsing_errors': '(True)', 'verbose': '(True)'}), '(tools + [time], llm, agent=AgentType.\n    CHAT_ZERO_SHOT_REACT_DESCRIPTION, handle_parsing_errors=True, verbose=True)\n', (1682, 1800), False, 'from langchain.agents import load_tools, initialize_agent\n'), ((936, 952), 'langchain.tools.python.tool.PythonREPLTool', 'PythonREPLTool', ([], {}), '()\n', (950, 952), False, 'from langchain.tools.python.tool import PythonREPLTool\n'), ((1638, 1650), 'datetime.date.today', 'date.today', ([], {}), '()\n', (1648, 1650), False, 'from datetime import date\n')]