Commit ·
b054d53
1
Parent(s): a1e2ed0
docs: add rendered architecture diagrams
Browse files- README.md +5 -71
- assets/architecture-agent-loop.mmd +22 -0
- assets/architecture-agent-loop.png +0 -0
- assets/architecture-runtime-fallbacks.mmd +30 -0
- assets/architecture-runtime-fallbacks.png +0 -0
- assets/architecture-system-flow.mmd +31 -0
- assets/architecture-system-flow.png +0 -0
- assets/puppeteer-config.json +3 -0
README.md
CHANGED
|
@@ -42,85 +42,19 @@ AI Puppet Theater is a Hugging Face Gradio Space for the Build Small Hackathon,
|
|
| 42 |
|
| 43 |
## Architecture
|
| 44 |
|
|
|
|
|
|
|
| 45 |
### System Flow
|
| 46 |
|
| 47 |
-
|
| 48 |
-
flowchart TD
|
| 49 |
-
A["User premise and audience actions"] --> B["Show Builder"]
|
| 50 |
-
B --> C["Director Agent"]
|
| 51 |
-
C --> D["Actor Agents"]
|
| 52 |
-
D --> E["Theatrical Tools"]
|
| 53 |
-
E --> F["Stage Renderer and TTS"]
|
| 54 |
-
F --> G["Transcript and Puppet Stage"]
|
| 55 |
-
|
| 56 |
-
C --> H["Behind the Curtain Trace"]
|
| 57 |
-
D --> H
|
| 58 |
-
E --> H
|
| 59 |
-
F --> H
|
| 60 |
-
|
| 61 |
-
R["Runtime and fallback layer"] --> C
|
| 62 |
-
R --> D
|
| 63 |
-
R --> F
|
| 64 |
-
R --> H
|
| 65 |
-
|
| 66 |
-
R1["HF API<br/>Qwen/Qwen3-4B-Instruct-2507:nscale"] --> R
|
| 67 |
-
R2["ZeroGPU or local OpenBMB path"] --> R
|
| 68 |
-
R3["Deterministic fallback"] --> R
|
| 69 |
-
```
|
| 70 |
|
| 71 |
### Agent Loop
|
| 72 |
|
| 73 |
-
|
| 74 |
-
sequenceDiagram
|
| 75 |
-
participant U as Audience
|
| 76 |
-
participant S as Gradio Stage
|
| 77 |
-
participant D as Director Agent
|
| 78 |
-
participant A as Actor Agent
|
| 79 |
-
participant T as Theatrical Tools
|
| 80 |
-
participant L as Trace Log
|
| 81 |
-
|
| 82 |
-
U->>S: Create show or interrupt
|
| 83 |
-
S->>D: Current session state
|
| 84 |
-
D->>D: Choose phase, speaker, beat, effect
|
| 85 |
-
D->>A: Beat instruction
|
| 86 |
-
A->>A: Update intent, mood, memory
|
| 87 |
-
A->>T: Optional tool request
|
| 88 |
-
T-->>A: Tool result
|
| 89 |
-
A-->>S: Line, emotion, gesture, effect
|
| 90 |
-
S-->>U: Render puppet beat and voice
|
| 91 |
-
D-->>L: Director decision
|
| 92 |
-
A-->>L: Actor response
|
| 93 |
-
T-->>L: Tool result
|
| 94 |
-
S-->>L: Audience and render events
|
| 95 |
-
```
|
| 96 |
|
| 97 |
### Runtime and Fallbacks
|
| 98 |
|
| 99 |
-
|
| 100 |
-
flowchart LR
|
| 101 |
-
M["Selected mode"] --> H{"HF API?"}
|
| 102 |
-
M --> O{"OpenBMB local?"}
|
| 103 |
-
M --> D["Deterministic mode"]
|
| 104 |
-
|
| 105 |
-
H -->|HF_TOKEN and model available| Q["Qwen/Qwen3-4B-Instruct-2507:nscale"]
|
| 106 |
-
H -->|missing token, timeout, invalid JSON| F["Deterministic fallback"]
|
| 107 |
-
|
| 108 |
-
O -->|USE_ZEROGPU=true and spaces available| Z["ZeroGPU generation"]
|
| 109 |
-
O -->|local CPU or unavailable GPU| L["Local Transformers attempt"]
|
| 110 |
-
O -->|load failure or invalid output| F
|
| 111 |
-
Z -->|failure| F
|
| 112 |
-
L -->|failure| F
|
| 113 |
-
|
| 114 |
-
Q --> V["Validate structured output"]
|
| 115 |
-
Z --> V
|
| 116 |
-
L --> V
|
| 117 |
-
D --> V
|
| 118 |
-
F --> V
|
| 119 |
-
|
| 120 |
-
V -->|valid| R["Stage beat"]
|
| 121 |
-
V -->|invalid after repair| F
|
| 122 |
-
R --> T["Sanitized trace export"]
|
| 123 |
-
```
|
| 124 |
|
| 125 |
## Agent Architecture
|
| 126 |
|
|
|
|
| 42 |
|
| 43 |
## Architecture
|
| 44 |
|
| 45 |
+
The diagrams below are rendered PNGs from Mermaid sources in `assets/` so they display correctly on Hugging Face Spaces.
|
| 46 |
+
|
| 47 |
### System Flow
|
| 48 |
|
| 49 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
### Agent Loop
|
| 52 |
|
| 53 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
### Runtime and Fallbacks
|
| 56 |
|
| 57 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
## Agent Architecture
|
| 60 |
|
assets/architecture-agent-loop.mmd
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%{init: {"theme": "base", "themeVariables": {"background": "#fffdf7", "primaryTextColor": "#222222", "actorBkg": "#fff2b8", "actorBorder": "#2c2c2c", "actorTextColor": "#222222", "activationBkgColor": "#d9f3df", "activationBorderColor": "#2c2c2c", "signalColor": "#565656", "signalTextColor": "#222222", "labelBoxBkgColor": "#dcecff", "labelBoxBorderColor": "#2c2c2c", "loopTextColor": "#222222", "fontFamily": "Arial, sans-serif"}}}%%
|
| 2 |
+
sequenceDiagram
|
| 3 |
+
participant U as Audience
|
| 4 |
+
participant S as Gradio Stage
|
| 5 |
+
participant D as Director Agent
|
| 6 |
+
participant A as Actor Agent
|
| 7 |
+
participant T as Theatrical Tools
|
| 8 |
+
participant L as Trace Log
|
| 9 |
+
|
| 10 |
+
U->>S: Create show or interrupt
|
| 11 |
+
S->>D: Current session state
|
| 12 |
+
D->>D: Choose phase, speaker, beat, effect
|
| 13 |
+
D->>A: Beat instruction
|
| 14 |
+
A->>A: Update intent, mood, memory
|
| 15 |
+
A->>T: Optional tool request
|
| 16 |
+
T-->>A: Tool result
|
| 17 |
+
A-->>S: Line, emotion, gesture, effect
|
| 18 |
+
S-->>U: Render puppet beat and voice
|
| 19 |
+
D-->>L: Director decision
|
| 20 |
+
A-->>L: Actor response
|
| 21 |
+
T-->>L: Tool result
|
| 22 |
+
S-->>L: Audience and render events
|
assets/architecture-agent-loop.png
ADDED
|
assets/architecture-runtime-fallbacks.mmd
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%{init: {"theme": "base", "themeVariables": {"background": "#fffdf7", "primaryTextColor": "#222222", "fontFamily": "Arial, sans-serif", "lineColor": "#565656"}}}%%
|
| 2 |
+
flowchart TD
|
| 3 |
+
M["Selected backend mode"] --> API["HF API<br/>Qwen/Qwen3-4B"]
|
| 4 |
+
M --> Local["ZeroGPU or local<br/>OpenBMB"]
|
| 5 |
+
M --> D["Deterministic mode<br/>no token required"]
|
| 6 |
+
|
| 7 |
+
API --> V["Validate structured output"]
|
| 8 |
+
Local --> V
|
| 9 |
+
D --> V
|
| 10 |
+
|
| 11 |
+
API -->|"missing token<br/>timeout<br/>invalid JSON"| F["Deterministic fallback"]
|
| 12 |
+
Local -->|"GPU unavailable<br/>load failure<br/>invalid output"| F
|
| 13 |
+
V -->|"invalid after repair"| F
|
| 14 |
+
F --> V
|
| 15 |
+
|
| 16 |
+
V -->|"valid"| R["Stage beat"]
|
| 17 |
+
R --> T["Sanitized trace export"]
|
| 18 |
+
|
| 19 |
+
classDef stage fill:#fff2b8,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 20 |
+
classDef model fill:#dcecff,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 21 |
+
classDef runtime fill:#ece8ff,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 22 |
+
classDef fallback fill:#fbdada,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 23 |
+
classDef validate fill:#d9f3df,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 24 |
+
classDef trace fill:#f9e1ee,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 25 |
+
class M runtime;
|
| 26 |
+
class API,Local model;
|
| 27 |
+
class D,F fallback;
|
| 28 |
+
class V validate;
|
| 29 |
+
class R stage;
|
| 30 |
+
class T trace;
|
assets/architecture-runtime-fallbacks.png
ADDED
|
assets/architecture-system-flow.mmd
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%{init: {"theme": "base", "themeVariables": {"background": "#fffdf7", "primaryTextColor": "#222222", "fontFamily": "Arial, sans-serif", "lineColor": "#565656"}}}%%
|
| 2 |
+
flowchart TD
|
| 3 |
+
U["User premise<br/>+ audience actions"] --> B["Show Builder"]
|
| 4 |
+
B --> D["Director Agent"]
|
| 5 |
+
D --> A["Actor Agents"]
|
| 6 |
+
A --> Tools["Theatrical Tools"]
|
| 7 |
+
Tools --> Stage["Stage Renderer<br/>+ TTS"]
|
| 8 |
+
Stage --> Output["Transcript<br/>+ Puppet Stage"]
|
| 9 |
+
|
| 10 |
+
D --> Trace["Behind the Curtain Trace"]
|
| 11 |
+
A --> Trace
|
| 12 |
+
Tools --> Trace
|
| 13 |
+
Stage --> Trace
|
| 14 |
+
|
| 15 |
+
HF["HF API<br/>Qwen/Qwen3-4B-Instruct-2507:nscale"] --> Runtime["Runtime + fallback layer"]
|
| 16 |
+
ZG["ZeroGPU or local<br/>OpenBMB path"] --> Runtime
|
| 17 |
+
Fallback["Deterministic<br/>fallback"] --> Runtime
|
| 18 |
+
Runtime --> D
|
| 19 |
+
Runtime --> A
|
| 20 |
+
|
| 21 |
+
classDef stage fill:#fff2b8,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 22 |
+
classDef agent fill:#d9f3df,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 23 |
+
classDef tool fill:#dcecff,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 24 |
+
classDef trace fill:#f9e1ee,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 25 |
+
classDef runtime fill:#ece8ff,stroke:#2c2c2c,color:#222222,stroke-width:2px;
|
| 26 |
+
class U,B,Stage,Output stage;
|
| 27 |
+
class D,A agent;
|
| 28 |
+
class Tools tool;
|
| 29 |
+
class Trace trace;
|
| 30 |
+
class Runtime,HF,ZG runtime;
|
| 31 |
+
class Fallback runtime;
|
assets/architecture-system-flow.png
ADDED
|
assets/puppeteer-config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"args": ["--no-sandbox", "--disable-setuid-sandbox"]
|
| 3 |
+
}
|