Spaces:
Runtime error
Runtime error
testing with llama3
Browse files- src/app.py +1 -1
- src/pdfchatbot.py +5 -2
src/app.py
CHANGED
|
@@ -5,7 +5,7 @@ from pdfchatbot import PDFChatBot
|
|
| 5 |
demo, chat_history, show_img, txt, submit_button, uploaded_pdf, slider1 = create_demo()
|
| 6 |
|
| 7 |
# Create PDFChatBot instance
|
| 8 |
-
pdf_chatbot = PDFChatBot()
|
| 9 |
pdf_chatbot.load_model()
|
| 10 |
pdf_chatbot.load_tokenizer()
|
| 11 |
|
|
|
|
| 5 |
demo, chat_history, show_img, txt, submit_button, uploaded_pdf, slider1 = create_demo()
|
| 6 |
|
| 7 |
# Create PDFChatBot instance
|
| 8 |
+
pdf_chatbot = PDFChatBot(chunk_size_slider=slider1)
|
| 9 |
pdf_chatbot.load_model()
|
| 10 |
pdf_chatbot.load_tokenizer()
|
| 11 |
|
src/pdfchatbot.py
CHANGED
|
@@ -16,7 +16,7 @@ from langchain_text_splitters import CharacterTextSplitter
|
|
| 16 |
|
| 17 |
|
| 18 |
class PDFChatBot:
|
| 19 |
-
def __init__(self, config_path="config.yaml"):
|
| 20 |
"""
|
| 21 |
Initialize the PDFChatBot instance.
|
| 22 |
|
|
@@ -37,6 +37,7 @@ class PDFChatBot:
|
|
| 37 |
self.pipeline = None
|
| 38 |
self.chain = None
|
| 39 |
self.chunk_size = None
|
|
|
|
| 40 |
|
| 41 |
def load_config(self, file_path):
|
| 42 |
"""
|
|
@@ -70,7 +71,7 @@ class PDFChatBot:
|
|
| 70 |
if not text:
|
| 71 |
raise gr.Error('Enter text')
|
| 72 |
history.append((text, ''))
|
| 73 |
-
self.
|
| 74 |
return history
|
| 75 |
|
| 76 |
def create_prompt_template(self):
|
|
@@ -193,6 +194,8 @@ class PDFChatBot:
|
|
| 193 |
Returns:
|
| 194 |
PIL.Image.Image: The rendered page as an image.
|
| 195 |
"""
|
|
|
|
|
|
|
| 196 |
print(chunk_size)
|
| 197 |
doc = fitz.open(file.name)
|
| 198 |
page = doc[self.page]
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
class PDFChatBot:
|
| 19 |
+
def __init__(self, config_path="config.yaml",chunk_size_slider=None):
|
| 20 |
"""
|
| 21 |
Initialize the PDFChatBot instance.
|
| 22 |
|
|
|
|
| 37 |
self.pipeline = None
|
| 38 |
self.chain = None
|
| 39 |
self.chunk_size = None
|
| 40 |
+
self.chunk_size_slider = chunk_size_slider
|
| 41 |
|
| 42 |
def load_config(self, file_path):
|
| 43 |
"""
|
|
|
|
| 71 |
if not text:
|
| 72 |
raise gr.Error('Enter text')
|
| 73 |
history.append((text, ''))
|
| 74 |
+
self.chunk_size_slider.interactive = False
|
| 75 |
return history
|
| 76 |
|
| 77 |
def create_prompt_template(self):
|
|
|
|
| 194 |
Returns:
|
| 195 |
PIL.Image.Image: The rendered page as an image.
|
| 196 |
"""
|
| 197 |
+
if self.chunk_size_slider.interactive == False:
|
| 198 |
+
self.chunk_size_slider.interactive = True
|
| 199 |
print(chunk_size)
|
| 200 |
doc = fitz.open(file.name)
|
| 201 |
page = doc[self.page]
|