Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 47 additions & 68 deletions go/provider_maestro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 67 additions & 74 deletions python/src/acedatacloud/resources/providers/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

from typing import Any, Literal # noqa: F401

from ..._runtime.tasks import AsyncTaskHandle, TaskHandle

MaestroAction = Literal[
"generate",
"remix",
"edit",
"extend",
]
MaestroScenario = Literal[
"auto",
"narrated",
"captions",
"avatar",
"drama",
]
MaestroStyle = Literal[
"auto",
"cinematic",
Expand Down Expand Up @@ -39,20 +54,6 @@
"energetic-male",
"storyteller-male",
]
MaestroAction = Literal[
"generate",
"remix",
"edit",
"extend",
]
MaestroScenario = Literal[
"auto",
"narrated",
"drama",
"avatar",
"motion",
"slideshow",
]


def _task_id(result: Any) -> str:
Expand All @@ -77,51 +78,47 @@ def generate(
self,
*,
prompt: str,
langs: list[str] | None = None,
style: MaestroStyle | None = None,
voice: MaestroVoice | None = None,
action: MaestroAction | None = None,
ref_task_id: str | None = None,
file_urls: list[str] | None = None,
langs: list[str] | None = None,
aspect: Literal["9:16", "16:9", "1:1"] | None = None,
quality: Literal["draft", "standard", "premium"] | None = None,
duration: int | None = None,
quality: Literal["lite", "standard", "pro"] | None = None,
scenario: MaestroScenario | None = None,
file_urls: list[str] | None = None,
ref_task_id: str | None = None,
style: MaestroStyle | None = None,
voice: MaestroVoice | None = None,
async_: bool | None = None,
wait: bool = False,
poll_interval: float = 3.0,
max_wait: float = 600.0,
callback_url: str | None = None,
**extra: Any,
) -> dict[str, Any]:
"""Maestro Video Generation API"""
) -> TaskHandle:
"""Call /maestro/videos."""
body: dict[str, Any] = {}
body["prompt"] = prompt
body["langs"] = langs if langs is not None else ["zh-cn"]
body["style"] = style if style is not None else "auto"
body["voice"] = voice if voice is not None else "auto"
body["action"] = action if action is not None else "generate"
if ref_task_id is not None:
body["ref_task_id"] = ref_task_id
if file_urls is not None:
body["file_urls"] = file_urls
body["langs"] = langs if langs is not None else ["zh-cn"]
body["aspect"] = aspect if aspect is not None else "9:16"
body["quality"] = quality if quality is not None else "standard"
body["duration"] = duration if duration is not None else 30
body["quality"] = quality if quality is not None else "standard"
body["scenario"] = scenario if scenario is not None else "auto"
if file_urls is not None:
body["file_urls"] = file_urls
if ref_task_id is not None:
body["ref_task_id"] = ref_task_id
body.update(extra)
if callback_url is not None:
body["callback_url"] = callback_url
return self._transport.request("POST", "/maestro/videos", json=body)

def estimates(
self,
*,
callback_url: str | None = None,
**extra: Any,
) -> dict[str, Any]:
"""Call /maestro/estimates."""
body: dict[str, Any] = {}
body["style"] = style if style is not None else "auto"
body["voice"] = voice if voice is not None else "auto"
body.update(extra)
if callback_url is not None:
body["callback_url"] = callback_url
return self._transport.request("POST", "/maestro/estimates", json=body)
body["async"] = True if async_ is None else async_
result = self._transport.request("POST", "/maestro/videos", json=body)
handle = TaskHandle(_task_id(result), "/maestro/tasks", self._transport, submitted=result)
if wait:
handle.wait(poll_interval=poll_interval, max_wait=max_wait)
return handle


class AsyncMaestro:
Expand All @@ -134,48 +131,44 @@ async def generate(
self,
*,
prompt: str,
langs: list[str] | None = None,
style: MaestroStyle | None = None,
voice: MaestroVoice | None = None,
action: MaestroAction | None = None,
ref_task_id: str | None = None,
file_urls: list[str] | None = None,
langs: list[str] | None = None,
aspect: Literal["9:16", "16:9", "1:1"] | None = None,
quality: Literal["draft", "standard", "premium"] | None = None,
duration: int | None = None,
quality: Literal["lite", "standard", "pro"] | None = None,
scenario: MaestroScenario | None = None,
file_urls: list[str] | None = None,
ref_task_id: str | None = None,
style: MaestroStyle | None = None,
voice: MaestroVoice | None = None,
async_: bool | None = None,
wait: bool = False,
poll_interval: float = 3.0,
max_wait: float = 600.0,
callback_url: str | None = None,
**extra: Any,
) -> dict[str, Any]:
"""Maestro Video Generation API"""
) -> AsyncTaskHandle:
"""Call /maestro/videos."""
body: dict[str, Any] = {}
body["prompt"] = prompt
body["langs"] = langs if langs is not None else ["zh-cn"]
body["style"] = style if style is not None else "auto"
body["voice"] = voice if voice is not None else "auto"
body["action"] = action if action is not None else "generate"
if ref_task_id is not None:
body["ref_task_id"] = ref_task_id
if file_urls is not None:
body["file_urls"] = file_urls
body["langs"] = langs if langs is not None else ["zh-cn"]
body["aspect"] = aspect if aspect is not None else "9:16"
body["quality"] = quality if quality is not None else "standard"
body["duration"] = duration if duration is not None else 30
body["quality"] = quality if quality is not None else "standard"
body["scenario"] = scenario if scenario is not None else "auto"
if file_urls is not None:
body["file_urls"] = file_urls
if ref_task_id is not None:
body["ref_task_id"] = ref_task_id
body.update(extra)
if callback_url is not None:
body["callback_url"] = callback_url
return await self._transport.request("POST", "/maestro/videos", json=body)

async def estimates(
self,
*,
callback_url: str | None = None,
**extra: Any,
) -> dict[str, Any]:
"""Call /maestro/estimates."""
body: dict[str, Any] = {}
body["style"] = style if style is not None else "auto"
body["voice"] = voice if voice is not None else "auto"
body.update(extra)
if callback_url is not None:
body["callback_url"] = callback_url
return await self._transport.request("POST", "/maestro/estimates", json=body)
body["async"] = True if async_ is None else async_
result = await self._transport.request("POST", "/maestro/videos", json=body)
handle = AsyncTaskHandle(_task_id(result), "/maestro/tasks", self._transport, submitted=result)
if wait:
await handle.wait(poll_interval=poll_interval, max_wait=max_wait)
return handle
Loading
Loading