Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ from threading import Lock, Thread
|
|
| 15 |
import spaces
|
| 16 |
import torch
|
| 17 |
|
| 18 |
-
from ui import CSS, THEME, build_demo, message_text
|
| 19 |
|
| 20 |
|
| 21 |
BASE_MODEL = os.environ.get("BASE_MODEL", "unsloth/gemma-3-12b-it")
|
|
@@ -196,4 +196,4 @@ demo = build_demo(respond)
|
|
| 196 |
|
| 197 |
|
| 198 |
if __name__ == "__main__":
|
| 199 |
-
demo.launch(show_error=True, css=CSS, theme=THEME)
|
|
|
|
| 15 |
import spaces
|
| 16 |
import torch
|
| 17 |
|
| 18 |
+
from ui import CSS, I18N, THEME, build_demo, message_text
|
| 19 |
|
| 20 |
|
| 21 |
BASE_MODEL = os.environ.get("BASE_MODEL", "unsloth/gemma-3-12b-it")
|
|
|
|
| 196 |
|
| 197 |
|
| 198 |
if __name__ == "__main__":
|
| 199 |
+
demo.launch(show_error=True, css=CSS, theme=THEME, i18n=I18N)
|
ui.py
CHANGED
|
@@ -10,6 +10,12 @@ Dark-only, earthy, calm sage-teal accent (gentler / more sensory-safe for ADHD
|
|
| 10 |
than vivid green). The palette is set straight on ``:root`` and mapped onto
|
| 11 |
Gradio's core CSS vars unconditionally, so the app is dark with no dependence on
|
| 12 |
JS or HF's ``?__theme``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"""
|
| 14 |
|
| 15 |
from __future__ import annotations
|
|
@@ -23,21 +29,26 @@ THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate")
|
|
| 23 |
TITLE = "🧠 NeuroBait"
|
| 24 |
|
| 25 |
DESCRIPTION = (
|
| 26 |
-
"A warm space and a gentle boost for your everyday
|
| 27 |
-
"
|
| 28 |
-
"wired for a different kind of focus."
|
| 29 |
)
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
|
|
|
|
|
|
|
| 37 |
EXAMPLES = [
|
| 38 |
-
["There's something I've been meaning to get to, and it keeps slipping by."
|
| 39 |
-
["My space feels a bit cluttered today."
|
| 40 |
-
["My mind feels a little foggy right now."
|
| 41 |
]
|
| 42 |
|
| 43 |
CSS = """
|
|
@@ -98,6 +109,73 @@ textarea, input[type="text"] {
|
|
| 98 |
button.primary, .submit-button, [variant="primary"] {
|
| 99 |
background: var(--brand-grad) !important; border: none !important; color: #fff !important;
|
| 100 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
"""
|
| 102 |
|
| 103 |
|
|
@@ -120,7 +198,12 @@ def build_demo(respond_fn):
|
|
| 120 |
|
| 121 |
respond_fn(message: str, history: list[dict], mood: str) -> str | generator[str]
|
| 122 |
"""
|
| 123 |
-
mood = gr.Radio(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
chatbot = gr.Chatbot(
|
| 125 |
height=560,
|
| 126 |
show_label=False,
|
|
|
|
| 10 |
than vivid green). The palette is set straight on ``:root`` and mapped onto
|
| 11 |
Gradio's core CSS vars unconditionally, so the app is dark with no dependence on
|
| 12 |
JS or HF's ``?__theme``.
|
| 13 |
+
|
| 14 |
+
UX notes for ADHD users:
|
| 15 |
+
- Fewer decisions: mood is 4 choices, examples are single-click starting points.
|
| 16 |
+
- No shame framing: copy is warm, safety scope is visible, no streaks/deadlines.
|
| 17 |
+
- Consistent language: the Gradio footer is forced to English so the whole app
|
| 18 |
+
feels like one voice, regardless of browser locale.
|
| 19 |
"""
|
| 20 |
|
| 21 |
from __future__ import annotations
|
|
|
|
| 29 |
TITLE = "🧠 NeuroBait"
|
| 30 |
|
| 31 |
DESCRIPTION = (
|
| 32 |
+
"A warm space and a gentle boost for your everyday. "
|
| 33 |
+
"No red pen · no urgency · no streaks."
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
+
# Force the Gradio shell footer to English so it does not clash with the app's
|
| 37 |
+
# English copy when the viewer's browser locale is Indonesian.
|
| 38 |
+
I18N = gr.I18n(
|
| 39 |
+
en={
|
| 40 |
+
"use_via_api": "Use via API",
|
| 41 |
+
"built_with_gradio": "Built with Gradio",
|
| 42 |
+
"settings": "Settings",
|
| 43 |
+
}
|
| 44 |
)
|
| 45 |
|
| 46 |
+
PLACEHOLDER = "What's on your mind? No need to be tidy."
|
| 47 |
+
|
| 48 |
EXAMPLES = [
|
| 49 |
+
["There's something I've been meaning to get to, and it keeps slipping by."],
|
| 50 |
+
["My space feels a bit cluttered today."],
|
| 51 |
+
["My mind feels a little foggy right now."],
|
| 52 |
]
|
| 53 |
|
| 54 |
CSS = """
|
|
|
|
| 109 |
button.primary, .submit-button, [variant="primary"] {
|
| 110 |
background: var(--brand-grad) !important; border: none !important; color: #fff !important;
|
| 111 |
}
|
| 112 |
+
|
| 113 |
+
/* ADHD-friendly examples: render as calm chips instead of a data table */
|
| 114 |
+
.examples table,
|
| 115 |
+
[data-testid="examples"] table,
|
| 116 |
+
.examples-wrap table {
|
| 117 |
+
display: block !important;
|
| 118 |
+
width: 100% !important;
|
| 119 |
+
}
|
| 120 |
+
.examples table thead,
|
| 121 |
+
[data-testid="examples"] table thead,
|
| 122 |
+
.examples-wrap table thead {
|
| 123 |
+
display: none !important;
|
| 124 |
+
}
|
| 125 |
+
.examples table tbody,
|
| 126 |
+
[data-testid="examples"] table tbody,
|
| 127 |
+
.examples-wrap table tbody {
|
| 128 |
+
display: flex !important;
|
| 129 |
+
flex-wrap: wrap !important;
|
| 130 |
+
gap: 8px !important;
|
| 131 |
+
}
|
| 132 |
+
.examples table tr,
|
| 133 |
+
[data-testid="examples"] table tr,
|
| 134 |
+
.examples-wrap table tr {
|
| 135 |
+
display: inline-flex !important;
|
| 136 |
+
}
|
| 137 |
+
.examples table td,
|
| 138 |
+
[data-testid="examples"] table td,
|
| 139 |
+
.examples-wrap table td {
|
| 140 |
+
background: var(--cream) !important;
|
| 141 |
+
border: 1px solid var(--sand) !important;
|
| 142 |
+
border-radius: 999px !important;
|
| 143 |
+
padding: 8px 14px !important;
|
| 144 |
+
color: var(--charcoal) !important;
|
| 145 |
+
cursor: pointer !important;
|
| 146 |
+
font-size: 0.9rem !important;
|
| 147 |
+
line-height: 1.4 !important;
|
| 148 |
+
transition: background 0.15s ease, border-color 0.15s ease !important;
|
| 149 |
+
}
|
| 150 |
+
.examples table td:hover,
|
| 151 |
+
[data-testid="examples"] table td:hover,
|
| 152 |
+
.examples-wrap table td:hover {
|
| 153 |
+
background: var(--mint) !important;
|
| 154 |
+
border-color: var(--forest) !important;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/* Make the empty-state placeholder feel centered and readable */
|
| 158 |
+
.chatbot .placeholder,
|
| 159 |
+
[data-testid="chatbot"] .placeholder {
|
| 160 |
+
text-align: center !important;
|
| 161 |
+
display: flex !important;
|
| 162 |
+
align-items: center !important;
|
| 163 |
+
justify-content: center !important;
|
| 164 |
+
height: 100% !important;
|
| 165 |
+
opacity: 0.9 !important;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/* Safety scope footer at the bottom of the app */
|
| 169 |
+
.gradio-container::after {
|
| 170 |
+
content: "Not a medical device · not a therapist · just a gentle nudge";
|
| 171 |
+
display: block;
|
| 172 |
+
text-align: center;
|
| 173 |
+
color: var(--stone);
|
| 174 |
+
font-size: 0.75rem;
|
| 175 |
+
padding: 1.5rem 0 1rem;
|
| 176 |
+
margin-top: 1rem;
|
| 177 |
+
border-top: 1px solid var(--sand);
|
| 178 |
+
}
|
| 179 |
"""
|
| 180 |
|
| 181 |
|
|
|
|
| 198 |
|
| 199 |
respond_fn(message: str, history: list[dict], mood: str) -> str | generator[str]
|
| 200 |
"""
|
| 201 |
+
mood = gr.Radio(
|
| 202 |
+
MOODS,
|
| 203 |
+
value="Calm",
|
| 204 |
+
label="🌳 How are you feeling?",
|
| 205 |
+
info="Pick the one that feels closest right now.",
|
| 206 |
+
)
|
| 207 |
chatbot = gr.Chatbot(
|
| 208 |
height=560,
|
| 209 |
show_label=False,
|