composio-videogen 2.5.3__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.
- composio_videogen/__init__.py +20 -0
- composio_videogen/client.py +47 -0
- composio_videogen/operations.py +88 -0
- composio_videogen/toolkit.py +89 -0
- composio_videogen/tools.py +1098 -0
- composio_videogen-2.5.3.dist-info/METADATA +125 -0
- composio_videogen-2.5.3.dist-info/RECORD +9 -0
- composio_videogen-2.5.3.dist-info/WHEEL +4 -0
- composio_videogen-2.5.3.dist-info/licenses/LICENSE +9 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Official Composio custom toolkit for the VideoGen API."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
from .client import resolve_client
|
|
6
|
+
from .operations import Controls
|
|
7
|
+
from .toolkit import create_videogen_toolkit
|
|
8
|
+
from .tools import register_videogen_tools
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Controls",
|
|
12
|
+
"create_videogen_toolkit",
|
|
13
|
+
"register_videogen_tools",
|
|
14
|
+
"resolve_client",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
__version__ = version("composio-videogen")
|
|
19
|
+
except PackageNotFoundError:
|
|
20
|
+
__version__ = "0.0.0"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# AUTO-GENERATED from api/integrations/python-agent-templates/client.py. DO NOT EDIT.
|
|
2
|
+
"""Client resolution for the VideoGen Composio integration."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
from videogen import VideoGen
|
|
10
|
+
|
|
11
|
+
_DEFAULT_BASE_URL = "https://api.videogen.io"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def resolve_client(
|
|
15
|
+
client: Optional[VideoGen] = None,
|
|
16
|
+
*,
|
|
17
|
+
api_key: Optional[str] = None,
|
|
18
|
+
base_url: Optional[str] = None,
|
|
19
|
+
) -> VideoGen:
|
|
20
|
+
"""Resolve a VideoGen client from an explicit client, an explicit key, or the environment.
|
|
21
|
+
|
|
22
|
+
Every tool call is authenticated as the team that owns the key.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
client: A pre-configured ``VideoGen`` client. Used as-is when provided.
|
|
26
|
+
api_key: API key. Falls back to the ``VIDEOGEN_API_KEY`` environment variable.
|
|
27
|
+
base_url: API base URL. Falls back to ``VIDEOGEN_BASE_URL``, then production.
|
|
28
|
+
"""
|
|
29
|
+
if client is not None:
|
|
30
|
+
return client
|
|
31
|
+
|
|
32
|
+
resolved_key = api_key or os.environ.get("VIDEOGEN_API_KEY")
|
|
33
|
+
|
|
34
|
+
if resolved_key is None or resolved_key.strip() == "":
|
|
35
|
+
raise ValueError(
|
|
36
|
+
"No VideoGen API key found. Pass `client` or `api_key`, or set the "
|
|
37
|
+
"VIDEOGEN_API_KEY environment variable. Create a key at "
|
|
38
|
+
"https://app.videogen.io/api."
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
resolved_base_url = base_url or os.environ.get("VIDEOGEN_BASE_URL") or _DEFAULT_BASE_URL
|
|
42
|
+
|
|
43
|
+
return VideoGen(
|
|
44
|
+
api_key=resolved_key.strip(),
|
|
45
|
+
base_url=resolved_base_url,
|
|
46
|
+
client_id="composio",
|
|
47
|
+
)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# AUTO-GENERATED from api/integrations/python-agent-templates/operations.py. DO NOT EDIT.
|
|
2
|
+
"""Shared helpers for starting and polling VideoGen operations."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Any, Callable, Dict, Optional
|
|
8
|
+
|
|
9
|
+
from videogen import VideoGen
|
|
10
|
+
from videogen.poll_executed_tool import poll_executed_tool
|
|
11
|
+
from videogen.poll_project_export import poll_project_export
|
|
12
|
+
from videogen.poll_workflow_run import poll_workflow_run
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Controls:
|
|
17
|
+
"""How the tools handle asynchronous VideoGen operations."""
|
|
18
|
+
|
|
19
|
+
wait: bool = True
|
|
20
|
+
poll_interval_ms: Optional[int] = None
|
|
21
|
+
timeout_ms: Optional[int] = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def to_dict(obj: Any) -> Any:
|
|
25
|
+
"""Convert an SDK response model into a plain, JSON-serializable structure."""
|
|
26
|
+
model_dump = getattr(obj, "model_dump", None)
|
|
27
|
+
if callable(model_dump):
|
|
28
|
+
return model_dump(mode="json")
|
|
29
|
+
return obj
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def drop_none(values: Dict[str, Any]) -> Dict[str, Any]:
|
|
33
|
+
"""Drop ``None``-valued keys so the SDK applies its own defaults."""
|
|
34
|
+
return {key: value for key, value in values.items() if value is not None}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _poll_kwargs(controls: Controls) -> Dict[str, int]:
|
|
38
|
+
kwargs: Dict[str, int] = {}
|
|
39
|
+
if controls.poll_interval_ms is not None:
|
|
40
|
+
kwargs["poll_interval_ms"] = controls.poll_interval_ms
|
|
41
|
+
if controls.timeout_ms is not None:
|
|
42
|
+
kwargs["timeout_ms"] = controls.timeout_ms
|
|
43
|
+
return kwargs
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def run_workflow(
|
|
47
|
+
client: VideoGen,
|
|
48
|
+
controls: Controls,
|
|
49
|
+
start: Callable[[], Any],
|
|
50
|
+
) -> Any:
|
|
51
|
+
"""Start a workflow and, unless ``wait`` is False, poll it to a terminal state."""
|
|
52
|
+
started = start()
|
|
53
|
+
if not controls.wait:
|
|
54
|
+
return to_dict(started)
|
|
55
|
+
|
|
56
|
+
run = poll_workflow_run(client, started["workflow_run_id"], **_poll_kwargs(controls))
|
|
57
|
+
return to_dict(run)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def run_tool(
|
|
61
|
+
client: VideoGen,
|
|
62
|
+
controls: Controls,
|
|
63
|
+
start: Callable[[], Any],
|
|
64
|
+
) -> Any:
|
|
65
|
+
"""Start a media tool execution and, unless ``wait`` is False, poll it to a terminal state."""
|
|
66
|
+
started = start()
|
|
67
|
+
if not controls.wait:
|
|
68
|
+
return to_dict(started)
|
|
69
|
+
|
|
70
|
+
execution = poll_executed_tool(client, started["tool_execution_id"], **_poll_kwargs(controls))
|
|
71
|
+
return to_dict(execution)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def run_export(
|
|
75
|
+
client: VideoGen,
|
|
76
|
+
controls: Controls,
|
|
77
|
+
project_id: str,
|
|
78
|
+
start: Callable[[], Any],
|
|
79
|
+
) -> Any:
|
|
80
|
+
"""Start a project export and, unless ``wait`` is False, poll until the download URL is ready."""
|
|
81
|
+
started = start()
|
|
82
|
+
if not controls.wait:
|
|
83
|
+
return to_dict(started)
|
|
84
|
+
|
|
85
|
+
project_export = poll_project_export(
|
|
86
|
+
client, project_id, started["export_id"], **_poll_kwargs(controls)
|
|
87
|
+
)
|
|
88
|
+
return to_dict(project_export)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Factory for the VideoGen Composio custom toolkit."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Iterable, Optional
|
|
6
|
+
|
|
7
|
+
from videogen import VideoGen
|
|
8
|
+
|
|
9
|
+
from .client import resolve_client
|
|
10
|
+
from .operations import Controls
|
|
11
|
+
from .tools import register_videogen_tools
|
|
12
|
+
|
|
13
|
+
DEFAULT_TOOLKIT_SLUG = "VIDEOGEN"
|
|
14
|
+
DEFAULT_TOOLKIT_NAME = "VideoGen"
|
|
15
|
+
DEFAULT_TOOLKIT_DESCRIPTION = (
|
|
16
|
+
"Generate videos, images, voiceovers, sound effects, music, and talking-head "
|
|
17
|
+
"avatars with the VideoGen API."
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _new_toolkit(
|
|
22
|
+
composio: Optional[Any],
|
|
23
|
+
*,
|
|
24
|
+
slug: str,
|
|
25
|
+
name: str,
|
|
26
|
+
description: str,
|
|
27
|
+
preload: Optional[bool],
|
|
28
|
+
) -> Any:
|
|
29
|
+
"""Construct an empty Composio custom toolkit.
|
|
30
|
+
|
|
31
|
+
Uses ``composio.experimental.Toolkit`` when a client is provided, otherwise
|
|
32
|
+
falls back to the toolkit class directly so the package is usable without
|
|
33
|
+
first constructing a ``Composio`` client.
|
|
34
|
+
"""
|
|
35
|
+
if composio is not None:
|
|
36
|
+
return composio.experimental.Toolkit(
|
|
37
|
+
slug=slug, name=name, description=description, preload=preload
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
from composio.core.models.custom_tool import ExperimentalToolkit
|
|
41
|
+
|
|
42
|
+
return ExperimentalToolkit(slug=slug, name=name, description=description, preload=preload)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def create_videogen_toolkit(
|
|
46
|
+
composio: Optional[Any] = None,
|
|
47
|
+
*,
|
|
48
|
+
client: Optional[VideoGen] = None,
|
|
49
|
+
api_key: Optional[str] = None,
|
|
50
|
+
base_url: Optional[str] = None,
|
|
51
|
+
wait: bool = True,
|
|
52
|
+
poll_interval_ms: Optional[int] = None,
|
|
53
|
+
timeout_ms: Optional[int] = None,
|
|
54
|
+
include: Optional[Iterable[str]] = None,
|
|
55
|
+
slug: str = DEFAULT_TOOLKIT_SLUG,
|
|
56
|
+
name: str = DEFAULT_TOOLKIT_NAME,
|
|
57
|
+
description: str = DEFAULT_TOOLKIT_DESCRIPTION,
|
|
58
|
+
preload: Optional[bool] = None,
|
|
59
|
+
) -> Any:
|
|
60
|
+
"""Build a Composio custom toolkit exposing the full VideoGen tool set.
|
|
61
|
+
|
|
62
|
+
Pass the returned toolkit to ``composio.create(experimental={"custom_toolkits": [toolkit]})``.
|
|
63
|
+
``session.tools()`` then includes every VideoGen tool alongside your other Composio tools.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
composio: A ``Composio`` client. When provided, the toolkit is created via
|
|
67
|
+
``composio.experimental.Toolkit``; otherwise the toolkit class is used directly.
|
|
68
|
+
client: A pre-configured ``VideoGen`` client. When omitted, one is built from
|
|
69
|
+
``api_key`` / ``base_url`` or the ``VIDEOGEN_API_KEY`` environment variable.
|
|
70
|
+
wait: When True (default), tools block until the workflow run or tool execution
|
|
71
|
+
finishes and return the completed result. Set False to return immediately
|
|
72
|
+
with the run/execution id for the caller to poll.
|
|
73
|
+
poll_interval_ms: Poll interval while waiting. Defaults to the SDK's default.
|
|
74
|
+
timeout_ms: Maximum time to wait before giving up. Defaults to the SDK's default.
|
|
75
|
+
include: Restrict the registered tools to these tool names. Defaults to all tools.
|
|
76
|
+
slug: Toolkit slug (final tool slugs are ``LOCAL_<slug>_<TOOL>``).
|
|
77
|
+
name: Human-readable toolkit name.
|
|
78
|
+
description: Toolkit description shown to the agent.
|
|
79
|
+
preload: When True, expose the toolkit's tools directly instead of via search.
|
|
80
|
+
"""
|
|
81
|
+
resolved_client = resolve_client(client, api_key=api_key, base_url=base_url)
|
|
82
|
+
controls = Controls(wait=wait, poll_interval_ms=poll_interval_ms, timeout_ms=timeout_ms)
|
|
83
|
+
|
|
84
|
+
toolkit = _new_toolkit(
|
|
85
|
+
composio, slug=slug, name=name, description=description, preload=preload
|
|
86
|
+
)
|
|
87
|
+
register_videogen_tools(toolkit, resolved_client, controls, include=include)
|
|
88
|
+
|
|
89
|
+
return toolkit
|