yangdx commited on
Commit
2400576
·
2 Parent(s): eddf889 1e4adfb

Merge branch 'main' into feat-node-expand

Browse files
README.md CHANGED
@@ -1061,7 +1061,7 @@ Valid modes are:
1061
  | **llm\_model\_func** | `callable` | Function for LLM generation | `gpt_4o_mini_complete` |
1062
  | **llm\_model\_name** | `str` | LLM model name for generation | `meta-llama/Llama-3.2-1B-Instruct` |
1063
  | **llm\_model\_max\_token\_size** | `int` | Maximum token size for LLM generation (affects entity relation summaries) | `32768`(default value changed by env var MAX_TOKENS) |
1064
- | **llm\_model\_max\_async** | `int` | Maximum number of concurrent asynchronous LLM processes | `16`(default value changed by env var MAX_ASYNC) |
1065
  | **llm\_model\_kwargs** | `dict` | Additional parameters for LLM generation | |
1066
  | **vector\_db\_storage\_cls\_kwargs** | `dict` | Additional parameters for vector database, like setting the threshold for nodes and relations retrieval. | cosine_better_than_threshold: 0.2(default value changed by env var COSINE_THRESHOLD) |
1067
  | **enable\_llm\_cache** | `bool` | If `TRUE`, stores LLM results in cache; repeated prompts return cached responses | `TRUE` |
 
1061
  | **llm\_model\_func** | `callable` | Function for LLM generation | `gpt_4o_mini_complete` |
1062
  | **llm\_model\_name** | `str` | LLM model name for generation | `meta-llama/Llama-3.2-1B-Instruct` |
1063
  | **llm\_model\_max\_token\_size** | `int` | Maximum token size for LLM generation (affects entity relation summaries) | `32768`(default value changed by env var MAX_TOKENS) |
1064
+ | **llm\_model\_max\_async** | `int` | Maximum number of concurrent asynchronous LLM processes | `4`(default value changed by env var MAX_ASYNC) |
1065
  | **llm\_model\_kwargs** | `dict` | Additional parameters for LLM generation | |
1066
  | **vector\_db\_storage\_cls\_kwargs** | `dict` | Additional parameters for vector database, like setting the threshold for nodes and relations retrieval. | cosine_better_than_threshold: 0.2(default value changed by env var COSINE_THRESHOLD) |
1067
  | **enable\_llm\_cache** | `bool` | If `TRUE`, stores LLM results in cache; repeated prompts return cached responses | `TRUE` |
env.example CHANGED
@@ -50,7 +50,8 @@
50
  # MAX_TOKEN_SUMMARY=500 # Max tokens for entity or relations summary
51
  # SUMMARY_LANGUAGE=English
52
  # MAX_EMBED_TOKENS=8192
53
- # ENABLE_LLM_CACHE_FOR_EXTRACT=false # Enable LLM cache for entity extraction, defaults to false
 
54
 
55
  ### LLM Configuration (Use valid host. For local services installed with docker, you can use host.docker.internal)
56
  LLM_BINDING=ollama
 
50
  # MAX_TOKEN_SUMMARY=500 # Max tokens for entity or relations summary
51
  # SUMMARY_LANGUAGE=English
52
  # MAX_EMBED_TOKENS=8192
53
+ # ENABLE_LLM_CACHE_FOR_EXTRACT=true # Enable LLM cache for entity extraction
54
+ # MAX_PARALLEL_INSERT=2 # Maximum number of parallel processing documents in pipeline
55
 
56
  ### LLM Configuration (Use valid host. For local services installed with docker, you can use host.docker.internal)
57
  LLM_BINDING=ollama
lightrag/api/README.md CHANGED
@@ -224,7 +224,7 @@ LightRAG supports binding to various LLM/Embedding backends:
224
  Use environment variables `LLM_BINDING` or CLI argument `--llm-binding` to select LLM backend type. Use environment variables `EMBEDDING_BINDING` or CLI argument `--embedding-binding` to select LLM backend type.
225
 
