Spaces:
Runtime error
Runtime error
File size: 1,242 Bytes
19dd0e8 b6f62dc 6b0cd05 747633c 4d2b65a 4afbb98 36ad350 19dd0e8 4afbb98 2f86043 4afbb98 3d27082 49eb330 66a916f 19dd0e8 be7084d 3e8ad00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#for learning
import os
import openai
import gradio as gr
openai.api_key = os.environ.get('O_APIKey')
Data_Read = os.environ.get('Data_Reader')
ChurnData = os.environ.get('Churn_Data')
ChurnData2 = os.environ.get('Churn_Data2')
#read data
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, SummaryIndex, download_loader
DataReader = download_loader(Data_Read)
loader = DataReader()
#loading options
# loader = SimpleDirectoryReader(input_files = ["pdf1","pdf2"])
# documents = loader.load_data()
# or
# documents = loader.load_data(file=['toolkit.pdf','pdf2','pdf3'])
### 1st file
documents = loader.load_data(file=ChurnData)
### 1st file
### 2nd file
documents2 = loader.load_data(file=ChurnData2)
documents = documents + documents2
### 2nd file
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="70vh"), retry_btn=None,theme=gr.themes.Monochrome(),
title = 'ECommerce And Digital Marketing 2024 Toolkit Q&A', undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch() |