Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- app.py +9 -2
- neurobait-logo.jpg +3 -0
- ui.py +69 -15
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
neurobait-logo.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -15,7 +15,7 @@ from threading import Lock, Thread
|
|
| 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,4 +196,11 @@ demo = build_demo(respond)
|
|
| 196 |
|
| 197 |
|
| 198 |
if __name__ == "__main__":
|
| 199 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
import spaces
|
| 16 |
import torch
|
| 17 |
|
| 18 |
+
from ui import CSS, I18N, JS, 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(
|
| 200 |
+
show_error=True,
|
| 201 |
+
css=CSS,
|
| 202 |
+
theme=THEME,
|
| 203 |
+
js=JS,
|
| 204 |
+
i18n=I18N,
|
| 205 |
+
allowed_paths=["."],
|
| 206 |
+
)
|
neurobait-logo.jpg
ADDED
|
Git LFS Details
|
ui.py
CHANGED
|
@@ -26,11 +26,18 @@ MOODS = ["Calm", "Tired", "Anxious", "Focused"]
|
|
| 26 |
|
| 27 |
THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate")
|
| 28 |
|
| 29 |
-
TITLE = "
|
| 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
|
|
@@ -93,6 +100,18 @@ body, .gradio-container {
|
|
| 93 |
|
| 94 |
h1 { letter-spacing: -0.5px; font-weight: 800; }
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
/* user bubble gets the brand accent, assistant stays flat/quiet */
|
| 97 |
.message.user, [data-testid="user"] {
|
| 98 |
background: var(--brand-grad) !important; color: #fff !important; border: none !important;
|
|
@@ -178,6 +197,38 @@ button.primary, .submit-button, [variant="primary"] {
|
|
| 178 |
}
|
| 179 |
"""
|
| 180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
def message_text(content) -> str:
|
| 183 |
if isinstance(content, str):
|
|
@@ -210,16 +261,19 @@ def build_demo(respond_fn):
|
|
| 210 |
placeholder=PLACEHOLDER,
|
| 211 |
avatar_images=(None, None),
|
| 212 |
)
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate")
|
| 28 |
|
| 29 |
+
TITLE = ""
|
| 30 |
|
| 31 |
DESCRIPTION = (
|
| 32 |
"A warm space and a gentle boost for your everyday. "
|
| 33 |
+
"No red pen 路 no urgency 路 no streaks. "
|
| 34 |
+
"Not diagnostic 路 needs ADHD experts."
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
HEADER_HTML = (
|
| 38 |
+
'<div class="nb-header">'
|
| 39 |
+
'<img src="/file=neurobait-logo.jpg" alt="NeuroBait logo" class="nb-logo" />'
|
| 40 |
+
"</div>"
|
| 41 |
)
|
| 42 |
|
| 43 |
# Force the Gradio shell footer to English so it does not clash with the app's
|
|
|
|
| 100 |
|
| 101 |
h1 { letter-spacing: -0.5px; font-weight: 800; }
|
| 102 |
|
| 103 |
+
.nb-header {
|
| 104 |
+
display: flex;
|
| 105 |
+
justify-content: center;
|
| 106 |
+
padding: 1.5rem 0 0.75rem;
|
| 107 |
+
}
|
| 108 |
+
.nb-logo {
|
| 109 |
+
display: block;
|
| 110 |
+
width: min(360px, 76vw);
|
| 111 |
+
height: auto;
|
| 112 |
+
border-radius: 0;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
/* user bubble gets the brand accent, assistant stays flat/quiet */
|
| 116 |
.message.user, [data-testid="user"] {
|
| 117 |
background: var(--brand-grad) !important; color: #fff !important; border: none !important;
|
|
|
|
| 197 |
}
|
| 198 |
"""
|
| 199 |
|
| 200 |
+
JS = """
|
| 201 |
+
() => {
|
| 202 |
+
const replacements = new Map([
|
| 203 |
+
["Gunakan melalui API", "Use via API"],
|
| 204 |
+
["Dibuat dengan Gradio", "Built with Gradio"],
|
| 205 |
+
["Pengaturan", "Settings"],
|
| 206 |
+
]);
|
| 207 |
+
const normalizeFooter = () => {
|
| 208 |
+
document.querySelectorAll("a, button, span").forEach((node) => {
|
| 209 |
+
const text = node.textContent?.trim();
|
| 210 |
+
if (text && replacements.has(text)) {
|
| 211 |
+
node.textContent = replacements.get(text);
|
| 212 |
+
}
|
| 213 |
+
const label = node.getAttribute?.("aria-label");
|
| 214 |
+
if (label && replacements.has(label)) {
|
| 215 |
+
node.setAttribute("aria-label", replacements.get(label));
|
| 216 |
+
}
|
| 217 |
+
const title = node.getAttribute?.("title");
|
| 218 |
+
if (title && replacements.has(title)) {
|
| 219 |
+
node.setAttribute("title", replacements.get(title));
|
| 220 |
+
}
|
| 221 |
+
});
|
| 222 |
+
};
|
| 223 |
+
normalizeFooter();
|
| 224 |
+
new MutationObserver(normalizeFooter).observe(document.body, {
|
| 225 |
+
childList: true,
|
| 226 |
+
subtree: true,
|
| 227 |
+
characterData: true,
|
| 228 |
+
});
|
| 229 |
+
}
|
| 230 |
+
"""
|
| 231 |
+
|
| 232 |
|
| 233 |
def message_text(content) -> str:
|
| 234 |
if isinstance(content, str):
|
|
|
|
| 261 |
placeholder=PLACEHOLDER,
|
| 262 |
avatar_images=(None, None),
|
| 263 |
)
|
| 264 |
+
with gr.Blocks(fill_height=True) as demo:
|
| 265 |
+
gr.HTML(HEADER_HTML, elem_id="neurobait-header")
|
| 266 |
+
gr.ChatInterface(
|
| 267 |
+
fn=respond_fn,
|
| 268 |
+
chatbot=chatbot,
|
| 269 |
+
additional_inputs=[mood],
|
| 270 |
+
additional_inputs_accordion=gr.Accordion("馃尦 How are you feeling?", open=True),
|
| 271 |
+
title=TITLE,
|
| 272 |
+
description=DESCRIPTION,
|
| 273 |
+
examples=EXAMPLES,
|
| 274 |
+
cache_examples=False,
|
| 275 |
+
save_history=True,
|
| 276 |
+
fill_height=True,
|
| 277 |
+
autoscroll=True,
|
| 278 |
+
)
|
| 279 |
+
return demo
|