226
  ### Entity Extraction Configuration
227
- * ENABLE_LLM_CACHE_FOR_EXTRACT: Enable LLM cache for entity extraction (default: false)
228
 
229
  It's very common to set `ENABLE_LLM_CACHE_FOR_EXTRACT` to true for test environment to reduce the cost of LLM calls.
230
 
 
224
  Use environment variables `LLM_BINDING` or CLI argument `--llm-binding` to select LLM backend type. Use environment variables `EMBEDDING_BINDING` or CLI argument `--embedding-binding` to select LLM backend type.
225
 
226
  ### Entity Extraction Configuration
227
+ * ENABLE_LLM_CACHE_FOR_EXTRACT: Enable LLM cache for entity extraction (default: true)
228
 
229
  It's very common to set `ENABLE_LLM_CACHE_FOR_EXTRACT` to true for test environment to reduce the cost of LLM calls.
230
 
lightrag/api/docs/LightRagWithPostGRESQL.md CHANGED
@@ -141,7 +141,7 @@ Start the LightRAG server using specified options:
141
  lightrag-server --port 9621 --key sk-somepassword --kv-storage PGKVStorage --graph-storage PGGraphStorage --vector-storage PGVectorStorage --doc-status-storage PGDocStatusStorage
142
  ```
143
 
144
- Replace `the-port-number` with your desired port number (default is 9621) and `your-secret-key` with a secure key.
145
 
146
  ## Conclusion
147
 
 
141
  lightrag-server --port 9621 --key sk-somepassword --kv-storage PGKVStorage --graph-storage PGGraphStorage --vector-storage PGVectorStorage --doc-status-storage PGDocStatusStorage
142
  ```
143
 
144
+ Replace the `port` number with your desired port number (default is 9621) and `your-secret-key` with a secure key.
145
 
146
  ## Conclusion
147
 
lightrag/api/utils_api.py CHANGED
@@ -364,7 +364,7 @@ def parse_args(is_uvicorn_mode: bool = False) -> argparse.Namespace:
364
 
365
  # Inject LLM cache configuration
366
  args.enable_llm_cache_for_extract = get_env_value(
367
- "ENABLE_LLM_CACHE_FOR_EXTRACT", False, bool
368
  )
369
 
370
  # Select Document loading tool (DOCLING, DEFAULT)
 
364
 
365
  # Inject LLM cache configuration
366
  args.enable_llm_cache_for_extract = get_env_value(
367
+ "ENABLE_LLM_CACHE_FOR_EXTRACT", True, bool
368
  )
369
 
370
  # Select Document loading tool (DOCLING, DEFAULT)
lightrag/kg/postgres_impl.py CHANGED
@@ -755,7 +755,7 @@ class PGDocStatusStorage(DocStatusStorage):
755
  result = await self.db.query(sql, params, True)
