code: import logging
  from llama_index.langchain_helpers.agents.tools import LlamaIndexTool
  from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters
  
  from app.llama_index.index import setup_index
  from app.llama_index.query_engine import setup_query_engine
  from app.database.crud import get_vectorized_election_programs_from_db
  from app.database.database import Session
  
  
  def setup_agent_tools():
      session = Session()
      vectorized_election_programs = get_vectorized_election_programs_from_db(session)
      logging.info(f"Loaded {len(vectorized_election_programs)} vectorized programs.")
  
      vector_tools = []
      for program in vectorized_election_programs:
          meta_data_filters = MetadataFilters(
              filters=[
                  ExactMatchFilter(key="group_id", value=program.id),
                  ExactMatchFilter(key="election_id", value=program.election_id),
                  ExactMatchFilter(key="party_id", value=program.party_id),
              ]
          )
  
          # define query engines
          vector_index = setup_index()
          vector_query_engine = setup_query_engine(
              vector_index, filters=meta_data_filters
          )
          # define tools
          query_engine_tool = LlamaIndexTool(
              name="vector_tool",
              description=(
                  f"Nützlich für Fragen zu spezifischen Aspekten des Wahlprogramms der {program.full_name} für die {program.label}."
              ),
              query_engine=vector_query_engine,
          )
          logging.info(f"Loaded query engine tool for {program.full_name}.")
          vector_tools.append(query_engine_tool)
      return vector_tools
  
apis: llama_index.langchain_helpers.agents.tools.LlamaIndexTool llama_index.vector_stores.types.ExactMatchFilter
extract_api: [((424, 433), 'app.database.database.Session', 'Session', ([], {}), '()\n', (431, 433), False, 'from app.database.database import Session\n'), ((469, 518), 'app.database.crud.get_vectorized_election_programs_from_db', 'get_vectorized_election_programs_from_db', (['session'], {}), '(session)\n', (509, 518), False, 'from app.database.crud import get_vectorized_election_programs_from_db\n'), ((1044, 1057), 'app.llama_index.index.setup_index', 'setup_index', ([], {}), '()\n', (1055, 1057), False, 'from app.llama_index.index import setup_index\n'), ((1088, 1147), 'app.llama_index.query_engine.setup_query_engine', 'setup_query_engine', (['vector_index'], {'filters': 'meta_data_filters'}), '(vector_index, filters=meta_data_filters)\n', (1106, 1147), False, 'from app.llama_index.query_engine import setup_query_engine\n'), ((1221, 1427), 'llama_index.langchain_helpers.agents.tools.LlamaIndexTool', 'LlamaIndexTool', ([], {'name': '"""vector_tool"""', 'description': 'f"""Nützlich für Fragen zu spezifischen Aspekten des Wahlprogramms der {program.full_name} für die {program.label}."""', 'query_engine': 'vector_query_engine'}), "(name='vector_tool', description=\n    f'Nützlich für Fragen zu spezifischen Aspekten des Wahlprogramms der {program.full_name} für die {program.label}.'\n    , query_engine=vector_query_engine)\n", (1235, 1427), False, 'from llama_index.langchain_helpers.agents.tools import LlamaIndexTool\n'), ((1505, 1571), 'logging.info', 'logging.info', (['f"""Loaded query engine tool for {program.full_name}."""'], {}), "(f'Loaded query engine tool for {program.full_name}.')\n", (1517, 1571), False, 'import logging\n'), ((759, 809), 'llama_index.vector_stores.types.ExactMatchFilter', 'ExactMatchFilter', ([], {'key': '"""group_id"""', 'value': 'program.id'}), "(key='group_id', value=program.id)\n", (775, 809), False, 'from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters\n'), ((827, 889), 'llama_index.vector_stores.types.ExactMatchFilter', 'ExactMatchFilter', ([], {'key': '"""election_id"""', 'value': 'program.election_id'}), "(key='election_id', value=program.election_id)\n", (843, 889), False, 'from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters\n'), ((907, 963), 'llama_index.vector_stores.types.ExactMatchFilter', 'ExactMatchFilter', ([], {'key': '"""party_id"""', 'value': 'program.party_id'}), "(key='party_id', value=program.party_id)\n", (923, 963), False, 'from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters\n')]