stivenDR14
commited on
Commit
·
5249474
1
Parent(s):
1af4f46
update notations in gradio ui
Browse files- app.py +5 -0
- pdf_processor.py +0 -2
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from pdf_processor import PDFProcessor
|
3 |
from utils import AI_MODELS, TRANSLATIONS
|
4 |
|
@@ -57,15 +58,19 @@ class PDFProcessorUI:
|
|
57 |
else:
|
58 |
return gr.update(visible=False), gr.update(visible=False)
|
59 |
|
|
|
60 |
def process_pdf(self, vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model, type_model, api_key, project_id_watsonx):
|
61 |
return self.processor.process_pdf(vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model, type_model, api_key, project_id_watsonx)
|
62 |
|
|
|
63 |
def qa_interface(self, vectorstore, message, history, ai_model, type_model, api_key, project_id_watsonx):
|
64 |
return self.processor.get_qa_response(vectorstore, message, history, ai_model, type_model, api_key, project_id_watsonx)
|
65 |
|
|
|
66 |
def summarize_interface(self, vectorstore, ai_model, type_model, api_key, project_id_watsonx):
|
67 |
return self.processor.get_summary(vectorstore, ai_model, type_model, api_key, project_id_watsonx)
|
68 |
|
|
|
69 |
def specialist_opinion(self, vectorstore, ai_model, type_model, api_key, project_id_watsonx, specialist_prompt):
|
70 |
return self.processor.get_specialist_opinion(vectorstore, ai_model, type_model, api_key, project_id_watsonx, specialist_prompt)
|
71 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import spaces
|
3 |
from pdf_processor import PDFProcessor
|
4 |
from utils import AI_MODELS, TRANSLATIONS
|
5 |
|
|
|
58 |
else:
|
59 |
return gr.update(visible=False), gr.update(visible=False)
|
60 |
|
61 |
+
@spaces.GPU
|
62 |
def process_pdf(self, vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model, type_model, api_key, project_id_watsonx):
|
63 |
return self.processor.process_pdf(vectorstore, pdf_file, chunk_size, chunk_overlap, ai_model, type_model, api_key, project_id_watsonx)
|
64 |
|
65 |
+
@spaces.GPU
|
66 |
def qa_interface(self, vectorstore, message, history, ai_model, type_model, api_key, project_id_watsonx):
|
67 |
return self.processor.get_qa_response(vectorstore, message, history, ai_model, type_model, api_key, project_id_watsonx)
|
68 |
|
69 |
+
@spaces.GPU
|
70 |
def summarize_interface(self, vectorstore, ai_model, type_model, api_key, project_id_watsonx):
|
71 |
return self.processor.get_summary(vectorstore, ai_model, type_model, api_key, project_id_watsonx)
|
72 |
|
73 |
+
@spaces.GPU
|
74 |
def specialist_opinion(self, vectorstore, ai_model, type_model, api_key, project_id_watsonx, specialist_prompt):
|
75 |
return self.processor.get_specialist_opinion(vectorstore, ai_model, type_model, api_key, project_id_watsonx, specialist_prompt)
|
76 |
|
pdf_processor.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import json
|
2 |
-
import tempfile
|
3 |
import spaces
|
4 |
from langchain_community.document_loaders import PyPDFLoader
|
5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
@@ -92,7 +91,6 @@ def authenticate_watsonx(api_key):
|
|
92 |
print("Response:", response.text)
|
93 |
return None
|
94 |
|
95 |
-
@spaces.GPU
|
96 |
class PDFProcessor:
|
97 |
def __init__(self):
|
98 |
self.language = "English"
|
|
|
1 |
import json
|
|
|
2 |
import spaces
|
3 |
from langchain_community.document_loaders import PyPDFLoader
|
4 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
|
91 |
print("Response:", response.text)
|
92 |
return None
|
93 |
|
|
|
94 |
class PDFProcessor:
|
95 |
def __init__(self):
|
96 |
self.language = "English"
|