Krishnavamshithumma commited on
Commit
0e1ca59
Β·
verified Β·
1 Parent(s): 7198735

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -3
app.py CHANGED
@@ -46,8 +46,38 @@ def chat_with_openai(user_input, history, api_key):
46
  with gr.Blocks(title="Voice Bot: Krishnavamshi Thumma", js="./custom.js") as demo:
47
  gr.Markdown("## πŸŽ™οΈ Krishnavamshi Thumma - Voice Assistant")
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  api_key = gr.Textbox(label="πŸ” OpenAI API Key", type="password", elem_id="apiKeyInput")
50
- chatbot = gr.Chatbot(elem_id="chatBox")
51
  state = gr.State([])
52
 
53
  with gr.Row():
@@ -56,7 +86,6 @@ with gr.Blocks(title="Voice Bot: Krishnavamshi Thumma", js="./custom.js") as dem
56
 
57
  # Hidden components for JS communication
58
  voice_input = gr.Textbox(visible=False, elem_id="voiceInput")
59
- js_trigger = gr.Textbox(visible=False, elem_id="jsTrigger")
60
 
61
  # Event handlers
62
  voice_input.change(
@@ -64,7 +93,9 @@ with gr.Blocks(title="Voice Bot: Krishnavamshi Thumma", js="./custom.js") as dem
64
  [voice_input, state, api_key],
65
  [chatbot, state]
66
  )
67
- mic_btn.click(None, None, None, _js="startListening")
 
 
68
  clear_btn.click(lambda: ([], []), None, [chatbot, state])
69
 
70
  demo.launch()
 
46
  with gr.Blocks(title="Voice Bot: Krishnavamshi Thumma", js="./custom.js") as demo:
47
  gr.Markdown("## πŸŽ™οΈ Krishnavamshi Thumma - Voice Assistant")
48
 
49
+ # Add custom CSS
50
+ gr.HTML("""
51
+ <style>
52
+ #chatBox {
53
+ height: 60vh;
54
+ overflow-y: auto;
55
+ padding: 20px;
56
+ border-radius: 10px;
57
+ background: #f9f9f9;
58
+ }
59
+ .message {
60
+ margin: 10px 0;
61
+ padding: 12px;
62
+ border-radius: 8px;
63
+ }
64
+ .user {
65
+ background: #e3f2fd;
66
+ text-align: right;
67
+ }
68
+ .bot {
69
+ background: #f5f5f5;
70
+ }
71
+ #micButton {
72
+ width: 100%;
73
+ padding: 12px;
74
+ font-size: 1.2em;
75
+ }
76
+ </style>
77
+ """)
78
+
79
  api_key = gr.Textbox(label="πŸ” OpenAI API Key", type="password", elem_id="apiKeyInput")
80
+ chatbot = gr.Chatbot(elem_id="chatBox", type="messages")
81
  state = gr.State([])
82
 
83
  with gr.Row():
 
86
 
87
  # Hidden components for JS communication
88
  voice_input = gr.Textbox(visible=False, elem_id="voiceInput")
 
89
 
90
  # Event handlers
91
  voice_input.change(
 
93
  [voice_input, state, api_key],
94
  [chatbot, state]
95
  )
96
+
97
+ # Corrected JS trigger syntax
98
+ mic_btn.click(None, [], [], js="startListening")
99
  clear_btn.click(lambda: ([], []), None, [chatbot, state])
100
 
101
  demo.launch()