diff --git a/lightrag/api/routers/graph_routes.py b/lightrag/api/routers/graph_routes.py index 078fd452..46e225b6 100644 --- a/lightrag/api/routers/graph_routes.py +++ b/lightrag/api/routers/graph_routes.py @@ -284,7 +284,9 @@ def create_graph_routes(rag, api_key: Optional[str] = None): "data": entity_data, } except ValueError as ve: - logger.error(f"Validation error creating entity '{request.entity_name}': {str(ve)}") + logger.error( + f"Validation error creating entity '{request.entity_name}': {str(ve)}" + ) raise HTTPException(status_code=400, detail=str(ve)) except Exception as e: logger.error(f"Error creating entity '{request.entity_name}': {str(e)}") @@ -328,9 +330,13 @@ def create_graph_routes(rag, api_key: Optional[str] = None): ) if not source_exists: - raise ValueError(f"Source entity '{request.source_entity}' does not exist") + raise ValueError( + f"Source entity '{request.source_entity}' does not exist" + ) if not target_exists: - raise ValueError(f"Target entity '{request.target_entity}' does not exist") + raise ValueError( + f"Target entity '{request.target_entity}' does not exist" + ) # Create the relationship await rag.chunk_entity_relation_graph.upsert_edge( diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index ad271b15..96f4be94 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -828,8 +828,8 @@ class PostgreSQLDB: # Execute the migration alter_sql = f""" - ALTER TABLE {migration['table']} - ALTER COLUMN {migration['column']} TYPE {migration['new_type']} + ALTER TABLE {migration["table"]} + ALTER COLUMN {migration["column"]} TYPE {migration["new_type"]} """ await self.execute(alter_sql) diff --git a/lightrag/operate.py b/lightrag/operate.py index cd8d8a64..e11b039e 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -401,7 +401,7 @@ async def _handle_single_relationship_extraction( ): # treat "relationship" and "relation" interchangeable if len(record_attributes) > 1 and "relation" in record_attributes[0]: logger.warning( - f"{chunk_key}: LLM output format error; found {len(record_attributes)}/5 fields on REALTION `{record_attributes[1]}`~`{record_attributes[2] if len(record_attributes) >2 else 'N/A'}`" + f"{chunk_key}: LLM output format error; found {len(record_attributes)}/5 fields on REALTION `{record_attributes[1]}`~`{record_attributes[2] if len(record_attributes) > 2 else 'N/A'}`" ) logger.debug(record_attributes) return None @@ -2225,7 +2225,7 @@ async def extract_entities( await asyncio.wait(pending) # Add progress prefix to the exception message - progress_prefix = f"C[{processed_chunks+1}/{total_chunks}]" + progress_prefix = f"C[{processed_chunks + 1}/{total_chunks}]" # Re-raise the original exception with a prefix prefixed_exception = create_prefixed_exception(first_exception, progress_prefix) diff --git a/lightrag/utils.py b/lightrag/utils.py index 60542e43..83a3c394 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -1472,8 +1472,7 @@ async def aexport_data( else: raise ValueError( - f"Unsupported file format: {file_format}. " - f"Choose from: csv, excel, md, txt" + f"Unsupported file format: {file_format}. Choose from: csv, excel, md, txt" ) if file_format is not None: print(f"Data exported to: {output_path} with format: {file_format}") diff --git a/reproduce/batch_eval.py b/reproduce/batch_eval.py index 424b4f54..5a4cfc38 100644 --- a/reproduce/batch_eval.py +++ b/reproduce/batch_eval.py @@ -73,7 +73,7 @@ def batch_eval(query_file, result1_file, result2_file, output_file_path): """ request_data = { - "custom_id": f"request-{i+1}", + "custom_id": f"request-{i + 1}", "method": "POST", "url": "/v1/chat/completions", "body": {