PaddlePaddle/PaddleOCR · error · ValueError
Unsupported model: {model!r}
Error message
Unsupported model: {model!r} What it means
ValueError from _resolve_vl_model in the langchain-paddleocr PaddleOCRVLLoader when a string model name cannot be converted to the Model enum. The loader accepts either a Model enum member or one of the enum's exact string values; anything else (wrong casing, typo, unknown model id) is rejected with 'Unsupported model: {model!r}'.
Source
Thrown at langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py:43
from paddleocr import Model, PaddleOCRClient, PaddleOCRVLOptions
from pydantic import SecretStr
logger = logging.getLogger(__name__)
_DEFAULT_BASE_URL = "https://paddleocr.aistudio-app.com"
_PAGES_DELIMITER = "\n\f"
def _resolve_vl_model(model: str | Model) -> Model:
if isinstance(model, Model):
resolved = model
else:
try:
resolved = Model(model)
except ValueError as exc:
msg = f"Unsupported model: {model!r}"
raise ValueError(msg) from exc
return resolved
class PaddleOCRVLLoader(BaseLoader):
"""Load documents using the PaddleOCR-VL document parsing API via SDK."""
def __init__(
self,
file_path: str | Iterable[str],
*,
access_token: SecretStr | None = None,
base_url: str | None = None,
model: str | Model | None = None,
use_doc_orientation_classify: bool | None = False,
use_doc_unwarping: bool | None = False,
use_layout_detection: bool | None = None,
use_chart_recognition: bool | None = None,View on GitHub (pinned to 2661c7c0ef)
Solutions
- List valid values: `from langchain_paddleocr... import Model; print([m.value for m in Model])` and pass one exactly.
- Upgrade langchain-paddleocr if the model you want was added in a newer release.
- Pass the Model enum member directly instead of a string to get static checking.
Example fix
// before loader = PaddleOCRVLLoader(path, model="paddleocr-vl") // after from langchain_paddleocr.document_loaders.paddleocr_vl import Model loader = PaddleOCRVLLoader(path, model=Model.PADDLEOCR_VL) # or the exact enum string value
Defensive patterns
Strategy: type-guard
Validate before calling
from langchain_paddleocr.document_loaders import paddleocr_vl
def model_supported(model: str) -> bool:
values = {m.value for m in paddleocr_vl.Model}
return model in values Type guard
from typing import Any
def is_vl_model(value: Any) -> bool:
"""True when value is a Model member or one of its exact string values."""
if isinstance(value, paddleocr_vl.Model):
return True
return isinstance(value, str) and value in {m.value for m in paddleocr_vl.Model} Try / catch
try:
loader = PaddleOCRVLLoader(path, model=name)
docs = loader.load()
except ValueError as e:
if "Unsupported model" in str(e):
valid = [m.value for m in Model]
raise ValueError(f"{name!r} invalid; choose from {valid}") from e
raise Prevention
- Derive model names from the Model enum at runtime instead of hardcoding strings.
- Run a startup assert that configured model names are enum members so failures surface at boot, not mid-load.
- Upgrade langchain-paddleocr when adopting newly released VL models.
When it happens
Trigger: Passing model="paddleocr-vl" when the enum expects e.g. "PaddleOCR-VL" or a specific version string; passing an arbitrary API model id not present in the local Model enum; passing None-like or empty strings.
Common situations: New server-side model names not yet in the installed langchain-paddleocr version; casing/whitespace differences between docs and enum values.
Related errors
- File not found: '{file_path}'
- The input data is inconsistent with expectations.
- Unknown provider: {provider}
- Unsupported model: {normalized!r}. Supported models: {suppor
- Invalid data URL: expected a comma after the MIME type.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/b71a8b8191ff87d5.
Report an issue: GitHub.