Browse Source

Merge pull request #3995 from myhloli/dev

fix: enhance http-client backend parameters in vlm_analyze.py for improved configuration options
Xiaomeng Zhao 2 weeks ago
parent
commit
4f8d897342
1 changed files with 7 additions and 1 deletions
  1. 7 1
      mineru/backend/vlm/vlm_analyze.py

+ 7 - 1
mineru/backend/vlm/vlm_analyze.py

@@ -46,8 +46,11 @@ class ModelSingleton:
             batch_size = kwargs.get("batch_size", 0)  # for transformers backend only
             batch_size = kwargs.get("batch_size", 0)  # for transformers backend only
             max_concurrency = kwargs.get("max_concurrency", 100)  # for http-client backend only
             max_concurrency = kwargs.get("max_concurrency", 100)  # for http-client backend only
             http_timeout = kwargs.get("http_timeout", 600)  # for http-client backend only
             http_timeout = kwargs.get("http_timeout", 600)  # for http-client backend only
+            server_headers = kwargs.get("server_headers", None)  # for http-client backend only
+            max_retries = kwargs.get("max_retries", 3)  # for http-client backend only
+            retry_backoff_factor = kwargs.get("retry_backoff_factor", 0.5)  # for http-client backend only
             # 从kwargs中移除这些参数,避免传递给不相关的初始化函数
             # 从kwargs中移除这些参数,避免传递给不相关的初始化函数
-            for param in ["batch_size", "max_concurrency", "http_timeout"]:
+            for param in ["batch_size", "max_concurrency", "http_timeout", "server_headers", "max_retries", "retry_backoff_factor"]:
                 if param in kwargs:
                 if param in kwargs:
                     del kwargs[param]
                     del kwargs[param]
             if backend not in ["http-client"] and not model_path:
             if backend not in ["http-client"] and not model_path:
@@ -175,6 +178,9 @@ class ModelSingleton:
                 batch_size=batch_size,
                 batch_size=batch_size,
                 max_concurrency=max_concurrency,
                 max_concurrency=max_concurrency,
                 http_timeout=http_timeout,
                 http_timeout=http_timeout,
+                server_headers=server_headers,
+                max_retries=max_retries,
+                retry_backoff_factor=retry_backoff_factor,
             )
             )
             elapsed = round(time.time() - start_time, 2)
             elapsed = round(time.time() - start_time, 2)
             logger.info(f"get {backend} predictor cost: {elapsed}s")
             logger.info(f"get {backend} predictor cost: {elapsed}s")