Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files- app.py +1 -0
- neurobait-mark.png +0 -0
- ui.py +64 -27
app.py
CHANGED
|
@@ -202,5 +202,6 @@ if __name__ == "__main__":
|
|
| 202 |
theme=THEME,
|
| 203 |
js=JS,
|
| 204 |
i18n=I18N,
|
|
|
|
| 205 |
allowed_paths=["."],
|
| 206 |
)
|
|
|
|
| 202 |
theme=THEME,
|
| 203 |
js=JS,
|
| 204 |
i18n=I18N,
|
| 205 |
+
footer_links=[],
|
| 206 |
allowed_paths=["."],
|
| 207 |
)
|
neurobait-mark.png
ADDED
|
ui.py
CHANGED
|
@@ -20,6 +20,9 @@ UX notes for ADHD users:
|
|
| 20 |
|
| 21 |
from __future__ import annotations
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
import gradio as gr
|
| 24 |
|
| 25 |
MOODS = ["Calm", "Tired", "Anxious", "Focused"]
|
|
@@ -27,7 +30,7 @@ MOODS = ["Calm", "Tired", "Anxious", "Focused"]
|
|
| 27 |
THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate")
|
| 28 |
|
| 29 |
TITLE = ""
|
| 30 |
-
|
| 31 |
|
| 32 |
DESCRIPTION = (
|
| 33 |
"A warm space and a gentle boost for your everyday. "
|
|
@@ -47,6 +50,27 @@ I18N = gr.I18n(
|
|
| 47 |
id=I18N_FOOTER,
|
| 48 |
)
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
PLACEHOLDER = "What's on your mind? No need to be tidy."
|
| 51 |
|
| 52 |
EXAMPLES = [
|
|
@@ -99,26 +123,29 @@ h1 { letter-spacing: -0.5px; font-weight: 800; }
|
|
| 99 |
|
| 100 |
.nb-header {
|
| 101 |
display: flex;
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
-
.nb-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
height: auto;
|
| 111 |
-
margin: 0 auto;
|
| 112 |
-
border-radius: 0;
|
| 113 |
}
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
}
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
}
|
| 123 |
|
| 124 |
/* user bubble gets the brand accent, assistant stays flat/quiet */
|
|
@@ -204,6 +231,23 @@ button.primary, .submit-button, [variant="primary"] {
|
|
| 204 |
margin-top: 1rem;
|
| 205 |
border-top: 1px solid var(--sand);
|
| 206 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
"""
|
| 208 |
|
| 209 |
JS = """
|
|
@@ -275,15 +319,7 @@ def build_demo(respond_fn):
|
|
| 275 |
respond_fn(message: str, history: list[dict], mood: str) -> str | generator[str]
|
| 276 |
"""
|
| 277 |
with gr.Blocks(fill_height=True) as demo:
|
| 278 |
-
|
| 279 |
-
gr.Image(
|
| 280 |
-
value=LOGO_PATH,
|
| 281 |
-
show_label=False,
|
| 282 |
-
interactive=False,
|
| 283 |
-
container=False,
|
| 284 |
-
height=148,
|
| 285 |
-
elem_id="neurobait-logo",
|
| 286 |
-
)
|
| 287 |
mood = gr.Radio(
|
| 288 |
MOODS,
|
| 289 |
value="Calm",
|
|
@@ -311,4 +347,5 @@ def build_demo(respond_fn):
|
|
| 311 |
fill_height=True,
|
| 312 |
autoscroll=True,
|
| 313 |
)
|
|
|
|
| 314 |
return demo
|
|
|
|
| 20 |
|
| 21 |
from __future__ import annotations
|
| 22 |
|
| 23 |
+
import base64
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
import gradio as gr
|
| 27 |
|
| 28 |
MOODS = ["Calm", "Tired", "Anxious", "Focused"]
|
|
|
|
| 30 |
THEME = gr.themes.Soft(primary_hue="teal", neutral_hue="slate")
|
| 31 |
|
| 32 |
TITLE = ""
|
| 33 |
+
MARK_PATH = Path(__file__).with_name("neurobait-mark.png")
|
| 34 |
|
| 35 |
DESCRIPTION = (
|
| 36 |
"A warm space and a gentle boost for your everyday. "
|
|
|
|
| 50 |
id=I18N_FOOTER,
|
| 51 |
)
|
| 52 |
|
| 53 |
+
MARK_SRC = f"data:image/png;base64,{base64.b64encode(MARK_PATH.read_bytes()).decode('ascii')}"
|
| 54 |
+
HEADER_HTML = f"""
|
| 55 |
+
<header class="nb-header">
|
| 56 |
+
<img src="{MARK_SRC}" alt="" class="nb-mark" />
|
| 57 |
+
<div>
|
| 58 |
+
<div class="nb-wordmark">NeuroBait</div>
|
| 59 |
+
<div class="nb-kicker">task initiation companion</div>
|
| 60 |
+
</div>
|
| 61 |
+
</header>
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
FOOTER_HTML = """
|
| 65 |
+
<div class="nb-footer-links">
|
| 66 |
+
<a href="/?view=api">Use via API</a>
|
| 67 |
+
<span>·</span>
|
| 68 |
+
<a href="https://gradio.app" target="_blank" rel="noreferrer">Built with Gradio</a>
|
| 69 |
+
<span>·</span>
|
| 70 |
+
<span>Settings</span>
|
| 71 |
+
</div>
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
PLACEHOLDER = "What's on your mind? No need to be tidy."
|
| 75 |
|
| 76 |
EXAMPLES = [
|
|
|
|
| 123 |
|
| 124 |
.nb-header {
|
| 125 |
display: flex;
|
| 126 |
+
align-items: center;
|
| 127 |
+
justify-content: flex-start;
|
| 128 |
+
gap: 12px;
|
| 129 |
+
padding: 1rem 0 0.4rem;
|
| 130 |
}
|
| 131 |
+
.nb-mark {
|
| 132 |
+
width: 42px;
|
| 133 |
+
height: 42px;
|
| 134 |
+
object-fit: contain;
|
| 135 |
+
flex: 0 0 auto;
|
|
|
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
+
.nb-wordmark {
|
| 138 |
+
font-size: 1.24rem;
|
| 139 |
+
line-height: 1.05;
|
| 140 |
+
font-weight: 780;
|
| 141 |
+
letter-spacing: 0;
|
| 142 |
+
color: var(--charcoal);
|
| 143 |
}
|
| 144 |
+
.nb-kicker {
|
| 145 |
+
margin-top: 3px;
|
| 146 |
+
color: var(--stone);
|
| 147 |
+
font-size: 0.78rem;
|
| 148 |
+
line-height: 1.2;
|
| 149 |
}
|
| 150 |
|
| 151 |
/* user bubble gets the brand accent, assistant stays flat/quiet */
|
|
|
|
| 231 |
margin-top: 1rem;
|
| 232 |
border-top: 1px solid var(--sand);
|
| 233 |
}
|
| 234 |
+
.nb-footer-links {
|
| 235 |
+
display: flex;
|
| 236 |
+
align-items: center;
|
| 237 |
+
justify-content: center;
|
| 238 |
+
gap: 9px;
|
| 239 |
+
color: var(--stone);
|
| 240 |
+
font-size: 0.8rem;
|
| 241 |
+
margin: 1.75rem 0 0.25rem;
|
| 242 |
+
}
|
| 243 |
+
.nb-footer-links a,
|
| 244 |
+
.nb-footer-links span {
|
| 245 |
+
color: var(--stone) !important;
|
| 246 |
+
text-decoration: none !important;
|
| 247 |
+
}
|
| 248 |
+
.nb-footer-links a:hover {
|
| 249 |
+
color: var(--charcoal) !important;
|
| 250 |
+
}
|
| 251 |
"""
|
| 252 |
|
| 253 |
JS = """
|
|
|
|
| 319 |
respond_fn(message: str, history: list[dict], mood: str) -> str | generator[str]
|
| 320 |
"""
|
| 321 |
with gr.Blocks(fill_height=True) as demo:
|
| 322 |
+
gr.HTML(HEADER_HTML)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
mood = gr.Radio(
|
| 324 |
MOODS,
|
| 325 |
value="Calm",
|
|
|
|
| 347 |
fill_height=True,
|
| 348 |
autoscroll=True,
|
| 349 |
)
|
| 350 |
+
gr.HTML(FOOTER_HTML)
|
| 351 |
return demo
|