MikelWL commited on
Commit
7e138b7
·
1 Parent(s): 07e0db7

Docs: update for current MVP and next config work

Browse files
Files changed (5) hide show
  1. README.md +14 -4
  2. docs/development.md +16 -2
  3. docs/hf.md +1 -1
  4. docs/overview.md +12 -7
  5. docs/roadmap.md +13 -11
README.md CHANGED
@@ -59,13 +59,21 @@ pip install -r requirements.txt
59
 
60
  ## 3. Run the Stack
61
 
62
- ### Option A – Single Command
 
 
 
 
 
 
 
 
63
  ```
64
  ./run_local.sh
65
  ```
66
  Reads `.env`, starts Ollama if needed, launches FastAPI + Gradio, and keeps them running until `Ctrl+C`.
67
 
68
- ### Option B – Manual Terminals
69
  1. *(Only if LLM_BACKEND=ollama)* `ollama serve`
70
  2. `cd backend && uvicorn api.main:app --host 0.0.0.0 --port 8000`
71
  3. `cd frontend && python gradio_app.py`
@@ -76,11 +84,13 @@ Backend listens on `http://localhost:8000`, Gradio on `http://localhost:7860`.
76
 
77
  ## 4. Use the App
78
 
79
- 1. Open the Gradio URL.
80
  2. Click **Start Conversation**. The UI auto-connects to the backend and refreshes once per second.
81
  3. Click **Stop Conversation** when finished.
82
 
83
- Any connection errors or LLM issues appear in the status panel.
 
 
84
 
85
  ---
86
 
 
59
 
60
  ## 3. Run the Stack
61
 
62
+ ### Option A – HF-like (recommended)
63
+
64
+ ```bash
65
+ ./run_docker_local.sh
66
+ ```
67
+
68
+ This runs the same Dockerized web UI used on Hugging Face Spaces.
69
+
70
+ ### Option B – Single Command (legacy local stack)
71
  ```
72
  ./run_local.sh
73
  ```
74
  Reads `.env`, starts Ollama if needed, launches FastAPI + Gradio, and keeps them running until `Ctrl+C`.
75
 
76
+ ### Option C – Manual Terminals (legacy)
77
  1. *(Only if LLM_BACKEND=ollama)* `ollama serve`
78
  2. `cd backend && uvicorn api.main:app --host 0.0.0.0 --port 8000`
79
  3. `cd frontend && python gradio_app.py`
 
84
 
85
  ## 4. Use the App
86
 
87
+ 1. Open the UI URL.
88
  2. Click **Start Conversation**. The UI auto-connects to the backend and refreshes once per second.
89
  3. Click **Stop Conversation** when finished.
90
 
91
+ After the conversation completes, the app runs post-conversation analysis and populates:
92
+ - Bottom-up findings (emergent themes) with evidence
93
+ - Top-down coding (care experience rubric + codebook categories) with evidence
94
 
95
  ---
96
 
docs/development.md CHANGED
@@ -23,7 +23,15 @@ Key environment variables (see `.env.example`):
23
 
24
  ## Running the Stack
25
 
26
- ### One Command
 
 
 
 
 
 
 
 
27
  ```bash
28
  ./run_local.sh
29
  ```
@@ -31,7 +39,7 @@ Key environment variables (see `.env.example`):
31
  - Launches FastAPI backend and Gradio frontend in the background
32
  - Press `Ctrl+C` to stop all three processes
33
 
34
- ### Manual Terminals (for logs)
35
  ```bash
36
  # Terminal 1
37
  ollama serve
@@ -45,6 +53,12 @@ cd frontend
45
  python gradio_app.py
46
  ```
47
 
 
 
 
 
 
 
48
  ## Making Changes Safely
49
 
50
  - Prefer editing personas via YAML (`data/`) and restart the backend to reload.
 
23
 
24
  ## Running the Stack
25
 
