fcaai 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fcaai/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Official Python client for the fcaai API (https://api.fcaai.ai). Standard library only."""
2
+ from ._errors import FcaaiError, FcaaiTimeoutError
3
+ from .client import (CHUNK_SIZE, DEFAULT_BASE_URL, SIMPLE_UPLOAD_MAX, Fcaai, Generation, Output, Template, TemplateInput, Transport, Voice,
4
+ VoiceSample,
5
+ __version__, urllib_transport)
6
+ from .webhooks import construct_event, parse_signature_header, sign_webhook_payload, verify_webhook_signature
7
+
8
+ __all__ = ["Fcaai", "Generation", "Output", "Voice", "Template", "TemplateInput", "FcaaiError", "FcaaiTimeoutError", "verify_webhook_signature", "sign_webhook_payload",
9
+ "parse_signature_header", "construct_event", "Transport", "VoiceSample", "urllib_transport", "DEFAULT_BASE_URL",
10
+ "SIMPLE_UPLOAD_MAX", "CHUNK_SIZE", "__version__"]
fcaai/_errors.py ADDED
@@ -0,0 +1,31 @@
1
+ from typing import Any, Optional
2
+
3
+
4
+ class FcaaiError(Exception):
5
+ """Raised for every non-2xx response (and network failures, status 0)."""
6
+
7
+ def __init__(self, message: str, *, status: int = 0, type: str = "api_error", code: str = "error",
8
+ request_id: Optional[str] = None, doc_url: Optional[str] = None,
9
+ retry_after: Optional[float] = None, body: Any = None) -> None:
10
+ super().__init__(message)
11
+ self.message = message
12
+ self.status = status
13
+ self.type = type
14
+ self.code = code
15
+ self.request_id = request_id
16
+ self.doc_url = doc_url
17
+ self.retry_after = retry_after
18
+ self.body = body
19
+
20
+ @property
21
+ def retryable(self) -> bool:
22
+ return self.status in (0, 408, 429) or self.status >= 500
23
+
24
+ def __repr__(self) -> str:
25
+ return f"FcaaiError(status={self.status}, code={self.code!r}, message={self.message!r}, request_id={self.request_id!r})"
26
+
27
+
28
+ class FcaaiTimeoutError(FcaaiError):
29
+ def __init__(self, message: str, generation_id: Optional[str] = None) -> None:
30
+ super().__init__(message, status=0, type="timeout", code="wait_timeout")
31
+ self.generation_id = generation_id