debug(rag): 加入 /rag/debug 診斷端點 — 確認容器路徑 + Ollama 連線
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 13m14s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 13m14s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,35 @@ async def query_rag(request: RagQueryRequest) -> RagQueryResponse:
|
||||
return RagQueryResponse(answer=answer, question=request.question)
|
||||
|
||||
|
||||
@router.get("/debug", summary="RAG 容器環境診斷", include_in_schema=False)
|
||||
async def rag_debug() -> dict:
|
||||
"""診斷用:確認容器內 docs 路徑 + Ollama 連線"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import httpx
|
||||
|
||||
paths_check = {}
|
||||
for p in ["docs/runbooks", "docs/adr", "docs", ".agents/skills"]:
|
||||
d = Path(p)
|
||||
paths_check[p] = {
|
||||
"exists": d.exists(),
|
||||
"files": [f.name for f in d.glob("*.md")][:3] if d.exists() else [],
|
||||
}
|
||||
|
||||
ollama_ok = False
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=5.0) as c:
|
||||
r = await c.post(
|
||||
"http://192.168.0.188:11434/api/embeddings",
|
||||
json={"model": "nomic-embed-text", "prompt": "test"},
|
||||
)
|
||||
ollama_ok = r.status_code == 200
|
||||
except Exception as e:
|
||||
ollama_ok = str(e)
|
||||
|
||||
return {"cwd": os.getcwd(), "paths": paths_check, "ollama_188_embed": ollama_ok}
|
||||
|
||||
|
||||
@router.get("/stats", summary="索引統計")
|
||||
async def rag_stats() -> dict:
|
||||
"""取得知識庫索引統計(chunk 數量等)"""
|
||||
|
||||
Reference in New Issue
Block a user