Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion part4_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ async def cache_stats() -> CacheStatsResponse:
async def flush_cache() -> dict:
state.cache.flush(); return {"status": "ok", "message": "Cache flushed."}

@app.get("/health")
# Allow HEAD as well as GET: uptime monitors (e.g. UptimeRobot) probe with
# HEAD by default, and a GET-only route answers HEAD with 405 Method Not Allowed.
@app.api_route("/health", methods=["GET", "HEAD"])
async def health() -> dict:
return {"status": "ok", "corpus_loaded": state.chroma_collection is not None, "fcm_loaded": state.cache._fcm is not None if state.cache else False, "cache_entries": len(state.cache) if state.cache else 0, "rag_ready": state.rag_graph is not None}

Expand Down
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Pull torch (and its deps) from PyTorch's CPU-only wheel index.
# Without this, pip installs the default CUDA build of torch, which drags in
# ~2.5 GB of unusable NVIDIA GPU libraries (cublas, cudnn, nccl, cufft, ...).
# On a CPU-only Hugging Face Space that bloat makes the image too large to
# schedule ("Scheduling failure: unable to schedule") and slows cold starts.
--extra-index-url https://download.pytorch.org/whl/cpu

fastapi>=0.111.0
uvicorn[standard]>=0.29.0
pydantic>=2.7.0
Expand All @@ -7,6 +14,9 @@ langchain-core>=0.2.0
langchain-groq>=0.1.0
langchain-huggingface>=0.0.3
langgraph>=0.1.0
# CPU-only torch build (the +cpu wheel declares no CUDA dependencies).
# Same version the CUDA build already resolved to, so nothing else changes.
torch==2.12.0+cpu
sentence-transformers>=3.0.0
chromadb>=1.0.0
numpy>=1.26.0
Expand Down