Skip to content

Commit

Permalink
SDK regeneration (#375)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Oct 15, 2024
1 parent 317b471 commit 01b74c8
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 325 deletions.
405 changes: 210 additions & 195 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "elevenlabs"
version = "1.9.0"
version = "1.10.0"
description = ""
readme = "README.md"
authors = []
Expand Down
6 changes: 3 additions & 3 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ client.text_to_speech.convert(
output_format="mp3_22050_32",
text="It sure does, Jackie… My mama always said: “In Carolina, the air's so thick you can wear it!”",
voice_settings=VoiceSettings(
stability=0.1,
similarity_boost=0.3,
style=0.2,
stability=0.5,
similarity_boost=0.75,
style=0.0,
),
)

Expand Down
44 changes: 22 additions & 22 deletions src/elevenlabs/audio_native/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def create(
self,
*,
name: str,
image: typing.Optional[str] = None,
author: typing.Optional[str] = None,
title: typing.Optional[str] = None,
small: typing.Optional[bool] = None,
text_color: typing.Optional[str] = None,
background_color: typing.Optional[str] = None,
sessionization: typing.Optional[int] = None,
voice_id: typing.Optional[str] = None,
model_id: typing.Optional[str] = None,
file: typing.Optional[core.File] = None,
auto_convert: typing.Optional[bool] = None,
image: typing.Optional[str] = OMIT,
author: typing.Optional[str] = OMIT,
title: typing.Optional[str] = OMIT,
small: typing.Optional[bool] = OMIT,
text_color: typing.Optional[str] = OMIT,
background_color: typing.Optional[str] = OMIT,
sessionization: typing.Optional[int] = OMIT,
voice_id: typing.Optional[str] = OMIT,
model_id: typing.Optional[str] = OMIT,
file: typing.Optional[core.File] = OMIT,
auto_convert: typing.Optional[bool] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> AudioNativeCreateProjectResponseModel:
"""
Expand Down Expand Up @@ -152,17 +152,17 @@ async def create(
self,
*,
name: str,
image: typing.Optional[str] = None,
author: typing.Optional[str] = None,
title: typing.Optional[str] = None,
small: typing.Optional[bool] = None,
text_color: typing.Optional[str] = None,
background_color: typing.Optional[str] = None,
sessionization: typing.Optional[int] = None,
voice_id: typing.Optional[str] = None,
model_id: typing.Optional[str] = None,
file: typing.Optional[core.File] = None,
auto_convert: typing.Optional[bool] = None,
image: typing.Optional[str] = OMIT,
author: typing.Optional[str] = OMIT,
title: typing.Optional[str] = OMIT,
small: typing.Optional[bool] = OMIT,
text_color: typing.Optional[str] = OMIT,
background_color: typing.Optional[str] = OMIT,
sessionization: typing.Optional[int] = OMIT,
voice_id: typing.Optional[str] = OMIT,
model_id: typing.Optional[str] = OMIT,
file: typing.Optional[core.File] = OMIT,
auto_convert: typing.Optional[bool] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> AudioNativeCreateProjectResponseModel:
"""
Expand Down
14 changes: 7 additions & 7 deletions src/elevenlabs/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "1.9.0",
"X-Fern-SDK-Version": "1.10.0",
}
if self._api_key is not None:
headers["xi-api-key"] = self._api_key
Expand All @@ -41,9 +41,9 @@ def __init__(
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
self.httpx_client = HttpClient(
httpx_client=httpx_client,
base_headers=self.get_headers(),
base_timeout=self.get_timeout(),
base_url=self.get_base_url(),
base_headers=self.get_headers,
base_timeout=self.get_timeout,
base_url=self.get_base_url,
)


Expand All @@ -59,7 +59,7 @@ def __init__(
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
self.httpx_client = AsyncHttpClient(
httpx_client=httpx_client,
base_headers=self.get_headers(),
base_timeout=self.get_timeout(),
base_url=self.get_base_url(),
base_headers=self.get_headers,
base_timeout=self.get_timeout,
base_url=self.get_base_url,
)
46 changes: 28 additions & 18 deletions src/elevenlabs/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,20 @@ def __init__(
self,
*,
httpx_client: httpx.Client,
base_timeout: typing.Optional[float],
base_headers: typing.Dict[str, str],
base_url: typing.Optional[str] = None,
base_timeout: typing.Callable[[], typing.Optional[float]],
base_headers: typing.Callable[[], typing.Dict[str, str]],
base_url: typing.Optional[typing.Callable[[], str]] = None,
):
self.base_url = base_url
self.base_timeout = base_timeout
self.base_headers = base_headers
self.httpx_client = httpx_client

def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str:
base_url = self.base_url if maybe_base_url is None else maybe_base_url
base_url = maybe_base_url
if self.base_url is not None and base_url is None:
base_url = self.base_url()

if base_url is None:
raise ValueError("A base_url is required to make this request, please provide one and try again.")
return base_url
Expand All @@ -187,7 +190,7 @@ def request(
timeout = (
request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else self.base_timeout
else self.base_timeout()
)

json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
Expand All @@ -198,7 +201,7 @@ def request(
headers=jsonable_encoder(
remove_none_from_dict(
{
**self.base_headers,
**self.base_headers(),
**(headers if headers is not None else {}),
**(request_options.get("additional_headers", {}) or {} if request_options is not None else {}),
}
Expand All @@ -224,7 +227,9 @@ def request(
json=json_body,
data=data_body,
content=content,
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None,
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
if (files is not None and files is not omit)
else None,
timeout=timeout,
)

Expand Down Expand Up @@ -269,7 +274,7 @@ def stream(
timeout = (
request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else self.base_timeout
else self.base_timeout()
)

json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
Expand All @@ -280,7 +285,7 @@ def stream(
headers=jsonable_encoder(
remove_none_from_dict(
{
**self.base_headers,
**self.base_headers(),
**(headers if headers is not None else {}),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
Expand All @@ -306,7 +311,9 @@ def stream(
json=json_body,
data=data_body,
content=content,
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None,
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
if (files is not None and files is not omit)
else None,
timeout=timeout,
) as stream:
yield stream
Expand All @@ -317,17 +324,20 @@ def __init__(
self,
*,
httpx_client: httpx.AsyncClient,
base_timeout: typing.Optional[float],
base_headers: typing.Dict[str, str],
base_url: typing.Optional[str] = None,
base_timeout: typing.Callable[[], typing.Optional[float]],
base_headers: typing.Callable[[], typing.Dict[str, str]],
base_url: typing.Optional[typing.Callable[[], str]] = None,
):
self.base_url = base_url
self.base_timeout = base_timeout
self.base_headers = base_headers
self.httpx_client = httpx_client

def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str:
base_url = self.base_url if maybe_base_url is None else maybe_base_url
base_url = maybe_base_url
if self.base_url is not None and base_url is None:
base_url = self.base_url()

if base_url is None:
raise ValueError("A base_url is required to make this request, please provide one and try again.")
return base_url
Expand All @@ -352,7 +362,7 @@ async def request(
timeout = (
request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else self.base_timeout
else self.base_timeout()
)

json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
Expand All @@ -364,7 +374,7 @@ async def request(
headers=jsonable_encoder(
remove_none_from_dict(
{
**self.base_headers,
**self.base_headers(),
**(headers if headers is not None else {}),
**(request_options.get("additional_headers", {}) or {} if request_options is not None else {}),
}
Expand Down Expand Up @@ -434,7 +444,7 @@ async def stream(
timeout = (
request_options.get("timeout_in_seconds")
if request_options is not None and request_options.get("timeout_in_seconds") is not None
else self.base_timeout
else self.base_timeout()
)

json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
Expand All @@ -445,7 +455,7 @@ async def stream(
headers=jsonable_encoder(
remove_none_from_dict(
{
**self.base_headers,
**self.base_headers(),
**(headers if headers is not None else {}),
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
}
Expand Down
29 changes: 26 additions & 3 deletions src/elevenlabs/core/pydantic_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
)

else:
_fields_set = self.__fields_set__
_fields_set = self.__fields_set__.copy()

fields = _get_model_fields(self.__class__)
for name, field in fields.items():
Expand All @@ -162,9 +162,12 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
# If the default values are non-null act like they've been set
# This effectively allows exclude_unset to work like exclude_none where
# the latter passes through intentionally set none values.
if default != None:
if default is not None or ("exclude_unset" in kwargs and not kwargs["exclude_unset"]):
_fields_set.add(name)

if default is not None:
self.__fields_set__.add(name)

kwargs_with_defaults_exclude_unset_include_fields: typing.Any = {
"by_alias": True,
"exclude_unset": True,
Expand All @@ -177,13 +180,33 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write")


def _union_list_of_pydantic_dicts(
source: typing.List[typing.Any], destination: typing.List[typing.Any]
) -> typing.List[typing.Any]:
converted_list: typing.List[typing.Any] = []
for i, item in enumerate(source):
destination_value = destination[i] # type: ignore
if isinstance(item, dict):
converted_list.append(deep_union_pydantic_dicts(item, destination_value))
elif isinstance(item, list):
converted_list.append(_union_list_of_pydantic_dicts(item, destination_value))
else:
converted_list.append(item)
return converted_list


def deep_union_pydantic_dicts(
source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any]
) -> typing.Dict[str, typing.Any]:
for key, value in source.items():
node = destination.setdefault(key, {})
if isinstance(value, dict):
node = destination.setdefault(key, {})
deep_union_pydantic_dicts(value, node)
# Note: we do not do this same processing for sets given we do not have sets of models
# and given the sets are unordered, the processing of the set and matching objects would
# be non-trivial.
elif isinstance(value, list):
destination[key] = _union_list_of_pydantic_dicts(value, node)
else:
destination[key] = value

Expand Down
18 changes: 18 additions & 0 deletions src/elevenlabs/core/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ def convert_and_respect_annotation_metadata(
if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping):
return _convert_mapping(object_, clean_type, direction)

if (
typing_extensions.get_origin(clean_type) == typing.Dict
or typing_extensions.get_origin(clean_type) == dict
or clean_type == typing.Dict
) and isinstance(object_, typing.Dict):
key_type = typing_extensions.get_args(clean_type)[0]
value_type = typing_extensions.get_args(clean_type)[1]

return {
key: convert_and_respect_annotation_metadata(
object_=value,
annotation=annotation,
inner_type=value_type,
direction=direction,
)
for key, value in object_.items()
}

# If you're iterating on a string, do not bother to coerce it to a sequence.
if not isinstance(object_, str):
if (
Expand Down
36 changes: 18 additions & 18 deletions src/elevenlabs/dubbing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def dub_a_video_or_an_audio_file(
self,
*,
target_lang: str,
file: typing.Optional[core.File] = None,
name: typing.Optional[str] = None,
source_url: typing.Optional[str] = None,
source_lang: typing.Optional[str] = None,
num_speakers: typing.Optional[int] = None,
watermark: typing.Optional[bool] = None,
start_time: typing.Optional[int] = None,
end_time: typing.Optional[int] = None,
highest_resolution: typing.Optional[bool] = None,
file: typing.Optional[core.File] = OMIT,
name: typing.Optional[str] = OMIT,
source_url: typing.Optional[str] = OMIT,
source_lang: typing.Optional[str] = OMIT,
num_speakers: typing.Optional[int] = OMIT,
watermark: typing.Optional[bool] = OMIT,
start_time: typing.Optional[int] = OMIT,
end_time: typing.Optional[int] = OMIT,
highest_resolution: typing.Optional[bool] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> DoDubbingResponse:
"""
Expand Down Expand Up @@ -401,15 +401,15 @@ async def dub_a_video_or_an_audio_file(
self,
*,
target_lang: str,
file: typing.Optional[core.File] = None,
name: typing.Optional[str] = None,
source_url: typing.Optional[str] = None,
source_lang: typing.Optional[str] = None,
num_speakers: typing.Optional[int] = None,
watermark: typing.Optional[bool] = None,
start_time: typing.Optional[int] = None,
end_time: typing.Optional[int] = None,
highest_resolution: typing.Optional[bool] = None,
file: typing.Optional[core.File] = OMIT,
name: typing.Optional[str] = OMIT,
source_url: typing.Optional[str] = OMIT,
source_lang: typing.Optional[str] = OMIT,
num_speakers: typing.Optional[int] = OMIT,
watermark: typing.Optional[bool] = OMIT,
start_time: typing.Optional[int] = OMIT,
end_time: typing.Optional[int] = OMIT,
highest_resolution: typing.Optional[bool] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> DoDubbingResponse:
"""
Expand Down
1 change: 1 addition & 0 deletions src/elevenlabs/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

class ElevenLabsEnvironment(enum.Enum):
PRODUCTION = "https://api.elevenlabs.io"
PRODUCTION_US = "https://api.us.elevenlabs.io"
Loading

0 comments on commit 01b74c8

Please sign in to comment.