Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from langchain_community.document_loaders import PyPDFLoader
|
|
10 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
11 |
from dotenv import load_dotenv
|
12 |
|
13 |
-
# Load environment variables
|
14 |
load_dotenv()
|
15 |
|
16 |
# Load the GROQ API key
|
@@ -46,12 +46,6 @@ def process_pdf(file):
|
|
46 |
return "PDF processed and added to the knowledge base."
|
47 |
return "No file uploaded."
|
48 |
|
49 |
-
# Function to clear the knowledge base
|
50 |
-
def clear_knowledge_base():
|
51 |
-
global vectors
|
52 |
-
vectors = None
|
53 |
-
return "Knowledge base cleared."
|
54 |
-
|
55 |
# Function to process questions
|
56 |
def process_question(question):
|
57 |
if vectors is None:
|
@@ -95,7 +89,6 @@ with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
95 |
with gr.Tab("PDF Uploader"):
|
96 |
pdf_file = gr.File(label="Upload PDF")
|
97 |
upload_button = gr.Button("Process PDF")
|
98 |
-
clear_button = gr.Button("Clear Knowledge Base")
|
99 |
upload_output = gr.Textbox(label="Upload Status")
|
100 |
|
101 |
with gr.Tab("Q&A System"):
|
@@ -108,9 +101,6 @@ with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
108 |
# Button actions
|
109 |
upload_button.click(process_pdf, inputs=[pdf_file], outputs=[upload_output])
|
110 |
submit_button.click(process_question, inputs=[question_input], outputs=[answer_output, context_output, confidence_output])
|
111 |
-
|
112 |
-
# Action to clear the knowledge base
|
113 |
-
clear_button.click(clear_knowledge_base, outputs=[upload_output])
|
114 |
|
115 |
gr.HTML(FOOTER_TEXT)
|
116 |
|
|
|
10 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
11 |
from dotenv import load_dotenv
|
12 |
|
13 |
+
# Load the environment variables
|
14 |
load_dotenv()
|
15 |
|
16 |
# Load the GROQ API key
|
|
|
46 |
return "PDF processed and added to the knowledge base."
|
47 |
return "No file uploaded."
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
# Function to process questions
|
50 |
def process_question(question):
|
51 |
if vectors is None:
|
|
|
89 |
with gr.Tab("PDF Uploader"):
|
90 |
pdf_file = gr.File(label="Upload PDF")
|
91 |
upload_button = gr.Button("Process PDF")
|
|
|
92 |
upload_output = gr.Textbox(label="Upload Status")
|
93 |
|
94 |
with gr.Tab("Q&A System"):
|
|
|
101 |
# Button actions
|
102 |
upload_button.click(process_pdf, inputs=[pdf_file], outputs=[upload_output])
|
103 |
submit_button.click(process_question, inputs=[question_input], outputs=[answer_output, context_output, confidence_output])
|
|
|
|
|
|
|
104 |
|
105 |
gr.HTML(FOOTER_TEXT)
|
106 |
|