Skip to content

ProviderConfig

Sub classes

Name Children Inherits
BaseAnnotatorConfig
docler_config.annotator_configs
Base configuration for annotators.
BaseChunkerConfig
docler_config.chunker_configs
Base configuration for text chunkers.
BaseConverterConfig
docler_config.converter_configs
Base configuration for document converters.
BaseProcessorConfig
docler_config.processor_configs
Base configuration for document processors.

Base classes

Name Children Inherits
BaseSettings
pydantic_settings.main
Base class for settings, allowing values to be overridden by environment variables.

⋔ Inheritance diagram

graph TD
  1396724084["provider.ProviderConfig"]
  1261767679["main.BaseSettings"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  1261767679 --> 1396724084
  3879467795 --> 1261767679
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseSettings

Base configuration for document converters.

Source code in src/docler_config/provider.py
class ProviderConfig(BaseSettings):
    """Base configuration for document converters."""

    type: str = Field(init=False)
    """Type discriminator for provider configs."""

    model_config = SettingsConfigDict(
        frozen=True,
        use_attribute_docstrings=True,
        extra="forbid",
        env_file_encoding="utf-8",
    )

    @classmethod
    def resolve_type(cls, name: str) -> type[Self]:  # type: ignore
        """Get a the config class of given type."""
        return next(kls for kls in cls.__subclasses__() if kls.type == name)

    @field_serializer("*", when_used="json-unless-none")
    def serialize_special_types(self, v: Any, _info: Any) -> Any:
        match v:
            case SecretStr():
                return v.get_secret_value()
            case HttpUrl():
                return str(v)
            case _:
                return v

    def get_config_fields(self) -> dict[str, Any]:
        return self.model_dump(exclude={"type"}, mode="json")

    def get_provider(self) -> Any:
        """Get the provider instance."""
        raise NotImplementedError

type class-attribute instance-attribute

type: str = Field(init=False)

Type discriminator for provider configs.

get_provider

get_provider() -> Any

Get the provider instance.

Source code in src/docler_config/provider.py
def get_provider(self) -> Any:
    """Get the provider instance."""
    raise NotImplementedError

resolve_type classmethod

resolve_type(name: str) -> type[Self]

Get a the config class of given type.

Source code in src/docler_config/provider.py
@classmethod
def resolve_type(cls, name: str) -> type[Self]:  # type: ignore
    """Get a the config class of given type."""
    return next(kls for kls in cls.__subclasses__() if kls.type == name)

:fa-brands-github: Show source on GitHub