Fix linting

This commit is contained in:
yangdx
2025-04-14 13:29:56 +08:00
parent c7d563f1aa
commit 017169b571

View File

@@ -41,7 +41,9 @@ def create_graph_routes(rag, api_key: Optional[str] = None):
except Exception as e: except Exception as e:
logger.error(f"Error getting graph labels: {str(e)}") logger.error(f"Error getting graph labels: {str(e)}")
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
raise HTTPException(status_code=500, detail=f"Error getting graph labels: {str(e)}") raise HTTPException(
status_code=500, detail=f"Error getting graph labels: {str(e)}"
)
@router.get("/graphs", dependencies=[Depends(combined_auth)]) @router.get("/graphs", dependencies=[Depends(combined_auth)])
async def get_knowledge_graph( async def get_knowledge_graph(
@@ -72,7 +74,9 @@ def create_graph_routes(rag, api_key: Optional[str] = None):
except Exception as e: except Exception as e:
logger.error(f"Error getting knowledge graph for label '{label}': {str(e)}") logger.error(f"Error getting knowledge graph for label '{label}': {str(e)}")
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
raise HTTPException(status_code=500, detail=f"Error getting knowledge graph: {str(e)}") raise HTTPException(
status_code=500, detail=f"Error getting knowledge graph: {str(e)}"
)
@router.get("/graph/entity/exists", dependencies=[Depends(combined_auth)]) @router.get("/graph/entity/exists", dependencies=[Depends(combined_auth)])
async def check_entity_exists( async def check_entity_exists(
@@ -120,7 +124,9 @@ def create_graph_routes(rag, api_key: Optional[str] = None):
"data": result, "data": result,
} }
except ValueError as ve: except ValueError as ve:
logger.error(f"Validation error updating entity '{request.entity_name}': {str(ve)}") logger.error(
f"Validation error updating entity '{request.entity_name}': {str(ve)}"
)
raise HTTPException(status_code=400, detail=str(ve)) raise HTTPException(status_code=400, detail=str(ve))
except Exception as e: except Exception as e:
logger.error(f"Error updating entity '{request.entity_name}': {str(e)}") logger.error(f"Error updating entity '{request.entity_name}': {str(e)}")
@@ -151,10 +157,14 @@ def create_graph_routes(rag, api_key: Optional[str] = None):
"data": result, "data": result,
} }
except ValueError as ve: except ValueError as ve:
logger.error(f"Validation error updating relation between '{request.source_id}' and '{request.target_id}': {str(ve)}") logger.error(
f"Validation error updating relation between '{request.source_id}' and '{request.target_id}': {str(ve)}"
)
raise HTTPException(status_code=400, detail=str(ve)) raise HTTPException(status_code=400, detail=str(ve))
except Exception as e: except Exception as e:
logger.error(f"Error updating relation between '{request.source_id}' and '{request.target_id}': {str(e)}") logger.error(
f"Error updating relation between '{request.source_id}' and '{request.target_id}': {str(e)}"
)
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
raise HTTPException( raise HTTPException(
status_code=500, detail=f"Error updating relation: {str(e)}" status_code=500, detail=f"Error updating relation: {str(e)}"