Merge pull request #696 from ultrageopro/main
Add the ability to specify a path for saving lightrag.log
This commit is contained in:
@@ -799,6 +799,7 @@ if __name__ == "__main__":
|
|||||||
| **addon\_params** | `dict` | Additional parameters, e.g., `{"example_number": 1, "language": "Simplified Chinese", "entity_types": ["organization", "person", "geo", "event"], "insert_batch_size": 10}`: sets example limit, output language, and batch size for document processing | `example_number: all examples, language: English, insert_batch_size: 10` |
|
| **addon\_params** | `dict` | Additional parameters, e.g., `{"example_number": 1, "language": "Simplified Chinese", "entity_types": ["organization", "person", "geo", "event"], "insert_batch_size": 10}`: sets example limit, output language, and batch size for document processing | `example_number: all examples, language: English, insert_batch_size: 10` |
|
||||||
| **convert\_response\_to\_json\_func** | `callable` | Not used | `convert_response_to_json` |
|
| **convert\_response\_to\_json\_func** | `callable` | Not used | `convert_response_to_json` |
|
||||||
| **embedding\_cache\_config** | `dict` | Configuration for question-answer caching. Contains three parameters:<br>- `enabled`: Boolean value to enable/disable cache lookup functionality. When enabled, the system will check cached responses before generating new answers.<br>- `similarity_threshold`: Float value (0-1), similarity threshold. When a new question's similarity with a cached question exceeds this threshold, the cached answer will be returned directly without calling the LLM.<br>- `use_llm_check`: Boolean value to enable/disable LLM similarity verification. When enabled, LLM will be used as a secondary check to verify the similarity between questions before returning cached answers. | Default: `{"enabled": False, "similarity_threshold": 0.95, "use_llm_check": False}` |
|
| **embedding\_cache\_config** | `dict` | Configuration for question-answer caching. Contains three parameters:<br>- `enabled`: Boolean value to enable/disable cache lookup functionality. When enabled, the system will check cached responses before generating new answers.<br>- `similarity_threshold`: Float value (0-1), similarity threshold. When a new question's similarity with a cached question exceeds this threshold, the cached answer will be returned directly without calling the LLM.<br>- `use_llm_check`: Boolean value to enable/disable LLM similarity verification. When enabled, LLM will be used as a secondary check to verify the similarity between questions before returning cached answers. | Default: `{"enabled": False, "similarity_threshold": 0.95, "use_llm_check": False}` |
|
||||||
|
|**log\_dir** | `str` | Directory to store logs. | `./` |
|
||||||
|
|
||||||
### Error Handling
|
### Error Handling
|
||||||
|
|
||||||
|
@@ -126,8 +126,10 @@ class LightRAG:
|
|||||||
vector_storage: str = field(default="NanoVectorDBStorage")
|
vector_storage: str = field(default="NanoVectorDBStorage")
|
||||||
graph_storage: str = field(default="NetworkXStorage")
|
graph_storage: str = field(default="NetworkXStorage")
|
||||||
|
|
||||||
|
# logging
|
||||||
current_log_level = logger.level
|
current_log_level = logger.level
|
||||||
log_level: str = field(default=current_log_level)
|
log_level: str = field(default=current_log_level)
|
||||||
|
log_dir: str = field(default=os.getcwd())
|
||||||
|
|
||||||
# text chunking
|
# text chunking
|
||||||
chunk_token_size: int = 1200
|
chunk_token_size: int = 1200
|
||||||
@@ -182,10 +184,11 @@ class LightRAG:
|
|||||||
chunking_func_kwargs: dict = field(default_factory=dict)
|
chunking_func_kwargs: dict = field(default_factory=dict)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
log_file = os.path.join("lightrag.log")
|
os.makedirs(self.log_dir, exist_ok=True)
|
||||||
|
log_file = os.path.join(self.log_dir, "lightrag.log")
|
||||||
set_logger(log_file)
|
set_logger(log_file)
|
||||||
logger.setLevel(self.log_level)
|
|
||||||
|
|
||||||
|
logger.setLevel(self.log_level)
|
||||||
logger.info(f"Logger initialized for working directory: {self.working_dir}")
|
logger.info(f"Logger initialized for working directory: {self.working_dir}")
|
||||||
if not os.path.exists(self.working_dir):
|
if not os.path.exists(self.working_dir):
|
||||||
logger.info(f"Creating working directory {self.working_dir}")
|
logger.info(f"Creating working directory {self.working_dir}")
|
||||||
|
Reference in New Issue
Block a user