wholewhale commited on
Commit
9b3cbf1
1 Parent(s): d8d32c4

gradio update

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -136,10 +136,15 @@ title = """
136
  <div style="text-align: center;max-width: 700px;">
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. <br />
140
- This version is set to erase chat history and uses OpenAI as LLM.</p>
141
  </div>
142
  """
 
 
 
 
 
143
 
144
  with gr.Blocks(css=css) as demo:
145
  with gr.Column(elem_id="col-container"):
@@ -151,13 +156,22 @@ with gr.Blocks(css=css) as demo:
151
  langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
152
  load_pdf = gr.Button("Convert PDF to Magic AI language")
153
  clear_btn = gr.Button("Clear Data")
 
 
 
 
154
 
155
  chatbot = gr.Chatbot([], elem_id="chatbot").style(height=450)
156
  question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
157
  submit_btn = gr.Button("Send Message")
158
 
 
 
 
 
 
159
  load_pdf.click(loading_pdf, None, langchain_status, queue=False)
160
- load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
161
  clear_btn.click(clear_data, outputs=[langchain_status], queue=False)
162
  question.submit(add_text, [chatbot, question], [chatbot, question]).then(
163
  bot, chatbot, chatbot
@@ -166,4 +180,4 @@ with gr.Blocks(css=css) as demo:
166
  bot, chatbot, chatbot
167
  )
168
 
169
- demo.launch()
 
136
  <div style="text-align: center;max-width: 700px;">
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 as LLM.</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
+ # ... (rest of your imports and function definitions)
148
 
149
  with gr.Blocks(css=css) as demo:
150
  with gr.Column(elem_id="col-container"):
 
156
  langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
157
  load_pdf = gr.Button("Convert PDF to Magic AI language")
158
  clear_btn = gr.Button("Clear Data")
159
+
160
+ # New Textbox to display summary
161
+ summary_box = gr.Textbox(label="Document Summary", placeholder="Summary will appear here.",
162
+ value=full_summary, interactive=False, rows=5)
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(update_summary_box) # Then update the summary_box
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
 
180
  bot, chatbot, chatbot
181
  )
182
 
183
+ demo.launch()