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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  from groq import Groq
4
 
5
  # =====================================================
6
- # Groq Client Initialization
7
  # =====================================================
8
  def get_groq_client():
9
  api_key = os.getenv("GROQ_API_KEY")
@@ -51,22 +51,18 @@ def chat_with_groq(user_message, history):
51
  def clear_chat():
52
  return [], ""
53
 
54
- # =====================================================
55
- # SAFE CSS (Fixes Vertical Text Bug)
56
- # =====================================================
57
- custom_css = """
58
- /* RESET ONLY INSIDE CHATBOT */
59
  .chatbot * {
60
  all: unset;
61
  }
62
 
63
- /* RESTORE MESSAGE STRUCTURE */
64
  .chatbot .message,
65
  .chatbot .message * {
66
  all: revert;
67
  }
68
 
69
- /* COLOR SYSTEM */
70
  :root {
71
  --bg: #0b0f19;
72
  --surface: #111827;
@@ -89,7 +85,7 @@ body {
89
  font-family: system-ui, sans-serif;
90
  }
91
 
92
- /* CHAT WINDOW */
93
  .chatbot {
94
  background: var(--surface);
95
  border-radius: 16px;
@@ -100,7 +96,7 @@ body {
100
  overflow-y: auto;
101
  }
102
 
103
- /* MESSAGES */
104
  .chatbot .message {
105
  display: block !important;
106
  max-width: 72%;
@@ -125,7 +121,7 @@ body {
125
  margin-right: auto;
126
  }
127
 
128
- /* INPUT */
129
  textarea {
130
  background: var(--surface) !important;
131
  color: var(--text) !important;
@@ -135,7 +131,7 @@ textarea {
135
  font-size: 15px;
136
  }
137
 
138
- /* BUTTONS */
139
  button {
140
  background: var(--user) !important;
141
  color: white !important;
@@ -144,7 +140,7 @@ button {
144
  font-weight: 600 !important;
145
  }
146
 
147
- /* REMOVE FLOATING ICONS */
148
  .chatbot-toolbar,
149
  .chatbot-actions,
150
  button[aria-label="Copy"],
@@ -152,14 +148,16 @@ button[aria-label="Share"],
152
  button[aria-label="Clear"] {
153
  display: none !important;
154
  }
155
- """
156
 
157
  # =====================================================
158
  # Gradio UI
159
  # =====================================================
160
  with gr.Blocks(title="GROQ AI CHATBOT") as demo:
161
  gr.Markdown("# 🤖 GROQ AI CHATBOT")
162
- gr.Markdown("<div class='subtitle'>Fast, reliable AI powered by Groq</div>")
 
 
163
 
164
  chatbot = gr.Chatbot(elem_classes="chatbot")
165
  state = gr.State([])
@@ -178,8 +176,7 @@ with gr.Blocks(title="GROQ AI CHATBOT") as demo:
178
  clear.click(clear_chat, outputs=[chatbot, txt], show_progress=False)
179
 
180
  # =====================================================
181
- # Launch
182
  # =====================================================
183
  if __name__ == "__main__":
184
  demo.launch(css=custom_css)
185
-
 
3
  from groq import Groq
4
 
5
  # =====================================================
6
+ # Groq Client Initialization (GLOBAL)
7
  # =====================================================
8
  def get_groq_client():
9
  api_key = os.getenv("GROQ_API_KEY")
 
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;
 
85
  font-family: system-ui, sans-serif;
86
  }
87
 
88
+ /* -------- CHAT WINDOW -------- */
89
  .chatbot {
90
  background: var(--surface);
91
  border-radius: 16px;
 
96
  overflow-y: auto;
97
  }
98
 
99
+ /* -------- MESSAGES -------- */
100
  .chatbot .message {
101
  display: block !important;
102
  max-width: 72%;
 
121
  margin-right: auto;
122
  }
123
 
124
+ /* -------- INPUT -------- */
125
  textarea {
126
  background: var(--surface) !important;
127
  color: var(--text) !important;
 
131
  font-size: 15px;
132
  }
133
 
134
+ /* -------- BUTTONS -------- */
135
  button {
136
  background: var(--user) !important;
137
  color: white !important;
 
140
  font-weight: 600 !important;
141
  }
142
 
143
+ /* -------- REMOVE FLOATING ICONS -------- */
144
  .chatbot-toolbar,
145
  .chatbot-actions,
146
  button[aria-label="Copy"],
 
148
  button[aria-label="Clear"] {
149
  display: none !important;
150
  }
151
+
152
 
153
  # =====================================================
154
  # Gradio UI
155
  # =====================================================
156
  with gr.Blocks(title="GROQ AI CHATBOT") as demo:
157
  gr.Markdown("# 🤖 GROQ AI CHATBOT")
158
+ gr.Markdown(
159
+ "<div class='subtitle'>Fast, reliable AI powered by Groq & LLaMA-3.3</div>"
160
+ )
161
 
162
  chatbot = gr.Chatbot(elem_classes="chatbot")
163
  state = gr.State([])
 
176
  clear.click(clear_chat, outputs=[chatbot, txt], show_progress=False)
177
 
178
  # =====================================================
179
+ # Launch (Gradio 6)
180
  # =====================================================
181
  if __name__ == "__main__":
182
  demo.launch(css=custom_css)