Fixed broken ainsert_custom_kg()
Browse files- lightrag/lightrag.py +9 -1
lightrag/lightrag.py
CHANGED
|
@@ -36,6 +36,7 @@ from .utils import (
|
|
| 36 |
limit_async_func_call,
|
| 37 |
logger,
|
| 38 |
set_logger,
|
|
|
|
| 39 |
)
|
| 40 |
from .types import KnowledgeGraph
|
| 41 |
|
|
@@ -863,7 +864,14 @@ class LightRAG:
|
|
| 863 |
source_id = chunk_data["source_id"]
|
| 864 |
chunk_id = compute_mdhash_id(chunk_content.strip(), prefix="chunk-")
|
| 865 |
|
| 866 |
-
chunk_entry = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
all_chunks_data[chunk_id] = chunk_entry
|
| 868 |
chunk_to_source_map[source_id] = chunk_id
|
| 869 |
update_storage = True
|
|
|
|
| 36 |
limit_async_func_call,
|
| 37 |
logger,
|
| 38 |
set_logger,
|
| 39 |
+
encode_string_by_tiktoken,
|
| 40 |
)
|
| 41 |
from .types import KnowledgeGraph
|
| 42 |
|
|
|
|
| 864 |
source_id = chunk_data["source_id"]
|
| 865 |
chunk_id = compute_mdhash_id(chunk_content.strip(), prefix="chunk-")
|
| 866 |
|
| 867 |
+
chunk_entry = {
|
| 868 |
+
"content": chunk_content.strip(),
|
| 869 |
+
"source_id": source_id,
|
| 870 |
+
"tokens": len(encode_string_by_tiktoken(chunk_entry["content"])),
|
| 871 |
+
"chunk_order_id": 0,
|
| 872 |
+
"full_doc_id": source_id,
|
| 873 |
+
"status": DocStatus.PROCESSED
|
| 874 |
+
}
|
| 875 |
all_chunks_data[chunk_id] = chunk_entry
|
| 876 |
chunk_to_source_map[source_id] = chunk_id
|
| 877 |
update_storage = True
|