Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,19 +7,22 @@ import gradio as gr
|
|
7 |
openai.api_key = os.environ.get('O_APIKey')
|
8 |
Data_Read = os.environ.get('Data_Reader')
|
9 |
ChurnData = os.environ.get('Churn_Data')
|
|
|
10 |
|
11 |
#read data
|
12 |
from llama_index import VectorStoreIndex, SimpleDirectoryReader, SummaryIndex, download_loader
|
13 |
DataReader = download_loader(Data_Read)
|
14 |
loader = DataReader()
|
15 |
|
16 |
-
|
17 |
-
# loader = SimpleDirectoryReader(input_files = ["pdf1","pdf2"])
|
18 |
-
# documents = loader.load_data()
|
19 |
-
# or
|
20 |
-
# documents = loader.load_data(file=['toolkit.pdf','pdf2','pdf3'])
|
21 |
-
|
22 |
documents = loader.load_data(file=ChurnData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
index = VectorStoreIndex.from_documents(documents)
|
24 |
query_engine = index.as_query_engine()
|
25 |
|
@@ -27,5 +30,5 @@ def reply(message, history):
|
|
27 |
answer = str(query_engine.query(message))
|
28 |
return answer
|
29 |
|
30 |
-
Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height="70vh"), retry_btn=None,theme=gr.themes.Monochrome(),
|
31 |
-
title = 'E-Commerce BT/AN/CA/DH CMS Q&A', undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()
|
|
|
7 |
openai.api_key = os.environ.get('O_APIKey')
|
8 |
Data_Read = os.environ.get('Data_Reader')
|
9 |
ChurnData = os.environ.get('Churn_Data')
|
10 |
+
ChurnData2 = os.environ.get('Churn_Data2')
|
11 |
|
12 |
#read data
|
13 |
from llama_index import VectorStoreIndex, SimpleDirectoryReader, SummaryIndex, download_loader
|
14 |
DataReader = download_loader(Data_Read)
|
15 |
loader = DataReader()
|
16 |
|
17 |
+
### 1st file
|
|
|
|
|
|
|
|
|
|
|
18 |
documents = loader.load_data(file=ChurnData)
|
19 |
+
### 1st file
|
20 |
+
|
21 |
+
### 2nd file
|
22 |
+
documents2 = loader.load_data(file=ChurnData2)
|
23 |
+
documents = documents + documents2
|
24 |
+
### 2nd file
|
25 |
+
|
26 |
index = VectorStoreIndex.from_documents(documents)
|
27 |
query_engine = index.as_query_engine()
|
28 |
|
|
|
30 |
answer = str(query_engine.query(message))
|
31 |
return answer
|
32 |
|
33 |
+
Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height="70vh",label="Conversation"), retry_btn=None,theme=gr.themes.Monochrome(),
|
34 |
+
title = 'E-Commerce BT/AN/CA/DH/VE/GA CMS Q&A', undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()
|