Refactor before imporve knowledge base.

This commit is contained in:
Liu Zhicong
2023-10-18 11:19:11 -07:00
parent 760087d945
commit b74b86b4d4
19 changed files with 683 additions and 445 deletions
+11
View File
@@ -47,6 +47,17 @@ class KnowledgeObject(ABC):
def get_body(self) -> dict:
return self.body
def get_summary(self) -> str:
return self.desc.get("summary")
def get_articl_catelog(self) -> str:
assert self.object_type == ObjectType.Document
return self.desc.get("catelog")
def get_article_full_content(self) -> str:
assert self.object_type == ObjectType.Document
return self.body
def calculate_id(self):
# Convert the object_type and desc to string and compute the SHA256 hash
+4
View File
@@ -6,6 +6,8 @@ from .vector import ChromaVectorStore, VectorBase
import logging
# KnowledgeStore class, which aggregates ChunkStore, ChunkTracker, and ObjectStore, and is a global singleton that makes it easy to use these three built-in store examples
class KnowledgeStore:
_instance = None
@@ -41,6 +43,8 @@ class KnowledgeStore:
self.chunk_list_writer = ChunkListWriter(self.chunk_store, self.chunk_tracker)
self.chunk_reader = ChunkReader(self.chunk_store, self.chunk_tracker)
self.vector_store = {}
def get_relation_store(self) -> ObjectRelationStore:
return self.relation_store