hassan773 commited on
Commit
970247f
·
verified ·
1 Parent(s): 8a57409

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
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. UI Styling for Minimalist Full-Screen
10
  custom_css = """
11
  .gradio-container {
12
  max-width: 100% !important;
@@ -22,7 +22,6 @@ custom_css = """
22
  background: white;
23
  }
24
 
25
- /* Scroll fixes for inputs */
26
  #system-prompt-container textarea, .scroll-input textarea {
27
  height: 45px !important;
28
  max-height: 45px !important;
@@ -30,7 +29,6 @@ custom_css = """
30
  resize: none !important;
31
  }
32
 
33
- /* FIXED ICON BUTTON STYLING */
34
  #settings-btn {
35
  width: 44px !important;
36
  height: 44px !important;
@@ -80,12 +78,13 @@ def chat_with_groq(message, history, model, temperature, system_prompt):
80
  yield f"⚠️ API Error: {str(e)}"
81
 
82
  # 4. Interface Setup
83
- with gr.Blocks(css=custom_css) as demo:
84
  sidebar_state = gr.State(False)
85
 
86
- # Header with minimalist icon button
87
  with gr.Row():
88
- gr.Markdown("# 🌿🤖 SageBot", scale=20)
 
89
  with gr.Column(scale=1, min_width=50):
90
  settings_btn = gr.Button("⚙️", elem_id="settings-btn")
91
 
@@ -104,7 +103,7 @@ with gr.Blocks(css=custom_css) as demo:
104
  )
105
  submit_btn = gr.Button("Send", variant="primary", scale=1, min_width=80)
106
 
107
- # Sidebar Area (Hidden by default)
108
  with gr.Column(scale=1, visible=False, elem_classes="sidebar-panel") as sidebar_col:
109
  gr.Markdown("### ⚙️ Global Settings")
110
  model_choice = gr.Dropdown(
@@ -130,7 +129,7 @@ with gr.Blocks(css=custom_css) as demo:
130
  </div>
131
  """)
132
 
133
- # --- Sidebar Toggle Logic ---
134
  def toggle_sidebar(current_state):
135
  new_state = not current_state
136
  return gr.update(visible=new_state), new_state
@@ -159,5 +158,6 @@ with gr.Blocks(css=custom_css) as demo:
159
  )
160
  clear.click(lambda: [], None, chatbot, queue=False)
161
 
 
162
  if __name__ == "__main__":
163
- demo.launch()
 
6
  api_key = os.environ.get("GROQ_API_KEY")
7
  client = Groq(api_key=api_key)
8
 
9
+ # 2. UI Styling
10
  custom_css = """
11
  .gradio-container {
12
  max-width: 100% !important;
 
22
  background: white;
23
  }
24
 
 
25
  #system-prompt-container textarea, .scroll-input textarea {
26
  height: 45px !important;
27
  max-height: 45px !important;
 
29
  resize: none !important;
30
  }
31
 
 
32
  #settings-btn {
33
  width: 44px !important;
34
  height: 44px !important;
 
78
  yield f"⚠️ API Error: {str(e)}"
79
 
80
  # 4. Interface Setup
81
+ with gr.Blocks() as demo:
82
  sidebar_state = gr.State(False)
83
 
84
+ # Header Section - Fixed scale issues
85
  with gr.Row():
86
+ with gr.Column(scale=20):
87
+ gr.Markdown("# 🌿🤖 SageBot")
88
  with gr.Column(scale=1, min_width=50):
89
  settings_btn = gr.Button("⚙️", elem_id="settings-btn")
90
 
 
103
  )
104
  submit_btn = gr.Button("Send", variant="primary", scale=1, min_width=80)
105
 
106
+ # Sidebar Area
107
  with gr.Column(scale=1, visible=False, elem_classes="sidebar-panel") as sidebar_col:
108
  gr.Markdown("### ⚙️ Global Settings")
109
  model_choice = gr.Dropdown(
 
129
  </div>
130
  """)
131
 
132
+ # Sidebar Toggle
133
  def toggle_sidebar(current_state):
134
  new_state = not current_state
135
  return gr.update(visible=new_state), new_state
 
158
  )
159
  clear.click(lambda: [], None, chatbot, queue=False)
160
 
161
+ # Pass CSS into launch() instead of Blocks
162
  if __name__ == "__main__":
163
+ demo.launch(css=custom_css)