RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
refactor: no need to inherit in python3 clean the code (#5659)
yihong4326873af666
diff --git a/api/db/services/llm_service.py b/api/db/services/llm_service.pyindex 5a61e4ed2c..039d459365 100644--- a/api/db/services/llm_service.py+++ b/api/db/services/llm_service.py@@ -224,7 +224,7 @@ class TenantLLMService(CommonService):return list(objs)-class LLMBundle(object):+class LLMBundle:def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese"):self.tenant_id = tenant_idself.llm_type = llm_typediff --git a/deepdoc/parser/pdf_parser.py b/deepdoc/parser/pdf_parser.pyindex 8a75ba6574..30a30f580d 100644--- a/deepdoc/parser/pdf_parser.py+++ b/deepdoc/parser/pdf_parser.py@@ -1170,7 +1170,7 @@ class RAGFlowPdfParser:return poss-class PlainParser(object):+class PlainParser:def __call__(self, filename, from_page=0, to_page=100000, **kwargs):self.outlines = []lines = []diff --git a/deepdoc/parser/ppt_parser.py b/deepdoc/parser/ppt_parser.pyindex 4e459d1933..25e8f84638 100644--- a/deepdoc/parser/ppt_parser.py+++ b/deepdoc/parser/ppt_parser.py@@ -19,7 +19,7 @@ from io import BytesIOfrom pptx import Presentation-class RAGFlowPptParser(object):+class RAGFlowPptParser:def __init__(self):super().__init__()diff --git a/deepdoc/vision/ocr.py b/deepdoc/vision/ocr.pyindex 4836f0339b..87ba2b6695 100644--- a/deepdoc/vision/ocr.py+++ b/deepdoc/vision/ocr.py@@ -122,7 +122,7 @@ def load_model(model_dir, nm):return loaded_model-class TextRecognizer(object):+class TextRecognizer:def __init__(self, model_dir):self.rec_image_shape = [int(v) for v in "3, 48, 320".split(",")]self.rec_batch_num = 16@@ -393,7 +393,7 @@ class TextRecognizer(object):return rec_res, time.time() - st-class TextDetector(object):+class TextDetector:def __init__(self, model_dir):pre_process_list = [{'DetResizeForTest': {@@ -506,7 +506,7 @@ class TextDetector(object):return dt_boxes, time.time() - st-class OCR(object):+class OCR:def __init__(self, model_dir=None):"""If you have trouble downloading HuggingFace models, -_^ this might help!!diff --git a/deepdoc/vision/operators.py b/deepdoc/vision/operators.pyindex a2ad17142d..4bee446b1a 100644--- a/deepdoc/vision/operators.py+++ b/deepdoc/vision/operators.py@@ -23,7 +23,7 @@ import mathfrom PIL import Image-class DecodeImage(object):+class DecodeImage:""" decode image """def __init__(self,@@ -65,7 +65,7 @@ class DecodeImage(object):return data-class StandardizeImage(object):+class StandardizeImag:"""normalize imageArgs:mean (list): im - mean@@ -102,7 +102,7 @@ class StandardizeImage(object):return im, im_info-class NormalizeImage(object):+class NormalizeImage:""" normalize image such as subtract mean, divide std"""@@ -129,7 +129,7 @@ class NormalizeImage(object):return data-class ToCHWImage(object):+class ToCHWImage:""" convert hwc image to chw image"""@@ -145,7 +145,7 @@ class ToCHWImage(object):return data-class KeepKeys(object):+class KeepKeys:def __init__(self, keep_keys, **kwargs):self.keep_keys = keep_keys@@ -156,7 +156,7 @@ class KeepKeys(object):return data_list-class Pad(object):+class Pad:def __init__(self, size=None, size_div=32, **kwargs):if size is not None and not isinstance(size, (int, list, tuple)):raise TypeError("Type of target_size is invalid. Now is {}".format(@@ -194,7 +194,7 @@ class Pad(object):return data-class LinearResize(object):+class LinearResize:"""resize image by target_size and max_sizeArgs:target_size (int): the target size of image@@ -261,7 +261,7 @@ class LinearResize(object):return im_scale_y, im_scale_x-class Resize(object):+class Resize:def __init__(self, size=(640, 640), **kwargs):self.size = size@@ -291,7 +291,7 @@ class Resize(object):return data-class DetResizeForTest(object):+class DetResizeForTest:def __init__(self, **kwargs):super(DetResizeForTest, self).__init__()self.resize_type = 0@@ -421,7 +421,7 @@ class DetResizeForTest(object):return img, [ratio_h, ratio_w]-class E2EResizeForTest(object):+class E2EResizeForTest:def __init__(self, **kwargs):super(E2EResizeForTest, self).__init__()self.max_side_len = kwargs['max_side_len']@@ -489,7 +489,7 @@ class E2EResizeForTest(object):return im, (ratio_h, ratio_w)-class KieResize(object):+class KieResize:def __init__(self, **kwargs):super(KieResize, self).__init__()self.max_side, self.min_side = kwargs['img_scale'][0], kwargs[@@ -539,7 +539,7 @@ class KieResize(object):return points-class SRResize(object):+class SRResize:def __init__(self,imgH=32,imgW=128,@@ -576,7 +576,7 @@ class SRResize(object):return data-class ResizeNormalize(object):+class ResizeNormalize:def __init__(self, size, interpolation=Image.BICUBIC):self.size = sizeself.interpolation = interpolation@@ -588,7 +588,7 @@ class ResizeNormalize(object):return img_numpy-class GrayImageChannelFormat(object):+class GrayImageChannelFormat:"""format gray scale image's channel: (3,h,w) -> (1,h,w)Args:@@ -612,7 +612,7 @@ class GrayImageChannelFormat(object):return data-class Permute(object):+class Permute:"""permute imageArgs:to_bgr (bool): whether convert RGB to BGR@@ -635,7 +635,7 @@ class Permute(object):return im, im_info-class PadStride(object):+class PadStride:""" padding image for model with FPN, instead PadBatch(pad_to_stride) in original configArgs:stride (bool): model with FPN need image shape % stride == 0diff --git a/deepdoc/vision/postprocess.py b/deepdoc/vision/postprocess.pyindex 27916cf45a..a61464382b 100644--- a/deepdoc/vision/postprocess.py+++ b/deepdoc/vision/postprocess.py@@ -38,7 +38,7 @@ def build_post_process(config, global_config=None):return module_class(**config)-class DBPostProcess(object):+class DBPostProcess:"""The post process for Differentiable Binarization (DB)."""@@ -259,7 +259,7 @@ class DBPostProcess(object):return boxes_batch-class BaseRecLabelDecode(object):+class BaseRecLabelDecode:""" Convert between text-label and text-index """def __init__(self, character_dict_path=None, use_space_char=False):diff --git a/deepdoc/vision/recognizer.py b/deepdoc/vision/recognizer.pyindex b3918ec7e3..1052350b88 100644--- a/deepdoc/vision/recognizer.py+++ b/deepdoc/vision/recognizer.py@@ -28,7 +28,7 @@ from .operators import preprocessfrom . import operatorsfrom .ocr import load_model-class Recognizer(object):+class Recognizer:def __init__(self, label_list, task_name, model_dir=None):"""If you have trouble downloading HuggingFace models, -_^ this might help!!diff --git a/rag/utils/azure_sas_conn.py b/rag/utils/azure_sas_conn.pyindex 48f9d0a64e..d1737546b1 100644--- a/rag/utils/azure_sas_conn.py+++ b/rag/utils/azure_sas_conn.py@@ -24,7 +24,7 @@ from azure.storage.blob import ContainerClient@singleton-class RAGFlowAzureSasBlob(object):+class RAGFlowAzureSasBlob:def __init__(self):self.conn = Noneself.container_url = os.getenv('CONTAINER_URL', settings.AZURE["container_url"])diff --git a/rag/utils/azure_spn_conn.py b/rag/utils/azure_spn_conn.pyindex 625ccc4b54..4b6b861f4a 100644--- a/rag/utils/azure_spn_conn.py+++ b/rag/utils/azure_spn_conn.py@@ -24,7 +24,7 @@ from azure.storage.filedatalake import FileSystemClient@singleton-class RAGFlowAzureSpnBlob(object):+class RAGFlowAzureSpnBlob:def __init__(self):self.conn = Noneself.account_url = os.getenv('ACCOUNT_URL', settings.AZURE["account_url"])diff --git a/rag/utils/minio_conn.py b/rag/utils/minio_conn.pyindex 48f02b6999..60707f4fc0 100644--- a/rag/utils/minio_conn.py+++ b/rag/utils/minio_conn.py@@ -24,7 +24,7 @@ from rag.utils import singleton@singleton-class RAGFlowMinio(object):+class RAGFlowMinio:def __init__(self):self.conn = Noneself.__open__()diff --git a/rag/utils/oss_conn.py b/rag/utils/oss_conn.pyindex 298c1a5b8d..a88eb9d181 100644--- a/rag/utils/oss_conn.py+++ b/rag/utils/oss_conn.py@@ -24,7 +24,7 @@ from rag import settings@singleton-class RAGFlowOSS(object):+class RAGFlowOSS:def __init__(self):self.conn = Noneself.oss_config = settings.OSSdiff --git a/rag/utils/s3_conn.py b/rag/utils/s3_conn.pyindex d1e7e72697..0318572e7c 100644--- a/rag/utils/s3_conn.py+++ b/rag/utils/s3_conn.py@@ -23,7 +23,7 @@ from rag.utils import singletonfrom rag import settings@singleton-class RAGFlowS3(object):+class RAGFlowS3:def __init__(self):self.conn = Noneself.s3_config = settings.S3diff --git a/sdk/python/ragflow_sdk/modules/base.py b/sdk/python/ragflow_sdk/modules/base.pyindex 5a6264f790..9014dd02d8 100644--- a/sdk/python/ragflow_sdk/modules/base.py+++ b/sdk/python/ragflow_sdk/modules/base.py@@ -14,7 +14,7 @@# limitations under the License.#-class Base(object):+class Base:def __init__(self, rag, res_dict):self.rag = ragfor k, v in res_dict.items():