Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from groq import Groq
|
|
| 6 |
api_key = os.environ.get("GROQ_API_KEY")
|
| 7 |
client = Groq(api_key=api_key)
|
| 8 |
|
| 9 |
-
# 2.
|
| 10 |
custom_css = """
|
| 11 |
.gradio-container { max-height: 100vh !important; overflow: hidden !important; }
|
| 12 |
#chatbot-window {
|
|
@@ -15,11 +15,18 @@ custom_css = """
|
|
| 15 |
border: 1px solid #e0e0e0;
|
| 16 |
background: white;
|
| 17 |
}
|
| 18 |
-
|
|
|
|
| 19 |
#system-prompt-container textarea {
|
| 20 |
max-height: 150px !important;
|
| 21 |
overflow-y: auto !important;
|
| 22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"""
|
| 24 |
|
| 25 |
# 3. Secure Chat Logic
|
|
@@ -53,7 +60,13 @@ with gr.Blocks() as demo:
|
|
| 53 |
with gr.Column(scale=4):
|
| 54 |
chatbot = gr.Chatbot(elem_id="chatbot-window")
|
| 55 |
with gr.Row():
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
submit_btn = gr.Button("Send", variant="primary", scale=1)
|
| 58 |
|
| 59 |
with gr.Column(scale=1):
|
|
@@ -64,7 +77,6 @@ with gr.Blocks() as demo:
|
|
| 64 |
)
|
| 65 |
temp = gr.Slider(0.0, 1.0, 0.7, label="Temperature")
|
| 66 |
|
| 67 |
-
# ADDED elem_id here to link with the CSS fix
|
| 68 |
sys_msg = gr.Textbox(
|
| 69 |
value="You are a professional assistant.",
|
| 70 |
label="System Prompt",
|
|
|
|
| 6 |
api_key = os.environ.get("GROQ_API_KEY")
|
| 7 |
client = Groq(api_key=api_key)
|
| 8 |
|
| 9 |
+
# 2. UI Styling with Scrolling Input Fix
|
| 10 |
custom_css = """
|
| 11 |
.gradio-container { max-height: 100vh !important; overflow: hidden !important; }
|
| 12 |
#chatbot-window {
|
|
|
|
| 15 |
border: 1px solid #e0e0e0;
|
| 16 |
background: white;
|
| 17 |
}
|
| 18 |
+
|
| 19 |
+
/* Fix for System Prompt scrolling */
|
| 20 |
#system-prompt-container textarea {
|
| 21 |
max-height: 150px !important;
|
| 22 |
overflow-y: auto !important;
|
| 23 |
}
|
| 24 |
+
|
| 25 |
+
/* Fix for Chat Input scrolling */
|
| 26 |
+
.scroll-input textarea {
|
| 27 |
+
max-height: 100px !important;
|
| 28 |
+
overflow-y: auto !important;
|
| 29 |
+
}
|
| 30 |
"""
|
| 31 |
|
| 32 |
# 3. Secure Chat Logic
|
|
|
|
| 60 |
with gr.Column(scale=4):
|
| 61 |
chatbot = gr.Chatbot(elem_id="chatbot-window")
|
| 62 |
with gr.Row():
|
| 63 |
+
# ADDED elem_classes here to enable scrolling
|
| 64 |
+
msg_input = gr.Textbox(
|
| 65 |
+
placeholder="Ask me anything...",
|
| 66 |
+
container=False,
|
| 67 |
+
scale=9,
|
| 68 |
+
elem_classes="scroll-input"
|
| 69 |
+
)
|
| 70 |
submit_btn = gr.Button("Send", variant="primary", scale=1)
|
| 71 |
|
| 72 |
with gr.Column(scale=1):
|
|
|
|
| 77 |
)
|
| 78 |
temp = gr.Slider(0.0, 1.0, 0.7, label="Temperature")
|
| 79 |
|
|
|
|
| 80 |
sys_msg = gr.Textbox(
|
| 81 |
value="You are a professional assistant.",
|
| 82 |
label="System Prompt",
|