Spaces:
Build error
Build error
Download utils.py from DurgaDeepak/eat2fit: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/spaces/DurgaDeepak/eat2fit/resolve/main/utils.py
- Command line
-
hf download hf://spaces/DurgaDeepak/eat2fit/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/DurgaDeepak/eat2fit/resolve/main/utils.py
521 Bytes
| 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}"]) | |