shukdevdatta123 commited on
Commit
573f655
·
verified ·
1 Parent(s): 63e1f97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -22
app.py CHANGED
@@ -262,33 +262,64 @@ def create_interface():
262
  - **Medium**: Offers a balanced response with a reasonable level of detail and thought.
263
  - **High**: Produces more detailed, analytical, or thoughtful responses, requiring deeper reasoning.
264
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
- with gr.Row():
267
- openai_api_key = gr.Textbox(label="Enter OpenAI API Key", type="password", placeholder="sk-...", interactive=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
268
 
269
- with gr.Row():
270
- image_input = gr.Image(label="Upload an Image", type="pil") # Image upload input
271
- input_text = gr.Textbox(label="Enter Text Question", placeholder="Ask a question or provide text", lines=2)
272
- audio_input = gr.Audio(label="Upload or Record Audio", type="filepath") # Audio upload or record input (using filepath)
273
 
274
- with gr.Row():
275
- reasoning_effort = gr.Dropdown(
276
- label="Reasoning Effort",
277
- choices=["low", "medium", "high"],
278
- value="medium"
279
- )
280
- model_choice = gr.Dropdown(
281
- label="Select Model",
282
- choices=["o1", "o3-mini"],
283
- value="o1" # Default to 'o1' for image-related tasks
284
- )
285
- submit_btn = gr.Button("Ask!", elem_id="submit-btn")
286
- clear_btn = gr.Button("Clear History", elem_id="clear-history")
 
 
287
 
288
- chat_history = gr.Chatbot()
289
 
290
- # Button interactions
291
- submit_btn.click(fn=chatbot, inputs=[input_text, image_input, audio_input, openai_api_key, reasoning_effort, model_choice, chat_history], outputs=[input_text, chat_history])
292
  clear_btn.click(fn=clear_history, inputs=[], outputs=[chat_history, chat_history])
293
 
294
  return demo
 
262
  - **Medium**: Offers a balanced response with a reasonable level of detail and thought.
263
  - **High**: Produces more detailed, analytical, or thoughtful responses, requiring deeper reasoning.
264
  """)
265
+
266
+ with gr.Tabs():
267
+ # Text Chat Tab
268
+ with gr.Tab("Text Chat"):
269
+ input_text = gr.Textbox(label="Enter Text Question", placeholder="Ask a question or provide text", lines=2)
270
+ reasoning_effort = gr.Dropdown(
271
+ label="Reasoning Effort",
272
+ choices=["low", "medium", "high"],
273
+ value="medium"
274
+ )
275
+ model_choice = gr.Dropdown(
276
+ label="Select Model",
277
+ choices=["o1", "o3-mini"],
278
+ value="o3-mini" # Default to 'o3-mini' for text-based tasks
279
+ )
280
+ submit_btn = gr.Button("Ask!", elem_id="submit-btn")
281
+ chat_history = gr.Chatbot()
282
+
283
+ submit_btn.click(fn=chatbot, inputs=[input_text, None, None, gr.Textbox(), reasoning_effort, model_choice, chat_history], outputs=[input_text, chat_history])
284
 
285
+ # Image Chat Tab
286
+ with gr.Tab("Image Chat"):
287
+ image_input = gr.Image(label="Upload an Image", type="pil") # Image upload input
288
+ reasoning_effort = gr.Dropdown(
289
+ label="Reasoning Effort",
290
+ choices=["low", "medium", "high"],
291
+ value="medium"
292
+ )
293
+ model_choice = gr.Dropdown(
294
+ label="Select Model",
295
+ choices=["o1", "o3-mini"],
296
+ value="o1" # Default to 'o1' for image-related tasks
297
+ )
298
+ submit_btn = gr.Button("Ask!", elem_id="submit-btn")
299
+ chat_history = gr.Chatbot()
300
 
301
+ submit_btn.click(fn=chatbot, inputs=[None, image_input, None, gr.Textbox(), reasoning_effort, model_choice, chat_history], outputs=[None, chat_history])
 
 
 
302
 
303
+ # Audio Chat Tab
304
+ with gr.Tab("Voice Chat"):
305
+ audio_input = gr.Audio(label="Upload or Record Audio", type="filepath") # Audio upload or record input (using filepath)
306
+ reasoning_effort = gr.Dropdown(
307
+ label="Reasoning Effort",
308
+ choices=["low", "medium", "high"],
309
+ value="medium"
310
+ )
311
+ model_choice = gr.Dropdown(
312
+ label="Select Model",
313
+ choices=["o1", "o3-mini"],
314
+ value="o3-mini" # Default to 'o3-mini' for voice-related tasks
315
+ )
316
+ submit_btn = gr.Button("Ask!", elem_id="submit-btn")
317
+ chat_history = gr.Chatbot()
318
 
319
+ submit_btn.click(fn=chatbot, inputs=[None, None, audio_input, gr.Textbox(), reasoning_effort, model_choice, chat_history], outputs=[None, chat_history])
320
 
321
+ # Clear history button
322
+ clear_btn = gr.Button("Clear History", elem_id="clear-history")
323
  clear_btn.click(fn=clear_history, inputs=[], outputs=[chat_history, chat_history])
324
 
325
  return demo