-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
38 lines (29 loc) · 1.24 KB
/
Copy pathrun.py
File metadata and controls
38 lines (29 loc) · 1.24 KB
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
37
38
"""Run Talk-to-DB: python run.py
First run bootstraps config.yaml from config.example.yaml if it's missing.
TTDB_HOST / TTDB_PORT environment variables override config (used by Docker).
"""
import os
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT)) # allow `python run.py` from anywhere
CFG = ROOT / "config.yaml"
EXAMPLE = ROOT / "config.example.yaml"
def main() -> None:
if not CFG.exists() and EXAMPLE.exists():
shutil.copy(EXAMPLE, CFG)
print("• created config.yaml from config.example.yaml — add your Anthropic API key there.")
import uvicorn
from app.config import get_config
cfg = get_config()
host = os.environ.get("TTDB_HOST", cfg.server.host)
port = int(os.environ.get("TTDB_PORT", cfg.server.port))
if not cfg.resolved_api_key:
print("• no Anthropic API key yet — the UI and /api/schema will work,")
print(" but /api/ask will return 503 until you set anthropic.api_key")
print(" in config.yaml or export ANTHROPIC_API_KEY.")
print(f"\n Talk-to-DB v3 → http://{host}:{port}\n")
uvicorn.run("app.main:app", host=host, port=port, log_level="info")
if __name__ == "__main__":
main()