Rahatara commited on
Commit
10d05a8
1 Parent(s): 6bc96c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -19
app.py CHANGED
@@ -96,21 +96,28 @@ def refresh_chat():
96
  app = MyApp()
97
 
98
  with gr.Blocks() as demo:
99
- with gr.Column():
100
- with gr.Row():
101
- with gr.Column(scale=2):
102
- chatbot = gr.Chatbot(value=[], elem_id="chatbot")
103
- txt = gr.Textbox(
104
- show_label=False,
105
- placeholder="Enter text and press submit",
106
- scale=2
107
- )
108
- submit_btn = gr.Button("Submit", scale=1)
109
- refresh_btn = gr.Button("Refresh Chat", scale=1)
110
-
111
- with gr.Column(scale=1):
112
- show_img = gr.Image(label="Upload PDF")
113
- btn = gr.UploadButton("📁 Upload a PDF", file_types=[".pdf"])
 
 
 
 
 
 
 
114
 
115
  btn.upload(
116
  fn=purge_chat_and_render_first,
@@ -118,17 +125,27 @@ with gr.Blocks() as demo:
118
  outputs=[show_img, chatbot],
119
  )
120
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  submit_btn.click(
122
  fn=add_text,
123
  inputs=[chatbot, txt],
124
- outputs=[
125
- chatbot,
126
- ],
127
  queue=False,
128
  ).success(
129
  fn=get_response, inputs=[chatbot, txt, btn], outputs=[chatbot, txt]
130
  ).success(
131
- fn=render_file, inputs=[btn], outputs=[show_img]
132
  )
133
 
134
  refresh_btn.click(
 
96
  app = MyApp()
97
 
98
  with gr.Blocks() as demo:
99
+ with gr.Tab("Step 1: Upload PDF"):
100
+ btn = gr.UploadButton("📁 Upload a PDF", file_types=[".pdf"])
101
+ show_img = gr.Image(label="Uploaded PDF")
102
+
103
+ with gr.Tab("Step 2: Process File"):
104
+ process_btn = gr.Button("Process PDF")
105
+ show_img_processed = gr.Image(label="Processed PDF")
106
+
107
+ with gr.Tab("Step 3: Build Vector Database"):
108
+ build_vector_btn = gr.Button("Build Vector Database")
109
+ status_text = gr.Textbox(label="Status", value="", interactive=False)
110
+
111
+ with gr.Tab("Step 4: Ask Questions"):
112
+ chatbot = gr.Chatbot(value=[], elem_id="chatbot")
113
+ txt = gr.Textbox(
114
+ show_label=False,
115
+ placeholder="Enter text and press submit",
116
+ scale=2
117
+ )
118
+ submit_btn = gr.Button("Submit", scale=1)
119
+ refresh_btn = gr.Button("Refresh Chat", scale=1)
120
+ temperature_slider = gr.Slider(0, 1, value=0.0, label="Temperature")
121
 
122
  btn.upload(
123
  fn=purge_chat_and_render_first,
 
125
  outputs=[show_img, chatbot],
126
  )
127
 
128
+ process_btn.click(
129
+ fn=app.process_file,
130
+ inputs=[btn],
131
+ outputs=[show_img_processed],
132
+ )
133
+
134
+ build_vector_btn.click(
135
+ fn=app.build_chain,
136
+ inputs=[btn],
137
+ outputs=[status_text],
138
+ )
139
+
140
  submit_btn.click(
141
  fn=add_text,
142
  inputs=[chatbot, txt],
143
+ outputs=[chatbot],
 
 
144
  queue=False,
145
  ).success(
146
  fn=get_response, inputs=[chatbot, txt, btn], outputs=[chatbot, txt]
147
  ).success(
148
+ fn=render_file, inputs=[btn], outputs=[show_img_processed]
149
  )
150
 
151
  refresh_btn.click(