code: def test_qa(self):
      # create project
      self.run_sql("create database proj")
      df = pd.DataFrame.from_dict(
          {
              "context": [
                  "For adults and children age 5 and older, OTC decongestants, "
                  "antihistamines and pain relievers might offer some symptom relief. "
                  "However, they won't prevent a cold or shorten its duration, and most have some side effects.",
                  "Paracetamol, also known as acetaminophen and APAP, "
                  "is a medication used to treat pain and fever as well as colds and flu. "
                  "It is typically used for mild to moderate pain relief. "
                  "Evidence is mixed for its use to relieve fever in children. "
                  "It is often sold in combination with other medications, such as in many cold medications.",
                  "lemsip is a brand of over-the-counter pharmaceuticals used to treat cold and flu symptoms. "
                  "The brand is currently owned by Reckitt Benckiser. "
                  "The original Lemsip product contained paracetamol as its active ingredient. "
                  "However, other products marketed under the Lemsip "
                  "brand contain other active ingredients such as ibuprofen,"
                  "pseudoephedrine, phenylephrine, and guaifenesin.",
              ],
              "url": [
                  "https://docs.mindsdb.com/sql/tutorials/recommenders/",
                  "https://docs.mindsdb.com/sql/tutorials/llm-chatbot-ui/",
                  "https://docs.mindsdb.com/sql/tutorials/house-sales-forecasting/",
              ],
          }
      )
      self.save_file("df", df)
  
      # test openai qa with chromadb
  
      self.run_sql(
          f"""
             create model proj.test_rag_openai_qa
             from files (select * from df)
             predict answer
             using
               engine='rag',
               llm_type='openai',
               openai_api_key='{OPENAI_API_KEY}',
               vector_store_folder_name='rag_openai_qa_test'
          """
      )
      self.wait_predictor("proj", "test_rag_openai_qa")
  
      result_df = self.run_sql(
          """
              SELECT p.answer
              FROM proj.test_rag_openai_qa as p
              WHERE question='What is the best treatment for a cold?'
          """
      )
      assert result_df["answer"].iloc[0]
  
      # test batching with openai qa chroma
  
      embeddings_batch_size = 1
  
      self.run_sql(
          f"""
             create model proj.test_rag_openai_qa_batch
             from files (select * from df)
             predict answer
             using
               engine='rag',
               llm_type='openai',
               openai_api_key='{OPENAI_API_KEY}',
               vector_store_folder_name='rag_openai_qa_test_batch',
               embeddings_batch_size={embeddings_batch_size}
          """
      )
  
      self.wait_predictor("proj", "test_rag_openai_qa_batch")
  
      result_df = self.run_sql(
          """
              SELECT p.answer
              FROM proj.test_rag_openai_qa_batch as p
              WHERE question='What is the best treatment for a cold?'
          """
      )
      assert result_df["answer"].iloc[0]
  
      # test writer qa with FAISS
  
      self.run_sql(
          f"""
             create model proj.test_rag_writer_qa
             from files (select * from df)
             predict answer
             using
               engine='rag',
               llm_type='writer',
               vector_store_name='faiss',
               writer_api_key='{WRITER_API_KEY}',
               writer_org_id='{WRITER_ORG_ID}',
               vector_store_folder_name='rag_writer_qa_test'
          """
      )
      self.wait_predictor("proj", "test_rag_writer_qa")
  
      result_df = self.run_sql(
          """
              SELECT p.answer
              FROM proj.test_rag_writer_qa as p
              WHERE question='What is the best treatment for a cold?'
          """
      )
      assert result_df["answer"].iloc[0]
  
      # test single url parsing
      self.run_sql(
          f"""
             create model proj.test_rag_writer_qa_single_url
             predict answer
             using
               engine='rag',
               llm_type='writer',
               url='https://docs.mindsdb.com/sql/tutorials/recommenders/',
               vector_store_name='faiss',
               writer_api_key='{WRITER_API_KEY}',
               writer_org_id='{WRITER_ORG_ID}',
               vector_store_folder_name='rag_writer_qa_test_single_url'
          """
      )
      self.wait_predictor("proj", "test_rag_writer_qa_single_url")
  
      result_df = self.run_sql(
          """
              SELECT p.answer
              FROM proj.test_rag_writer_qa as p
              WHERE question='What recommender models does mindsdb support?'
          """
      )
      assert result_df["answer"].iloc[0]
  
      # test multi url parsing
      self.run_sql(
          f"""
             create model proj.test_rag_writer_qa_multi_url
             from files (select * from df)
             predict answer
             using
               engine='rag',
               llm_type='writer',
               vector_store_name='faiss',
               url_column_name='url',
               writer_api_key='{WRITER_API_KEY}',
               writer_org_id='{WRITER_ORG_ID}',
               vector_store_folder_name='rag_writer_qa_test_multi_url'
          """
      )
  
      self.wait_predictor("proj", "test_rag_writer_qa_multi_url")
  
      result_df = self.run_sql(
          """
              SELECT p.answer
              FROM proj.test_rag_writer_qa_multi_url as p
              WHERE question='which chat app currently works with mindsdb chatbot?'
          """
      )
  
      assert result_df["answer"].iloc[0]
  
file_path: mindsdb/tests/unit/ml_handlers/test_rag.py
imports: import os
  import time
  import pandas
  import pytest
  from mindsdb_sql import parse_sql
  from tests.unit.executor_test_base import BaseExecutorTest
label_desc: Use image node_id 8 for calling the TestRAG obj's underlying member method code with example usage: obj.test_qa() without return types