fix 文档管理模块 & 法规对话模块
This commit is contained in:
@@ -80,6 +80,8 @@ async def get_document_status(doc_id: str):
|
||||
num_chunks=document.chunk_count,
|
||||
summary=document.summary,
|
||||
summary_latency_ms=document.summary_latency_ms,
|
||||
regulation_type=document.regulation_type,
|
||||
version=document.version,
|
||||
)
|
||||
|
||||
|
||||
@@ -123,7 +125,7 @@ async def list_documents():
|
||||
@router.get("/management-list")
|
||||
async def get_document_management_list():
|
||||
"""Return document management list."""
|
||||
documents = get_document_query_service().list_documents(limit=10)
|
||||
documents = get_document_query_service().list_documents()
|
||||
return {
|
||||
"documents": [
|
||||
{
|
||||
@@ -131,10 +133,37 @@ async def get_document_management_list():
|
||||
"doc_name": item.doc_name,
|
||||
"status": item.status.value,
|
||||
"chunk_count": item.chunk_count,
|
||||
"size_bytes": item.size_bytes,
|
||||
"summary": item.summary,
|
||||
"updated_at": item.updated_at.isoformat(),
|
||||
"regulation_type": item.regulation_type,
|
||||
"version": item.version,
|
||||
}
|
||||
for item in documents
|
||||
],
|
||||
"total": len(documents),
|
||||
"limit": 10,
|
||||
}
|
||||
|
||||
|
||||
@router.delete("/{doc_id}")
|
||||
async def delete_document(doc_id: str):
|
||||
"""Delete a document and its associated data."""
|
||||
deleted = get_document_command_service().delete(doc_id)
|
||||
if not deleted:
|
||||
raise HTTPException(status_code=404, detail="文档不存在")
|
||||
return {"doc_id": doc_id, "deleted": True}
|
||||
|
||||
|
||||
@router.post("/{doc_id}/retry", response_model=DocumentUploadResponse)
|
||||
async def retry_document(doc_id: str):
|
||||
"""Re-process a failed document."""
|
||||
try:
|
||||
result = get_document_command_service().retry(doc_id)
|
||||
if result.status == "failed":
|
||||
raise HTTPException(status_code=500, detail=result.message)
|
||||
return _document_response(result)
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.exception("文档重试失败")
|
||||
raise HTTPException(status_code=500, detail=str(exc))
|
||||
|
||||
Reference in New Issue
Block a user