Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix elasticsearch status display (#3487)

Jin Hai883fafde72c9
diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py
index 104b53ab1c..503bcb43de 100644
--- a/rag/utils/es_conn.py
+++ b/rag/utils/es_conn.py
@@ -63,7 +63,9 @@ class ESConnection(DocStoreConnection):
return "elasticsearch"
def health(self) -> dict:
- return dict(self.es.cluster.health()) + {"type": "elasticsearch"}
+ health_dict = dict(self.es.cluster.health())
+ health_dict["type"] = "elasticsearch"
+ return health_dict
"""
Table operations
diff --git a/rag/utils/minio_conn.py b/rag/utils/minio_conn.py
index 5952482feb..11682988e3 100644
--- a/rag/utils/minio_conn.py
+++ b/rag/utils/minio_conn.py
@@ -55,7 +55,7 @@ class RAGFlowMinio(object):
)
return r
except Exception:
- logging.exception(f"Fail put {bucket}/{fnm}:")
+ logging.exception(f"Fail to put {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
@@ -63,37 +63,37 @@ class RAGFlowMinio(object):
try:
self.conn.remove_object(bucket, fnm)
except Exception:
- logging.exception(f"Fail put {bucket}/{fnm}:")
+ logging.exception(f"Fail to remove {bucket}/{fnm}:")
- def get(self, bucket, fnm):
+ def get(self, bucket, filename):
for _ in range(1):
try:
- r = self.conn.get_object(bucket, fnm)
+ r = self.conn.get_object(bucket, filename)
return r.read()
except Exception:
- logging.exception(f"Fail put {bucket}/{fnm}:")
+ logging.exception(f"Fail to get {bucket}/{filename}")
self.__open__()
time.sleep(1)
return
- def obj_exist(self, bucket, fnm):
+ def obj_exist(self, bucket, filename):
try:
if not self.conn.bucket_exists(bucket):
return False
- if self.conn.stat_object(bucket, fnm):
+ if self.conn.stat_object(bucket, filename):
return True
- return False
+ else:
+ return False
except Exception:
- logging.exception(f"RAGFlowMinio.obj_exist {bucket}/{fnm} got exception:")
- return False
-
+ logging.exception(f"Not found: {bucket}/{filename}")
+ return False
def get_presigned_url(self, bucket, fnm, expires):
for _ in range(10):
try:
return self.conn.get_presigned_url("GET", bucket, fnm, expires)
except Exception:
- logging.exception(f"Fail put {bucket}/{fnm}:")
+ logging.exception(f"Fail to get_presigned {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
return
@@ -101,11 +101,11 @@ class RAGFlowMinio(object):
MINIO = RAGFlowMinio()
-
if __name__ == "__main__":
conn = RAGFlowMinio()
fnm = "/opt/home/kevinhu/docgpt/upload/13/11-408.jpg"
from PIL import Image
+
img = Image.open(fnm)
buff = BytesIO()
img.save(buff, format='JPEG')