shell knowledge commands

This commit is contained in:
tsukasa
2023-09-21 18:32:17 +08:00
parent edbd1c41da
commit a0a45b8998
11 changed files with 409 additions and 74 deletions
+2 -2
View File
@@ -49,7 +49,7 @@ class DocumentObjectBuilder:
self.text = text
return self
def build(self, relation_store: ObjectRelationStore) -> DocumentObject:
def build(self) -> DocumentObject:
chunk_list = KnowledgeStore().get_chunk_list_writer().create_chunk_list_from_text(
self.text,
1024 * 4,
@@ -60,6 +60,6 @@ class DocumentObjectBuilder:
# Add relation to store
for chunk_id in chunk_list.chunk_list:
relation_store.add_relation(chunk_id, doc_id)
KnowledgeStore().get_relation_store().add_relation(chunk_id, doc_id)
return doc
+1 -1
View File
@@ -94,7 +94,7 @@ class EmailObjectBuilder:
with open(content_file, "r", encoding="utf-8") as f:
text = f.read()
document = DocumentObjectBuilder({}, {}, text).build(relation_store=relation)
document = DocumentObjectBuilder({}, {}, text).build()
document_id = document.calculate_id()
store.put_object(document_id, document.encode())
documents = {"email.txt": document_id}
+1 -1
View File
@@ -52,7 +52,7 @@ def get_exif_data(image_path: str):
return {
TAGS.get(key): exif_data[key]
for key in exif_data.keys()
if key in TAGS and isinstance(exif_data[key], (bytes, str))
if key in TAGS and isinstance(exif_data[key], str)
}
else:
return {}