Spaces:
Running
Running
Anirudh Esthuri
commited on
Commit
·
cdd476e
1
Parent(s):
8617ea0
Refresh Streamlit UI styling
Browse files- app.py +78 -1
- styles.css +161 -22
app.py
CHANGED
|
@@ -95,7 +95,10 @@ if not IMPORTS_SUCCESSFUL:
|
|
| 95 |
# Debug: Show that app is loading
|
| 96 |
print("Rendering initial content...", file=sys.stderr)
|
| 97 |
sys.stderr.flush() # Force flush to ensure logs appear
|
| 98 |
-
st.
|
|
|
|
|
|
|
|
|
|
| 99 |
print("✓ Initial content rendered", file=sys.stderr)
|
| 100 |
sys.stderr.flush()
|
| 101 |
|
|
@@ -171,6 +174,80 @@ else:
|
|
| 171 |
st.error(f"Failed to delete profile for '{persona_name}'.")
|
| 172 |
st.divider()
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
# ──────────────────────────────────────────────────────────────
|
| 175 |
# Session state
|
| 176 |
# ──────────────────────────────────────────────────────────────
|
|
|
|
| 95 |
# Debug: Show that app is loading
|
| 96 |
print("Rendering initial content...", file=sys.stderr)
|
| 97 |
sys.stderr.flush() # Force flush to ensure logs appear
|
| 98 |
+
st.markdown(
|
| 99 |
+
'<div class="pill on">🚀 Playground Ready</div>',
|
| 100 |
+
unsafe_allow_html=True,
|
| 101 |
+
)
|
| 102 |
print("✓ Initial content rendered", file=sys.stderr)
|
| 103 |
sys.stderr.flush()
|
| 104 |
|
|
|
|
| 174 |
st.error(f"Failed to delete profile for '{persona_name}'.")
|
| 175 |
st.divider()
|
| 176 |
|
| 177 |
+
# ──────────────────────────────────────────────────────────────
|
| 178 |
+
# Hero / Context panels
|
| 179 |
+
# ──────────────────────────────────────────────────────────────
|
| 180 |
+
persona_badge = persona_name if persona_name == selected_persona else f"{persona_name} • custom"
|
| 181 |
+
|
| 182 |
+
hero_html = f"""
|
| 183 |
+
<div class="hero-card">
|
| 184 |
+
<div>
|
| 185 |
+
<p class="eyebrow">Live Persona Playground</p>
|
| 186 |
+
<h2>MemMachine Conversational Memory</h2>
|
| 187 |
+
<p>Use rapid persona rewrites, compare against control personas, and stream
|
| 188 |
+
LLM output from your preferred provider without leaving this panel.</p>
|
| 189 |
+
</div>
|
| 190 |
+
<div class="status-chip">
|
| 191 |
+
<span>Active model</span>
|
| 192 |
+
<strong>{model_id}</strong>
|
| 193 |
+
<small>{provider.title()}</small>
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
"""
|
| 197 |
+
st.markdown(hero_html, unsafe_allow_html=True)
|
| 198 |
+
|
| 199 |
+
stat_cols = st.columns(3)
|
| 200 |
+
stat_cols[0].markdown(
|
| 201 |
+
f"""
|
| 202 |
+
<div class="stat-card">
|
| 203 |
+
<span>Persona</span>
|
| 204 |
+
<h4>{persona_badge}</h4>
|
| 205 |
+
</div>
|
| 206 |
+
""",
|
| 207 |
+
unsafe_allow_html=True,
|
| 208 |
+
)
|
| 209 |
+
stat_cols[1].markdown(
|
| 210 |
+
f"""
|
| 211 |
+
<div class="stat-card">
|
| 212 |
+
<span>Comparison mode</span>
|
| 213 |
+
<h4>{"Control vs Persona" if compare_personas else "Single persona"}</h4>
|
| 214 |
+
</div>
|
| 215 |
+
""",
|
| 216 |
+
unsafe_allow_html=True,
|
| 217 |
+
)
|
| 218 |
+
stat_cols[2].markdown(
|
| 219 |
+
f"""
|
| 220 |
+
<div class="stat-card">
|
| 221 |
+
<span>Rewrite</span>
|
| 222 |
+
<h4>{"Enabled" if not skip_rewrite else "Skipped"}</h4>
|
| 223 |
+
</div>
|
| 224 |
+
""",
|
| 225 |
+
unsafe_allow_html=True,
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
st.markdown(
|
| 229 |
+
f"""
|
| 230 |
+
<div class="pill-group">
|
| 231 |
+
<span class="pill {'on' if not skip_rewrite else ''}">Rewrite</span>
|
| 232 |
+
<span class="pill {'on' if compare_personas else ''}">Compare personas</span>
|
| 233 |
+
<span class="pill {'on' if show_rationale else ''}">Persona rationale</span>
|
| 234 |
+
<span class="pill on">Backend: {os.getenv("MEMORY_SERVER_URL", "default")}</span>
|
| 235 |
+
</div>
|
| 236 |
+
""",
|
| 237 |
+
unsafe_allow_html=True,
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
with st.expander("How to use this playground", expanded=False):
|
| 241 |
+
st.markdown(
|
| 242 |
+
"""
|
| 243 |
+
1. Pick a model + persona in the sidebar.
|
| 244 |
+
2. Toggle rewrite / comparison to control how memories are applied.
|
| 245 |
+
3. Type a message below — MemMachine will rewrite user input if enabled, call the model, and stream the response.
|
| 246 |
+
4. Use *Clear chat* or *Delete profile* to reset memories.
|
| 247 |
+
"""
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
# ──────────────────────────────────────────────────────────────
|
| 251 |
# ──────────────────────────────────────────────────────────────
|
| 252 |
# Session state
|
| 253 |
# ──────────────────────────────────────────────────────────────
|
styles.css
CHANGED
|
@@ -1,26 +1,165 @@
|
|
| 1 |
-
/*
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
/*
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|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Theme -------------------------------------------------------- */
|
| 2 |
+
.stApp {
|
| 3 |
+
background: radial-gradient(circle at top, #1e2433 0%, #0f131d 55%, #0c0f17 100%);
|
| 4 |
+
color: #f7f8fc;
|
| 5 |
+
font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
| 6 |
+
}
|
| 7 |
|
| 8 |
+
/* Sidebar --------------------------------------------------------------- */
|
| 9 |
+
section[data-testid="stSidebar"] {
|
| 10 |
+
width: 240px !important;
|
| 11 |
+
}
|
| 12 |
|
| 13 |
+
section[data-testid="stSidebarContent"] {
|
| 14 |
+
width: 240px !important;
|
| 15 |
+
padding: 1rem;
|
| 16 |
+
background: rgba(10, 12, 20, 0.85);
|
| 17 |
+
border-right: 1px solid rgba(255, 255, 255, 0.05);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
section[data-testid="stSidebar"] h4,
|
| 21 |
+
section[data-testid="stSidebar"] label,
|
| 22 |
+
section[data-testid="stSidebar"] p,
|
| 23 |
+
section[data-testid="stSidebar"] span {
|
| 24 |
+
color: #f5f6fa !important;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.stButton button {
|
| 28 |
+
border-radius: 999px;
|
| 29 |
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
| 30 |
+
background: rgba(255, 255, 255, 0.04);
|
| 31 |
+
color: #f7f8fc;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.stButton button:hover {
|
| 35 |
+
border-color: rgba(88, 130, 255, 0.9);
|
| 36 |
+
background: rgba(88, 130, 255, 0.15);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/* Headlines ------------------------------------------------------------- */
|
| 40 |
+
h1 {
|
| 41 |
+
font-size: 2.4rem !important;
|
| 42 |
+
margin-bottom: 1rem !important;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.eyebrow {
|
| 46 |
+
text-transform: uppercase;
|
| 47 |
+
letter-spacing: 0.2em;
|
| 48 |
+
font-size: 0.7rem;
|
| 49 |
+
color: rgba(255, 255, 255, 0.6);
|
| 50 |
+
margin-bottom: 0.3rem;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/* Hero + Stat cards ----------------------------------------------------- */
|
| 54 |
+
.hero-card {
|
| 55 |
+
display: flex;
|
| 56 |
+
justify-content: space-between;
|
| 57 |
+
gap: 1.5rem;
|
| 58 |
+
padding: 1.5rem;
|
| 59 |
+
margin: 0.5rem 0 1rem;
|
| 60 |
+
border-radius: 18px;
|
| 61 |
+
background: linear-gradient(130deg, rgba(73, 99, 255, 0.15), rgba(9, 10, 18, 0.85));
|
| 62 |
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.hero-card h2 {
|
| 66 |
+
margin: 0 0 0.4rem;
|
| 67 |
+
font-size: 1.6rem;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.hero-card p {
|
| 71 |
+
margin: 0;
|
| 72 |
+
color: rgba(255, 255, 255, 0.7);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.status-chip {
|
| 76 |
+
align-self: center;
|
| 77 |
+
text-align: right;
|
| 78 |
+
padding: 0.8rem 1rem;
|
| 79 |
+
border-radius: 16px;
|
| 80 |
+
background: rgba(12, 18, 35, 0.75);
|
| 81 |
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
| 82 |
+
min-width: 170px;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.status-chip span {
|
| 86 |
+
display: block;
|
| 87 |
+
font-size: 0.7rem;
|
| 88 |
+
text-transform: uppercase;
|
| 89 |
+
letter-spacing: 0.15em;
|
| 90 |
+
color: rgba(255, 255, 255, 0.5);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.status-chip strong {
|
| 94 |
+
font-size: 1.1rem;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.status-chip small {
|
| 98 |
+
display: block;
|
| 99 |
+
font-size: 0.75rem;
|
| 100 |
+
color: rgba(255, 255, 255, 0.4);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.stat-card {
|
| 104 |
+
border-radius: 16px;
|
| 105 |
+
padding: 1rem 1.25rem;
|
| 106 |
+
background: rgba(15, 22, 38, 0.9);
|
| 107 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
| 108 |
+
height: 100%;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
.stat-card span {
|
| 112 |
+
font-size: 0.75rem;
|
| 113 |
+
letter-spacing: 0.08em;
|
| 114 |
+
text-transform: uppercase;
|
| 115 |
+
color: rgba(255, 255, 255, 0.5);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.stat-card h4 {
|
| 119 |
+
margin: 0.35rem 0 0;
|
| 120 |
+
font-size: 1.1rem;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.pill {
|
| 124 |
+
display: inline-flex;
|
| 125 |
+
align-items: center;
|
| 126 |
+
gap: 0.4rem;
|
| 127 |
+
border-radius: 999px;
|
| 128 |
+
padding: 0.2rem 0.85rem;
|
| 129 |
+
font-size: 0.75rem;
|
| 130 |
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
| 131 |
+
color: rgba(255, 255, 255, 0.75);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.pill.on {
|
| 135 |
+
border-color: rgba(87, 214, 141, 0.6);
|
| 136 |
+
background: rgba(87, 214, 141, 0.12);
|
| 137 |
+
color: #8ef2c9;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.pill-group {
|
| 141 |
+
display: flex;
|
| 142 |
+
flex-wrap: wrap;
|
| 143 |
+
gap: 0.5rem;
|
| 144 |
+
margin: 0.75rem 0 1.25rem;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/* Chat history columns -------------------------------------------------- */
|
| 148 |
+
div.answer {
|
| 149 |
+
white-space: pre-wrap;
|
| 150 |
+
overflow-wrap: anywhere;
|
| 151 |
+
}
|
| 152 |
|
|
|
|
| 153 |
div[data-testid="column"] {
|
| 154 |
+
padding-left: 0.25rem !important;
|
| 155 |
+
padding-right: 0.25rem !important;
|
| 156 |
+
margin-left: 0 !important;
|
| 157 |
+
margin-right: 0 !important;
|
| 158 |
+
flex-grow: 1;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.vertical-divider {
|
| 162 |
+
height: 100%;
|
| 163 |
+
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
| 164 |
+
margin: 0 0.4rem;
|
| 165 |
+
}
|
|
|