use gr.Tab components instead of TabbedInterface

#1
Files changed (1) hide show
  1. app.py +52 -51
app.py CHANGED
@@ -17,33 +17,6 @@ def use_gemini(pdf_filepath, key):
17
  result = gemini_extractor.extract(content, config)
18
  return result
19
 
20
- with gr.Blocks(title="PDF data extraction with Gemini & Indexify") as gemini_demo:
21
- gr.HTML("<h1 style='text-align: center'>PDF data extraction with Gemini & <a href='https://getindexify.ai/'>Indexify</a></h1>")
22
- gr.HTML("<p style='text-align: center'>Indexify is a scalable realtime and continuous indexing and structured extraction engine for unstructured data to build generative AI applications</p>")
23
- gr.HTML("<h3 style='text-align: center'>If you like this demo, please ⭐ Star us on <a href='https://github.com/tensorlakeai/indexify' target='_blank'>GitHub</a>!</h3>")
24
- gr.HTML("<h4 style='text-align: center'>Here's an example notebook that demonstrates how to build a continuous <a href='https://github.com/tensorlakeai/indexify/blob/main/docs/docs/examples/multimodal_gemini.ipynb' target='_blank'>extraction pipeline</a> with Indexify</h4>")
25
-
26
- with gr.Row():
27
- with gr.Column():
28
- gr.HTML(
29
- "<p><b>Step 1:</b> Upload a PDF file from local storage.</p>"
30
- "<p style='color: #A0A0A0;'>Use this demo for single PDF file only. "
31
- "You can extract from PDF files continuously and try various other extractors locally with "
32
- "<a href='https://getindexify.ai/'>Indexify</a>.</p>"
33
- )
34
- pdf_file_1 = gr.File(type="filepath")
35
- gr.HTML("<p><b>Step 2:</b> Enter your API key.</p>")
36
- key_1 = gr.Textbox(info="Please enter your GEMINI_API_KEY", label="Key:")
37
- with gr.Column():
38
- gr.HTML("<p><b>Step 3:</b> Run the extractor.</p>")
39
- go_button_1 = gr.Button(value="Run Gemini extractor", variant="primary")
40
- model_output_text_box_1 = gr.Textbox(label="Extractor Output", elem_id="model_output_text_box_1")
41
-
42
- with gr.Row():
43
- gr.HTML("<p style='text-align: center'>Developed with 🫶 by <a href='https://getindexify.ai/' target='_blank'>Indexify</a> | a <a href='https://www.tensorlake.ai/' target='_blank'>Tensorlake</a> product</p>")
44
-
45
- go_button_1.click(fn=use_gemini, inputs=[pdf_file_1, key_1], outputs=[model_output_text_box_1])
46
-
47
  def use_openai(pdf_filepath, key):
48
  if pdf_filepath is None:
49
  raise gr.Error("Please provide some input PDF: upload a PDF file")
@@ -54,34 +27,62 @@ def use_openai(pdf_filepath, key):
54
  result = oai_extractor.extract(content, config)
55
  return result
56
 
57
- with gr.Blocks(title="PDF data extraction with OpenAI & Indexify") as openai_demo:
58
- gr.HTML("<h1 style='text-align: center'>PDF data extraction with OpenAI & <a href='https://getindexify.ai/'>Indexify</a></h1>")
59
- gr.HTML("<p style='text-align: center'>Indexify is a scalable realtime and continuous indexing and structured extraction engine for unstructured data to build generative AI applications</p>")
60
- gr.HTML("<h3 style='text-align: center'>If you like this demo, please Star us on <a href='https://github.com/tensorlakeai/indexify' target='_blank'>GitHub</a>!</h3>")
61
- gr.HTML("<h4 style='text-align: center'>Here's an example notebook that demonstrates how to build a continuous <a href='https://github.com/tensorlakeai/indexify/blob/main/docs/docs/examples/multimodal_openai.ipynb' target='_blank'>extraction pipeline</a> with Indexify</h4>")
 
62
 
63
- with gr.Row():
64
- with gr.Column():
65
- gr.HTML(
66
- "<p><b>Step 1:</b> Upload a PDF file from local storage.</p>"
67
- "<p style='color: #A0A0A0;'>Use this demo for single PDF file only. "
68
- "You can extract from PDF files continuously and try various other extractors locally with "
69
- "<a href='https://getindexify.ai/'>Indexify</a>.</p>"
70
- )
71
- pdf_file_2 = gr.File(type="filepath")
72
- gr.HTML("<p><b>Step 2:</b> Enter your API key.</p>")
73
- key_2 = gr.Textbox(info="Please enter your OPENAI_API_KEY", label="Key:")
74
- with gr.Column():
75
- gr.HTML("<p><b>Step 3:</b> Run the extractor.</p>")
76
- go_button_2 = gr.Button(value="Run OpenAI extractor", variant="primary")
77
- model_output_text_box_2 = gr.Textbox(label="Extractor Output", elem_id="model_output_text_box_2")
78
 
79
- with gr.Row():
80
- gr.HTML("<p style='text-align: center'>Developed with 🫶 by <a href='https://getindexify.ai/' target='_blank'>Indexify</a> | a <a href='https://www.tensorlake.ai/' target='_blank'>Tensorlake</a> product</p>")
81
 
82
- go_button_2.click(fn=use_openai, inputs=[pdf_file_2, key_2], outputs=[model_output_text_box_2])
83
 
