File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 11import asyncio
22import math
3+ import os
34import re
45from concurrent .futures import Executor
56from typing import Literal , Sequence
67
78from PIL import Image
9+ from loguru import logger
810
911from .post_process import post_process
1012from .structs import BLOCK_TYPES , ContentBlock
@@ -322,6 +324,15 @@ def __init__(
322324 max_retries : int = 3 , # for http-client backend only
323325 retry_backoff_factor : float = 0.5 , # for http-client backend only
324326 ) -> None :
327+ env_debug_value = os .getenv ('MINERU_VL_DEBUG_ENABLE' , '' )
328+ if env_debug_value :
329+ if env_debug_value .lower () in ['true' , '1' , 'yes' ]:
330+ debug = True
331+ elif env_debug_value .lower () in ['false' , '0' , 'no' ]:
332+ debug = False
333+ else :
334+ logger .warning (f'unknown MINERU_VL_DEBUG_ENABLE config: { env_debug_value } , pass' )
335+
325336 if backend == "transformers" :
326337 if model is None or processor is None :
327338 if not model_path :
Original file line number Diff line number Diff line change 22import json
33import os
44import re
5+ from enum import Enum
56from typing import AsyncIterable , Iterable , Sequence
67
78import httpx
@@ -35,6 +36,16 @@ def _get_env(key: str, default: str | None = None) -> str:
3536 raise ValueError (f"Environment variable { key } is not set." )
3637
3738
39+ class HTTPMethod (str , Enum ):
40+ HEAD = "HEAD"
41+ GET = "GET"
42+ PUT = "PUT"
43+ DELETE = "DELETE"
44+ OPTIONS = "OPTIONS"
45+ TRACE = "TRACE"
46+ POST = "POST"
47+
48+
3849class HttpVlmClient (VlmClient ):
3950 def __init__ (
4051 self ,
@@ -120,6 +131,7 @@ def _new_client(self) -> httpx.Client:
120131 retry = Retry (
121132 total = self .max_retries ,
122133 backoff_factor = self .retry_backoff_factor ,
134+ allowed_methods = list (HTTPMethod ),
123135 ),
124136 transport = httpx .HTTPTransport (
125137 limits = httpx .Limits (
@@ -144,6 +156,7 @@ async def _new_aio_client(self) -> httpx.AsyncClient:
144156 retry = Retry (
145157 total = self .max_retries ,
146158 backoff_factor = self .retry_backoff_factor ,
159+ allowed_methods = list (HTTPMethod ),
147160 ),
148161 transport = httpx .AsyncHTTPTransport (
149162 limits = httpx .Limits (
You can’t perform that action at this time.
0 commit comments