-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (29 loc) · 879 Bytes
/
Copy pathmain.py
File metadata and controls
36 lines (29 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Entrypoint for the ACLED Multi-Agent Analytics Chat.
Usage:
python main.py # launches Streamlit UI (default)
python main.py --api # launches FastAPI server instead
"""
import subprocess
import sys
from pathlib import Path
def start_streamlit() -> None:
"""Launch the Streamlit application."""
app_path = Path(__file__).parent / "app" / "app.py"
cmd = [
sys.executable, "-m", "streamlit", "run",
str(app_path),
"--server.port", "8501",
"--server.address", "0.0.0.0",
]
subprocess.run(cmd, check=True)
def start_api() -> None:
"""Launch the FastAPI server via uvicorn."""
import uvicorn
from app.api import create_app
uvicorn.run(create_app(), host="0.0.0.0", port=8000)
if __name__ == "__main__":
if "--api" in sys.argv:
start_api()
else:
start_streamlit()