756
  docs_by_status = {
757
  element["id"]: DocProcessingStatus(
758
- content=result[0]["content"],
759
  content_summary=element["content_summary"],
760
  content_length=element["content_length"],
761
  status=element["status"],
@@ -1556,7 +1556,7 @@ TABLES = {
1556
  content_vector VECTOR,
1557
  create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
1558
  update_time TIMESTAMP,
1559
- chunk_id VARCHAR(255) NULL,
1560
  CONSTRAINT LIGHTRAG_VDB_ENTITY_PK PRIMARY KEY (workspace, id)
1561
  )"""
1562
  },
@@ -1570,7 +1570,7 @@ TABLES = {
1570
  content_vector VECTOR,
1571
  create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
1572
  update_time TIMESTAMP,
1573
- chunk_id VARCHAR(255) NULL,
1574
  CONSTRAINT LIGHTRAG_VDB_RELATION_PK PRIMARY KEY (workspace, id)
1575
  )"""
1576
  },
 
755
  result = await self.db.query(sql, params, True)
756
  docs_by_status = {
757
  element["id"]: DocProcessingStatus(
758
+ content=element["content"],
759
  content_summary=element["content_summary"],
760
  content_length=element["content_length"],
761
  status=element["status"],
 
1556
  content_vector VECTOR,
1557
  create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
1558
  update_time TIMESTAMP,
1559
+ chunk_id TEXT NULL,
1560
  CONSTRAINT LIGHTRAG_VDB_ENTITY_PK PRIMARY KEY (workspace, id)
1561
  )"""
1562
  },
 
1570
  content_vector VECTOR,
1571
  create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
1572
  update_time TIMESTAMP,
1573
+ chunk_id TEXT NULL,
1574
  CONSTRAINT LIGHTRAG_VDB_RELATION_PK PRIMARY KEY (workspace, id)
1575
  )"""
1576
  },
lightrag/lightrag.py CHANGED
@@ -214,7 +214,7 @@ class LightRAG:
214
  llm_model_max_token_size: int = field(default=int(os.getenv("MAX_TOKENS", 32768)))
215
  """Maximum number of tokens allowed per LLM response."""
216
 
217
- llm_model_max_async: int = field(default=int(os.getenv("MAX_ASYNC", 16)))
218
  """Maximum number of concurrent LLM calls."""
219
 
220
  llm_model_kwargs: dict[str, Any] = field(default_factory=dict)
@@ -238,7 +238,7 @@ class LightRAG:
238
  # Extensions
239
  # ---
240
 
241
- max_parallel_insert: int = field(default=int(os.getenv("MAX_PARALLEL_INSERT", 20)))
242
  """Maximum number of parallel insert operations."""
243
 
244
  addon_params: dict[str, Any] = field(
@@ -553,6 +553,7 @@ class LightRAG:
553
  Args:
554
  input: Single document string or list of document strings
555
  split_by_character: if split_by_character is not None, split the string by character, if chunk longer than
 
556
  split_by_character_only: if split_by_character_only is True, split the string by character only, when
557
  split_by_character is None, this parameter is ignored.
558
  ids: single string of the document ID or list of unique document IDs, if not provided, MD5 hash IDs will be generated
@@ -574,6 +575,7 @@ class LightRAG:
574
  Args:
575
  input: Single document string or list of document strings
576
  split_by_character: if split_by_character is not None, split the string by character, if chunk longer than
 
577
  split_by_character_only: if split_by_character_only is True, split the string by character only, when
578
  split_by_character is None, this parameter is ignored.
579
  ids: list of unique document IDs, if not provided, MD5 hash IDs will be generated
 
214
  llm_model_max_token_size: int = field(default=int(os.getenv("MAX_TOKENS", 32768)))
215
  """Maximum number of tokens allowed per LLM response."""
216
 
217
+ llm_model_max_async: int = field(default=int(os.getenv("MAX_ASYNC", 4)))
218
  """Maximum number of concurrent LLM calls."""
219
 
220
  llm_model_kwargs: dict[str, Any] = field(default_factory=dict)
 
238
  # Extensions
239
  # ---
240
 
241
+ max_parallel_insert: int = field(default=int(os.getenv("MAX_PARALLEL_INSERT", 2)))
242
  """Maximum number of parallel insert operations."""
243
 
244
  addon_params: dict[str, Any] = field(
 
553
  Args:
554
  input: Single document string or list of document strings
555
  split_by_character: if split_by_character is not None, split the string by character, if chunk longer than
556
+ chunk_token_size, it will be split again by token size.
557
  split_by_character_only: if split_by_character_only is True, split the string by character only, when
558
  split_by_character is None, this parameter is ignored.
559
  ids: single string of the document ID or list of unique document IDs, if not provided, MD5 hash IDs will be generated
 
575
  Args:
576
  input: Single document string or list of document strings
577
  split_by_character: if split_by_character is not None, split the string by character, if chunk longer than
578
+ chunk_token_size, it will be split again by token size.
579
  split_by_character_only: if split_by_character_only is True, split the string by character only, when
580
  split_by_character is None, this parameter is ignored.
581
  ids: list of unique document IDs, if not provided, MD5 hash IDs will be generated