code: import lancedb
  import numpy as np
  import pandas as pd
  import pyarrow as pa
  
  
  def client_vector_db(vector_db_config: dict) -> lancedb.LanceDBConnection:
      """Connect to a lancedb instance"""
      return lancedb.connect(**vector_db_config)
  
  
  def initialize_vector_db_indices(
      client_vector_db: lancedb.LanceDBConnection,
      class_name: str,
      embedding_dimension: int,
  ) -> bool:
      """Initialize the LanceDB table;
      NOTE this pattern currently doesn't work and is due to a bug with lancedb
      """
      schema = pa.schema(
          [
              ("squad_id", pa.string()),
              ("title", pa.string()),
              ("context", pa.string()),
              ("embedding_service", pa.string()),
              ("model_name", pa.string()),
              pa.field("vector", type=pa.list_(pa.float32(), list_size=embedding_dimension)),
          ]
      )
  
      client_vector_db.create_table(name=class_name, schema=schema, mode="create")
  
      return True
  
  
  def reset_vector_db(client_vector_db: lancedb.LanceDBConnection) -> bool:
      """Delete all tables from the database"""
      for table_name in client_vector_db.table_names():
          client_vector_db.drop_table(table_name)
      return True
  
  
  def data_objects(
      ids: list[str],
      titles: list[str],
      text_contents: list[str],
      embeddings: list[np.ndarray],
      metadata: dict,
  ) -> list[dict]:
      """Create valid LanceDB objects"""
      assert len(ids) == len(titles) == len(text_contents) == len(embeddings)
      return [
          dict(squad_id=id_, title=title, context=context, vector=embedding, **metadata)
          for id_, title, context, embedding in zip(ids, titles, text_contents, embeddings)
      ]
  
  
  def push_to_vector_db(
      client_vector_db: lancedb.LanceDBConnection,
      class_name: str,
      data_objects: list[dict],
      embedding_metric: str = "cosine",
  ) -> int:
      """Push dataframe of objects to LanceDB.
      Return number of objects.
      """
      df = pd.DataFrame.from_records(data_objects)
      table = client_vector_db.create_table(name=class_name, data=df, mode="overwrite")
  
      return table.to_pandas().shape[0]
  
apis: lancedb.connect
extract_api: [((203, 238), 'lancedb.connect', 'lancedb.connect', ([], {}), '(**vector_db_config)\n', (218, 238), False, 'import lancedb\n'), ((1932, 1971), 'pandas.DataFrame.from_records', 'pd.DataFrame.from_records', (['data_objects'], {}), '(data_objects)\n', (1957, 1971), True, 'import pandas as pd\n'), ((568, 579), 'pyarrow.string', 'pa.string', ([], {}), '()\n', (577, 579), True, 'import pyarrow as pa\n'), ((604, 615), 'pyarrow.string', 'pa.string', ([], {}), '()\n', (613, 615), True, 'import pyarrow as pa\n'), ((642, 653), 'pyarrow.string', 'pa.string', ([], {}), '()\n', (651, 653), True, 'import pyarrow as pa\n'), ((690, 701), 'pyarrow.string', 'pa.string', ([], {}), '()\n', (699, 701), True, 'import pyarrow as pa\n'), ((731, 742), 'pyarrow.string', 'pa.string', ([], {}), '()\n', (740, 742), True, 'import pyarrow as pa\n'), ((790, 802), 'pyarrow.float32', 'pa.float32', ([], {}), '()\n', (800, 802), True, 'import pyarrow as pa\n')]