summaryrefslogtreecommitdiff
path: root/rag/db/document.py
diff options
context:
space:
mode:
Diffstat (limited to 'rag/db/document.py')
-rw-r--r--rag/db/document.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/rag/db/document.py b/rag/db/document.py
index 528a399..54ac451 100644
--- a/rag/db/document.py
+++ b/rag/db/document.py
@@ -1,6 +1,7 @@
import hashlib
import os
+from langchain_community.document_loaders.blob_loaders import Blob
import psycopg
from loguru import logger as log
@@ -26,11 +27,11 @@ class DocumentDB:
cur.execute(TABLES)
self.conn.commit()
- def __hash(self, blob: bytes) -> str:
+ def __hash(self, blob: Blob) -> str:
log.debug("Hashing document...")
- return hashlib.sha256(blob).hexdigest()
+ return hashlib.sha256(blob.as_bytes()).hexdigest()
- def add(self, blob: bytes) -> bool:
+ def add(self, blob: Blob) -> bool:
with self.conn.cursor() as cur:
hash = self.__hash(blob)
cur.execute(