26
+ ### Recommended (HF-like) Local Run
27
+
28
+ This project is deployed on Hugging Face Spaces using Docker. The closest local workflow is to run the Docker image locally:
29
+
30
+ ```bash
31
+ ./run_docker_local.sh
32
+ ```
33
+
34
+ ### One Command (legacy local stack)
35
  ```bash
36
  ./run_local.sh
37
  ```
 
39
  - Launches FastAPI backend and Gradio frontend in the background
40
  - Press `Ctrl+C` to stop all three processes
41
 
42
+ ### Manual Terminals (for logs, legacy)
43
  ```bash
44
  # Terminal 1
45
  ollama serve
 
53
  python gradio_app.py
54
  ```
55
 
56
+ ### Web UI (React hybrid)
57
+
58
+ The primary demo UI is served by `frontend/react_gradio_hybrid.py` and includes bottom-up + top-down analysis panels.
59
+
60
+ When running outside Docker, you typically run the backend and the web UI separately; when running in Docker/HF, the backend is mounted under `/api` inside the same server.
61
+
62
  ## Making Changes Safely
63
 
64
  - Prefer editing personas via YAML (`data/`) and restart the backend to reload.
docs/hf.md CHANGED
@@ -56,7 +56,7 @@ git push --force hf main
56
 
57
  ## Troubleshooting
58
 
59
- - **UI loads but QA Monitor shows “Failed to connect to backend”**
60
  - Ensure `FRONTEND_WEBSOCKET_URL` is set to `ws://127.0.0.1:7860/api/ws/conversation`.
61
  - **Space crashes on startup**
62
  - Check Space → Logs for the Python traceback.
 
56
 
57
  ## Troubleshooting
58
 
59
+ - **UI loads but analysis never appears / shows backend connection errors**
60
  - Ensure `FRONTEND_WEBSOCKET_URL` is set to `ws://127.0.0.1:7860/api/ws/conversation`.
61
  - **Space crashes on startup**
62
  - Check Space → Logs for the Python traceback.
docs/overview.md CHANGED
@@ -6,8 +6,9 @@ The AI Survey Simulator orchestrates AI-to-AI healthcare survey conversations so
6
 
7
  ## Architecture at a Glance
8
 
9
- - **Gradio Frontend (`frontend/`)**
10
- Presents the control panel, connects to the backend via WebSocket, and renders streaming messages.
 
11
 
12
  - **FastAPI Backend (`backend/api/`)**
13
  Hosts REST endpoints for conversation control, WebSocket endpoints for live streaming, and the conversation service that manages active sessions.
@@ -23,10 +24,13 @@ The AI Survey Simulator orchestrates AI-to-AI healthcare survey conversations so
23
 
24
  ## Runtime Flow
25
 
26
- 1. Frontend requests a new conversation (REST) or emits `start_conversation` over WebSocket.
27
- 2. Backend spawns a `ConversationManager`, which alternates surveyor/patient turns using the configured LLM.
28
- 3. Generated messages stream back to the frontend over the WebSocket connection.
29
- 4. Conversation statuses and errors are broadcast so the UI can show progress and failures.
 
 
 
30
 
31
  ## Repository Map (Key Paths)
32
 
@@ -42,7 +46,8 @@ backend/
42
  persona_system.py
43
  llm_client.py
44
  frontend/
45
- gradio_app.py
 
46
  websocket_manager.py
47
  data/
48
  patient_personas.yaml
 
6
 
7
  ## Architecture at a Glance
8
 
9
+ - **Web UI (`frontend/react_gradio_hybrid.py`)**
10
+ Serves a browser UI (React rendered in-page) and provides a small WebSocket bridge from the UI to the backend conversation WebSocket.
11
+ This is the primary demo/UI path (including analysis panels).
12
 
13
  - **FastAPI Backend (`backend/api/`)**
14
  Hosts REST endpoints for conversation control, WebSocket endpoints for live streaming, and the conversation service that manages active sessions.
 
24
 
