wholewhale
commited on
Commit
•
6f46024
1
Parent(s):
9b3cbf1
gradio
Browse files
app.py
CHANGED
@@ -137,14 +137,16 @@ title = """
|
|
137 |
<h1>CauseWriter Chat with PDF • OpenAI</h1>
|
138 |
<p style="text-align: center;">Upload a .PDF from your computer, click the "Load PDF to LangChain" button, <br />
|
139 |
when everything is ready, you can start asking questions about the pdf. Limit ~11k words. <br />
|
140 |
-
This version is set to erase chat history automatically after page timeout and uses OpenAI
|
141 |
</div>
|
142 |
"""
|
143 |
# Global variable for tracking last interaction time
|
144 |
last_interaction_time = 0
|
145 |
full_summary = "" # Added global full_summary
|
146 |
|
147 |
-
|
|
|
|
|
148 |
|
149 |
with gr.Blocks(css=css) as demo:
|
150 |
with gr.Column(elem_id="col-container"):
|
@@ -159,19 +161,16 @@ with gr.Blocks(css=css) as demo:
|
|
159 |
|
160 |
# New Textbox to display summary
|
161 |
summary_box = gr.Textbox(label="Document Summary", placeholder="Summary will appear here.",
|
162 |
-
|
163 |
|
164 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=450)
|
165 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
166 |
submit_btn = gr.Button("Send Message")
|
167 |
|
168 |
-
# Function to update summary box
|
169 |
-
def update_summary_box():
|
170 |
-
global full_summary
|
171 |
-
summary_box.value = full_summary
|
172 |
-
|
173 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|
174 |
-
load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False).then(
|
|
|
|
|
175 |
clear_btn.click(clear_data, outputs=[langchain_status], queue=False)
|
176 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
177 |
bot, chatbot, chatbot
|
|
|
137 |
<h1>CauseWriter Chat with PDF • OpenAI</h1>
|
138 |
<p style="text-align: center;">Upload a .PDF from your computer, click the "Load PDF to LangChain" button, <br />
|
139 |
when everything is ready, you can start asking questions about the pdf. Limit ~11k words. <br />
|
140 |
+
This version is set to erase chat history automatically after page timeout and uses OpenAI.</p>
|
141 |
</div>
|
142 |
"""
|
143 |
# Global variable for tracking last interaction time
|
144 |
last_interaction_time = 0
|
145 |
full_summary = "" # Added global full_summary
|
146 |
|
147 |
+
def update_summary_box():
|
148 |
+
global full_summary
|
149 |
+
return {"summary_box": full_summary}
|
150 |
|
151 |
with gr.Blocks(css=css) as demo:
|
152 |
with gr.Column(elem_id="col-container"):
|
|
|
161 |
|
162 |
# New Textbox to display summary
|
163 |
summary_box = gr.Textbox(label="Document Summary", placeholder="Summary will appear here.",
|
164 |
+
interactive=False, rows=5, elem_id="summary_box")
|
165 |
|
166 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=450)
|
167 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
168 |
submit_btn = gr.Button("Send Message")
|
169 |
|
|
|
|
|
|
|
|
|
|
|
170 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|
171 |
+
load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False).then(
|
172 |
+
update_summary_box, state={"summary_box": summary_box}
|
173 |
+
) # Then update the summary_box
|
174 |
clear_btn.click(clear_data, outputs=[langchain_status], queue=False)
|
175 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
176 |
bot, chatbot, chatbot
|