chibop commited on
Commit
dc6cc04
·
verified ·
1 Parent(s): 891df10

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. chat.py +31 -26
chat.py CHANGED
@@ -11,6 +11,7 @@ def login(username, password):
11
  return users[username] == password
12
 
13
  print("Start")
 
14
  client = OpenAI(api_key=api_key)
15
  assistants = client.beta.assistants.list()
16
  for a in assistants:
@@ -78,30 +79,34 @@ css = """
78
  footer{display:none !important}
79
  """
80
 
81
- with gr.Blocks(title="Paitient Sim", css=css) as demo:
82
- with gr.Column(elem_classes=["container"]):
83
- gr.Markdown("""
84
- # Patient Sim
85
- Say goodbye to end the session and receive a feedback.
86
- """, elem_id="title_markdown")
87
- chatbot = gr.Chatbot(label="Messages", elem_id="chatbot")
88
- chatbot.like(vote, None, None)
89
- speech = gr.Button("Record", size="sm", elem_id="speech")
90
- speech.click(None, js=toggle_js)
91
- msg = gr.Textbox(label="Say something.", elem_id="textbox")
92
- mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
93
- thread = gr.State(start_thread)
94
- audio_html = gr.HTML(visible=False)
95
- msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
96
- bot, [chatbot, thread], chatbot
97
- ).then(
98
- speak, chatbot, audio_html
99
- )
100
- mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
101
- lambda:None, None, mic).then(
102
- bot, [chatbot, thread], chatbot).then(
103
- speak, chatbot, audio_html
104
- )
 
 
 
105
 
106
- #demo.queue()
107
- demo.launch(auth=login)
 
 
11
  return users[username] == password
12
 
13
  print("Start")
14
+
15
  client = OpenAI(api_key=api_key)
16
  assistants = client.beta.assistants.list()
17
  for a in assistants:
 
79
  footer{display:none !important}
80
  """
81
 
82
+ def main():
83
+ with gr.Blocks(title="Paitient Sim", css=css) as demo:
84
+ with gr.Column(elem_classes=["container"]):
85
+ gr.Markdown("""
86
+ # Patient Sim
87
+ Say goodbye to end the session and receive a feedback.
88
+ """, elem_id="title_markdown")
89
+ chatbot = gr.Chatbot(label="Messages", elem_id="chatbot")
90
+ chatbot.like(vote, None, None)
91
+ speech = gr.Button("Record", size="sm", elem_id="speech")
92
+ speech.click(None, js=toggle_js)
93
+ msg = gr.Textbox(label="Say something.", elem_id="textbox")
94
+ mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
95
+ thread = gr.State(start_thread)
96
+ audio_html = gr.HTML(visible=False)
97
+ msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
98
+ bot, [chatbot, thread], chatbot).then(
99
+ speak, chatbot, audio_html
100
+ )
101
+ mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
102
+ lambda:None, None, mic).then(
103
+ bot, [chatbot, thread], chatbot).then(
104
+ speak, chatbot, audio_html
105
+ )
106
+
107
+ demo.queue()
108
+ demo.launch(auth=login)
109
 
110
+ if __name__ == "__main__":
111
+ main()
112
+