Rachit-Mangawa commited on
Commit
2ce8902
·
1 Parent(s): 83674d5

fix(infra): upgrade OpenRouter hierarchy and sanitize health check schema

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -13,7 +13,7 @@ from dotenv import load_dotenv
13
  load_dotenv()
14
 
15
  # Vera Engine - Autonomous Local-First Build
16
- # Priority: Ollama (SmollM2-1.7B) -> Fallback: OpenRouter
17
  logging.basicConfig(level=logging.INFO)
18
  logger = logging.getLogger("VeraEngine")
19
 
@@ -162,6 +162,21 @@ JSON: {{"body": "...", "cta": "...", "rationale": "..."}}"""
162
  res["body"] = prune_message(res.get("body", ""))
163
  return res
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  @app.get("/v1/healthz")
166
  async def healthz():
167
  async with httpx.AsyncClient() as client:
 
13
  load_dotenv()
14
 
15
  # Vera Engine - Autonomous Local-First Build
16
+ # Priority: Ollama (Llama-3.2-3B) -> Fallback: OpenRouter
17
  logging.basicConfig(level=logging.INFO)
18
  logger = logging.getLogger("VeraEngine")
19
 
 
162
  res["body"] = prune_message(res.get("body", ""))
163
  return res
164
 
165
+ @app.on_event("startup")
166
+ async def startup_event():
167
+ logger.info("Performing OpenRouter API Dry Run...")
168
+ if OPENROUTER_KEYS:
169
+ try:
170
+ res = await call_llm_api("ping", system="Respond with JSON pong")
171
+ if res:
172
+ logger.info("OpenRouter API Dry Run: SUCCESS")
173
+ else:
174
+ logger.warning("OpenRouter API Dry Run: FAILED (No response)")
175
+ except Exception as e:
176
+ logger.error(f"OpenRouter API Dry Run: ERROR - {e}")
177
+ else:
178
+ logger.warning("OpenRouter API Dry Run: SKIPPED (No keys found)")
179
+
180
  @app.get("/v1/healthz")
181
  async def healthz():
182
  async with httpx.AsyncClient() as client: