Expose DuckLM runtime status
This commit is contained in:
@@ -94,6 +94,43 @@ class VectorMemory:
|
||||
response.raise_for_status()
|
||||
return response.json().get("result", [])
|
||||
|
||||
def config_status(self) -> dict[str, Any]:
|
||||
if self.embeddings_base_url:
|
||||
embedding_source = f"remote:{self.embeddings_base_url}"
|
||||
elif self._local_model_path:
|
||||
embedding_source = f"local:{self._local_model_path}"
|
||||
else:
|
||||
embedding_source = "none"
|
||||
return {
|
||||
"configured": bool(self.qdrant_url and embedding_source != "none"),
|
||||
"qdrant_url": self.qdrant_url,
|
||||
"collection": self.collection_name,
|
||||
"embedding_source": embedding_source,
|
||||
}
|
||||
|
||||
async def health(self) -> dict[str, Any]:
|
||||
"""Probe Qdrant without loading the local embedding model."""
|
||||
import time
|
||||
|
||||
status = self.config_status()
|
||||
started = time.perf_counter()
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=5.0, trust_env=False) as client:
|
||||
response = await client.get(f"{self.qdrant_url}/")
|
||||
response.raise_for_status()
|
||||
return {
|
||||
**status,
|
||||
"ok": True,
|
||||
"latency_ms": round((time.perf_counter() - started) * 1000, 1),
|
||||
}
|
||||
except httpx.HTTPError as exc:
|
||||
return {
|
||||
**status,
|
||||
"ok": False,
|
||||
"error": str(exc),
|
||||
"latency_ms": round((time.perf_counter() - started) * 1000, 1),
|
||||
}
|
||||
|
||||
async def _embed(self, text: str) -> list[float]:
|
||||
"""Generate embeddings using local model or remote endpoint."""
|
||||
# Prefer local model if available
|
||||
|
||||
Reference in New Issue
Block a user