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(
|
||||
"/delete_by_doc_id",
|
||||
"/delete_document",
|
||||
response_model=DeleteDocByIdResponse,
|
||||
dependencies=[Depends(combined_auth)],
|
||||
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,
|
||||
) -> DeleteDocByIdResponse:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ class StoragesStatus(str, Enum):
|
|||
class DeletionResult:
|
||||
"""Represents the result of a deletion operation."""
|
||||
|
||||
status: Literal["success", "not_found", "failure"]
|
||||
status: Literal["success", "not_found", "fail"]
|
||||
doc_id: str
|
||||
message: str
|
||||
status_code: int = 200
|
||||
|
|
|
|||
|
|
@ -1698,10 +1698,10 @@ class LightRAG:
|
|||
|
||||
Returns:
|
||||
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.
|
||||
- `deleted_ids` (dict[str, list[str]]): A dictionary detailing the IDs of
|
||||
all deleted items, categorized by storage type (e.g., "chunks", "entities").
|
||||
- `status_code` (int): HTTP status code (e.g., 200, 404, 500).
|
||||
"""
|
||||
try:
|
||||
# 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(traceback.format_exc())
|
||||
return DeletionResult(
|
||||
status="failure",
|
||||
status="fail",
|
||||
doc_id=doc_id,
|
||||
message=error_message,
|
||||
status_code=500,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue