code: from langchain.vectorstores import LanceDB
  import lancedb
  from langchain.embeddings.openai import OpenAIEmbeddings
  from langchain.chat_models import ChatOpenAI
  from langchain.chains import RetrievalQA
  
  # load agents and tools modules
  import pandas as pd
  from io import StringIO
  from langchain.tools.python.tool import PythonAstREPLTool
  from langchain.agents import initialize_agent, Tool
  from langchain.agents import AgentType
  from langchain import LLMMathChain
  from langchain.embeddings import HuggingFaceEmbeddings
  from langchain.document_loaders import PyPDFLoader, DirectoryLoader
  from langchain.text_splitter import RecursiveCharacterTextSplitter
  from langchain.llms import CTransformers
  from langchain.chains import RetrievalQA
  from langchain.document_loaders import TextLoader
  from scripts.load_llm import llm_openai
  
  
  class HRChatbot:
      def __init__(self, df_path, text_data_path, user):
          self.df_path = df_path
          self.text_data_path = text_data_path
          self.user = user
          self.llm = llm_openai().llm
          self.df = None
          self.timekeeping_policy = None
          self.agent = None
  
          self.load_data()
          self.initialize_tools()
  
      def load_data(self):
          # Load text documents
          loader = TextLoader(self.text_data_path)
          docs = loader.load()
  
          # Split documents into smaller chunks
          text_splitter = RecursiveCharacterTextSplitter(
              chunk_size=100,
              chunk_overlap=30,
          )
          documents = text_splitter.split_documents(docs)
  
          # Create Hugging Face embeddings
          embeddings = HuggingFaceEmbeddings(
              model_name="sentence-transformers/all-MiniLM-L6-v2",
              model_kwargs={"device": "cpu"},
          )
  
          # create lancedb vectordb
          db = lancedb.connect("/tmp/lancedb")
          table = db.create_table(
              "pandas_docs",
              data=[
                  {
                      "vector": embeddings.embed_query("Hello World"),
                      "text": "Hello World",
                      "id": "1",
                  }
              ],
              mode="overwrite",
          )
          self.vectorstore = LanceDB.from_documents(
              documents, embeddings, connection=table
          )
  
          self.df = pd.read_csv(self.df_path)
  
      def initialize_tools(self):
          # Initialize retrieval question-answering model
          # Initialize tools for the agent
          timekeeping_policy = RetrievalQA.from_chain_type(
              llm=self.llm,
              chain_type="stuff",
              retriever=self.vectorstore.as_retriever(),
          )
          python = PythonAstREPLTool(locals={"df": self.df})
          calculator = LLMMathChain.from_llm(llm=self.llm, verbose=True)
  
          # Set up variables and descriptions for the tools
          user = self.user
          df_columns = self.df.columns.to_list()
          tools = [
              Tool(
                  name="Timekeeping Policies",
                  func=timekeeping_policy.run,
                  description="""
                  Useful for when you need to answer questions about employee timekeeping policies.
  
                  <user>: What is the policy on unused vacation leave?
                  <assistant>: I need to check the timekeeping policies to answer this question.
                  <assistant>: Action: Timekeeping Policies
                  <assistant>: Action Input: Vacation Leave Policy - Unused Leave
                  ...
                  """,
              ),
              Tool(
                  name="Employee Data",
                  func=python.run,
                  description=f"""
                  Useful for when you need to answer questions about employee data stored in pandas dataframe 'df'. 
                  Run python pandas operations on 'df' to help you get the right answer.
                  'df' has the following columns: {df_columns}
                  
                  <user>: How many Sick Leave do I have left?
                  <assistant>: df[df['name'] == '{user}']['vacation_leave']
                  <assistant>: You have n  vacation_leave left.              
                  """,
              ),
              Tool(
                  name="Calculator",
                  func=calculator.run,
                  description=f"""
                  Useful when you need to do math operations or arithmetic operations.
                  """,
              ),
          ]
  
          # Initialize the LLM agent
          agent_kwargs = {
              "prefix": f"You are friendly HR assistant. You are tasked to assist the current user: {user} on questions related to HR. ..."
          }
          self.timekeeping_policy = timekeeping_policy
          self.agent = initialize_agent(
              tools,
              self.llm,
              agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
              verbose=True,
              agent_kwargs=agent_kwargs,
          )
  
      def get_response(self, user_input):
          response = self.agent.run(user_input)
          return response
  
