stivenDR14 commited on
Commit
b4def70
·
1 Parent(s): c92be56

making intialized vectorstore

Browse files
Files changed (2) hide show
  1. app.py +7 -7
  2. pdf_processor.py +2 -0
app.py CHANGED
@@ -9,6 +9,7 @@ class PDFProcessorUI:
9
  self.current_language = "English"
10
  self.current_ai_model = "Huggingface / IBM granite granite 3.1 8b Instruct"
11
  self.current_type_model = "Api Key"
 
12
 
13
  def change_language(self, language):
14
  self.current_language = language
@@ -76,7 +77,6 @@ class PDFProcessorUI:
76
 
77
  def create_ui(self):
78
  with gr.Blocks() as demo:
79
- vectorstore = gr.State()
80
  title = gr.Markdown(TRANSLATIONS[self.current_language]["title"])
81
 
82
  with gr.Row():
@@ -212,31 +212,31 @@ class PDFProcessorUI:
212
 
213
  chat_placeholder.submit(
214
  fn=self.qa_interface,
215
- inputs=[vectorstore, chat_placeholder, chatbot, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
216
  outputs=[chatbot]
217
  )
218
 
219
  process_btn.click(
220
  fn=self.process_pdf,
221
- inputs=[vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
222
- outputs=[process_output, vectorstore]
223
  )
224
 
225
  summarize_btn.click(
226
  fn=self.summarize_interface,
227
- inputs=[vectorstore, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
228
  outputs=[summary_output]
229
  )
230
 
231
  specialist_btn.click(
232
  fn=self.specialist_opinion,
233
- inputs=[vectorstore, ai_model_dropdown, type_model, api_key_input, project_id_watsonx, specialist_placeholder],
234
  outputs=[specialist_output]
235
  )
236
 
237
  chat_btn.click(
238
  fn=self.qa_interface,
239
- inputs=[vectorstore, chat_placeholder, chatbot, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
240
  outputs=[chatbot]
241
  )
242
 
 
9
  self.current_language = "English"
10
  self.current_ai_model = "Huggingface / IBM granite granite 3.1 8b Instruct"
11
  self.current_type_model = "Api Key"
12
+ self.vectorstore = gr.State()
13
 
14
  def change_language(self, language):
15
  self.current_language = language
 
77
 
78
  def create_ui(self):
79
  with gr.Blocks() as demo:
 
80
  title = gr.Markdown(TRANSLATIONS[self.current_language]["title"])
81
 
82
  with gr.Row():
 
212
 
213
  chat_placeholder.submit(
214
  fn=self.qa_interface,
215
+ inputs=[self.vectorstore, chat_placeholder, chatbot, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
216
  outputs=[chatbot]
217
  )
218
 
219
  process_btn.click(
220
  fn=self.process_pdf,
221
+ inputs=[self.vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
222
+ outputs=[process_output, self.vectorstore]
223
  )
224
 
225
  summarize_btn.click(
226
  fn=self.summarize_interface,
227
+ inputs=[self.vectorstore, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
228
  outputs=[summary_output]
229
  )
230
 
231
  specialist_btn.click(
232
  fn=self.specialist_opinion,
233
+ inputs=[self.vectorstore, ai_model_dropdown, type_model, api_key_input, project_id_watsonx, specialist_placeholder],
234
  outputs=[specialist_output]
235
  )
236
 
237
  chat_btn.click(
238
  fn=self.qa_interface,
239
+ inputs=[self.vectorstore, chat_placeholder, chatbot, ai_model_dropdown, type_model, api_key_input, project_id_watsonx],
240
  outputs=[chatbot]
241
  )
242
 
pdf_processor.py CHANGED
@@ -188,6 +188,8 @@ class PDFProcessor:
188
  collection_name="pdf_collection"
189
  #persist_directory="./chroma_db"
190
  )
 
 
191
 
192
  return TRANSLATIONS[self.language]["pdf_processed"], vectorstore #+ f" ---- Chunks: {len(vectorstore.get()["documents"])}"
193
 
 
188
  collection_name="pdf_collection"
189
  #persist_directory="./chroma_db"
190
  )
191
+
192
+ print("vectorstore: ", vectorstore)
193
 
194
  return TRANSLATIONS[self.language]["pdf_processed"], vectorstore #+ f" ---- Chunks: {len(vectorstore.get()["documents"])}"
195