import PyPDF2 import os import io import csv import pandas as pd from openpyxl import load_workbook def read_pdf(file): reader = PyPDF2.PdfReader(file) text = "" for page in reader.pages: text += page.extract_text() or "" return text def load_children_data(source=None): if source is None: path = os.path.join(os.path.dirname(__file__), "children_requirements.xlsx") if not os.path.exists(path): return [] else: path = None if path: if path.endswith(".csv"): return pd.read_csv(path) return pd.read_excel(path) file_bytes = source.getvalue() name = source.name.lower() if name.endswith(".csv"): return pd.read_csv(io.StringIO(file_bytes.decode("utf-8"))) wb = load_workbook(io.BytesIO(file_bytes)) ws = wb.active rows = list(ws.iter_rows(values_only=True)) headers = rows[0] return [dict(zip(headers, r)) for r in rows[1:]] def build_prompt(resume_text, child_profile): return f""" You are an HR assistant for an autism therapy company. Resume: {resume_text} Child Requirements: {child_profile} Answer clearly: 1. Is the therapist suitable? (Yes or No) 2. Short reason 3. Interview recommendation """