#for learning import os import openai import gradio as gr openai.api_key = os.environ.get('O_APIKey') #using a folder from llama_index import VectorStoreIndex, SimpleDirectoryReader, SummaryIndex, download_loader PDFReader = download_loader("PDFReader") loader = PDFReader() #loading options # loader = SimpleDirectoryReader(input_files = ["pdf1","pdf2"]) # documents = loader.load_data() # or # documents = loader.load_data(file=['toolkit.pdf','pdf2','pdf3']) documents = loader.load_data(file='toolkit.pdf') index = VectorStoreIndex.from_documents(documents) query_engine = index.as_query_engine() def reply(message, history): answer = str(query_engine.query(message)) return answer Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height=500), retry_btn=None,theme=gr.themes.Monochrome(), title = 'E-Commerce And Digital Marketing Toolkit Q&A', undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()