Fix trailing whitespace and formatting issues in lightrag.py
This commit is contained in:
@@ -460,16 +460,15 @@ class LightRAG:
|
|||||||
|
|
||||||
def insert_custom_chunks(self, full_text: str, text_chunks: list[str]):
|
def insert_custom_chunks(self, full_text: str, text_chunks: list[str]):
|
||||||
loop = always_get_an_event_loop()
|
loop = always_get_an_event_loop()
|
||||||
return loop.run_until_complete(self.ainsert_custom_chunks(full_text, text_chunks))
|
return loop.run_until_complete(
|
||||||
|
self.ainsert_custom_chunks(full_text, text_chunks)
|
||||||
|
)
|
||||||
|
|
||||||
async def ainsert_custom_chunks(self, full_text: str, text_chunks: list[str]):
|
async def ainsert_custom_chunks(self, full_text: str, text_chunks: list[str]):
|
||||||
|
|
||||||
update_storage = False
|
update_storage = False
|
||||||
try:
|
try:
|
||||||
doc_key = compute_mdhash_id(full_text.strip(), prefix="doc-")
|
doc_key = compute_mdhash_id(full_text.strip(), prefix="doc-")
|
||||||
new_docs = {
|
new_docs = {doc_key: {"content": full_text.strip()}}
|
||||||
doc_key: {"content": full_text.strip()}
|
|
||||||
}
|
|
||||||
|
|
||||||
_add_doc_keys = await self.full_docs.filter_keys([doc_key])
|
_add_doc_keys = await self.full_docs.filter_keys([doc_key])
|
||||||
new_docs = {k: v for k, v in new_docs.items() if k in _add_doc_keys}
|
new_docs = {k: v for k, v in new_docs.items() if k in _add_doc_keys}
|
||||||
@@ -490,7 +489,9 @@ class LightRAG:
|
|||||||
"full_doc_id": doc_key,
|
"full_doc_id": doc_key,
|
||||||
}
|
}
|
||||||
|
|
||||||
_add_chunk_keys = await self.text_chunks.filter_keys(list(inserting_chunks.keys()))
|
_add_chunk_keys = await self.text_chunks.filter_keys(
|
||||||
|
list(inserting_chunks.keys())
|
||||||
|
)
|
||||||
inserting_chunks = {
|
inserting_chunks = {
|
||||||
k: v for k, v in inserting_chunks.items() if k in _add_chunk_keys
|
k: v for k, v in inserting_chunks.items() if k in _add_chunk_keys
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user