# app.py import gradio as gr from ALNISF import process_pdf as process_alnisf from federal_electric import process_pdf as process_federal_electric from bhel import process_pdf as process_bhel def process_file(pdf_file, extractor): try: if extractor == "ALNISF": return process_alnisf(pdf_file) elif extractor == "Federal Electric": return process_federal_electric(pdf_file) elif extractor == "BHEL": return process_bhel(pdf_file) else: return None, "Invalid extractor selected." except Exception as e: return None, f"An error occurred: {str(e)}" def create_main_interface(): return gr.Interface( fn=process_file, inputs=[ gr.File(label="Upload PDF", file_types=[".pdf"]), gr.Radio( ["ALNISF", "Federal Electric", "BHEL"], label="Select Extractor", value="ALNISF" ), ], outputs=[ gr.File(label="Download Extracted Data"), gr.Textbox(label="Status"), ], title="UC3 Unified PO Data Extraction", description="Upload a Purchase Order PDF and select the extractor (ALNISF, Federal Electric, BHEL) to process the file and download the extracted data.", ) if __name__ == "__main__": interface = create_main_interface() interface.launch()