BICORP commited on
Commit
79cb1bc
·
verified ·
1 Parent(s): a710c69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -7
app.py CHANGED
@@ -27,8 +27,8 @@ def call_api(message, model, preset):
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
30
- # Custom CSS for clean UI
31
- css = """
32
  .gradio-container {
33
  background-color: #f9f9f9;
34
  font-family: 'Arial', sans-serif;
@@ -65,10 +65,10 @@ css = """
65
  border: none;
66
  background: none;
67
  cursor: pointer;
68
- padding: 5px; /* Reduced padding for a smaller button */
69
- font-size: 12px; /* Smaller font size */
70
- width: 30px; /* Set a specific width */
71
- height: 30px; /* Set a specific height */
72
  color: #007BFF; /* Text color */
73
  transition: opacity 0.3s; /* Smooth transition for hover effect */
74
  }
@@ -82,9 +82,36 @@ css = """
82
  }
83
  """
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  # Create Gradio interface
86
  def create_interface():
87
- with gr.Blocks(css=css) as demo:
88
  gr.Markdown("## 💬 Chatbot")
89
 
90
  # Chat display area
@@ -104,6 +131,9 @@ def create_interface():
104
  # Button click event
105
  send_btn.click(call_api, inputs=[message, model, preset], outputs=chatbox)
106
 
 
 
 
107
  return demo
108
 
109
  # Launch the interface
 
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
30
+ # Custom CSS for light mode
31
+ light_css = """
32
  .gradio-container {
33
  background-color: #f9f9f9;
34
  font-family: 'Arial', sans-serif;
 
65
  border: none;
66
  background: none;
67
  cursor: pointer;
68
+ padding: 2px; /* Reduced padding for a smaller button */
69
+ font-size: 10px; /* Smaller font size */
70
+ width: 20px; /* Set a specific width */
71
+ height: 20px; /* Set a specific height */
72
  color: #007BFF; /* Text color */
73
  transition: opacity 0.3s; /* Smooth transition for hover effect */
74
  }
 
82
  }
83
  """
84
 
85
+ # Dark mode CSS
86
+ dark_css = """
87
+ .dark-mode .gradio-container {
88
+ background-color: #1e1e1e; /* Dark background */
89
+ color: white; /* Light text color */
90
+ }
91
+
92
+ .dark-mode #chatbox {
93
+ background-color: #2e2e2e; /* Dark chatbox */
94
+ color: white; /* Light text color */
95
+ }
96
+
97
+ .dark-mode #input-container {
98
+ background-color: #2e2e2e; /* Dark input container */
99
+ border: 1px solid #444; /* Dark border */
100
+ }
101
+
102
+ .dark-mode #message-input {
103
+ background-color: #3e3e3e; /* Dark input field */
104
+ color: white; /* Light text color */
105
+ }
106
+
107
+ .dark-mode #send-button {
108
+ color: #007BFF; /* Button text color */
109
+ }
110
+ """
111
+
112
  # Create Gradio interface
113
  def create_interface():
114
+ with gr.Blocks() as demo:
115
  gr.Markdown("## 💬 Chatbot")
116
 
117
  # Chat display area
 
131
  # Button click event
132
  send_btn.click(call_api, inputs=[message, model, preset], outputs=chatbox)
133
 
134
+ # Toggle dark mode
135
+ dark_mode.change(lambda x: demo.css = dark_css if x else light_css, inputs=[dark_mode])
136
+
137
  return demo
138
 
139
  # Launch the interface