Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from parse_bhel_po import extract_po_details # Import
|
| 3 |
|
| 4 |
-
# Define a function to handle file processing based on the selected format
|
| 5 |
def process_pdf(uploaded_file, selected_format):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
if selected_format == "BHEL":
|
| 7 |
# Use the BHEL parser to extract data
|
| 8 |
df = extract_po_details(uploaded_file)
|
|
|
|
| 9 |
return df.to_string(index=False)
|
| 10 |
else:
|
|
|
|
| 11 |
return "Selected format not supported."
|
| 12 |
|
| 13 |
-
# Set up Gradio interface
|
| 14 |
interface = gr.Interface(
|
| 15 |
fn=process_pdf,
|
| 16 |
inputs=[
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from parse_bhel_po import extract_po_details # Import the BHEL-specific parsing function
|
| 3 |
|
|
|
|
| 4 |
def process_pdf(uploaded_file, selected_format):
|
| 5 |
+
# Debug: Print the selected format
|
| 6 |
+
print(f"[DEBUG] Selected format: {selected_format}")
|
| 7 |
+
|
| 8 |
+
# Check selected format and process accordingly
|
| 9 |
if selected_format == "BHEL":
|
| 10 |
# Use the BHEL parser to extract data
|
| 11 |
df = extract_po_details(uploaded_file)
|
| 12 |
+
# Return as formatted text output
|
| 13 |
return df.to_string(index=False)
|
| 14 |
else:
|
| 15 |
+
# Return message if format is not recognized
|
| 16 |
return "Selected format not supported."
|
| 17 |
|
| 18 |
+
# Set up the Gradio interface
|
| 19 |
interface = gr.Interface(
|
| 20 |
fn=process_pdf,
|
| 21 |
inputs=[
|