Spaces:
Sleeping
Sleeping
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}"]) | |