syncsdk 0.1.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.
Files changed (52) hide show
  1. sync/__init__.py +63 -0
  2. sync/client.py +144 -0
  3. sync/common/__init__.py +46 -0
  4. sync/common/errors/__init__.py +8 -0
  5. sync/common/errors/bad_request_error.py +9 -0
  6. sync/common/errors/internal_server_error.py +9 -0
  7. sync/common/errors/not_found_error.py +9 -0
  8. sync/common/errors/unauthorized_error.py +9 -0
  9. sync/common/types/__init__.py +39 -0
  10. sync/common/types/audio.py +27 -0
  11. sync/common/types/create_generation_dto.py +44 -0
  12. sync/common/types/estimated_generation_cost.py +33 -0
  13. sync/common/types/generation.py +77 -0
  14. sync/common/types/generation_error.py +35 -0
  15. sync/common/types/generation_error_message.py +5 -0
  16. sync/common/types/generation_id.py +3 -0
  17. sync/common/types/generation_options.py +28 -0
  18. sync/common/types/generation_status.py +7 -0
  19. sync/common/types/input.py +8 -0
  20. sync/common/types/model.py +7 -0
  21. sync/common/types/segment_frames.py +5 -0
  22. sync/common/types/segment_secs.py +5 -0
  23. sync/common/types/sync_mode.py +5 -0
  24. sync/common/types/tts.py +28 -0
  25. sync/common/types/tts_provider_config.py +34 -0
  26. sync/common/types/video.py +35 -0
  27. sync/core/__init__.py +50 -0
  28. sync/core/api_error.py +15 -0
  29. sync/core/client_wrapper.py +55 -0
  30. sync/core/datetime_utils.py +28 -0
  31. sync/core/file.py +67 -0
  32. sync/core/http_client.py +497 -0
  33. sync/core/http_response.py +47 -0
  34. sync/core/jsonable_encoder.py +100 -0
  35. sync/core/pydantic_utilities.py +294 -0
  36. sync/core/query_encoder.py +58 -0
  37. sync/core/remove_none_from_dict.py +11 -0
  38. sync/core/request_options.py +35 -0
  39. sync/core/serialization.py +276 -0
  40. sync/environment.py +7 -0
  41. sync/generate/__init__.py +2 -0
  42. sync/generate/client.py +446 -0
  43. sync/generate/raw_client.py +648 -0
  44. sync/py.typed +0 -0
  45. sync/version.py +3 -0
  46. sync/webhooks/__init__.py +5 -0
  47. sync/webhooks/types/__init__.py +6 -0
  48. sync/webhooks/types/generation_notification.py +73 -0
  49. sync/webhooks/types/webhook_status.py +5 -0
  50. syncsdk-0.1.0.dist-info/METADATA +190 -0
  51. syncsdk-0.1.0.dist-info/RECORD +52 -0
  52. syncsdk-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
+ import typing
5
+ from .tts_provider_config import TtsProviderConfig
6
+ import pydantic
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
8
+
9
+
10
+ class Tts(UniversalBaseModel):
11
+ """
12
+ Text to speech input
13
+ """
14
+
15
+ type: typing.Literal["text"] = "text"
16
+ provider: TtsProviderConfig = pydantic.Field()
17
+ """
18
+ Integration provider configuration
19
+ """
20
+
21
+ if IS_PYDANTIC_V2:
22
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
23
+ else:
24
+
25
+ class Config:
26
+ frozen = True
27
+ smart_union = True
28
+ extra = pydantic.Extra.allow
@@ -0,0 +1,34 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
+ import pydantic
5
+ import typing_extensions
6
+ from ...core.serialization import FieldMetadata
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
8
+ import typing
9
+
10
+
11
+ class TtsProviderConfig(UniversalBaseModel):
12
+ name: str = pydantic.Field()
13
+ """
14
+ name of the provider
15
+ """
16
+
17
+ script: str = pydantic.Field()
18
+ """
19
+ script to be used for generation
20
+ """
21
+
22
+ voice_id: typing_extensions.Annotated[str, FieldMetadata(alias="voiceId")] = pydantic.Field()
23
+ """
24
+ id of the voice to be used for generation
25
+ """
26
+
27
+ if IS_PYDANTIC_V2:
28
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
29
+ else:
30
+
31
+ class Config:
32
+ frozen = True
33
+ smart_union = True
34
+ extra = pydantic.Extra.allow
@@ -0,0 +1,35 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
+ import typing
5
+ import pydantic
6
+ from .segment_secs import SegmentSecs
7
+ from .segment_frames import SegmentFrames
8
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
9
+
10
+
11
+ class Video(UniversalBaseModel):
12
+ type: typing.Literal["video"] = "video"
13
+ url: str = pydantic.Field()
14
+ """
15
+ URL of the video to be used for generation
16
+ """
17
+
18
+ segments_secs: typing.Optional[SegmentSecs] = pydantic.Field(default=None)
19
+ """
20
+ Start time and end time (in seconds) of the video segment to apply generation to. Configured as a list of lists, where each inner list contains the start time and end time of the segment. Currently only one segment is supported. ex: [[10.5, 20.5]] will lipsync only the segment between 10.5 and 20.5 seconds of the video.
21
+ """
22
+
23
+ segments_frames: typing.Optional[SegmentFrames] = pydantic.Field(default=None)
24
+ """
25
+ Start frame and end frame of the video segment to apply generation to. Configured as a list of lists, where each inner list contains the start frame and end frame of the segment. Currently only one segment is supported. ex: [[100, 200]] will lipsync only the segment between frames 100 and 200 of the video
26
+ """
27
+
28
+ if IS_PYDANTIC_V2:
29
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
30
+ else:
31
+
32
+ class Config:
33
+ frozen = True
34
+ smart_union = True
35
+ extra = pydantic.Extra.allow
sync/core/__init__.py ADDED
@@ -0,0 +1,50 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .api_error import ApiError
4
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
+ from .datetime_utils import serialize_datetime
6
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
+ from .http_client import AsyncHttpClient, HttpClient
8
+ from .http_response import AsyncHttpResponse, HttpResponse
9
+ from .jsonable_encoder import jsonable_encoder
10
+ from .pydantic_utilities import (
11
+ IS_PYDANTIC_V2,
12
+ UniversalBaseModel,
13
+ UniversalRootModel,
14
+ parse_obj_as,
15
+ universal_field_validator,
16
+ universal_root_validator,
17
+ update_forward_refs,
18
+ )
19
+ from .query_encoder import encode_query
20
+ from .remove_none_from_dict import remove_none_from_dict
21
+ from .request_options import RequestOptions
22
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
23
+
24
+ __all__ = [
25
+ "ApiError",
26
+ "AsyncClientWrapper",
27
+ "AsyncHttpClient",
28
+ "AsyncHttpResponse",
29
+ "BaseClientWrapper",
30
+ "FieldMetadata",
31
+ "File",
32
+ "HttpClient",
33
+ "HttpResponse",
34
+ "IS_PYDANTIC_V2",
35
+ "RequestOptions",
36
+ "SyncClientWrapper",
37
+ "UniversalBaseModel",
38
+ "UniversalRootModel",
39
+ "convert_and_respect_annotation_metadata",
40
+ "convert_file_dict_to_httpx_tuples",
41
+ "encode_query",
42
+ "jsonable_encoder",
43
+ "parse_obj_as",
44
+ "remove_none_from_dict",
45
+ "serialize_datetime",
46
+ "universal_field_validator",
47
+ "universal_root_validator",
48
+ "update_forward_refs",
49
+ "with_content_type",
50
+ ]
sync/core/api_error.py ADDED
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+
6
+ class ApiError(Exception):
7
+ status_code: typing.Optional[int]
8
+ body: typing.Any
9
+
10
+ def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
11
+ self.status_code = status_code
12
+ self.body = body
13
+
14
+ def __str__(self) -> str:
15
+ return f"status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,55 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import httpx
5
+ from .http_client import HttpClient
6
+ from .http_client import AsyncHttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None):
11
+ self.api_key = api_key
12
+ self._base_url = base_url
13
+ self._timeout = timeout
14
+
15
+ def get_headers(self) -> typing.Dict[str, str]:
16
+ headers: typing.Dict[str, str] = {
17
+ "User-Agent": "syncsdk/0.1.0",
18
+ "X-Fern-Language": "Python",
19
+ "X-Fern-SDK-Name": "syncsdk",
20
+ "X-Fern-SDK-Version": "0.1.0",
21
+ }
22
+ headers["x-api-key"] = self.api_key
23
+ return headers
24
+
25
+ def get_base_url(self) -> str:
26
+ return self._base_url
27
+
28
+ def get_timeout(self) -> typing.Optional[float]:
29
+ return self._timeout
30
+
31
+
32
+ class SyncClientWrapper(BaseClientWrapper):
33
+ def __init__(
34
+ self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
35
+ ):
36
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
37
+ self.httpx_client = HttpClient(
38
+ httpx_client=httpx_client,
39
+ base_headers=self.get_headers,
40
+ base_timeout=self.get_timeout,
41
+ base_url=self.get_base_url,
42
+ )
43
+
44
+
45
+ class AsyncClientWrapper(BaseClientWrapper):
46
+ def __init__(
47
+ self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
48
+ ):
49
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
50
+ self.httpx_client = AsyncHttpClient(
51
+ httpx_client=httpx_client,
52
+ base_headers=self.get_headers,
53
+ base_timeout=self.get_timeout,
54
+ base_url=self.get_base_url,
55
+ )
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)
sync/core/file.py ADDED
@@ -0,0 +1,67 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast
4
+
5
+ # File typing inspired by the flexibility of types within the httpx library
6
+ # https://github.com/encode/httpx/blob/master/httpx/_types.py
7
+ FileContent = Union[IO[bytes], bytes, str]
8
+ File = Union[
9
+ # file (or bytes)
10
+ FileContent,
11
+ # (filename, file (or bytes))
12
+ Tuple[Optional[str], FileContent],
13
+ # (filename, file (or bytes), content_type)
14
+ Tuple[Optional[str], FileContent, Optional[str]],
15
+ # (filename, file (or bytes), content_type, headers)
16
+ Tuple[
17
+ Optional[str],
18
+ FileContent,
19
+ Optional[str],
20
+ Mapping[str, str],
21
+ ],
22
+ ]
23
+
24
+
25
+ def convert_file_dict_to_httpx_tuples(
26
+ d: Dict[str, Union[File, List[File]]],
27
+ ) -> List[Tuple[str, File]]:
28
+ """
29
+ The format we use is a list of tuples, where the first element is the
30
+ name of the file and the second is the file object. Typically HTTPX wants
31
+ a dict, but to be able to send lists of files, you have to use the list
32
+ approach (which also works for non-lists)
33
+ https://github.com/encode/httpx/pull/1032
34
+ """
35
+
36
+ httpx_tuples = []
37
+ for key, file_like in d.items():
38
+ if isinstance(file_like, list):
39
+ for file_like_item in file_like:
40
+ httpx_tuples.append((key, file_like_item))
41
+ else:
42
+ httpx_tuples.append((key, file_like))
43
+ return httpx_tuples
44
+
45
+
46
+ def with_content_type(*, file: File, default_content_type: str) -> File:
47
+ """
48
+ This function resolves to the file's content type, if provided, and defaults
49
+ to the default_content_type value if not.
50
+ """
51
+ if isinstance(file, tuple):
52
+ if len(file) == 2:
53
+ filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
54
+ return (filename, content, default_content_type)
55
+ elif len(file) == 3:
56
+ filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
57
+ out_content_type = file_content_type or default_content_type
58
+ return (filename, content, out_content_type)
59
+ elif len(file) == 4:
60
+ filename, content, file_content_type, headers = cast( # type: ignore
61
+ Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file
62
+ )
63
+ out_content_type = file_content_type or default_content_type
64
+ return (filename, content, out_content_type, headers)
65
+ else:
66
+ raise ValueError(f"Unexpected tuple length: {len(file)}")
67
+ return (None, file, default_content_type)