@@ -193,48 +193,116 @@ def create_interface():
193193 repo_button = gr .Button ("Process Repository" )
194194 repo_output = gr .Textbox (label = "Repository Processing Output" )
195195
196- with gr .Tab ("Chat Interface" ):
196+ with gr .Tab ("Standard Chat Interface" ):
197197 with gr .Row ():
198198 with gr .Column ():
199- agent_dropdown = gr .Dropdown (
199+ standard_agent_dropdown = gr .Dropdown (
200200 choices = ["Local (Mistral)" , "OpenAI" ] if openai_key else ["Local (Mistral)" ],
201201 value = "Local (Mistral)" ,
202202 label = "Select Agent"
203203 )
204- cot_checkbox = gr .Checkbox (label = "Enable Chain of Thought Reasoning" , value = False )
205204 with gr .Column ():
206- language_dropdown = gr .Dropdown (
205+ standard_language_dropdown = gr .Dropdown (
207206 choices = ["English" , "Spanish" ],
208207 value = "English" ,
209208 label = "Response Language"
210209 )
211210 with gr .Column ():
212- collection_dropdown = gr .Dropdown (
211+ standard_collection_dropdown = gr .Dropdown (
213212 choices = ["PDF Collection" , "Repository Collection" , "General Knowledge" ],
214213 value = "PDF Collection" ,
215214 label = "Knowledge Collection"
216215 )
217- chatbot = gr .Chatbot (height = 400 )
218- msg = gr .Textbox (label = "Your Message" )
219- clear = gr .Button ("Clear Chat" )
216+ standard_chatbot = gr .Chatbot (height = 400 )
217+ with gr .Row ():
218+ standard_msg = gr .Textbox (label = "Your Message" , scale = 9 )
219+ standard_send = gr .Button ("Send" , scale = 1 )
220+ standard_clear = gr .Button ("Clear Chat" )
221+
222+ with gr .Tab ("Chain of Thought Chat Interface" ):
223+ with gr .Row ():
224+ with gr .Column ():
225+ cot_agent_dropdown = gr .Dropdown (
226+ choices = ["Local (Mistral)" , "OpenAI" ] if openai_key else ["Local (Mistral)" ],
227+ value = "Local (Mistral)" ,
228+ label = "Select Agent"
229+ )
230+ with gr .Column ():
231+ cot_language_dropdown = gr .Dropdown (
232+ choices = ["English" , "Spanish" ],
233+ value = "English" ,
234+ label = "Response Language"
235+ )
236+ with gr .Column ():
237+ cot_collection_dropdown = gr .Dropdown (
238+ choices = ["PDF Collection" , "Repository Collection" , "General Knowledge" ],
239+ value = "PDF Collection" ,
240+ label = "Knowledge Collection"
241+ )
242+ cot_chatbot = gr .Chatbot (height = 400 )
243+ with gr .Row ():
244+ cot_msg = gr .Textbox (label = "Your Message" , scale = 9 )
245+ cot_send = gr .Button ("Send" , scale = 1 )
246+ cot_clear = gr .Button ("Clear Chat" )
220247
221248 # Event handlers
222249 pdf_button .click (process_pdf , inputs = [pdf_file ], outputs = [pdf_output ])
223250 url_button .click (process_url , inputs = [url_input ], outputs = [url_output ])
224251 repo_button .click (process_repo , inputs = [repo_input ], outputs = [repo_output ])
225- msg .submit (
252+
253+ # Standard chat handlers
254+ standard_msg .submit (
226255 chat ,
227256 inputs = [
228- msg ,
229- chatbot ,
230- agent_dropdown ,
231- cot_checkbox ,
232- language_dropdown ,
233- collection_dropdown
257+ standard_msg ,
258+ standard_chatbot ,
259+ standard_agent_dropdown ,
260+ gr . State ( False ), # use_cot=False
261+ standard_language_dropdown ,
262+ standard_collection_dropdown
234263 ],
235- outputs = [chatbot ]
264+ outputs = [standard_chatbot ]
236265 )
237- clear .click (lambda : None , None , chatbot , queue = False )
266+ standard_send .click (
267+ chat ,
268+ inputs = [
269+ standard_msg ,
270+ standard_chatbot ,
271+ standard_agent_dropdown ,
272+ gr .State (False ), # use_cot=False
273+ standard_language_dropdown ,
274+ standard_collection_dropdown
275+ ],
276+ outputs = [standard_chatbot ]
277+ )
278+ standard_clear .click (lambda : None , None , standard_chatbot , queue = False )
279+
280+ # CoT chat handlers
281+ cot_msg .submit (
282+ chat ,
283+ inputs = [
284+ cot_msg ,
285+ cot_chatbot ,
286+ cot_agent_dropdown ,
287+ gr .State (True ), # use_cot=True
288+ cot_language_dropdown ,
289+ cot_collection_dropdown
290+ ],
291+ outputs = [cot_chatbot ]
292+ )
293+ cot_send .click (
294+ chat ,
295+ inputs = [
296+ cot_msg ,
297+ cot_chatbot ,
298+ cot_agent_dropdown ,
299+ gr .State (True ), # use_cot=True
300+ cot_language_dropdown ,
301+ cot_collection_dropdown
302+ ],
303+ outputs = [cot_chatbot ]
304+ )
305+ cot_clear .click (lambda : None , None , cot_chatbot , queue = False )
238306
239307 # Instructions
240308 gr .Markdown ("""
@@ -246,12 +314,17 @@ def create_interface():
246314 - Process repositories by entering paths or GitHub URLs
247315 - All processed content is added to the knowledge base
248316
249- 2. **Chat Interface**:
317+ 2. **Standard Chat Interface**:
318+ - Quick responses without detailed reasoning steps
250319 - Select your preferred agent (Local Mistral or OpenAI)
251- - Toggle Chain of Thought reasoning for more detailed responses
252- - Choose your preferred response language (English or Spanish)
320+ - Choose your preferred response language
253321 - Select which knowledge collection to query
254- - Chat with your documents using natural language
322+
323+ 3. **Chain of Thought Chat Interface**:
324+ - Detailed responses with step-by-step reasoning
325+ - See the planning, research, reasoning, and synthesis steps
326+ - Great for complex queries or when you want to understand the reasoning process
327+ - May take longer but provides more detailed and thorough answers
255328
256329 Note: OpenAI agent requires an API key in `.env` file
257330 """ )
0 commit comments