enh: mineru api timeout
This commit is contained in:
@@ -337,6 +337,7 @@ class Loader:
|
||||
api_url=self.kwargs.get("MINERU_API_URL", "http://localhost:8000"),
|
||||
api_key=self.kwargs.get("MINERU_API_KEY", ""),
|
||||
params=self.kwargs.get("MINERU_PARAMS", {}),
|
||||
timeout=int(self.kwargs.get("MINERU_API_TIMEOUT", 300)),
|
||||
)
|
||||
elif (
|
||||
self.engine == "mistral_ocr"
|
||||
|
||||
@@ -26,11 +26,13 @@ class MinerULoader:
|
||||
api_url: str = "http://localhost:8000",
|
||||
api_key: str = "",
|
||||
params: dict = None,
|
||||
timeout: int = 300,
|
||||
):
|
||||
self.file_path = file_path
|
||||
self.api_mode = api_mode.lower()
|
||||
self.api_url = api_url.rstrip("/")
|
||||
self.api_key = api_key
|
||||
self.timeout = timeout
|
||||
|
||||
# Parse params dict with defaults
|
||||
self.params = params or {}
|
||||
@@ -101,7 +103,7 @@ class MinerULoader:
|
||||
f"{self.api_url}/file_parse",
|
||||
data=form_data,
|
||||
files=files,
|
||||
timeout=300, # 5 minute timeout for large documents
|
||||
timeout=self.timeout, # 5 minute timeout for large documents
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
@@ -300,7 +302,7 @@ class MinerULoader:
|
||||
response = requests.put(
|
||||
upload_url,
|
||||
data=f,
|
||||
timeout=300, # 5 minute timeout for large files
|
||||
timeout=self.timeout, # 5 minute timeout for large files
|
||||
)
|
||||
response.raise_for_status()
|
||||
except FileNotFoundError:
|
||||
|
||||
Reference in New Issue
Block a user