apis: lancedb.connect
extract_api: [((1254, 1285), 'langchain.document_loaders.TextLoader', 'TextLoader', (['self.text_data_path'], {}), '(self.text_data_path)\n', (1264, 1285), False, 'from langchain.document_loaders import TextLoader\n'), ((1386, 1450), 'langchain.text_splitter.RecursiveCharacterTextSplitter', 'RecursiveCharacterTextSplitter', ([], {'chunk_size': '(100)', 'chunk_overlap': '(30)'}), '(chunk_size=100, chunk_overlap=30)\n', (1416, 1450), False, 'from langchain.text_splitter import RecursiveCharacterTextSplitter\n'), ((1605, 1715), 'langchain.embeddings.HuggingFaceEmbeddings', 'HuggingFaceEmbeddings', ([], {'model_name': '"""sentence-transformers/all-MiniLM-L6-v2"""', 'model_kwargs': "{'device': 'cpu'}"}), "(model_name='sentence-transformers/all-MiniLM-L6-v2',\n    model_kwargs={'device': 'cpu'})\n", (1626, 1715), False, 'from langchain.embeddings import HuggingFaceEmbeddings\n'), ((1795, 1826), 'lancedb.connect', 'lancedb.connect', (['"""/tmp/lancedb"""'], {}), "('/tmp/lancedb')\n", (1810, 1826), False, 'import lancedb\n'), ((2167, 2230), 'langchain.vectorstores.LanceDB.from_documents', 'LanceDB.from_documents', (['documents', 'embeddings'], {'connection': 'table'}), '(documents, embeddings, connection=table)\n', (2189, 2230), False, 'from langchain.vectorstores import LanceDB\n'), ((2272, 2297), 'pandas.read_csv', 'pd.read_csv', (['self.df_path'], {}), '(self.df_path)\n', (2283, 2297), True, 'import pandas as pd\n'), ((2626, 2667), 'langchain.tools.python.tool.PythonAstREPLTool', 'PythonAstREPLTool', ([], {'locals': "{'df': self.df}"}), "(locals={'df': self.df})\n", (2643, 2667), False, 'from langchain.tools.python.tool import PythonAstREPLTool\n'), ((2689, 2738), 'langchain.LLMMathChain.from_llm', 'LLMMathChain.from_llm', ([], {'llm': 'self.llm', 'verbose': '(True)'}), '(llm=self.llm, verbose=True)\n', (2710, 2738), False, 'from langchain import LLMMathChain\n'), ((4670, 4794), 'langchain.agents.initialize_agent', 'initialize_agent', (['tools', 'self.llm'], {'agent': 'AgentType.ZERO_SHOT_REACT_DESCRIPTION', 'verbose': '(True)', 'agent_kwargs': 'agent_kwargs'}), '(tools, self.llm, agent=AgentType.\n    ZERO_SHOT_REACT_DESCRIPTION, verbose=True, agent_kwargs=agent_kwargs)\n', (4686, 4794), False, 'from langchain.agents import initialize_agent, Tool\n'), ((1018, 1030), 'scripts.load_llm.llm_openai', 'llm_openai', ([], {}), '()\n', (1028, 1030), False, 'from scripts.load_llm import llm_openai\n'), ((2900, 3430), 'langchain.agents.Tool', 'Tool', ([], {'name': '"""Timekeeping Policies"""', 'func': 'timekeeping_policy.run', 'description': '"""\n                Useful for when you need to answer questions about employee timekeeping policies.\n\n                <user>: What is the policy on unused vacation leave?\n                <assistant>: I need to check the timekeeping policies to answer this question.\n                <assistant>: Action: Timekeeping Policies\n                <assistant>: Action Input: Vacation Leave Policy - Unused Leave\n                ...\n                """'}), '(name=\'Timekeeping Policies\', func=timekeeping_policy.run, description=\n    """\n                Useful for when you need to answer questions about employee timekeeping policies.\n\n                <user>: What is the policy on unused vacation leave?\n                <assistant>: I need to check the timekeeping policies to answer this question.\n                <assistant>: Action: Timekeeping Policies\n                <assistant>: Action Input: Vacation Leave Policy - Unused Leave\n                ...\n                """\n    )\n', (2904, 3430), False, 'from langchain.agents import initialize_agent, Tool\n'), ((3497, 4078), 'langchain.agents.Tool', 'Tool', ([], {'name': '"""Employee Data"""', 'func': 'python.run', 'description': 'f"""\n                Useful for when you need to answer questions about employee data stored in pandas dataframe \'df\'. \n                Run python pandas operations on \'df\' to help you get the right answer.\n                \'df\' has the following columns: {df_columns}\n                \n                <user>: How many Sick Leave do I have left?\n                <assistant>: df[df[\'name\'] == \'{user}\'][\'vacation_leave\']\n                <assistant>: You have n  vacation_leave left.              \n                """'}), '(name=\'Employee Data\', func=python.run, description=\n    f"""\n                Useful for when you need to answer questions about employee data stored in pandas dataframe \'df\'. \n                Run python pandas operations on \'df\' to help you get the right answer.\n                \'df\' has the following columns: {df_columns}\n                \n                <user>: How many Sick Leave do I have left?\n                <assistant>: df[df[\'name\'] == \'{user}\'][\'vacation_leave\']\n                <assistant>: You have n  vacation_leave left.              \n                """\n    )\n', (3501, 4078), False, 'from langchain.agents import initialize_agent, Tool\n'), ((4145, 4322), 'langchain.agents.Tool', 'Tool', ([], {'name': '"""Calculator"""', 'func': 'calculator.run', 'description': 'f"""\n                Useful when you need to do math operations or arithmetic operations.\n                """'}), '(name=\'Calculator\', func=calculator.run, description=\n    f"""\n                Useful when you need to do math operations or arithmetic operations.\n                """\n    )\n', (4149, 4322), False, 'from langchain.agents import initialize_agent, Tool\n')]