aazankhanYousafzai commited on
Commit
28e5fa5
·
verified ·
1 Parent(s): 27d1272

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -66
app.py CHANGED
@@ -52,29 +52,25 @@ def clear_chat():
52
  return [], ""
53
 
54
  # =====================================================
55
- # CSS (Light/Dark + Gradio 6 UI FIX)
56
  # =====================================================
57
  custom_css = """
 
 
 
 
 
 
 
58
  /* ---------- Color System ---------- */
59
  :root {
60
- --bg: #f9fafb;
61
- --surface: #ffffff;
62
  --user: #2563eb;
63
- --assistant: #e5e7eb;
64
- --text: #111827;
65
- --muted: #6b7280;
66
- --border: #d1d5db;
67
- }
68
-
69
- @media (prefers-color-scheme: dark) {
70
- :root {
71
- --bg: #0b0f19;
72
- --surface: #111827;
73
- --assistant: #1f2937;
74
- --text: #f9fafb;
75
- --muted: #9ca3af;
76
- --border: #1f2937;
77
- }
78
  }
79
 
80
  /* ---------- Base Layout ---------- */
@@ -90,20 +86,6 @@ body {
90
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
91
  }
92
 
93
- /* ---------- Typography ---------- */
94
- h1 {
95
- color: var(--text);
96
- text-align: center;
97
- font-size: 2rem;
98
- margin-bottom: 6px;
99
- }
100
-
101
- .subtitle {
102
- color: var(--muted);
103
- text-align: center;
104
- margin-bottom: 20px;
105
- }
106
-
107
  /* ---------- Chatbot ---------- */
108
  .chatbot {
109
  background: var(--surface);
@@ -121,7 +103,7 @@ h1 {
121
  padding: 15px 20px;
122
  border-radius: 12px;
123
  margin-bottom: 12px;
124
- line-height: 1.3;
125
  font-size: 15px;
126
 
127
  white-space: normal !important;
@@ -129,39 +111,35 @@ h1 {
129
  overflow-wrap: break-word !important;
130
 
131
  box-sizing: border-box !important;
 
132
  }
133
 
134
- /* 🔧 REMOVE BLACK GHOST BLOCKS */
135
- .message::before,
136
- .message::after,
137
- .chatbot .message div::before,
138
- .chatbot .message div::after {
139
- display: none !important;
140
- content: none !important;
141
- }
142
-
143
- .message {
144
- overflow: visible !important;
145
- background-clip: padding-box !important;
146
  }
147
 
148
- .chatbot * {
149
- box-shadow: none !important;
150
- filter: none !important;
 
 
 
151
  }
152
 
153
  .message.user {
154
  background: var(--user);
155
  color: white;
156
  margin-left: 0 !important;
157
- border-bottom-right-radius: 4px;
158
  }
159
 
160
  .message.bot {
161
  background: var(--assistant);
162
  color: var(--text);
163
- margin-right: 0 !important;
164
- border-bottom-left-radius: 4px;
165
  }
166
 
167
  /* ---------- Input ---------- */
@@ -195,7 +173,7 @@ button:hover {
195
  opacity: 0.9;
196
  }
197
 
198
- /* ---------- GRADIO 6 FIXES ---------- */
199
  .chatbot-toolbar,
200
  .chatbot-actions,
201
  button[aria-label="Copy"],
@@ -203,11 +181,6 @@ button[aria-label="Share"],
203
  button[aria-label="Clear"] {
204
  display: none !important;
205
  }
206
-
207
- .chatbot .scroll-to-bottom {
208
- right: 16px !important;
209
- bottom: 80px !important;
210
- }
211
  """
212
 
213
  # =====================================================
