code: import os
  import time
  import shutil
  
  import pandas as pd
  import lancedb
  from lancedb.embeddings import with_embeddings
  from langchain import PromptTemplate
  import predictionguard as pg
  import numpy as np
  from sentence_transformers import SentenceTransformer
  
  #---------------------#
  # Lance DB Setup     #
  #---------------------#
  
  #Import datasets
  
  #JOBS
  df1=pd.read_csv('datasets/jobs.csv')
  df1_table_name = "jobs"
  
  #SOCIAL
  df2=pd.read_csv('datasets/social.csv')
  df2_table_name = "social"
  
  #movies
  df3=pd.read_csv('datasets/movies.csv')
  df3_table_name = "movies"
  
  # local path of the vector db
  uri = "schema.lancedb"
  db = lancedb.connect(uri)
  
  # Embeddings setup
  name="all-MiniLM-L12-v2"
  
  # Load model
  
  def load_model():
     return SentenceTransformer(name)
  
  def embed(query, embModel):
      return embModel.encode(query)
  
  #---------------------#
  # SQL Schema Creation #
  #---------------------#
  
  def create_schema(df,table_name):
      # Here we will create an example SQL schema based on the data in this dataset.
      # In a real use case, you likely already have this sort of CREATE TABLE statement.
      # Performance can be improved by manually curating the descriptions.
  
      columns_info = []
  
      # Iterate through each column in the DataFrame
      for col in df.columns:
          # Determine the SQL data type based on the first non-null value in the column
          first_non_null = df[col].dropna().iloc[0]
          if isinstance(first_non_null, np.int64):
              kind = "INTEGER"
          elif isinstance(first_non_null, np.float64):
              kind = "DECIMAL(10,2)"
          elif isinstance(first_non_null, str):
              kind = "VARCHAR(255)"  # Assuming a default max length of 255
          else:
              kind = "VARCHAR(255)"  # Default to VARCHAR for other types or customize as needed
  
          # Sample a few example values
          example_values = ', '.join([str(x) for x in df[col].dropna().unique()[0:4]])
  
          # Append column info to the list
          columns_info.append(f"{col} {kind}, -- Example values are {example_values}")
  
      # Construct the CREATE TABLE statement
      create_table_statement = "CREATE TABLE" + " " + table_name + " (\n  " + ",\n  ".join(columns_info) + "\n);"
  
      # Adjust the statement to handle the final comma, primary keys, or other specifics
      create_table_statement = create_table_statement.replace(",\n);", "\n);")
  
      return create_table_statement
  
  # SQL Schema for Table Jobs
  df1_schema=create_schema(df1,df1_table_name)
  
  # SQL Schema for Table Social
  df2_schema=create_schema(df2,df2_table_name)
  
  # SQL Schema for Table Movies
  df3_schema=create_schema(df3,df3_table_name)
  
  #---------------------#
  #  Prompt Templates          #
  #---------------------#
  
  template=""" 
  ###System:
  Generate a brief description of the below data. Be as detailed as possible.
  
  ###User:
  {schema}
  
  ###Assistant:
  """
  
  prompt=PromptTemplate(template=template,input_variables=["schema"])
  
  #---------------------#
  #  Generate Description #
  #---------------------#
  
  def generate_description(schema):
      prompt_filled=prompt.format(schema=schema)
      result=pg.Completion.create(
          model="Neural-Chat-7B",
          prompt=prompt_filled,
          temperature=0.1,
          max_tokens=300
      )
      return result['choices'][0]['text']
  
  df1_desc=generate_description(df1_schema)
  df2_desc=generate_description(df2_schema)
  df3_desc=generate_description(df3_schema)
  
  # Create Pandas DataFrame
  df = pd.DataFrame({
      'text': [df1_desc, df2_desc, df3_desc],
      'table_name': [df1_table_name, df2_table_name, df3_table_name],
      'schema': [df1_schema, df2_schema, df3_schema],
  })
  
  print(df)
  
  def load_data():
  
      if os.path.exists("schema.lancedb"):
          shutil.rmtree("schema.lancedb")
      os.mkdir("schema.lancedb")
      db = lancedb.connect(uri)
      
      batchModel = SentenceTransformer(name)
  
      def batch_embed_func(batch):
         return [batchModel.encode(sentence) for sentence in batch]
      
      vecData = with_embeddings(batch_embed_func, df)
  
      if "schema" not in db.table_names():
          db.create_table("schema", data=vecData)
      else:
          table = db.open_table("schema")
          table.add(data=vecData)
      
      return
  
  load_data()
  print("Done")
