Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,24 +105,20 @@ def predict(user_input, history, access_granted):
|
|
| 105 |
with gr.Blocks(theme, css="""
|
| 106 |
#chatbot { flex-grow: 1; height: 460px; overflow-y: auto; }
|
| 107 |
.gradio-container { height: 680px; max-width: 100% !important; padding: 0 !important; }
|
| 108 |
-
#component-0 { height:
|
| 109 |
-
#component-3 { height: calc(
|
| 110 |
footer { display: none !important; }
|
| 111 |
#submit-btn { margin-top: 10px; }
|
| 112 |
#code_submit {
|
| 113 |
height: 50px !important;
|
| 114 |
font-size: 1.2em !important;
|
| 115 |
}
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
text-align: center !important;
|
| 123 |
-
}
|
| 124 |
-
#code_message.error { color: #d32f2f !important; background-color: #ffcdd2 !important; }
|
| 125 |
-
#code_message.success { color: #388e3c !important; background-color: #c8e6c9 !important; }
|
| 126 |
@media (max-width: 600px) {
|
| 127 |
#code_submit {
|
| 128 |
height: 60px !important;
|
|
@@ -137,24 +133,26 @@ with gr.Blocks(theme, css="""
|
|
| 137 |
access_granted = gr.State(False)
|
| 138 |
|
| 139 |
with gr.Tab("Access"):
|
| 140 |
-
gr.
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
| 144 |
|
| 145 |
with gr.Tab("Chat"):
|
| 146 |
-
chatbot = gr.Chatbot(label="Conversation")
|
| 147 |
msg = gr.Textbox(
|
| 148 |
label=f"Chat with {coach_name_short}",
|
| 149 |
placeholder="Type your message here... (MAX: 1000 characters)",
|
|
|
|
| 150 |
interactive=False
|
| 151 |
)
|
| 152 |
submit = gr.Button("Submit Message", interactive=False)
|
| 153 |
|
| 154 |
def submit_code(code, access_granted):
|
| 155 |
success, _, _, message = verify_code(code, access_granted)
|
| 156 |
-
|
| 157 |
-
return success, gr.update(interactive=success), gr.update(interactive=success), gr.update(value=message,
|
| 158 |
|
| 159 |
code_input.submit(submit_code, inputs=[code_input, access_granted], outputs=[access_granted, msg, submit, code_message])
|
| 160 |
code_submit.click(submit_code, inputs=[code_input, access_granted], outputs=[access_granted, msg, submit, code_message])
|
|
|
|
| 105 |
with gr.Blocks(theme, css="""
|
| 106 |
#chatbot { flex-grow: 1; height: 460px; overflow-y: auto; }
|
| 107 |
.gradio-container { height: 680px; max-width: 100% !important; padding: 0 !important; }
|
| 108 |
+
#component-0 { height: 100%; }
|
| 109 |
+
#component-3 { height: calc(100% - 250px); }
|
| 110 |
footer { display: none !important; }
|
| 111 |
#submit-btn { margin-top: 10px; }
|
| 112 |
#code_submit {
|
| 113 |
height: 50px !important;
|
| 114 |
font-size: 1.2em !important;
|
| 115 |
}
|
| 116 |
+
|
| 117 |
+
/* Add these new rules here */
|
| 118 |
+
.message-wrap { max-height: 300px !important; overflow-y: auto !important; }
|
| 119 |
+
.chat-wrap { max-height: 400px !important; overflow-y: auto !important; }
|
| 120 |
+
.gradio-container { height: auto !important; min-height: 0 !important; }
|
| 121 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
@media (max-width: 600px) {
|
| 123 |
#code_submit {
|
| 124 |
height: 60px !important;
|
|
|
|
| 133 |
access_granted = gr.State(False)
|
| 134 |
|
| 135 |
with gr.Tab("Access"):
|
| 136 |
+
with gr.Tab("Access"):
|
| 137 |
+
gr.Markdown("Enter the Access Code displayed in the upper-left corner.")
|
| 138 |
+
code_input = gr.Textbox(label="Access Code", type="text", placeholder="Enter CODE here...")
|
| 139 |
+
code_submit = gr.Button("Submit Code", elem_id="code_submit")
|
| 140 |
+
code_message = gr.Label(label="Status", elem_id="code_message")
|
| 141 |
|
| 142 |
with gr.Tab("Chat"):
|
| 143 |
+
chatbot = gr.Chatbot(label="Conversation", height=340) # Adjust the height as needed
|
| 144 |
msg = gr.Textbox(
|
| 145 |
label=f"Chat with {coach_name_short}",
|
| 146 |
placeholder="Type your message here... (MAX: 1000 characters)",
|
| 147 |
+
autofocus=True,
|
| 148 |
interactive=False
|
| 149 |
)
|
| 150 |
submit = gr.Button("Submit Message", interactive=False)
|
| 151 |
|
| 152 |
def submit_code(code, access_granted):
|
| 153 |
success, _, _, message = verify_code(code, access_granted)
|
| 154 |
+
color = "#388e3c" if success else "#d32f2f" # Green for success, Red for error
|
| 155 |
+
return success, gr.update(interactive=success), gr.update(interactive=success), gr.update(value=message, color=color)
|
| 156 |
|
| 157 |
code_input.submit(submit_code, inputs=[code_input, access_granted], outputs=[access_granted, msg, submit, code_message])
|
| 158 |
code_submit.click(submit_code, inputs=[code_input, access_granted], outputs=[access_granted, msg, submit, code_message])
|