KSvend commited on
Commit
4f52b3e
·
1 Parent(s): 9f90242

feat: add /api/aoi-advice endpoint and startup logging

Browse files
Files changed (1) hide show
  1. app/main.py +11 -0
app/main.py CHANGED
@@ -13,6 +13,8 @@ from app.indicators import registry
13
  from app.api.jobs import router as jobs_router, init_router as init_jobs
14
  from app.api.indicators_api import router as indicators_router
15
  from app.api.auth import router as auth_router, get_current_user
 
 
16
 
17
  # Resolve paths relative to this file so they work regardless of cwd
18
  _HERE = pathlib.Path(__file__).resolve().parent
@@ -30,6 +32,11 @@ def create_app(db_path: str = "aperture.db", run_worker: bool = False) -> FastAP
30
  print(f"[Aperture] CDSE credentials configured (client_id={OPENEO_CLIENT_ID[:8]}...)")
31
  else:
32
  print("[Aperture] WARNING: CDSE credentials NOT configured — EO indicators will fail")
 
 
 
 
 
33
  print(f"[Aperture] SPACE_ID={os.environ.get('SPACE_ID', '<not set>')}")
34
  await db.init()
35
  worker_task = None
@@ -56,6 +63,10 @@ def create_app(db_path: str = "aperture.db", run_worker: bool = False) -> FastAP
56
  app.include_router(indicators_router)
57
  app.include_router(auth_router)
58
 
 
 
 
 
59
  @app.get("/health")
60
  async def health():
61
  return {"status": "ok"}
 
13
  from app.api.jobs import router as jobs_router, init_router as init_jobs
14
  from app.api.indicators_api import router as indicators_router
15
  from app.api.auth import router as auth_router, get_current_user
16
+ from app.advisor import get_aoi_advice
17
+ from app.models import AoiAdviceRequest
18
 
19
  # Resolve paths relative to this file so they work regardless of cwd
20
  _HERE = pathlib.Path(__file__).resolve().parent
 
32
  print(f"[Aperture] CDSE credentials configured (client_id={OPENEO_CLIENT_ID[:8]}...)")
33
  else:
34
  print("[Aperture] WARNING: CDSE credentials NOT configured — EO indicators will fail")
35
+ from app.config import ANTHROPIC_API_KEY
36
+ if ANTHROPIC_API_KEY:
37
+ print("[Aperture] Anthropic API key configured (AOI advisor enabled)")
38
+ else:
39
+ print("[Aperture] Anthropic API key not set — AOI advisor disabled")
40
  print(f"[Aperture] SPACE_ID={os.environ.get('SPACE_ID', '<not set>')}")
41
  await db.init()
42
  worker_task = None
 
63
  app.include_router(indicators_router)
64
  app.include_router(auth_router)
65
 
66
+ @app.post("/api/aoi-advice")
67
+ async def aoi_advice(request: AoiAdviceRequest, email: str = Depends(get_current_user)):
68
+ return await get_aoi_advice(request.bbox)
69
+
70
  @app.get("/health")
71
  async def health():
72
  return {"status": "ok"}