DSatishchandra/PMP_PO_Extraction
0
1# app.py2 3import gradio as gr4from ALNISF import process_pdf as process_alnisf5from federal_electric import process_pdf as process_federal_electric6from bhel import process_pdf as process_bhel7 8def process_file(pdf_file, extractor):9 try:10 if extractor == "ALNISF":11 return process_alnisf(pdf_file)12 elif extractor == "Federal Electric":13 return process_federal_electric(pdf_file)14 elif extractor == "BHEL":15 return process_bhel(pdf_file)16 else:17 return None, "Invalid extractor selected."18 except Exception as e:19 return None, f"An error occurred: {str(e)}"20 21def create_main_interface():22 return gr.Interface(23 fn=process_file,24 inputs=[25 gr.File(label="Upload PDF", file_types=[".pdf"]),26 gr.Radio(27 ["ALNISF", "Federal Electric", "BHEL"],28 label="Select Extractor",29 value="ALNISF"30 ),31 ],32 outputs=[33 gr.File(label="Download Extracted Data"),34 gr.Textbox(label="Status"),35 ],36 title="UC3 Unified PO Data Extraction",37 description="Upload a Purchase Order PDF and select the extractor (ALNISF, Federal Electric, BHEL) to process the file and download the extracted data.",38 )39 40if __name__ == "__main__":41 interface = create_main_interface()42 interface.launch()43 