Skip to main content
Glama
README.md
# Continuum

An autonomous AI showrunner for serialized vertical micro-drama. Give it a premise and a
recurring protagonist; it writes the script, storyboards the shots, generates the video with
Wan, and edits the cut together, producing **episode after episode with the same character,
world, and style**. The moat is an agent-maintained **Series Bible** that locks the
protagonist's canonical look and injects it into every episode, so continuity holds across
episodes rather than drifting shot to shot.

![Mei across both episodes of the demo series, generated by Continuum](docs/assets/consistency.png)

_The same protagonist across two episodes and four very different shots. Cross-episode identity, measured by a Qwen-VL critic, is 0.98 on this series._

Built for the Qwen Cloud Global AI Hackathon, Track 2 (AI Showrunner).

## How it works

A small team of agents hands work down a pipeline, orchestrated by the Showrunner:

1. **Showrunner** owns the Series Bible, locks the protagonist's appearance, and runs the series.
2. **Writer** (Qwen3) writes each episode and its dialogue, with the locked look injected.
3. **Storyboard** breaks the script into shots.
4. **Cinematographer** renders each shot on Wan (9:16 vertical).
5. **Critic** scores continuity and can re-render a shot through an optimizer loop.
6. **Editor** concatenates the shots and burns in subtitles with ffmpeg.

The agents are also exposed as MCP tools (`backend/mcp/`) so a Qwen-Agent can drive the studio.

## Stack

- **Brain:** Qwen3 (`qwen3-max`) for scripting and prompt optimization, via the DashScope
  OpenAI-compatible endpoint.
- **Video:** Wan on Qwen Cloud (`wan2.6-t2v`; image/reference models wired for the next pass).
- **Edit:** ffmpeg (concat, subtitle burn-in, 9:16 vertical).
- **Serving:** Python + FastAPI with Server-Sent Events for the live-agent view.

## Status

Working end to end. A real 2-episode series renders from a single premise, the protagonist
stays visually consistent across episodes (a Qwen-VL critic measures the cross-episode identity
match, 0.98 on the demo series), and the live control room streams each agent's work as it
happens. Tests pass (`tests/`). Next: routing character-bearing shots to Wan reference-to-video
(`wan2.6-r2v` / `wan2.7-i2v`), and packaging the Function Compute deployment.

## Setup

```bash
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
cp .env.example .env        # then paste your DASHSCOPE_API_KEY
```

`ffmpeg` must be on PATH.

## Run

Live control room (premise in, episodes out, streamed agent activity):

```bash
PYTHONPATH=. .venv/bin/uvicorn backend.server:app --port 8000
# open http://127.0.0.1:8000
```

Or from the CLI:

```bash
# one episode
PYTHONPATH=. .venv/bin/python -m backend.run_episode "<premise>"

# a multi-episode series with a recurring protagonist
PYTHONPATH=. .venv/bin/python -m backend.run_series "<premise>" "<name>" "<locked look>" 2
```

## Tests

```bash
for m in test_series_bible test_consistency test_critic_loop; do
  PYTHONPATH=. .venv/bin/python -m tests.$m
done
```

## License

MIT