Spaces:
Sleeping
Sleeping
stivenDR14
commited on
Commit
·
b29e8f3
1
Parent(s):
f02b6b1
demo.queue() at launch
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ 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 |
-
self.vectorstore = None
|
| 13 |
|
| 14 |
def change_language(self, language):
|
| 15 |
self.current_language = language
|
|
@@ -77,6 +76,7 @@ class PDFProcessorUI:
|
|
| 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,31 +212,31 @@ class PDFProcessorUI:
|
|
| 212 |
|
| 213 |
chat_placeholder.submit(
|
| 214 |
fn=self.qa_interface,
|
| 215 |
-
inputs=[
|
| 216 |
outputs=[chatbot]
|
| 217 |
)
|
| 218 |
|
| 219 |
process_btn.click(
|
| 220 |
fn=self.process_pdf,
|
| 221 |
-
inputs=[
|
| 222 |
-
outputs=[process_output,
|
| 223 |
)
|
| 224 |
|
| 225 |
summarize_btn.click(
|
| 226 |
fn=self.summarize_interface,
|
| 227 |
-
inputs=[
|
| 228 |
outputs=[summary_output]
|
| 229 |
)
|
| 230 |
|
| 231 |
specialist_btn.click(
|
| 232 |
fn=self.specialist_opinion,
|
| 233 |
-
inputs=[
|
| 234 |
outputs=[specialist_output]
|
| 235 |
)
|
| 236 |
|
| 237 |
chat_btn.click(
|
| 238 |
fn=self.qa_interface,
|
| 239 |
-
inputs=[
|
| 240 |
outputs=[chatbot]
|
| 241 |
)
|
| 242 |
|
|
@@ -245,4 +245,4 @@ class PDFProcessorUI:
|
|
| 245 |
if __name__ == "__main__":
|
| 246 |
ui = PDFProcessorUI()
|
| 247 |
demo = ui.create_ui()
|
| 248 |
-
demo.launch()
|
|
|
|
| 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 |
|
| 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 |
|
| 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 |
|
|
|
|
| 245 |
if __name__ == "__main__":
|
| 246 |
ui = PDFProcessorUI()
|
| 247 |
demo = ui.create_ui()
|
| 248 |
+
demo.queue().launch()
|