apis: lancedb.embeddings.with_embeddings lancedb.connect
extract_api: [((359, 391), 'pandas.read_csv', 'pd.read_csv', (['"""datasets/jobs.csv"""'], {}), "('datasets/jobs.csv')\n", (370, 391), True, 'import pandas as pd\n'), ((429, 463), 'pandas.read_csv', 'pd.read_csv', (['"""datasets/social.csv"""'], {}), "('datasets/social.csv')\n", (440, 463), True, 'import pandas as pd\n'), ((503, 537), 'pandas.read_csv', 'pd.read_csv', (['"""datasets/movies.csv"""'], {}), "('datasets/movies.csv')\n", (514, 537), True, 'import pandas as pd\n'), ((623, 643), 'lancedb.connect', 'lancedb.connect', (['uri'], {}), '(uri)\n', (638, 643), False, 'import lancedb\n'), ((2866, 2927), 'langchain.PromptTemplate', 'PromptTemplate', ([], {'template': 'template', 'input_variables': "['schema']"}), "(template=template, input_variables=['schema'])\n", (2880, 2927), False, 'from langchain import PromptTemplate\n'), ((3432, 3607), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': [df1_desc, df2_desc, df3_desc], 'table_name': [df1_table_name,\n    df2_table_name, df3_table_name], 'schema': [df1_schema, df2_schema,\n    df3_schema]}"], {}), "({'text': [df1_desc, df2_desc, df3_desc], 'table_name': [\n    df1_table_name, df2_table_name, df3_table_name], 'schema': [df1_schema,\n    df2_schema, df3_schema]})\n", (3444, 3607), True, 'import pandas as pd\n'), ((732, 757), 'sentence_transformers.SentenceTransformer', 'SentenceTransformer', (['name'], {}), '(name)\n', (751, 757), False, 'from sentence_transformers import SentenceTransformer\n'), ((3095, 3198), 'predictionguard.Completion.create', 'pg.Completion.create', ([], {'model': '"""Neural-Chat-7B"""', 'prompt': 'prompt_filled', 'temperature': '(0.1)', 'max_tokens': '(300)'}), "(model='Neural-Chat-7B', prompt=prompt_filled,\n    temperature=0.1, max_tokens=300)\n", (3115, 3198), True, 'import predictionguard as pg\n'), ((3651, 3683), 'os.path.exists', 'os.path.exists', (['"""schema.lancedb"""'], {}), "('schema.lancedb')\n", (3665, 3683), False, 'import os\n'), ((3729, 3755), 'os.mkdir', 'os.mkdir', (['"""schema.lancedb"""'], {}), "('schema.lancedb')\n", (3737, 3755), False, 'import os\n'), ((3765, 3785), 'lancedb.connect', 'lancedb.connect', (['uri'], {}), '(uri)\n', (3780, 3785), False, 'import lancedb\n'), ((3808, 3833), 'sentence_transformers.SentenceTransformer', 'SentenceTransformer', (['name'], {}), '(name)\n', (3827, 3833), False, 'from sentence_transformers import SentenceTransformer\n'), ((3953, 3990), 'lancedb.embeddings.with_embeddings', 'with_embeddings', (['batch_embed_func', 'df'], {}), '(batch_embed_func, df)\n', (3968, 3990), False, 'from lancedb.embeddings import with_embeddings\n'), ((3693, 3724), 'shutil.rmtree', 'shutil.rmtree', (['"""schema.lancedb"""'], {}), "('schema.lancedb')\n", (3706, 3724), False, 'import shutil\n')]