Marthee commited on
Commit
6d90c86
·
verified ·
1 Parent(s): 09310e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -212,14 +212,31 @@ def identify_headers_with_openrouter(pdf_path, model,LLM_prompt, pages_to_check=
212
 
213
  return out
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
 
 
217
  iface = gr.Interface(
218
- fn=identify_headers_with_openrouter,
219
- inputs=[gr.Textbox(label="Document Link"),
 
220
  gr.Textbox(label="Model Type"),
221
- gr.Textbox(label="LLM Prompt")]
222
- outputs=gr.Textbox(label="Output")
 
223
  )
224
 
225
  iface.launch()
 
212
 
213
  return out
214
 
215
+ # Wrapper function to convert JSON to a dataframe-friendly format
216
+ def identify_headers_with_table(pdf_path, model, LLM_prompt):
217
+ # Call your existing function
218
+ result = identify_headers_with_openrouter(pdf_path, model, LLM_prompt)
219
+
220
+ # Convert list of dicts to list of lists for Gradio Dataframe
221
+ if not result:
222
+ return [] # empty table if no results
223
+
224
+ table_data = [[item['text'], item['page']+1, item['suggested_level'], item['confidence']] for item in result]
225
+ return table_data
226
+
227
+ # Column names for the table
228
+ columns = ["Text", "Page", "Suggested Level", "Confidence"]
229
 
230
 
231
+ # Gradio Interface
232
  iface = gr.Interface(
233
+ fn=identify_headers_with_table,
234
+ inputs=[
235
+ gr.Textbox(label="Document Link"),
236
  gr.Textbox(label="Model Type"),
237
+ gr.Textbox(label="LLM Prompt")
238
+ ],
239
+ outputs=gr.Dataframe(headers=columns)
240
  )
241
 
242
  iface.launch()