Spaces:
Sleeping
Sleeping
Update chatbot.py
Browse files- chatbot.py +12 -12
chatbot.py
CHANGED
|
@@ -147,15 +147,6 @@ with gr.Blocks() as demo:
|
|
| 147 |
chat_output = gr.Textbox(label="Conversation")
|
| 148 |
state = gr.State()
|
| 149 |
|
| 150 |
-
chat_interface = gr.Interface(
|
| 151 |
-
fn=chatbot,
|
| 152 |
-
inputs=[user_id_state, chat_input, state],
|
| 153 |
-
outputs=[chat_output, state],
|
| 154 |
-
title="AttachmentBot",
|
| 155 |
-
description="Let me survey you about your attachment with certain people in your life. To begin, enter 'start'.",
|
| 156 |
-
visible=False # Initially hidden, shown after login
|
| 157 |
-
)
|
| 158 |
-
|
| 159 |
def login(username, password):
|
| 160 |
user_id = authenticate(username, password)
|
| 161 |
if user_id:
|
|
@@ -170,7 +161,16 @@ with gr.Blocks() as demo:
|
|
| 170 |
else:
|
| 171 |
return gr.update(visible=False), None, "Registration failed, try a different username."
|
| 172 |
|
| 173 |
-
login_button.click(login, inputs=[username, password], outputs=[
|
| 174 |
-
register_button.click(register, inputs=[username, password], outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
demo.launch()
|
|
|
|
| 147 |
chat_output = gr.Textbox(label="Conversation")
|
| 148 |
state = gr.State()
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
def login(username, password):
|
| 151 |
user_id = authenticate(username, password)
|
| 152 |
if user_id:
|
|
|
|
| 161 |
else:
|
| 162 |
return gr.update(visible=False), None, "Registration failed, try a different username."
|
| 163 |
|
| 164 |
+
login_button.click(login, inputs=[username, password], outputs=[gr.update(visible=True), user_id_state, gr.Textbox(visible=False)])
|
| 165 |
+
register_button.click(register, inputs=[username, password], outputs=[gr.update(visible=True), user_id_state, gr.Textbox(visible=False)])
|
| 166 |
+
|
| 167 |
+
chat_interface = gr.Interface(
|
| 168 |
+
fn=chatbot,
|
| 169 |
+
inputs=[user_id_state, chat_input, state],
|
| 170 |
+
outputs=[chat_output, state],
|
| 171 |
+
title="AttachmentBot",
|
| 172 |
+
description="Let me survey you about your attachment with certain people in your life. To begin, enter 'start'.",
|
| 173 |
+
visible=False # Initially hidden, shown after login
|
| 174 |
+
)
|
| 175 |
|
| 176 |
+
demo.launch()
|