Skip to content

Models Reference

FloweryAPIConfig dataclass

Configuration for the Flowery API

Attributes:

Name Type Description
user_agent str

User-Agent string to use for the HTTP requests. Required as of 2.1.0.

logger Logger

Logger to use for logging messages

allow_truncation bool

Whether to allow truncation of text that is too long, defaults to True

retry_limit int

Number of times to retry a request before giving up, defaults to 3

interval int

Seconds to wait between each retried request, multiplied by how many attempted requests have been made, defaults to 5

Properties

prepended_user_agent (str): The user_agent with the PyFlowery module version prepended and the Python version appended

Source code in pyflowery/models.py
@dataclass
class FloweryAPIConfig:
    """Configuration for the Flowery API

    Attributes:
        user_agent (str): User-Agent string to use for the HTTP requests. Required as of 2.1.0.
        logger (Logger): Logger to use for logging messages
        allow_truncation (bool): Whether to allow truncation of text that is too long, defaults to `True`
        retry_limit (int): Number of times to retry a request before giving up, defaults to `3`
        interval (int): Seconds to wait between each retried request, multiplied by how many attempted requests have been made, defaults to `5`

    Properties:
        prepended_user_agent (str): The user_agent with the PyFlowery module version prepended and the Python version appended
    """

    user_agent: str
    logger: Logger = getLogger("pyflowery")
    allow_truncation: bool = False
    retry_limit: int = 3
    interval: int = 5

    @property
    def prepended_user_agent(self) -> str:
        """Return the user_agent with the PyFlowery module version prepended"""
        return f"PyFlowery/{version} {self.user_agent} (Python {pyversion})"

prepended_user_agent: str property

Return the user_agent with the PyFlowery module version prepended

Language dataclass

Language object returned from the Flowery API

Attributes:

Name Type Description
name str

Name of the language

code str

Code of the language

Source code in pyflowery/models.py
@dataclass
class Language:
    """Language object returned from the Flowery API

    Attributes:
        name (str): Name of the language
        code (str): Code of the language
    """

    name: str
    code: str

Result dataclass

Result returned from low-level RestAdapter

Attributes:

Name Type Description
success bool

Boolean of whether the request was successful

status_code int

Standard HTTP Status code

message str = ''

Human readable result

data Union[List[Dict], Dict, bytes]

Python List of Dictionaries (or maybe just a single Dictionary on error), can also be a ByteString

Source code in pyflowery/models.py
@dataclass
class Result:
    """Result returned from low-level RestAdapter

    Attributes:
        success (bool): Boolean of whether the request was successful
        status_code (int): Standard HTTP Status code
        message (str = ''): Human readable result
        data (Union[List[Dict], Dict, bytes]): Python List of Dictionaries (or maybe just a single Dictionary on error), can also be a ByteString
    """

    success: bool
    status_code: int
    message: str = ""
    data: Union[List[Dict], Dict, bytes] = field(default_factory=dict)

Voice dataclass

Voice object returned from the Flowery API

Attributes:

Name Type Description
id str

UUID of the voice

name str

Name of the voice

gender str

Gender of the voice

source str

Source of the voice

language Language

Language object

Source code in pyflowery/models.py
@dataclass
class Voice:
    """Voice object returned from the Flowery API

    Attributes:
        id (str): UUID of the voice
        name (str): Name of the voice
        gender (str): Gender of the voice
        source (str): Source of the voice
        language (Language): Language object
    """

    id: str
    name: str
    gender: str
    source: str
    language: "Language"