Files
AIRegulation-DocAnalysis/backend/app/api/routes/status.py
ash66 c22b03dc07 feat: Migrate document parsing to Aliyun and update embedding configurations
- Updated LocalDocumentParser to include raw_layouts and artifact_prefix from settings.
- Added new documents with failure reasons and metadata to documents.json for better error tracking.
- Created a new documentation file detailing the Aliyun ingest implementation process.
- Updated RFC to reflect changes in the parsing backend and embedding dimensions.
- Modified tests to accommodate the new embedding dimension of 1024 and updated parser and chunk builder assertions.
- Verified migration configurations to ensure correct settings for embedding model and backend.
2026-05-18 22:30:28 +08:00

49 lines
1.6 KiB
Python

"""Define API routes for status."""
from fastapi import APIRouter
from app.config.settings import settings
from app.shared.bootstrap import get_document_query_service, get_vector_index
# Keep route handlers close to their transport-layer wiring for easier auditing.
router = APIRouter(prefix="/status", tags=["系统状态"])
@router.get("/stats")
async def get_stats():
"""Return stats."""
documents = get_document_query_service().list_documents()
indexed = sum(1 for item in documents if item.status.value == "indexed")
failed = sum(1 for item in documents if item.status.value == "failed")
return {
"documents_total": len(documents),
"documents_indexed": indexed,
"documents_failed": failed,
"chunks_total": sum(item.chunk_count for item in documents),
}
@router.get("/config")
async def get_config():
"""Return config."""
return {
"embedding_model": settings.embedding_model,
"embedding_dim": settings.embedding_dim,
"embedding_base_url": settings.embedding_base_url,
"milvus_collection": settings.milvus_collection,
"parser_backend": settings.parser_backend,
"chunk_backend": settings.chunk_backend,
"artifact_prefix": settings.document_parse_artifact_prefix,
"parser_failure_mode": settings.parser_failure_mode,
"llm_provider": settings.llm_provider,
"llm_model": settings.llm_model,
"document_metadata_path": settings.document_metadata_path,
}
@router.get("/milvus/health")
async def milvus_health():
"""Handle milvus health."""
return get_vector_index().health()