code: from langchain import PromptTemplate, LLMChain
  from langchain.text_splitter import RecursiveCharacterTextSplitter
  from langchain.vectorstores import Chroma
  from langchain.chains import RetrievalQA
  from langchain.embeddings import HuggingFaceBgeEmbeddings
  from io import BytesIO
  from langchain.document_loaders import PyPDFLoader
  import gradio as gr
  import lancedb
  from langchain.vectorstores import LanceDB
  from langchain.document_loaders import ArxivLoader
  from langchain.chains import FlareChain
  from langchain.prompts import PromptTemplate
  from langchain.chains import LLMChain
  import os
  from langchain.llms import OpenAI
  import getpass
  
  os.environ["OPENAI_API_KEY"] = "sk-yourapikeyforopenai"
  
  llm = OpenAI()
  
  model_name = "BAAI/bge-large-en"
  model_kwargs = {"device": "cpu"}
  encode_kwargs = {"normalize_embeddings": False}
  embeddings = HuggingFaceBgeEmbeddings(
      model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
  )
  
  # here is example https://arxiv.org/pdf/2305.06983.pdf
  # you need to pass this number to query 2305.06983
  # fetch docs from arxiv, in this case it's the FLARE paper
  docs = ArxivLoader(query="2305.06983", load_max_docs=2).load()
  
  # instantiate text splitter
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=1500, chunk_overlap=150)
  
  # split the document into chunks
  doc_chunks = text_splitter.split_documents(docs)
  
  # lancedb vectordb
  db = lancedb.connect("/tmp/lancedb")
  table = db.create_table(
      "documentsai",
      data=[
          {
              "vector": embeddings.embed_query("Hello World"),
              "text": "Hello World",
              "id": "1",
          }
      ],
      mode="overwrite",
  )
  vector_store = LanceDB.from_documents(doc_chunks, embeddings, connection=table)
  
  vector_store_retriever = vector_store.as_retriever()
  
  flare = FlareChain.from_llm(
      llm=llm, retriever=vector_store_retriever, max_generation_len=300, min_prob=0.45
  )
  
  
  # Define a function to generate FLARE output based on user input
  def generate_flare_output(input_text):
      output = flare.run(input_text)
      return output
  
  
  input = gr.Text(
      label="Prompt",
      show_label=False,
      max_lines=1,
      placeholder="Enter your prompt",
      container=False,
  )
  
  iface = gr.Interface(
      fn=generate_flare_output,
      inputs=input,
      outputs="text",
      title="My AI bot",
      description="FLARE implementation with lancedb & bge embedding.",
  )
  
  iface.launch(debug=True, share=True)
  
apis: lancedb.connect
extract_api: [((704, 712), 'langchain.llms.OpenAI', 'OpenAI', ([], {}), '()\n', (710, 712), False, 'from langchain.llms import OpenAI\n'), ((841, 948), 'langchain.embeddings.HuggingFaceBgeEmbeddings', 'HuggingFaceBgeEmbeddings', ([], {'model_name': 'model_name', 'model_kwargs': 'model_kwargs', 'encode_kwargs': 'encode_kwargs'}), '(model_name=model_name, model_kwargs=model_kwargs,\n    encode_kwargs=encode_kwargs)\n', (865, 948), False, 'from langchain.embeddings import HuggingFaceBgeEmbeddings\n'), ((1225, 1291), 'langchain.text_splitter.RecursiveCharacterTextSplitter', 'RecursiveCharacterTextSplitter', ([], {'chunk_size': '(1500)', 'chunk_overlap': '(150)'}), '(chunk_size=1500, chunk_overlap=150)\n', (1255, 1291), False, 'from langchain.text_splitter import RecursiveCharacterTextSplitter\n'), ((1400, 1431), 'lancedb.connect', 'lancedb.connect', (['"""/tmp/lancedb"""'], {}), "('/tmp/lancedb')\n", (1415, 1431), False, 'import lancedb\n'), ((1672, 1736), 'langchain.vectorstores.LanceDB.from_documents', 'LanceDB.from_documents', (['doc_chunks', 'embeddings'], {'connection': 'table'}), '(doc_chunks, embeddings, connection=table)\n', (1694, 1736), False, 'from langchain.vectorstores import LanceDB\n'), ((1800, 1905), 'langchain.chains.FlareChain.from_llm', 'FlareChain.from_llm', ([], {'llm': 'llm', 'retriever': 'vector_store_retriever', 'max_generation_len': '(300)', 'min_prob': '(0.45)'}), '(llm=llm, retriever=vector_store_retriever,\n    max_generation_len=300, min_prob=0.45)\n', (1819, 1905), False, 'from langchain.chains import FlareChain\n'), ((2077, 2186), 'gradio.Text', 'gr.Text', ([], {'label': '"""Prompt"""', 'show_label': '(False)', 'max_lines': '(1)', 'placeholder': '"""Enter your prompt"""', 'container': '(False)'}), "(label='Prompt', show_label=False, max_lines=1, placeholder=\n    'Enter your prompt', container=False)\n", (2084, 2186), True, 'import gradio as gr\n'), ((2214, 2377), 'gradio.Interface', 'gr.Interface', ([], {'fn': 'generate_flare_output', 'inputs': 'input', 'outputs': '"""text"""', 'title': '"""My AI bot"""', 'description': '"""FLARE implementation with lancedb & bge embedding."""'}), "(fn=generate_flare_output, inputs=input, outputs='text', title=\n    'My AI bot', description=\n    'FLARE implementation with lancedb & bge embedding.')\n", (2226, 2377), True, 'import gradio as gr\n'), ((1124, 1172), 'langchain.document_loaders.ArxivLoader', 'ArxivLoader', ([], {'query': '"""2305.06983"""', 'load_max_docs': '(2)'}), "(query='2305.06983', load_max_docs=2)\n", (1135, 1172), False, 'from langchain.document_loaders import ArxivLoader\n')]