|
23 | 23 | [bold cyan]MetaScreener {VERSION}[/bold cyan] |
24 | 24 | [dim]AI-assisted systematic review tool[/dim] |
25 | 25 | [dim]Hierarchical Consensus Network (HCN) with 4 open-source LLMs[/dim] |
26 | | -[dim]Tip: Enter [bold]7[/bold] or [bold]/ui[/bold] to open the web dashboard[/dim] |
| 26 | +[dim]Tip: Enter [bold]7[/bold] or [bold]/serve[/bold] to open the web UI[/dim] |
27 | 27 | """ |
28 | 28 |
|
29 | 29 | # Numbered menu items: (number, slash_cmd, description, handler_name) |
|
34 | 34 | ("/assess-rob", "Assess risk of bias (RoB 2 / ROBINS-I / QUADAS-2)", "_handle_assess_rob"), |
35 | 35 | ("/evaluate", "Evaluate screening performance", "_handle_evaluate"), |
36 | 36 | ("/export", "Export results (CSV, JSON, Excel, RIS)", "_handle_export"), |
37 | | - ("/ui", "Open web dashboard (Streamlit)", "_handle_ui"), |
| 37 | + ("/serve", "Open web UI (http://localhost:8000)", "_handle_serve"), |
38 | 38 | ] |
39 | 39 |
|
40 | 40 | COMMANDS: dict[str, str] = { |
|
44 | 44 | "/assess-rob": "Assess risk of bias (RoB 2 / ROBINS-I / QUADAS-2)", |
45 | 45 | "/evaluate": "Evaluate screening performance and compute metrics", |
46 | 46 | "/export": "Export results (CSV, JSON, Excel, RIS)", |
47 | | - "/ui": "Open web dashboard (Streamlit)", |
| 47 | + "/serve": "Launch web server and open browser (http://localhost:8000)", |
48 | 48 | "/help": "Show this help message", |
49 | 49 | "/status": "Show current working files and project state", |
50 | 50 | "/quit": "Exit MetaScreener", |
|
58 | 58 | "/assess-rob": "_handle_assess_rob", |
59 | 59 | "/evaluate": "_handle_evaluate", |
60 | 60 | "/export": "_handle_export", |
61 | | - "/ui": "_handle_ui", |
| 61 | + "/serve": "_handle_serve", |
62 | 62 | } |
63 | 63 |
|
64 | 64 |
|
@@ -571,28 +571,32 @@ def _handle_export() -> None: |
571 | 571 |
|
572 | 572 |
|
573 | 573 | # --------------------------------------------------------------------------- |
574 | | -# /ui — Launch Streamlit Web Dashboard |
| 574 | +# /serve — Launch FastAPI Web UI |
575 | 575 | # --------------------------------------------------------------------------- |
576 | | -def _handle_ui() -> None: |
577 | | - """Launch the Streamlit web dashboard in the user's browser.""" |
578 | | - app_path = Path(__file__).parent.parent / "app" / "main.py" |
579 | | - if not app_path.exists(): |
580 | | - console.print("[red]Streamlit app not found. Reinstall MetaScreener.[/red]") |
581 | | - return |
| 576 | +def _handle_serve() -> None: |
| 577 | + """Launch the FastAPI web server and open the browser.""" |
| 578 | + import webbrowser # noqa: PLC0415 |
| 579 | + |
| 580 | + port = 8000 |
| 581 | + url = f"http://localhost:{port}" |
582 | 582 |
|
583 | 583 | console.print( |
584 | | - "[cyan]Launching Streamlit dashboard...[/cyan]\n" |
585 | | - "[dim]Opening http://localhost:8501 in your browser.[/dim]\n" |
| 584 | + f"[cyan]Launching MetaScreener web UI...[/cyan]\n" |
| 585 | + f"[dim]Opening {url} in your browser.[/dim]\n" |
586 | 586 | "[dim]Press Ctrl+C to stop the server and return here.[/dim]" |
587 | 587 | ) |
588 | 588 | try: |
| 589 | + webbrowser.open(url) |
589 | 590 | subprocess.run( |
590 | | - [sys.executable, "-m", "streamlit", "run", str(app_path), |
591 | | - "--server.headless=true"], |
| 591 | + [sys.executable, "-m", "uvicorn", |
| 592 | + "metascreener.api.main:create_app", |
| 593 | + "--factory", |
| 594 | + "--host", "127.0.0.1", |
| 595 | + "--port", str(port)], |
592 | 596 | check=False, |
593 | 597 | ) |
594 | 598 | except KeyboardInterrupt: |
595 | | - console.print("\n[dim]Streamlit server stopped.[/dim]") |
| 599 | + console.print("\n[dim]Web server stopped.[/dim]") |
596 | 600 |
|
597 | 601 |
|
598 | 602 | # --------------------------------------------------------------------------- |
|
0 commit comments