84
- demo = gr.TabbedInterface([gemini_demo, openai_demo], ["Gemini Extractor", "OpenAI Extractor"], theme=gr.themes.Soft())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  demo.queue()
87
  demo.launch()
 
17
  result = gemini_extractor.extract(content, config)
18
  return result
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def use_openai(pdf_filepath, key):
21
  if pdf_filepath is None:
22
  raise gr.Error("Please provide some input PDF: upload a PDF file")
 
27
  result = oai_extractor.extract(content, config)
28
  return result
29
 
30
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
31
+ with gr.Tab("PDF data extraction with Gemini & Indexify"):
32
+ gr.HTML("<h1 style='text-align: center'>PDF data extraction with Gemini & <a href='https://getindexify.ai/'>Indexify</a></h1>")
33
+ gr.HTML("<p style='text-align: center'>Indexify is a scalable realtime and continuous indexing and structured extraction engine for unstructured data to build generative AI applications</p>")
34
+ gr.HTML("<h3 style='text-align: center'>If you like this demo, please Star us on <a href='https://github.com/tensorlakeai/indexify' target='_blank'>GitHub</a>!</h3>")
35
+ gr.HTML("<h4 style='text-align: center'>Here's an example notebook that demonstrates how to build a continuous <a href='https://github.com/tensorlakeai/indexify/blob/main/docs/docs/examples/multimodal_gemini.ipynb' target='_blank'>extraction pipeline</a> with Indexify</h4>")
36
 
37
+ with gr.Row():
38
+ with gr.Column():
39
+ gr.HTML(
40
+ "<p><b>Step 1:</b> Upload a PDF file from local storage.</p>"
41
+ "<p style='color: #A0A0A0;'>Use this demo for single PDF file only. "
42
+ "You can extract from PDF files continuously and try various other extractors locally with "
43
+ "<a href='https://getindexify.ai/'>Indexify</a>.</p>"
44
+ )
45
+ pdf_file_1 = gr.File(type="filepath")
46
+ gr.HTML("<p><b>Step 2:</b> Enter your API key.</p>")
47
+ key_1 = gr.Textbox(info="Please enter your GEMINI_API_KEY", label="Key:")
48
+ with gr.Column():
49
+ gr.HTML("<p><b>Step 3:</b> Run the extractor.</p>")
50
+ go_button_1 = gr.Button(value="Run Gemini extractor", variant="primary")
51
+ model_output_text_box_1 = gr.Textbox(label="Extractor Output", elem_id="model_output_text_box_1")
52
 
53
+ with gr.Row():
54
+ gr.HTML("<p style='text-align: center'>Developed with 🫶 by <a href='https://getindexify.ai/' target='_blank'>Indexify</a> | a <a href='https://www.tensorlake.ai/' target='_blank'>Tensorlake</a> product</p>")
55
 
56
+ go_button_1.click(fn=use_gemini, inputs=[pdf_file_1, key_1], outputs=[model_output_text_box_1])
57
 
58
+
59
+
60
+ with gr.Tab("PDF data extraction with OpenAI & Indexify"):
61
+ gr.HTML("<h1 style='text-align: center'>PDF data extraction with OpenAI & <a href='https://getindexify.ai/'>Indexify</a></h1>")
62
+ gr.HTML("<p style='text-align: center'>Indexify is a scalable realtime and continuous indexing and structured extraction engine for unstructured data to build generative AI applications</p>")
63
+ gr.HTML("<h3 style='text-align: center'>If you like this demo, please ⭐ Star us on <a href='https://github.com/tensorlakeai/indexify' target='_blank'>GitHub</a>!</h3>")
64
+ gr.HTML("<h4 style='text-align: center'>Here's an example notebook that demonstrates how to build a continuous <a href='https://github.com/tensorlakeai/indexify/blob/main/docs/docs/examples/multimodal_openai.ipynb' target='_blank'>extraction pipeline</a> with Indexify</h4>")
65
+
66
+ with gr.Row():
67
+ with gr.Column():
68
+ gr.HTML(
69
+ "<p><b>Step 1:</b> Upload a PDF file from local storage.</p>"
70
+ "<p style='color: #A0A0A0;'>Use this demo for single PDF file only. "
71
+ "You can extract from PDF files continuously and try various other extractors locally with "
72
+ "<a href='https://getindexify.ai/'>Indexify</a>.</p>"
73
+ )
74
+ pdf_file_2 = gr.File(type="filepath")
75
+ gr.HTML("<p><b>Step 2:</b> Enter your API key.</p>")
76
+ key_2 = gr.Textbox(info="Please enter your OPENAI_API_KEY", label="Key:")
77
+ with gr.Column():
78
+ gr.HTML("<p><b>Step 3:</b> Run the extractor.</p>")
79
+ go_button_2 = gr.Button(value="Run OpenAI extractor", variant="primary")
80
+ model_output_text_box_2 = gr.Textbox(label="Extractor Output", elem_id="model_output_text_box_2")
81
+
82
+ with gr.Row():
83
+ gr.HTML("<p style='text-align: center'>Developed with 🫶 by <a href='https://getindexify.ai/' target='_blank'>Indexify</a> | a <a href='https://www.tensorlake.ai/' target='_blank'>Tensorlake</a> product</p>")
84
+
85
+ go_button_2.click(fn=use_openai, inputs=[pdf_file_2, key_2], outputs=[model_output_text_box_2])
86
 
87
  demo.queue()
88
  demo.launch()