@@ -215,19 +188,13 @@ button[aria-label="Clear"] {
215
  # =====================================================
216
  with gr.Blocks(title="GROQ CHATBOT") as demo:
217
  gr.Markdown("# 🤖 GROQ CHATBOT")
218
- gr.Markdown(
219
- "<div class='subtitle'>Fast, reliable AI powered by Groq & LLaMA-3.3</div>"
220
- )
221
 
222
  chatbot = gr.Chatbot(elem_classes="chatbot")
223
  state = gr.State([])
224
 
225
  with gr.Row():
226
- txt = gr.Textbox(
227
- placeholder="Type your message…",
228
- show_label=False,
229
- scale=5,
230
- )
231
  send = gr.Button("Send", scale=1)
232
  clear = gr.Button("Clear", scale=1)
233
 
@@ -236,7 +203,7 @@ with gr.Blocks(title="GROQ CHATBOT") as demo:
236
  clear.click(clear_chat, outputs=[chatbot, txt], show_progress=False)
237
 
238
  # =====================================================
239
- # Launch (Gradio 6)
240
  # =====================================================
241
  if __name__ == "__main__":
242
  demo.launch(css=custom_css)
 
52
  return [], ""
53
 
54
  # =====================================================
55
+ # CSS (FINAL FIXED VERSION)
56
  # =====================================================
57
  custom_css = """
58
+ /* ---------- GLOBAL BOX FIX ---------- */
59
+ *,
60
+ *::before,
61
+ *::after {
62
+ box-sizing: border-box !important;
63
+ }
64
+
65
  /* ---------- Color System ---------- */
66
  :root {
67
+ --bg: #0b0f19;
68
+ --surface: #111827;
69
  --user: #2563eb;
70
+ --assistant: #1f2937;
71
+ --text: #f9fafb;
72
+ --muted: #9ca3af;
73
+ --border: #1f2937;
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  /* ---------- Base Layout ---------- */
 
86
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  /* ---------- Chatbot ---------- */
90
  .chatbot {
91
  background: var(--surface);
 
103
  padding: 15px 20px;
104
  border-radius: 12px;
105
  margin-bottom: 12px;
106
+ line-height: 1.4;
107
  font-size: 15px;
108
 
109
  white-space: normal !important;
 
111
  overflow-wrap: break-word !important;
112
 
113
  box-sizing: border-box !important;
114
+ background-clip: padding-box !important;
115
  }
116
 
117
+ /* Remove ghost masks */
118
+ .chatbot .message,
119
+ .chatbot .message * {
120
+ mask: none !important;
121
+ -webkit-mask: none !important;
122
+ background-image: none !important;
 
 
 
 
 
 
123
  }
124
 
125
+ .chatbot .message::before,
126
+ .chatbot .message::after,
127
+ .chatbot .message *::before,
128
+ .chatbot .message *::after {
129
+ display: none !important;
130
+ content: none !important;
131
  }
132
 
133
  .message.user {
134
  background: var(--user);
135
  color: white;
136
  margin-left: 0 !important;
 
137
  }
138
 
139
  .message.bot {
140
  background: var(--assistant);
141
  color: var(--text);
142
+ margin-right: auto;
 
143
  }
144
 
145
  /* ---------- Input ---------- */
 
173
  opacity: 0.9;
174
  }
175
 
176
+ /* Hide gradio default tools */
177
  .chatbot-toolbar,
178
  .chatbot-actions,
179
  button[aria-label="Copy"],
 
181
  button[aria-label="Clear"] {
182
  display: none !important;
183
  }
 
 
 
 
 
184
  """
185
 
186
  # =====================================================
 
188
  # =====================================================
189
  with gr.Blocks(title="GROQ CHATBOT") as demo:
190
  gr.Markdown("# 🤖 GROQ CHATBOT")
191
+ gr.Markdown("<div class='subtitle'>Fast, reliable AI powered by Groq & LLaMA-3.3</div>")
 
 
192
 
193
  chatbot = gr.Chatbot(elem_classes="chatbot")
194
  state = gr.State([])
195
 
196
  with gr.Row():
197
+ txt = gr.Textbox(placeholder="Type your message…", show_label=False, scale=5)
 
 
 
 
198
  send = gr.Button("Send", scale=1)
199
  clear = gr.Button("Clear", scale=1)
200
 
 
203
  clear.click(clear_chat, outputs=[chatbot, txt], show_progress=False)
204
 
205
  # =====================================================
206
+ # Launch
207
  # =====================================================
208
  if __name__ == "__main__":
209
  demo.launch(css=custom_css)