aazankhanYousafzai commited on
Commit
ae7b53e
·
verified ·
1 Parent(s): 6cff41c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -31
app.py CHANGED
@@ -51,28 +51,33 @@ def chat_with_groq(user_message, history):
51
  def clear_chat():
52
  return [], ""
53
 
54
- /* -------- RESET ONLY CHAT AREA -------- */
55
- .chatbot * {
56
- all: unset;
57
- }
58
-
59
- /* -------- RESTORE DEFAULT BLOCKS -------- */
60
- .chatbot .message,
61
- .chatbot .message * {
62
- all: revert;
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
  body {
77
  background-color: var(--bg);
78
  }
@@ -82,10 +87,24 @@ body {
82
  margin: auto;
83
  padding: 24px;
84
  overflow-x: hidden !important;
85
- font-family: system-ui, sans-serif;
 
 
 
 
 
 
 
 
86
  }
87
 
88
- /* -------- CHAT WINDOW -------- */
 
 
 
 
 
 
89
  .chatbot {
90
  background: var(--surface);
91
  border-radius: 16px;
@@ -96,32 +115,32 @@ body {
96
  overflow-y: auto;
97
  }
98
 
99
- /* -------- MESSAGES -------- */
100
- .chatbot .message {
101
- display: block !important;
102
  max-width: 72%;
103
  padding: 12px 14px;
104
  border-radius: 14px;
105
  margin-bottom: 10px;
106
  line-height: 1.6;
107
  font-size: 15px;
108
- white-space: pre-wrap !important;
109
- word-break: normal !important;
110
  }
111
 
112
- .chatbot .message.user {
113
  background: var(--user);
114
  color: white;
115
  margin-left: auto;
 
116
  }
117
 
118
- .chatbot .message.bot {
119
  background: var(--assistant);
120
  color: var(--text);
121
  margin-right: auto;
 
122
  }
123
 
124
- /* -------- INPUT -------- */
125
  textarea {
126
  background: var(--surface) !important;
127
  color: var(--text) !important;
@@ -131,7 +150,11 @@ textarea {
131
  font-size: 15px;
132
  }
133
 
134
- /* -------- BUTTONS -------- */
 
 
 
 
135
  button {
136
  background: var(--user) !important;
137
  color: white !important;
@@ -140,7 +163,11 @@ button {
140
  font-weight: 600 !important;
141
  }
142
 
143
- /* -------- REMOVE FLOATING ICONS -------- */
 
 
 
 
144
  .chatbot-toolbar,
145
  .chatbot-actions,
146
  button[aria-label="Copy"],
@@ -149,6 +176,11 @@ button[aria-label="Clear"] {
149
  display: none !important;
150
  }
151
 
 
 
 
 
 
152
 
153
  # =====================================================
154
  # Gradio UI
@@ -179,4 +211,4 @@ with gr.Blocks(title="GROQ AI CHATBOT") as demo:
179
  # Launch (Gradio 6)
180
  # =====================================================
181
  if __name__ == "__main__":
182
- demo.launch(css=custom_css)
 
51
  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 ---------- */
81
  body {
82
  background-color: var(--bg);
83
  }
 
87
  margin: auto;
88
  padding: 24px;
89
  overflow-x: hidden !important;
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);
110
  border-radius: 16px;
 
115
  overflow-y: auto;
116
  }
117
 
118
+ /* ---------- Messages ---------- */
119
+ .message {
 
120
  max-width: 72%;
121
  padding: 12px 14px;
122
  border-radius: 14px;
123
  margin-bottom: 10px;
124
  line-height: 1.6;
125
  font-size: 15px;
126
+ box-sizing: border-box;
 
127
  }
128
 
129
+ .message.user {
130
  background: var(--user);
131
  color: white;
132
  margin-left: auto;
133
+ border-bottom-right-radius: 4px;
134
  }
135
 
136
+ .message.bot {
137
  background: var(--assistant);
138
  color: var(--text);
139
  margin-right: auto;
140
+ border-bottom-left-radius: 4px;
141
  }
142
 
143
+ /* ---------- Input ---------- */
144
  textarea {
145
  background: var(--surface) !important;
146
  color: var(--text) !important;
 
150
  font-size: 15px;
151
  }
152
 
153
+ textarea::placeholder {
154
+ color: var(--muted);
155
+ }
156
+
157
+ /* ---------- Buttons ---------- */
158
  button {
159
  background: var(--user) !important;
160
  color: white !important;
 
163
  font-weight: 600 !important;
164
  }
165
 
166
+ button:hover {
167
+ opacity: 0.9;
168
+ }
169
+
170
+ /* ---------- GRADIO 6 FIXES ---------- */
171
  .chatbot-toolbar,
172
  .chatbot-actions,
173
  button[aria-label="Copy"],
 
176
  display: none !important;
177
  }
178
 
179
+ .chatbot .scroll-to-bottom {
180
+ right: 16px !important;
181
+ bottom: 80px !important;
182
+ }
183
+ """
184
 
185
  # =====================================================
186
  # Gradio UI
 
211
  # Launch (Gradio 6)
212
  # =====================================================
213
  if __name__ == "__main__":
214
+ demo.launch(css=custom_css)