Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -233,7 +233,7 @@ def identify_headers_with_openrouter(pdf_path, model,LLM_prompt, pages_to_check=
|
|
| 233 |
|
| 234 |
|
| 235 |
def identify_headers_and_save_excel(pdf_path, model, llm_prompt):
|
| 236 |
-
#
|
| 237 |
result = identify_headers_with_openrouter(pdf_path, model, llm_prompt)
|
| 238 |
|
| 239 |
if not result:
|
|
@@ -241,12 +241,11 @@ def identify_headers_and_save_excel(pdf_path, model, llm_prompt):
|
|
| 241 |
|
| 242 |
df = pd.DataFrame(result)
|
| 243 |
|
| 244 |
-
# Save to
|
| 245 |
-
|
| 246 |
-
df.to_excel(
|
| 247 |
-
output.seek(0) # reset pointer to start
|
| 248 |
|
| 249 |
-
return
|
| 250 |
|
| 251 |
iface = gr.Interface(
|
| 252 |
fn=identify_headers_and_save_excel,
|
|
@@ -255,8 +254,7 @@ iface = gr.Interface(
|
|
| 255 |
gr.Textbox(label="Model Type"),
|
| 256 |
gr.Textbox(label="LLM Prompt")
|
| 257 |
],
|
| 258 |
-
outputs=gr.File(label="Download Excel")
|
| 259 |
)
|
| 260 |
|
| 261 |
-
iface.launch()
|
| 262 |
-
|
|
|
|
| 233 |
|
| 234 |
|
| 235 |
def identify_headers_and_save_excel(pdf_path, model, llm_prompt):
|
| 236 |
+
# Call your existing function
|
| 237 |
result = identify_headers_with_openrouter(pdf_path, model, llm_prompt)
|
| 238 |
|
| 239 |
if not result:
|
|
|
|
| 241 |
|
| 242 |
df = pd.DataFrame(result)
|
| 243 |
|
| 244 |
+
# Save Excel to a file on disk
|
| 245 |
+
output_path = "output.xlsx"
|
| 246 |
+
df.to_excel(output_path, index=False, engine='openpyxl')
|
|
|
|
| 247 |
|
| 248 |
+
return output_path # return file path, not BytesIO
|
| 249 |
|
| 250 |
iface = gr.Interface(
|
| 251 |
fn=identify_headers_and_save_excel,
|
|
|
|
| 254 |
gr.Textbox(label="Model Type"),
|
| 255 |
gr.Textbox(label="LLM Prompt")
|
| 256 |
],
|
| 257 |
+
outputs=gr.File(label="Download Excel") # File expects a path
|
| 258 |
)
|
| 259 |
|
| 260 |
+
iface.launch()
|
|
|