Unify document APIs returen status string
This commit is contained in:
parent
ce50135efb
commit
bd487dd252
3 changed files with 7 additions and 7 deletions
|
|
@ -1341,12 +1341,12 @@ def create_document_routes(
|
||||||
)
|
)
|
||||||
|
|
||||||
@router.delete(
|
@router.delete(
|
||||||
"/delete_by_doc_id",
|
"/delete_document",
|
||||||
response_model=DeleteDocByIdResponse,
|
response_model=DeleteDocByIdResponse,
|
||||||
dependencies=[Depends(combined_auth)],
|
dependencies=[Depends(combined_auth)],
|
||||||
summary="Delete a document and all its associated data by its ID.",
|
summary="Delete a document and all its associated data by its ID.",
|
||||||
)
|
)
|
||||||
async def delete_by_doc_id(
|
async def delete_document(
|
||||||
delete_request: DeleteDocRequest,
|
delete_request: DeleteDocRequest,
|
||||||
) -> DeleteDocByIdResponse:
|
) -> DeleteDocByIdResponse:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -619,7 +619,7 @@ class StoragesStatus(str, Enum):
|
||||||
class DeletionResult:
|
class DeletionResult:
|
||||||
"""Represents the result of a deletion operation."""
|
"""Represents the result of a deletion operation."""
|
||||||
|
|
||||||
status: Literal["success", "not_found", "failure"]
|
status: Literal["success", "not_found", "fail"]
|
||||||
doc_id: str
|
doc_id: str
|
||||||
message: str
|
message: str
|
||||||
status_code: int = 200
|
status_code: int = 200
|
||||||
|
|
|
||||||
|
|
@ -1698,10 +1698,10 @@ class LightRAG:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DeletionResult: An object containing the outcome of the deletion process.
|
DeletionResult: An object containing the outcome of the deletion process.
|
||||||
- `success` (bool): True if the deletion was successful, False otherwise.
|
- `status` (str): "success", "not_found", or "failure".
|
||||||
|
- `doc_id` (str): The ID of the document attempted to be deleted.
|
||||||
- `message` (str): A summary of the operation's result.
|
- `message` (str): A summary of the operation's result.
|
||||||
- `deleted_ids` (dict[str, list[str]]): A dictionary detailing the IDs of
|
- `status_code` (int): HTTP status code (e.g., 200, 404, 500).
|
||||||
all deleted items, categorized by storage type (e.g., "chunks", "entities").
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 1. Get the document status and related data
|
# 1. Get the document status and related data
|
||||||
|
|
@ -1902,7 +1902,7 @@ Rebuilt: {len(entities_to_rebuild)} entities, {len(relationships_to_rebuild)} re
|
||||||
logger.error(error_message)
|
logger.error(error_message)
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
return DeletionResult(
|
return DeletionResult(
|
||||||
status="failure",
|
status="fail",
|
||||||
doc_id=doc_id,
|
doc_id=doc_id,
|
||||||
message=error_message,
|
message=error_message,
|
||||||
status_code=500,
|
status_code=500,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue