Spaces:
Runtime error
Runtime error
#for learning | |
import os | |
import openai | |
import gradio as gr | |
openai.api_key = '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' | |
#using a folder | |
from llama_index import VectorStoreIndex, SimpleDirectoryReader, SummaryIndex, download_loader | |
PDFReader = download_loader("PDFReader") | |
loader = PDFReader() | |
documents = loader.load_data(file=Path('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() |