Leon4gr45 commited on
Commit
a08ad5f
·
verified ·
1 Parent(s): 4c96e6f

Delete vrag/cli.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. vrag/cli.py +0 -107
vrag/cli.py DELETED
@@ -1,107 +0,0 @@
1
- """vrag command line. Pipeline order: ingest -> transcribe -> segment -> embed -> evalset -> experiments."""
2
-
3
- import typer
4
-
5
- app = typer.Typer(no_args_is_help=True, add_completion=False)
6
-
7
-
8
- @app.command()
9
- def download(n: int = 15):
10
- """Download the latest N channel uploads from YouTube (may be bot-blocked; prefer `ingest`)."""
11
- from . import download as d
12
- d.run(n)
13
-
14
-
15
- @app.command()
16
- def ingest():
17
- """Ingest local files from sams-videos/ (transcode to 480p, match to YouTube uploads)."""
18
- from . import ingest as i
19
- i.run()
20
-
21
-
22
- @app.command()
23
- def transcribe(engine: str = typer.Option(None, help="gemma (default, needs vLLM) or whisper"), force: bool = False):
24
- """Timestamped transcripts (creator captions if present, else Gemma 4 or Whisper)."""
25
- from . import transcribe as t
26
- from .config import ASR_ENGINE
27
- t.run(engine or ASR_ENGINE, force=force)
28
-
29
-
30
- @app.command()
31
- def switch_transcripts(engine: str):
32
- """Make ENGINE's transcripts active, keep segment boundaries, and re-embed the text + fused views."""
33
- from . import embed as e
34
- from . import segment as s
35
- from . import transcribe as t
36
- from .config import VIDEOS_DIR
37
-
38
- for vdir in sorted(p for p in VIDEOS_DIR.iterdir() if (p / "video.mp4").exists()):
39
- t.ensure_transcript(vdir, engine=engine, activate=True)
40
- s.retext()
41
- e.run(["text", "fused"], force=True)
42
-
43
-
44
- @app.command()
45
- def compare_transcripts(a: str = "whisper", b: str = "gemma"):
46
- """Word-level disagreement (WER of B against A) per video."""
47
- from . import transcribe as t
48
- for r in t.compare((a, b)):
49
- print(f"{r['wer']:.3f} {r['words']} {r['title']}")
50
-
51
-
52
- @app.command()
53
- def segment():
54
- """Cut ~30s segments and extract clip/audio/keyframe media."""
55
- from . import segment as s
56
- s.run()
57
-
58
-
59
- @app.command()
60
- def embed(view: list[str] = typer.Option(None, help="Subset of views to (re)build"), force: bool = False):
61
- """Embed every segment under every view with EmbeddingGemma 2."""
62
- from . import embed as e
63
- e.run(view, force=force)
64
-
65
-
66
- @app.command()
67
- def evalset(per_video: int = 8):
68
- """Generate spoken + visual eval queries with Gemma 4 (needs serve/serve.sh running)."""
69
- from . import evalset as ev
70
- ev.run(per_video)
71
-
72
-
73
- @app.command()
74
- def experiments():
75
- """Run the view x MRL-dim retrieval grid over the eval set."""
76
- from . import experiments as ex
77
- ex.run()
78
-
79
-
80
- @app.command()
81
- def build():
82
- """ingest -> transcribe -> segment -> embed."""
83
- ingest()
84
- transcribe()
85
- segment()
86
- embed()
87
-
88
-
89
- @app.command()
90
- def ask(question: str, view: str = "fused", dim: int = 768, k: int = 4, audio: bool = False):
91
- """Ask a question over the corpus from the terminal."""
92
- from . import rag
93
- res = rag.answer(question, view=view, dim=dim, k=k, use_audio=audio)
94
- print(res["answer"])
95
- for n, c in enumerate(res["clips"], 1):
96
- print(f"[{n}] {c['title']} @ {rag.fmt_ts(c['start'])} (score {c['score']:.3f})")
97
-
98
-
99
- @app.command()
100
- def api(host: str = "127.0.0.1", port: int = 8000, reload: bool = False):
101
- """Serve the FastAPI backend for the web UI."""
102
- import uvicorn
103
- uvicorn.run("vrag.api:app", host=host, port=port, reload=reload)
104
-
105
-
106
- if __name__ == "__main__":
107
- app()