ndahlbom commited on
Commit
e5a4a6c
·
verified ·
1 Parent(s): fd3f736

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -20,9 +20,9 @@ model_path = hf_hub_download(
20
  print("Initializing llama.cpp LLM ...")
21
  llm = Llama(
22
  model_path=model_path,
23
- n_ctx=2048,
24
- n_threads=2,
25
- n_batch=64,
26
  use_mmap=True,
27
  use_mlock=False,
28
  )
@@ -59,7 +59,6 @@ def build_prompt(message, history, style):
59
  return "".join(prompt_parts)
60
 
61
  def chat_fn(message, history, max_new_tokens, style):
62
- # Hardcoded values
63
  temperature = 0.7
64
  top_p = 0.9
65
  repetition_penalty = 1.1
@@ -78,7 +77,6 @@ def chat_fn(message, history, max_new_tokens, style):
78
 
79
  # --- 4. Winter/Christmas Theme Configuration ---
80
 
81
- # We remove the specific 'text_color_subdued' argument to fix the crash
82
  winter_theme = gr.themes.Soft(
83
  primary_hue="blue",
84
  neutral_hue="slate",
@@ -90,23 +88,25 @@ winter_theme = gr.themes.Soft(
90
  button_primary_text_color="#000000",
91
  )
92
 
93
- # Custom CSS for the "Perfect" Look
 
94
  custom_css = """
95
- /* 1. Background Image: Snowy Winter Forest */
96
- .gradio-container {
97
- background: url('https://images.unsplash.com/photo-1477601263568-180e2c6d046e?q=80&w=2560&auto=format&fit=crop') no-repeat center center fixed;
98
- background-size: cover;
99
  }
100
 
101
- /* 2. Transparency */
102
- .gradio-container > .main {
103
  background: transparent !important;
 
104
  }
105
 
106
  /* 3. The Chat & Settings Blocks - "Frosty Glass" with White Borders */
107
  .group, .form, .bubble-wrap {
108
- background: rgba(15, 23, 42, 0.75) !important; /* Dark Blue/Grey Glass */
109
- border: 2px solid #FFFFFF !important; /* THE WHITE BORDER */
110
  border-radius: 12px !important;
111
  backdrop-filter: blur(4px);
112
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
@@ -114,11 +114,10 @@ custom_css = """
114
 
115
  /* 4. Chat Bubbles */
116
  .user-message {
117
- background-color: rgba(255, 255, 255, 0.2) !important; /* Icy White transparency */
118
  border: 1px solid #FFFFFF !important;
119
  color: #FFFFFF !important;
120
  }
121
-
122
  .bot-message {
123
  background-color: rgba(0, 0, 0, 0.6) !important;
124
  border: 1px solid #A0A0A0 !important;
@@ -131,7 +130,6 @@ textarea, input {
131
  border: 1px solid #FFFFFF !important;
132
  color: white !important;
133
  }
134
- /* This CSS handles the text color we removed from the Python code */
135
  label, span, p, .prose {
136
  color: #FFFFFF !important;
137
  text-shadow: 1px 1px 2px black;
@@ -158,6 +156,7 @@ demo = gr.ChatInterface(
158
  additional_inputs_accordion="Settings",
159
  )
160
 
 
161
  demo.theme = winter_theme
162
  demo.css = custom_css
163
 
 
20
  print("Initializing llama.cpp LLM ...")
21
  llm = Llama(
22
  model_path=model_path,
23
+ n_ctx=2048,
24
+ n_threads=2,
25
+ n_batch=64,
26
  use_mmap=True,
27
  use_mlock=False,
28
  )
 
59
  return "".join(prompt_parts)
60
 
61
  def chat_fn(message, history, max_new_tokens, style):
 
62
  temperature = 0.7
63
  top_p = 0.9
64
  repetition_penalty = 1.1
 
77
 
78
  # --- 4. Winter/Christmas Theme Configuration ---
79
 
 
80
  winter_theme = gr.themes.Soft(
81
  primary_hue="blue",
82
  neutral_hue="slate",
 
88
  button_primary_text_color="#000000",
89
  )
90
 
91
+ # --- UPDATED CSS ---
92
+ # Changed logic: Apply background to 'body' and force '.gradio-container' to be transparent
93
  custom_css = """
94
+ /* 1. APPLY BACKGROUND TO BODY directly to ensure it loads behind everything */
95
+ body {
96
+ background: url('https://images.unsplash.com/photo-1477601263568-180e2c6d046e?q=80&w=2560&auto=format&fit=crop') no-repeat center center fixed !important;
97
+ background-size: cover !important;
98
  }
99
 
100
+ /* 2. Make the Gradio Container TRANSPARENT so body shows through */
101
+ .gradio-container {
102
  background: transparent !important;
103
+ background-color: transparent !important;
104
  }
105
 
106
  /* 3. The Chat & Settings Blocks - "Frosty Glass" with White Borders */
107
  .group, .form, .bubble-wrap {
108
+ background: rgba(15, 23, 42, 0.75) !important;
109
+ border: 2px solid #FFFFFF !important;
110
  border-radius: 12px !important;
111
  backdrop-filter: blur(4px);
112
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
 
114
 
115
  /* 4. Chat Bubbles */
116
  .user-message {
117
+ background-color: rgba(255, 255, 255, 0.2) !important;
118
  border: 1px solid #FFFFFF !important;
119
  color: #FFFFFF !important;
120
  }
 
121
  .bot-message {
122
  background-color: rgba(0, 0, 0, 0.6) !important;
123
  border: 1px solid #A0A0A0 !important;
 
130
  border: 1px solid #FFFFFF !important;
131
  color: white !important;
132
  }
 
133
  label, span, p, .prose {
134
  color: #FFFFFF !important;
135
  text-shadow: 1px 1px 2px black;
 
156
  additional_inputs_accordion="Settings",
157
  )
158
 
159
+ # Apply Theme and CSS
160
  demo.theme = winter_theme
161
  demo.css = custom_css
162