update
Browse files
app.py
CHANGED
@@ -93,7 +93,7 @@ def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, pr
|
|
93 |
llm_name = list_llm[llm_option]
|
94 |
print("llm_name: ",llm_name)
|
95 |
qa_chain = initialize_llmchain(llm_name, llm_temperature, max_tokens, top_k, vector_db, progress)
|
96 |
-
return qa_chain, "QA chain
|
97 |
|
98 |
|
99 |
def format_chat_history(message, chat_history):
|
@@ -138,16 +138,16 @@ def demo():
|
|
138 |
vector_db = gr.State()
|
139 |
qa_chain = gr.State()
|
140 |
gr.HTML("<center><h1>RAG PDF chatbot</h1><center>")
|
141 |
-
gr.Markdown("""<b>
|
142 |
<b>Please do not upload confidential documents.</b>
|
143 |
""")
|
144 |
with gr.Row():
|
145 |
with gr.Column(scale = 86):
|
146 |
-
gr.Markdown("<b>Step 1 -
|
147 |
with gr.Row():
|
148 |
document = gr.Files(height=300, file_count="multiple", file_types=["pdf"], interactive=True, label="Upload PDF documents")
|
149 |
with gr.Row():
|
150 |
-
db_btn = gr.Button("
|
151 |
with gr.Row():
|
152 |
db_progress = gr.Textbox(value="Not initialized", show_label=False) # label="Vector database status",
|
153 |
gr.Markdown("<style>body { font-size: 16px; }</style><b>Select Large Language Model (LLM) and input parameters</b>")
|
@@ -167,7 +167,7 @@ def demo():
|
|
167 |
llm_progress = gr.Textbox(value="Not initialized", show_label=False) # label="Chatbot status",
|
168 |
|
169 |
with gr.Column(scale = 200):
|
170 |
-
gr.Markdown("<b>Step 2 -
|
171 |
chatbot = gr.Chatbot(height=505)
|
172 |
with gr.Accordion("Relevent context from the source document", open=False):
|
173 |
with gr.Row():
|
@@ -182,7 +182,7 @@ def demo():
|
|
182 |
with gr.Row():
|
183 |
msg = gr.Textbox(placeholder="Ask a question", container=True)
|
184 |
with gr.Row():
|
185 |
-
submit_btn = gr.Button("
|
186 |
clear_btn = gr.ClearButton([msg, chatbot], value="Clear")
|
187 |
|
188 |
# Preprocessing events
|
|
|
93 |
llm_name = list_llm[llm_option]
|
94 |
print("llm_name: ",llm_name)
|
95 |
qa_chain = initialize_llmchain(llm_name, llm_temperature, max_tokens, top_k, vector_db, progress)
|
96 |
+
return qa_chain, "QA chain initialized. Chatbot is ready!"
|
97 |
|
98 |
|
99 |
def format_chat_history(message, chat_history):
|
|
|
138 |
vector_db = gr.State()
|
139 |
qa_chain = gr.State()
|
140 |
gr.HTML("<center><h1>RAG PDF chatbot</h1><center>")
|
141 |
+
gr.Markdown("""<b>Query your PDF documents!</b> This AI agent is designed to perform retrieval augmented generation (RAG) on PDF documents. The app is hosted on Hugging Face Hub for the sole purpose of demonstration. \
|
142 |
<b>Please do not upload confidential documents.</b>
|
143 |
""")
|
144 |
with gr.Row():
|
145 |
with gr.Column(scale = 86):
|
146 |
+
gr.Markdown("<b>Step 1 - Upload PDF documents and Initialize RAG pipeline</b>")
|
147 |
with gr.Row():
|
148 |
document = gr.Files(height=300, file_count="multiple", file_types=["pdf"], interactive=True, label="Upload PDF documents")
|
149 |
with gr.Row():
|
150 |
+
db_btn = gr.Button("Create vector database")
|
151 |
with gr.Row():
|
152 |
db_progress = gr.Textbox(value="Not initialized", show_label=False) # label="Vector database status",
|
153 |
gr.Markdown("<style>body { font-size: 16px; }</style><b>Select Large Language Model (LLM) and input parameters</b>")
|
|
|
167 |
llm_progress = gr.Textbox(value="Not initialized", show_label=False) # label="Chatbot status",
|
168 |
|
169 |
with gr.Column(scale = 200):
|
170 |
+
gr.Markdown("<b>Step 2 - Chat with your Document</b>")
|
171 |
chatbot = gr.Chatbot(height=505)
|
172 |
with gr.Accordion("Relevent context from the source document", open=False):
|
173 |
with gr.Row():
|
|
|
182 |
with gr.Row():
|
183 |
msg = gr.Textbox(placeholder="Ask a question", container=True)
|
184 |
with gr.Row():
|
185 |
+
submit_btn = gr.Button("Submit")
|
186 |
clear_btn = gr.ClearButton([msg, chatbot], value="Clear")
|
187 |
|
188 |
# Preprocessing events
|