refactor code (#583)
### What problem does this PR solve? ### Type of change - [x] Refactoring
This commit is contained in:
@@ -15,9 +15,6 @@ def singleton(cls, *args, **kw):
|
||||
return _singleton
|
||||
|
||||
|
||||
from .minio_conn import MINIO
|
||||
from .es_conn import ELASTICSEARCH
|
||||
|
||||
def rmSpace(txt):
|
||||
txt = re.sub(r"([^a-z0-9.,]) +([^ ])", r"\1\2", txt, flags=re.IGNORECASE)
|
||||
return re.sub(r"([^ ]) +([^a-z0-9.,])", r"\1\2", txt, flags=re.IGNORECASE)
|
||||
|
||||
@@ -15,7 +15,7 @@ es_logger.info("Elasticsearch version: "+str(elasticsearch.__version__))
|
||||
|
||||
|
||||
@singleton
|
||||
class HuEs:
|
||||
class ESConnection:
|
||||
def __init__(self):
|
||||
self.info = {}
|
||||
self.conn()
|
||||
@@ -454,4 +454,4 @@ class HuEs:
|
||||
scroll_size = len(page['hits']['hits'])
|
||||
|
||||
|
||||
ELASTICSEARCH = HuEs()
|
||||
ELASTICSEARCH = ESConnection()
|
||||
|
||||
@@ -8,7 +8,7 @@ from rag.utils import singleton
|
||||
|
||||
|
||||
@singleton
|
||||
class HuMinio(object):
|
||||
class RAGFlowMinio(object):
|
||||
def __init__(self):
|
||||
self.conn = None
|
||||
self.__open__()
|
||||
@@ -86,10 +86,12 @@ class HuMinio(object):
|
||||
time.sleep(1)
|
||||
return
|
||||
|
||||
MINIO = HuMinio()
|
||||
|
||||
MINIO = RAGFlowMinio()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
conn = HuMinio()
|
||||
conn = RAGFlowMinio()
|
||||
fnm = "/opt/home/kevinhu/docgpt/upload/13/11-408.jpg"
|
||||
from PIL import Image
|
||||
img = Image.open(fnm)
|
||||
|
||||
Reference in New Issue
Block a user