Python 64.6%
TypeScript 33.7%
CSS 0.8%
1"""CLI: ingest course material.23 python -m scripts.ingest --course imm1033 --site ../content/imm1033/dist # generated website4 python -m scripts.ingest --course imm1033 --path ../content/imm1033/ # pdf/docx/pptx/md5"""67from __future__ import annotations89import argparse10import asyncio11from pathlib import Path1213from app.db import init_db14from app.rag import retriever15from app.rag.ingest import ingest_file, ingest_site161718async def main() -> None:19 ap = argparse.ArgumentParser()20 ap.add_argument("--course", required=True)21 ap.add_argument("--site", help="dist/<course> directory of the generated course website")22 ap.add_argument("--path", help="directory of pdf/docx/pptx/md files")23 ap.add_argument("--visibility", default="students", choices=["students", "professor_only"])24 args = ap.parse_args()25 await init_db()26 total = 027 if args.site:28 total += await ingest_site(args.course, Path(args.site), args.visibility)29 if args.path:30 for p in sorted(Path(args.path).rglob("*")):31 if p.suffix.lower() in {".pdf", ".docx", ".pptx", ".md", ".txt"} and p.is_file():32 n = await ingest_file(args.course, p, args.visibility)33 print(f" {p.name}: {n} chunks")34 total += n35 n = await retriever.rebuild_index()36 print(f"Ingested {total} chunks; index now holds {n} chunks.")373839if __name__ == "__main__":40 asyncio.run(main())41