make value on str enum
Browse files- lightrag/kg/json_doc_status_impl.py +4 -4
- lightrag/kg/redis_impl.py +1 -0
- lightrag/lightrag.py +4 -4
lightrag/kg/json_doc_status_impl.py
CHANGED
@@ -49,10 +49,10 @@ class JsonDocStatusStorage(DocStatusStorage):
|
|
49 |
) -> dict[str, DocProcessingStatus]:
|
50 |
"""Get all documents with a specific status"""
|
51 |
return {
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
async def index_done_callback(self) -> None:
|
58 |
write_json(self._data, self._file_name)
|
|
|
49 |
) -> dict[str, DocProcessingStatus]:
|
50 |
"""Get all documents with a specific status"""
|
51 |
return {
|
52 |
+
k: DocProcessingStatus(**v)
|
53 |
+
for k, v in self._data.items()
|
54 |
+
if v["status"] == status.value
|
55 |
+
}
|
56 |
|
57 |
async def index_done_callback(self) -> None:
|
58 |
write_json(self._data, self._file_name)
|
lightrag/kg/redis_impl.py
CHANGED
@@ -18,6 +18,7 @@ import json
|
|
18 |
config = configparser.ConfigParser()
|
19 |
config.read("config.ini", "utf-8")
|
20 |
|
|
|
21 |
@final
|
22 |
@dataclass
|
23 |
class RedisKVStorage(BaseKVStorage):
|
|
|
18 |
config = configparser.ConfigParser()
|
19 |
config.read("config.ini", "utf-8")
|
20 |
|
21 |
+
|
22 |
@final
|
23 |
@dataclass
|
24 |
class RedisKVStorage(BaseKVStorage):
|
lightrag/lightrag.py
CHANGED
@@ -674,7 +674,7 @@ class LightRAG:
|
|
674 |
"content": content,
|
675 |
"content_summary": self._get_content_summary(content),
|
676 |
"content_length": len(content),
|
677 |
-
"status": DocStatus.PENDING,
|
678 |
"created_at": datetime.now().isoformat(),
|
679 |
"updated_at": datetime.now().isoformat(),
|
680 |
}
|
@@ -745,7 +745,7 @@ class LightRAG:
|
|
745 |
await self.doc_status.upsert(
|
746 |
{
|
747 |
doc_status_id: {
|
748 |
-
"status": DocStatus.PROCESSING,
|
749 |
"updated_at": datetime.now().isoformat(),
|
750 |
"content": status_doc.content,
|
751 |
"content_summary": status_doc.content_summary,
|
@@ -782,7 +782,7 @@ class LightRAG:
|
|
782 |
await self.doc_status.upsert(
|
783 |
{
|
784 |
doc_status_id: {
|
785 |
-
"status": DocStatus.PROCESSED,
|
786 |
"chunks_count": len(chunks),
|
787 |
"content": status_doc.content,
|
788 |
"content_summary": status_doc.content_summary,
|
@@ -799,7 +799,7 @@ class LightRAG:
|
|
799 |
await self.doc_status.upsert(
|
800 |
{
|
801 |
doc_status_id: {
|
802 |
-
"status": DocStatus.FAILED,
|
803 |
"error": str(e),
|
804 |
"content": status_doc.content,
|
805 |
"content_summary": status_doc.content_summary,
|
|
|
674 |
"content": content,
|
675 |
"content_summary": self._get_content_summary(content),
|
676 |
"content_length": len(content),
|
677 |
+
"status": DocStatus.PENDING.value,
|
678 |
"created_at": datetime.now().isoformat(),
|
679 |
"updated_at": datetime.now().isoformat(),
|
680 |
}
|
|
|
745 |
await self.doc_status.upsert(
|
746 |
{
|
747 |
doc_status_id: {
|
748 |
+
"status": DocStatus.PROCESSING.value,
|
749 |
"updated_at": datetime.now().isoformat(),
|
750 |
"content": status_doc.content,
|
751 |
"content_summary": status_doc.content_summary,
|
|
|
782 |
await self.doc_status.upsert(
|
783 |
{
|
784 |
doc_status_id: {
|
785 |
+
"status": DocStatus.PROCESSED.value,
|
786 |
"chunks_count": len(chunks),
|
787 |
"content": status_doc.content,
|
788 |
"content_summary": status_doc.content_summary,
|
|
|
799 |
await self.doc_status.upsert(
|
800 |
{
|
801 |
doc_status_id: {
|
802 |
+
"status": DocStatus.FAILED.value,
|
803 |
"error": str(e),
|
804 |
"content": status_doc.content,
|
805 |
"content_summary": status_doc.content_summary,
|