Upload folder using huggingface_hub
Browse files
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 |
-
|
82 |
-
with gr.
|
83 |
-
gr.
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
|
|
|
|
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 |
+
|