# tencent/weviscut architecture

> Architecture diagram of the GitHub repository tencent/weviscut, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencent/weviscut
- Repository: https://github.com/tencent/weviscut

## Overview

WeVisCut turns an article or narration script into an edited multi-minute video through a policy-driven tool loop: the inference orchestrator reads editing state, chooses one action, dispatches a tool, and continues until stitching. The Studio serves that workflow and adds live monitoring, timeline editing, chat revision, rerendering, and rollback. A separate data-construction package records training trajectories and provides campaign operations. The README documents these capabilities; some data-pipeline and Studio internals were not sampled, so their unverified links are omitted.

Main entry points: [`server/infer_graph.py`](https://github.com/tencent/weviscut/blob/main/server/infer_graph.py) (Policy Orchestrator), [`studio/app.py`](https://github.com/tencent/weviscut/blob/main/studio/app.py) (Studio HTTP App), [`pipeline/llm.py`](https://github.com/tencent/weviscut/blob/main/pipeline/llm.py) (LLM Client), [`studio/newvis0907/router.py`](https://github.com/tencent/weviscut/blob/main/studio/newvis0907/router.py) (Edit Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Inference Runtime"]
  node_infer["Policy Orchestrator<br/>[infer_graph.py]"]
  node_state["Editing State<br/>[state.py]"]
  node_policy["9B Model<br/>[model_loader.py]"]
  node_llm["LLM Client<br/>[llm.py]"]
end

subgraph group_editing["Editing Tools"]
  node_segment["Article Segmenter<br/>[segment_article.py]"]
  node_planning["Shot Planner<br/>[plan_shots.py]"]
  node_audio["Narration TTS<br/>[generate_audio.py]"]
  node_visual["Footage Retrieval<br/>[retrieve_visual.py]"]
  node_decoration["Template Decoration<br/>[decorate_shot.py]"]
  node_music["BGM Search<br/>[music_search.py]"]
  node_compose["Shot Composer"]
  node_judge["Quality Judges"]
  node_reflect["Repair Reflection<br/>[self_reflect.py]"]
  node_stitch["Video Stitcher<br/>[stitch_video.py]"]
end

subgraph group_studio["Studio"]
  node_studio_app["Studio HTTP App<br/>[app.py]"]
  node_studio_model["Model Access<br/>[model_client.py]"]
  node_studio_config["Runtime Config<br/>[config.py]"]
  node_studio_ops["Edit Operations<br/>[operations.py]"]
  node_chat_planner["Chat Edit Planner<br/>[chat_planner.py]"]
  node_edit_router["Edit Router<br/>[router.py]"]
end

subgraph group_data["Trajectory Data"]
  node_bridge["Pipeline Bridge<br/>[pipeline_bridge.py]"]
  node_data_model["Data Model Client<br/>[model_client.py]"]
  node_recorder[("Trajectory Recorder<br/>[recorder.py]")]
  node_campaign_ui["Campaign Control<br/>[server.py]"]
end

node_user(("Editor / User"))
node_article["Article / Script"]

node_user -->|"starts / edits"| node_studio_app
node_article -->|"provides input"| node_infer
node_infer -->|"updates state"| node_state
node_infer -->|"requests decision"| node_policy
node_infer -->|"dispatches tool"| node_segment
node_infer -->|"dispatches tool"| node_planning
node_infer -->|"dispatches tool"| node_audio
node_infer -->|"dispatches tool"| node_visual
node_infer -->|"dispatches tool"| node_decoration
node_infer -->|"dispatches tool"| node_music
node_infer -->|"dispatches tool"| node_compose
node_infer -->|"dispatches tool"| node_judge
node_infer -->|"dispatches tool"| node_reflect
node_infer -->|"dispatches tool"| node_stitch
node_segment -->|"calls"| node_llm
node_planning -->|"calls"| node_llm
node_visual -->|"calls"| node_llm
node_reflect -->|"calls"| node_llm
node_studio_app -->|"uses model access"| node_studio_model
node_studio_app -->|"uses configuration"| node_studio_config
node_studio_app -->|"routes editing"| node_edit_router
node_edit_router -->|"calls operations"| node_studio_ops
node_edit_router -->|"plans chat edits"| node_chat_planner
node_chat_planner -->|"uses operations"| node_studio_ops
node_bridge -->|"loads inference loop"| node_infer
node_data_model -->|"records trajectories"| node_recorder
node_campaign_ui -.->|"manages campaign data"| node_recorder

click node_infer "https://github.com/tencent/weviscut/blob/main/server/infer_graph.py"
click node_state "https://github.com/tencent/weviscut/blob/main/pipeline/state.py"
click node_policy "https://github.com/tencent/weviscut/blob/main/server/model_loader.py"
click node_llm "https://github.com/tencent/weviscut/blob/main/pipeline/llm.py"
click node_segment "https://github.com/tencent/weviscut/blob/main/pipeline/tools/segment_article.py"
click node_planning "https://github.com/tencent/weviscut/blob/main/pipeline/tools/plan_shots.py"
click node_audio "https://github.com/tencent/weviscut/blob/main/pipeline/tools/generate_audio.py"
click node_visual "https://github.com/tencent/weviscut/blob/main/pipeline/tools/retrieve_visual.py"
click node_decoration "https://github.com/tencent/weviscut/blob/main/pipeline/tools/decorate_shot.py"
click node_music "https://github.com/tencent/weviscut/blob/main/pipeline/tools/music_search.py"
click node_compose "https://github.com/tencent/weviscut/blob/main/pipeline/tools/timeline_compose.py"
click node_judge "https://github.com/tencent/weviscut/blob/main/pipeline/tools/vlm_render_judge.py"
click node_reflect "https://github.com/tencent/weviscut/blob/main/pipeline/tools/self_reflect.py"
click node_stitch "https://github.com/tencent/weviscut/blob/main/pipeline/tools/stitch_video.py"
click node_studio_app "https://github.com/tencent/weviscut/blob/main/studio/app.py"
click node_studio_model "https://github.com/tencent/weviscut/blob/main/studio/model_client.py"
click node_studio_config "https://github.com/tencent/weviscut/blob/main/studio/config.py"
click node_studio_ops "https://github.com/tencent/weviscut/blob/main/studio/newvis0907/operations.py"
click node_chat_planner "https://github.com/tencent/weviscut/blob/main/studio/newvis0907/chat_planner.py"
click node_edit_router "https://github.com/tencent/weviscut/blob/main/studio/newvis0907/router.py"
click node_bridge "https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/pipeline_bridge.py"
click node_data_model "https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/model_client.py"
click node_recorder "https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/recorder.py"
click node_campaign_ui "https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/webui/server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_infer,node_state,node_policy,node_llm,node_user toneBlue
class node_segment,node_planning,node_audio,node_visual,node_decoration,node_music,node_compose,node_judge,node_reflect,node_stitch toneAmber
class node_studio_app,node_studio_model,node_studio_config,node_studio_ops,node_chat_planner,node_edit_router toneMint
class node_bridge,node_data_model,node_recorder,node_campaign_ui toneRose
class node_article toneIndigo
```

## Components

### Inference Runtime

- [Policy Orchestrator](https://github.com/tencent/weviscut/blob/main/server/infer_graph.py): `server/infer_graph.py`
- [Editing State](https://github.com/tencent/weviscut/blob/main/pipeline/state.py): `pipeline/state.py`
- [9B Model](https://github.com/tencent/weviscut/blob/main/server/model_loader.py): `server/model_loader.py`
- [LLM Client](https://github.com/tencent/weviscut/blob/main/pipeline/llm.py): `pipeline/llm.py`

### Editing Tools

- [Article Segmenter](https://github.com/tencent/weviscut/blob/main/pipeline/tools/segment_article.py): `pipeline/tools/segment_article.py`
- [Shot Planner](https://github.com/tencent/weviscut/blob/main/pipeline/tools/plan_shots.py): `pipeline/tools/plan_shots.py`
- [Narration TTS](https://github.com/tencent/weviscut/blob/main/pipeline/tools/generate_audio.py): `pipeline/tools/generate_audio.py`
- [Footage Retrieval](https://github.com/tencent/weviscut/blob/main/pipeline/tools/retrieve_visual.py): `pipeline/tools/retrieve_visual.py`
- [Template Decoration](https://github.com/tencent/weviscut/blob/main/pipeline/tools/decorate_shot.py): `pipeline/tools/decorate_shot.py`
- [BGM Search](https://github.com/tencent/weviscut/blob/main/pipeline/tools/music_search.py): `pipeline/tools/music_search.py`
- [Shot Composer](https://github.com/tencent/weviscut/blob/main/pipeline/tools/timeline_compose.py): `pipeline/tools/timeline_compose.py`
- [Quality Judges](https://github.com/tencent/weviscut/blob/main/pipeline/tools/vlm_render_judge.py): `pipeline/tools/vlm_render_judge.py`
- [Repair Reflection](https://github.com/tencent/weviscut/blob/main/pipeline/tools/self_reflect.py): `pipeline/tools/self_reflect.py`
- [Video Stitcher](https://github.com/tencent/weviscut/blob/main/pipeline/tools/stitch_video.py): `pipeline/tools/stitch_video.py`

### Studio

- [Studio HTTP App](https://github.com/tencent/weviscut/blob/main/studio/app.py): `studio/app.py`
- [Model Access](https://github.com/tencent/weviscut/blob/main/studio/model_client.py): `studio/model_client.py`
- [Runtime Config](https://github.com/tencent/weviscut/blob/main/studio/config.py): `studio/config.py`
- [Edit Operations](https://github.com/tencent/weviscut/blob/main/studio/newvis0907/operations.py): `studio/newvis0907/operations.py`
- [Chat Edit Planner](https://github.com/tencent/weviscut/blob/main/studio/newvis0907/chat_planner.py): `studio/newvis0907/chat_planner.py`
- [Edit Router](https://github.com/tencent/weviscut/blob/main/studio/newvis0907/router.py): `studio/newvis0907/router.py`

### Trajectory Data

- [Pipeline Bridge](https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/pipeline_bridge.py): `data_construct_pipeline/src/longvideo_polar/pipeline_bridge.py`
- [Data Model Client](https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/model_client.py): `data_construct_pipeline/src/longvideo_polar/model_client.py`
- [Trajectory Recorder](https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/recorder.py): `data_construct_pipeline/src/longvideo_polar/recorder.py`
- [Campaign Control](https://github.com/tencent/weviscut/blob/main/data_construct_pipeline/src/longvideo_polar/webui/server.py): `data_construct_pipeline/src/longvideo_polar/webui/server.py`

### Other components

- **Editor / User**
- **Article / Script**

## Connections

- Editor / User → Studio HTTP App: starts / edits (evidence: `studio/app.py`)
- Article / Script → Policy Orchestrator: provides input (evidence: `README.md`)
- Policy Orchestrator → Editing State: updates state (evidence: `server/infer_graph.py`)
- Policy Orchestrator → 9B Model: requests decision (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Article Segmenter: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Shot Planner: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Narration TTS: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Footage Retrieval: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Template Decoration: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → BGM Search: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Shot Composer: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Quality Judges: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Repair Reflection: dispatches tool (evidence: `server/infer_graph.py`)
- Policy Orchestrator → Video Stitcher: dispatches tool (evidence: `server/infer_graph.py`)
- Article Segmenter → LLM Client: calls (evidence: `pipeline/tools/segment_article.py`)
- Shot Planner → LLM Client: calls (evidence: `pipeline/tools/plan_shots.py`)
- Footage Retrieval → LLM Client: calls (evidence: `pipeline/tools/retrieve_visual.py`)
- Repair Reflection → LLM Client: calls (evidence: `pipeline/tools/self_reflect.py`)
- Studio HTTP App → Model Access: uses model access (evidence: `studio/app.py`)
- Studio HTTP App → Runtime Config: uses configuration (evidence: `studio/app.py`)
- Studio HTTP App → Edit Router: routes editing (evidence: `studio/app.py`)
- Edit Router → Edit Operations: calls operations (evidence: `studio/newvis0907/router.py`)
- Edit Router → Chat Edit Planner: plans chat edits (evidence: `studio/newvis0907/router.py`)
- Chat Edit Planner → Edit Operations: uses operations (evidence: `studio/newvis0907/chat_planner.py`)
- Pipeline Bridge → Policy Orchestrator: loads inference loop (evidence: `data_construct_pipeline/src/longvideo_polar/pipeline_bridge.py`)
- Data Model Client → Trajectory Recorder: records trajectories (evidence: `data_construct_pipeline/src/longvideo_polar/model_client.py`)
- Campaign Control → Trajectory Recorder: manages campaign data