25
  ## Runtime Flow
26
 
27
+ 1. Browser loads the Web UI and opens `ws://.../ws/frontend/{conversation_id}`.
28
+ 2. The Web UI server bridges that connection to the backend conversation socket at `/api/ws/conversation/{conversation_id}`.
29
+ 3. Backend spawns a `ConversationManager`, which alternates surveyor/patient turns using the configured LLM.
30
+ 4. Generated messages stream back to the browser over the bridged WebSocket connection.
31
+ 5. When the conversation completes, the backend runs a post-conversation analysis pass and returns:
32
+ - Bottom-up findings (emergent themes) with evidence pointers
33
+ - Top-down coding (care experience rubric + codebook categories) with evidence pointers
34
 
35
  ## Repository Map (Key Paths)
36
 
 
46
  persona_system.py
47
  llm_client.py
48
  frontend/
49
+ gradio_app.py # legacy/optional local UI
50
+ react_gradio_hybrid.py # primary demo UI (web)
51
  websocket_manager.py
52
  data/
53
  patient_personas.yaml
docs/roadmap.md CHANGED
@@ -1,28 +1,30 @@
1
  # Roadmap & Status
2
 
3
- _Last updated: 2025-11-05_
4
 
5
  ## Current Capabilities
6
 
7
- - Gradio UI driven by WebSocket streaming
 
 
 
 
8
  - FastAPI backend with conversation management service
9
  - Personas defined via YAML and loaded dynamically
10
  - Ollama integration with fallback to `/api/generate`
 
 
11
 
12
  ## Near-Term Priorities
13
 
14
- 1. **Persona Selection in UI**
15
- Allow users to choose surveyor/patient personas from dropdowns instead of hard-coded IDs.
16
 
17
- 2. **Hosted LLM Support**
18
- Add an HTTP client implementation for a cloud provider (Hugging Face Inference, OpenRouter, etc.) and expose configuration via `.env`.
19
 
20
  3. **Basic Test Coverage**
21
- Introduce smoke tests (mocked LLM responses) to prevent regressions in conversation flow.
22
-
23
- 4. **Export / Logging Enhancements**
24
- Persist conversation transcripts and expose a simple export (JSON/CSV) endpoint or UI action.
25
- - Future: add a “Download conversation metadata” action in the UI to export transcript + analysis output + provenance metadata (e.g., evidence pointers, prompt/schema versions).
26
 
27
  ## Longer-Term Ideas
28
 
 
1
  # Roadmap & Status
2
 
3
+ _Last updated: 2026-01-12_
4
 
5
  ## Current Capabilities
6
 
7
+ - Web UI (React-in-HTML) served by FastAPI
8
+ - Real-time conversation streaming over WebSockets
9
+ - Post-conversation analysis with evidence-backed outputs:
10
+ - Bottom-up findings (emergent themes)
11
+ - Top-down coding (care experience rubric + codebook categories)
12
  - FastAPI backend with conversation management service
13
  - Personas defined via YAML and loaded dynamically
14
  - Ollama integration with fallback to `/api/generate`
15
+ - Hosted LLM support via OpenRouter (`LLM_BACKEND=openrouter`)
16
+ - Hugging Face Spaces (Docker) deployment
17
 
18
  ## Near-Term Priorities
19
 
20
+ 1. **Configuration Panel (Personas + Prompts)**
21
+ Add a UI panel to select surveyor/patient personas and optionally tweak what the LLM receives (system prompts / parameters) without editing YAML.
22
 
23
+ 2. **Evidence Export (Metadata Download)**
24
+ Add a “Download conversation metadata” UI action to export transcript + analysis output + provenance metadata (e.g., evidence pointers, prompt/schema versions).
25
 
26
  3. **Basic Test Coverage**
27
+ Add smoke tests (mocked LLM responses) to prevent regressions in conversation flow and analysis schema parsing.
 
 
 
 
28
 
29
  ## Longer-Term Ideas
30