SathvikGanta's picture
Update app.py
b72ce3f verified
import gradio as gr
from parse_bhel_po import extract_po_details # Import the BHEL-specific parsing function
def process_pdf(uploaded_file, selected_format):
# Debug: Print the selected format
print(f"[DEBUG] Selected format: {selected_format}")
# Check selected format and process accordingly
if selected_format == "BHEL":
# Use the BHEL parser to extract data
df = extract_po_details(uploaded_file)
# Return as formatted text output
return df.to_string(index=False)
else:
# Return message if format is not recognized
return "Selected format not supported."
# Set up the Gradio interface
interface = gr.Interface(
fn=process_pdf,
inputs=[
gr.Dropdown(label="Select Format", choices=["BHEL"], value="BHEL"),
gr.File(label="Upload PDF"),
],
outputs="text",
title="PO Details Extraction",
description="Select the format and upload the PO PDF to extract details."
)
if __name__ == "__main__":
interface.launch()