Store, connect_lancedb, gather_database_info and run_doctor take a location, a path or a URI, and classify it with ConnectionMode.of. SingleDatabaseSession owns the resolved DatabaseRef and passes its location down. This removes DatabaseRef.connection(), default_db_path, the placeholder path for URI-backed databases and the per-database config copies, so the configuration a client holds is the one the caller gave it. The chat hands its capabilities the scope it opened along with the client it lends, and the v0.58.0 migration no longer checks local free disk for a database behind a URI.
23 lines
975 B
Python
23 lines
975 B
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
|
|
from haiku.rag.ingester.api.server import APIState, get_state
|
|
from haiku.rag.store.info import DatabaseInfo, gather_database_info
|
|
|
|
router = APIRouter(tags=["database"])
|
|
|
|
|
|
@router.get("/database", response_model=DatabaseInfo)
|
|
async def database(state: APIState = Depends(get_state)) -> DatabaseInfo:
|
|
"""Read-only snapshot of the LanceDB target — stored version, embeddings,
|
|
per-table counts/sizes, vector index status, pending migrations and
|
|
package versions. The same data the `haiku-rag info` command prints.
|
|
|
|
Opens a fresh read-only connection per call; not cached and not part of
|
|
the dashboard's polling loop."""
|
|
if state.scope is None:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
|
detail="database not configured",
|
|
)
|
|
[ref] = state.scope.databases
|
|
return await gather_database_info(ref.location, state.config)
|