Skip to content

horde_sdk.ai_horde_api.apimodels.documents

DocumentFormat

Bases: StrEnum

The supported formats for a document.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class DocumentFormat(StrEnum):
    """The supported formats for a document."""

    html = "html"
    markdown = "markdown"

html class-attribute instance-attribute

html = 'html'

markdown class-attribute instance-attribute

markdown = 'markdown'

HordeDocument

Bases: HordeResponseBaseModel

Represents the data returned from the following endpoints and http status codes
  • /v2/documents/terms | AIHordeGetTermsRequest [GET] -> 200
  • /v2/documents/sponsors | AIHordeGetSponsorsRequest [GET] -> 200
  • /v2/documents/privacy | AIHordeGetPrivacyPolicyRequest [GET] -> 200

v2 API Model: HordeDocument

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class HordeDocument(HordeResponseBaseModel):
    """Represents the data returned from the following endpoints and http status codes:
        - /v2/documents/terms | AIHordeGetTermsRequest [GET] -> 200
        - /v2/documents/sponsors | AIHordeGetSponsorsRequest [GET] -> 200
        - /v2/documents/privacy | AIHordeGetPrivacyPolicyRequest [GET] -> 200

    v2 API Model: `HordeDocument`
    """  # noqa: D205, D415

    html: str | None = None
    """The HTML content of the document, if requested."""
    markdown: str | None = None
    """The markdown content of the document, if requested."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str:
        return "HordeDocument"

html class-attribute instance-attribute

html: str | None = None

The HTML content of the document, if requested.

markdown class-attribute instance-attribute

markdown: str | None = None

The markdown content of the document, if requested.

get_api_model_name classmethod

get_api_model_name() -> str
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_model_name(cls) -> str:
    return "HordeDocument"

AIHordeDocumentRequestMixin

Bases: HordeAPIObjectBaseModel

Mixin for requests that retrieve a document from the AI Horde API.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class AIHordeDocumentRequestMixin(HordeAPIObjectBaseModel):
    """Mixin for requests that retrieve a document from the AI Horde API."""

    format: DocumentFormat | str = DocumentFormat.html

    """The format of the document to return. Default is markdown."""

    @field_validator("format")
    def validate_format(cls, value: DocumentFormat | str) -> DocumentFormat | str:
        """Validate the format is a valid document format."""
        if isinstance(value, DocumentFormat):
            return value

        try:
            DocumentFormat(value)
        except ValueError:
            logger.warning(f"Unknown document format: {value}. Is your SDK out of date or did the API change?")

        return value

format class-attribute instance-attribute

format: DocumentFormat | str = DocumentFormat.html

The format of the document to return. Default is markdown.

validate_format

validate_format(
    value: DocumentFormat | str,
) -> DocumentFormat | str

Validate the format is a valid document format.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@field_validator("format")
def validate_format(cls, value: DocumentFormat | str) -> DocumentFormat | str:
    """Validate the format is a valid document format."""
    if isinstance(value, DocumentFormat):
        return value

    try:
        DocumentFormat(value)
    except ValueError:
        logger.warning(f"Unknown document format: {value}. Is your SDK out of date or did the API change?")

    return value

AIHordeGetPrivacyPolicyRequest

Bases: BaseAIHordeRequest, AIHordeDocumentRequestMixin

Represents a GET request to the /v2/documents/privacy endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class AIHordeGetPrivacyPolicyRequest(BaseAIHordeRequest, AIHordeDocumentRequestMixin):
    """Represents a GET request to the /v2/documents/privacy endpoint."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return None

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.GET

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_privacy

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[HordeDocument]:
        return HordeDocument

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return None

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_privacy

get_default_success_response_type classmethod

get_default_success_response_type() -> type[HordeDocument]
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[HordeDocument]:
    return HordeDocument

AIHordeGetSponsorsRequest

Bases: BaseAIHordeRequest, AIHordeDocumentRequestMixin

Represents a GET request to the /v2/documents/sponsors endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class AIHordeGetSponsorsRequest(BaseAIHordeRequest, AIHordeDocumentRequestMixin):
    """Represents a GET request to the /v2/documents/sponsors endpoint."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return None

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.GET

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_sponsors

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[HordeDocument]:
        return HordeDocument

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return None

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_sponsors

get_default_success_response_type classmethod

get_default_success_response_type() -> type[HordeDocument]
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[HordeDocument]:
    return HordeDocument

AIHordeGetTermsRequest

Bases: BaseAIHordeRequest, AIHordeDocumentRequestMixin

Represents a GET request to the /v2/documents/terms endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/documents.py
class AIHordeGetTermsRequest(BaseAIHordeRequest, AIHordeDocumentRequestMixin):
    """Represents a GET request to the /v2/documents/terms endpoint."""

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return None

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.GET

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_terms

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[HordeDocument]:
        return HordeDocument

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return None

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_documents_terms

get_default_success_response_type classmethod

get_default_success_response_type() -> type[HordeDocument]
Source code in horde_sdk/ai_horde_api/apimodels/documents.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[HordeDocument]:
    return HordeDocument