Rahatara commited on
Commit
0f79c5c
·
verified ·
1 Parent(s): 671a105

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -100,15 +100,14 @@ def refresh_chat():
100
 
101
  app = MyApp()
102
 
103
- # Pre-process the saved PDF file
104
- saved_file_path = "track_training.pdf"
105
- with open(saved_file_path, 'rb') as saved_file:
106
- app.process_file(saved_file)
107
- app.build_chain(saved_file)
108
-
109
  # Function to set API key
110
  def set_api_key(api_key):
111
  app.set_api_key(api_key)
 
 
 
 
 
112
  return f"API Key set to {api_key[:4]}...{api_key[-4:]}"
113
 
114
  # Gradio interface
@@ -190,7 +189,7 @@ with gr.Blocks() as demo:
190
  source_texts_output_current = gr.Textbox(label="Source Texts", interactive=False)
191
 
192
  def get_response_current(history, query):
193
- return get_response(history, query, open(saved_file_path, 'rb'))
194
 
195
  submit_btn_current.click(
196
  fn=add_text,
 
100
 
101
  app = MyApp()
102
 
 
 
 
 
 
 
103
  # Function to set API key
104
  def set_api_key(api_key):
105
  app.set_api_key(api_key)
106
+ # Pre-process the saved PDF file after setting the API key
107
+ saved_file_path = "track_training.pdf"
108
+ with open(saved_file_path, 'rb') as saved_file:
109
+ app.process_file(saved_file)
110
+ app.build_chain(saved_file)
111
  return f"API Key set to {api_key[:4]}...{api_key[-4:]}"
112
 
113
  # Gradio interface
 
189
  source_texts_output_current = gr.Textbox(label="Source Texts", interactive=False)
190
 
191
  def get_response_current(history, query):
192
+ return get_response(history, query, open("track_training.pdf", 'rb'))
193
 
194
  submit_btn_current.click(
195
  fn=add_text,