flutterbasit commited on
Commit
461d781
·
verified ·
1 Parent(s): 0d59a42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -57
app.py CHANGED
@@ -127,78 +127,109 @@ def rag_pipeline(files, question, summarize_before_sending=False):
127
  except Exception as e:
128
  return f"Error: {str(e)}"
129
 
130
- # Enhanced UI with modern and clean style
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  with gr.Blocks() as app:
132
  with gr.Row():
133
- # Left Column for instructions
134
  with gr.Column(scale=1, min_width=250):
135
  gr.Markdown("""
136
- <div style="background: linear-gradient(145deg, #6e7dff, #1c2b58); padding: 30px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); font-family: 'Roboto', sans-serif;">
137
- <h2 style="color: #fff; font-size: 32px; font-weight: bold;">DocAI: Document Assistant</h2>
138
- <p style="color: #ddd; font-size: 18px;">Welcome to DocAI! Upload your documents and get intelligent answers based on their content.</p>
139
- <p style="color: #ddd; font-size: 16px; line-height: 1.6;"><strong>Steps to use:</strong></p>
140
- <ul style="color: #ddd; font-size: 16px; line-height: 1.6;">
141
- <li>Upload your PDF or DOCX files.</li>
142
- <li>Ask questions related to the document.</li>
143
- <li>Enable "Summarize Before Sending" for a brief summary of the document.</li>
144
- <li>Click "Submit" to get your answers.</li>
145
- </ul>
146
- <p style="color: #ddd; font-size: 16px; line-height: 1.6;">Upload multiple files and get answers based on their contents.</p>
147
- </div>
148
  """)
149
 
150
- # Right Column for the main application content
151
  with gr.Column(scale=2, min_width=600):
152
  gr.Markdown("""
153
- <div style="background: linear-gradient(135deg, #6e7dff, #1c2b58); padding: 20px; border-radius: 15px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); font-family: 'Roboto', sans-serif;">
154
- <h2 style="color: #fff; font-size: 36px; font-weight: bold; text-align: center; letter-spacing: 2px; text-transform: uppercase;">
155
- Ask Your Document
156
- </h2>
157
- <p style="color: #ddd; font-size: 18px; text-align: center; line-height: 1.6;">
158
- Get intelligent answers based on the content of your uploaded documents. Just ask a question!
159
- </p>
160
- </div>
161
  """)
162
 
163
  # File input
164
- file_input = gr.File(
165
- label="Upload Documents (PDF/DOCX)",
166
- file_types=[".pdf", ".docx"],
167
- file_count="multiple",
168
- interactive=True
169
- )
170
 
171
  # Question input
172
- question_input = gr.Textbox(
173
- label="Ask a question",
174
- placeholder="Type your question here...",
175
- interactive=True,
176
- lines=2,
177
- max_lines=4
178
- )
179
-
180
- # Summarize before sending checkbox
181
- summarize_before_input = gr.Checkbox(
182
- label="Summarize Before Sending",
183
- value=False
184
- )
185
-
186
- # Output text box with enhanced styling
187
- output = gr.Textbox(
188
- label="Answer from LLM",
189
- interactive=False,
190
- lines=4,
191
- max_lines=6
192
- )
193
-
194
- # Submit button with icon and modern styling
195
  submit_button = gr.Button("Submit", icon="send")
196
 
197
- # Loading spinner
198
- with gr.Row():
199
- with gr.Column(scale=1, min_width=250):
200
- gr.Markdown("<div style='font-size: 14px; color: #555;'>Your answer will appear here...</div>")
201
-
202
  # Apply the logic for the button to trigger the RAG pipeline
203
  submit_button.click(rag_pipeline, inputs=[file_input, question_input, summarize_before_input], outputs=output)
204
 
 
127
  except Exception as e:
128
  return f"Error: {str(e)}"
129
 
