File size: 2,375 Bytes
77da5ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# app.md β€” Gradio Interface Reference

`app.py` β€” Gradio multi-tab interactive interface for LifeStack.

---

## Overview

`app.py` is the entry point for the demo. It wires together all LifeStack modules into
a single Gradio `Blocks` application served on `http://127.0.0.1:7860`.

---

## Module-level Singletons

These are instantiated once at import time:

| Variable | Type | Purpose |
|---|---|---|
| `MEMORY` | `LifeStackMemory` | ChromaDB trajectory + feedback store |
| `AGENT` | `LifeStackAgent` | LLM-backed decision agent |
| `INTAKE` | `LifeIntake` | NL β†’ structured conflict parser |
| `DEMO_CONFLICT` | `ConflictEvent` | Fixed "Friday 6PM" conflict for tab 1 |
| `DEMO_PREDICTOR` | `TrajectoryPredictor` | 7-day risk score tracker |
| `LONG_DEMO` | `LongitudinalDemo` | Arjun's multi-week journey |
| `GMAIL` | `GmailSignalExtractor` | Optional Gmail stress signal extractor |

---

## Tabs

| Tab | Label | Key Function |
|---|---|---|
| 1 | 🎯 Live Demo | `run_demo(person_label, conflict_label)` |
| 2 | πŸ’­ Try Your Situation | `run_custom(situation, sliders..., gmail_signals)` |
| 3 | πŸ“Š Training Results | `load_training_tab()` |
| 4 | πŸ—“οΈ Arjun's Journey | `LONG_DEMO.show_longitudinal_comparison()` |
| 5 | πŸ—ΊοΈ Task Explorer | `load_demo_task()` |
| 6 | πŸ“¬ Follow-up | `submit_outcome_feedback(...)` |

---

## Key Functions

### `submit_outcome_feedback(ep_id, score, domains_up, domains_down, notes, time_spent)`

Stores real-world outcome data into ChromaDB via `MEMORY.store_feedback(feedback)`.

> **Note:** Uses `MEMORY` (the module-level `LifeStackMemory` instance). The previously
> undefined `AGENT_MEMORY` reference was corrected to `MEMORY` on 2026-04-23.

### `run_demo(person_label, conflict_label)`

Generator β€” yields `(pred_html, before_html, narrative, decision_html)` tuples for each
animation frame. Runs cascade animation then agent intervention.

### `run_custom(situation, ...)`

Calls `INTAKE.full_intake()` to parse NL input, then `AGENT.get_action()`, steps the env,
returns `(life_html, after_html, plan_html)`.

---

## Running

```bash
python app.py
```

Starts on port `7860` with `share=False`. Edit `__main__` block to change port/theme.

---

## Change Log

| Date | Change |
|---|---|
| 2026-04-23 | `AGENT_MEMORY` undefined crash fixed β€” replaced with `MEMORY` in `submit_outcome_feedback` |