Spaces:
Sleeping
Sleeping
File size: 521 Bytes
fa22a1e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import fitz # PyMuPDF
def extract_text_from_pdfs(folder_path="meal_plans"):
import os
texts = []
for file_name in os.listdir(folder_path):
if file_name.endswith(".pdf"):
doc = fitz.open(os.path.join(folder_path, file_name))
text = "\n".join([page.get_text() for page in doc])
texts.append(text)
return "\n\n".join(texts)
def format_chat(history, new_input):
return "\n".join([f"User: {inp}\nBot: {out}" for inp, out in history] + [f"User: {new_input}"])
|