130
+ # # Enhanced UI with modern and clean style
131
+ # with gr.Blocks() as app:
132
+ # with gr.Row():
133
+ # # Left Column for instructions
134
+ # with gr.Column(scale=1, min_width=250):
135
+ # gr.Markdown("""
136
+ # <div style="background: linear-gradient(145deg, #6e7dff, #1c2b58); padding: 30px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); font-family: 'Roboto', sans-serif;">
137
+ # <h2 style="color: #fff; font-size: 32px; font-weight: bold;">DocAI: Document Assistant</h2>
138
+ # <p style="color: #ddd; font-size: 18px;">Welcome to DocAI! Upload your documents and get intelligent answers based on their content.</p>
139
+ # <p style="color: #ddd; font-size: 16px; line-height: 1.6;"><strong>Steps to use:</strong></p>
140
+ # <ul style="color: #ddd; font-size: 16px; line-height: 1.6;">
141
+ # <li>Upload your PDF or DOCX files.</li>
142
+ # <li>Ask questions related to the document.</li>
143
+ # <li>Enable "Summarize Before Sending" for a brief summary of the document.</li>
144
+ # <li>Click "Submit" to get your answers.</li>
145
+ # </ul>
146
+ # <p style="color: #ddd; font-size: 16px; line-height: 1.6;">Upload multiple files and get answers based on their contents.</p>
147
+ # </div>
148
+ # """)
149
+
150
+ # # Right Column for the main application content
151
+ # with gr.Column(scale=2, min_width=600):
152
+ # gr.Markdown("""
153
+ # <div style="background: linear-gradient(135deg, #6e7dff, #1c2b58); padding: 20px; border-radius: 15px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); font-family: 'Roboto', sans-serif;">
154
+ # <h2 style="color: #fff; font-size: 36px; font-weight: bold; text-align: center; letter-spacing: 2px; text-transform: uppercase;">
155
+ # Ask Your Document
156
+ # </h2>
157
+ # <p style="color: #ddd; font-size: 18px; text-align: center; line-height: 1.6;">
158
+ # Get intelligent answers based on the content of your uploaded documents. Just ask a question!
159
+ # </p>
160
+ # </div>
161
+ # """)
162
+
163
+ # # File input
164
+ # file_input = gr.File(
165
+ # label="Upload Documents (PDF/DOCX)",
166
+ # file_types=[".pdf", ".docx"],
167
+ # file_count="multiple",
168
+ # interactive=True
169
+ # )
170
+
171
+ # # Question input
172
+ # question_input = gr.Textbox(
173
+ # label="Ask a question",
174
+ # placeholder="Type your question here...",
175
+ # interactive=True,
176
+ # lines=2,
177
+ # max_lines=4
178
+ # )
179
+
180
+ # # Summarize before sending checkbox
181
+ # summarize_before_input = gr.Checkbox(
182
+ # label="Summarize Before Sending",
183
+ # value=False
184
+ # )
185
+
186
+ # # Output text box with enhanced styling
187
+ # output = gr.Textbox(
188
+ # label="Answer from LLM",
189
+ # interactive=False,
190
+ # lines=4,
191
+ # max_lines=6
192
+ # )
193
+
194
+ # # Submit button with icon and modern styling
195
+ # submit_button = gr.Button("Submit", icon="send")
196
+
197
+ # # Loading spinner
198
+ # with gr.Row():
199
+ # with gr.Column(scale=1, min_width=250):
200
+ # gr.Markdown("<div style='font-size: 14px; color: #555;'>Your answer will appear here...</div>")
201
+
202
+ # # Apply the logic for the button to trigger the RAG pipeline
203
+ # submit_button.click(rag_pipeline, inputs=[file_input, question_input, summarize_before_input], outputs=output)
204
+
205
+ # Launch the app
206
+ # app.launch()
207
  with gr.Blocks() as app:
208
  with gr.Row():
 
209
  with gr.Column(scale=1, min_width=250):
210
  gr.Markdown("""
211
+ <h2>Welcome to DocAI</h2>
212
+ <p>Upload your documents and get intelligent answers.</p>
 
 
 
 
 
 
 
 
 
 
213
  """)
214
 
 
215
  with gr.Column(scale=2, min_width=600):
216
  gr.Markdown("""
217
+ <h2>Ask Your Document</h2>
218
+ <p>Get intelligent answers based on the content of your uploaded documents. Just ask a question!</p>
 
 
 
 
 
 
219
  """)
220
 
221
  # File input
222
+ file_input = gr.File(label="Upload Documents (PDF/DOCX)", file_types=[".pdf", ".docx"], file_count="multiple")
 
 
 
 
 
223
 
224
  # Question input
225
+ question_input = gr.Textbox(label="Ask a question", placeholder="Type your question here...")
226
+
227
+ # Output text box
228
+ output = gr.Textbox(label="Answer from LLM")
229
+
230
+ # Submit button
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  submit_button = gr.Button("Submit", icon="send")
232
 
 
 
 
 
 
233
  # Apply the logic for the button to trigger the RAG pipeline
234
  submit_button.click(rag_pipeline, inputs=[file_input, question_input, summarize_before_input], outputs=output)
235