openai-agents-videogen 2.5.3__tar.gz
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.
- openai_agents_videogen-2.5.3/.gitignore +8 -0
- openai_agents_videogen-2.5.3/PKG-INFO +120 -0
- openai_agents_videogen-2.5.3/README.md +103 -0
- openai_agents_videogen-2.5.3/pyproject.toml +46 -0
- openai_agents_videogen-2.5.3/src/openai_agents_videogen/__init__.py +18 -0
- openai_agents_videogen-2.5.3/src/openai_agents_videogen/client.py +47 -0
- openai_agents_videogen-2.5.3/src/openai_agents_videogen/operations.py +88 -0
- openai_agents_videogen-2.5.3/src/openai_agents_videogen/toolkit.py +46 -0
- openai_agents_videogen-2.5.3/src/openai_agents_videogen/tools.py +1024 -0
- openai_agents_videogen-2.5.3/tests/test_tools.py +59 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: openai-agents-videogen
|
|
3
|
+
Version: 2.5.3
|
|
4
|
+
Summary: Official OpenAI Agents SDK tools for the VideoGen API. Generate videos, images, voiceovers, sound effects, music, and avatars from any OpenAI Agents SDK agent.
|
|
5
|
+
Project-URL: Homepage, https://videogen.io
|
|
6
|
+
Project-URL: Documentation, https://github.com/video-gen/video-workflow-recipes/tree/main/integrations/openai-agents-videogen#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/video-gen/video-workflow-recipes
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: agents,ai,ai-video-generation,image-generation,openai-agents,openai-agents-sdk,text-to-speech,text-to-video,tools,videogen
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: openai-agents>=0.1.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0.0
|
|
13
|
+
Requires-Dist: videogen>=2.5.3
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# openai-agents-videogen
|
|
19
|
+
|
|
20
|
+
Official [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) tools for the [VideoGen API](https://docs.videogen.io). Give any OpenAI Agents SDK agent the ability to turn a script into a finished narrated video, plus generate standalone images, video clips, voiceovers, sound effects, music, and talking-head avatars.
|
|
21
|
+
|
|
22
|
+
Every tool wraps the official [`videogen`](https://pypi.org/project/videogen/) SDK and runs as the team that owns your API key.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install openai-agents-videogen
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Setup
|
|
31
|
+
|
|
32
|
+
Get an API key from [app.videogen.io/api](https://app.videogen.io/api) and set it as `VIDEOGEN_API_KEY`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
export VIDEOGEN_API_KEY="your_api_key"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import asyncio
|
|
42
|
+
|
|
43
|
+
from agents import Agent, Runner
|
|
44
|
+
from openai_agents_videogen import create_videogen_tools
|
|
45
|
+
|
|
46
|
+
agent = Agent(
|
|
47
|
+
name="Video Producer",
|
|
48
|
+
instructions="You produce short narrated videos with VideoGen when asked.",
|
|
49
|
+
tools=create_videogen_tools(),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def main() -> None:
|
|
54
|
+
result = await Runner.run(
|
|
55
|
+
agent,
|
|
56
|
+
"Make a short narrated video explaining why staying hydrated matters.",
|
|
57
|
+
)
|
|
58
|
+
print(result.final_output)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
asyncio.run(main())
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
By default each tool blocks until the workflow or tool execution finishes and returns the completed result.
|
|
65
|
+
|
|
66
|
+
## Options
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from videogen import VideoGen
|
|
70
|
+
from openai_agents_videogen import create_videogen_tools
|
|
71
|
+
|
|
72
|
+
tools = create_videogen_tools(
|
|
73
|
+
# Provide a pre-configured client, or pass api_key / base_url, or rely on env.
|
|
74
|
+
client=VideoGen(api_key="your_api_key"),
|
|
75
|
+
|
|
76
|
+
# Return the run/execution id immediately instead of waiting.
|
|
77
|
+
wait=False,
|
|
78
|
+
|
|
79
|
+
# Only expose a subset of tools to the agent.
|
|
80
|
+
include=["script_to_video", "generate_image", "text_to_speech"],
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Option | Default | Description |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| `client` | — | A pre-configured `VideoGen` client. |
|
|
87
|
+
| `api_key` | `VIDEOGEN_API_KEY` | API key used to build a client when `client` is omitted. |
|
|
88
|
+
| `base_url` | `VIDEOGEN_BASE_URL` or production | Override the API base URL. |
|
|
89
|
+
| `wait` | `True` | Block until the operation finishes and return the result. |
|
|
90
|
+
| `poll_interval_ms` | SDK default | Poll interval while waiting. |
|
|
91
|
+
| `timeout_ms` | SDK default | Maximum time to wait before giving up. |
|
|
92
|
+
| `include` | all tools | Restrict the returned tool set to these tool names. |
|
|
93
|
+
|
|
94
|
+
## Tools
|
|
95
|
+
|
|
96
|
+
<!-- BEGIN GENERATED PYTHON AGENT TOOLS -->
|
|
97
|
+
- Workflows: `cancel_workflow_run`, `get_workflow_run`, `list_workflow_runs`, `prompt_to_video_clip`, `script_to_video`, `slideshow_to_video`, `storyboard_to_video`, `video_to_video`, `voiceover_to_video`.
|
|
98
|
+
- Media generation: `cancel_tool_execution`, `generate_avatar`, `generate_image`, `generate_motion_graphic`, `generate_music`, `generate_sound_effect`, `generate_video_clip`, `get_tool_execution`, `image_3d_effect`, `list_tool_executions`, `remove_image_background`, `remove_video_background`, `text_to_speech`, `upscale_image`, `upscale_video`, `vectorize_image`.
|
|
99
|
+
- Projects: `export_project`, `get_project`, `list_project_remix_actions`, `list_projects`, `remix_project`.
|
|
100
|
+
- Files: `get_file`, `list_files`, `upload_file`.
|
|
101
|
+
- Resources and account: `get_me`, `list_languages`, `list_tts_voices`.
|
|
102
|
+
|
|
103
|
+
Avatar generation and supported video workflows use reusable actor entities. Pass `actor_entity_id` and set `avatar_quality` to `LOW`, `STANDARD`, `HIGH`, or `MAX`. Narrator changes are passed in `remix_actions` as `CHANGE_NARRATOR` action dictionaries.
|
|
104
|
+
<!-- END GENERATED PYTHON AGENT TOOLS -->
|
|
105
|
+
|
|
106
|
+
## Documentation
|
|
107
|
+
|
|
108
|
+
- [Use with AI agents](https://docs.videogen.io/use-with-ai-agents)
|
|
109
|
+
- [MCP server](https://docs.videogen.io/libraries/mcp)
|
|
110
|
+
- [API reference](https://docs.videogen.io)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
|
115
|
+
|
|
116
|
+
## Account and permissions
|
|
117
|
+
|
|
118
|
+
Generation and editing use VideoGen account credits. Obtain user approval before credit-consuming calls, and restrict the `include` list for agents that only need read access. Keep API keys in environment variables and out of shared transcripts.
|
|
119
|
+
|
|
120
|
+
[VideoGen](https://videogen.io/) · [MCP setup](https://videogen.io/videogen-mcp)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# openai-agents-videogen
|
|
2
|
+
|
|
3
|
+
Official [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) tools for the [VideoGen API](https://docs.videogen.io). Give any OpenAI Agents SDK agent the ability to turn a script into a finished narrated video, plus generate standalone images, video clips, voiceovers, sound effects, music, and talking-head avatars.
|
|
4
|
+
|
|
5
|
+
Every tool wraps the official [`videogen`](https://pypi.org/project/videogen/) SDK and runs as the team that owns your API key.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install openai-agents-videogen
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
Get an API key from [app.videogen.io/api](https://app.videogen.io/api) and set it as `VIDEOGEN_API_KEY`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
export VIDEOGEN_API_KEY="your_api_key"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import asyncio
|
|
25
|
+
|
|
26
|
+
from agents import Agent, Runner
|
|
27
|
+
from openai_agents_videogen import create_videogen_tools
|
|
28
|
+
|
|
29
|
+
agent = Agent(
|
|
30
|
+
name="Video Producer",
|
|
31
|
+
instructions="You produce short narrated videos with VideoGen when asked.",
|
|
32
|
+
tools=create_videogen_tools(),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async def main() -> None:
|
|
37
|
+
result = await Runner.run(
|
|
38
|
+
agent,
|
|
39
|
+
"Make a short narrated video explaining why staying hydrated matters.",
|
|
40
|
+
)
|
|
41
|
+
print(result.final_output)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
asyncio.run(main())
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
By default each tool blocks until the workflow or tool execution finishes and returns the completed result.
|
|
48
|
+
|
|
49
|
+
## Options
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from videogen import VideoGen
|
|
53
|
+
from openai_agents_videogen import create_videogen_tools
|
|
54
|
+
|
|
55
|
+
tools = create_videogen_tools(
|
|
56
|
+
# Provide a pre-configured client, or pass api_key / base_url, or rely on env.
|
|
57
|
+
client=VideoGen(api_key="your_api_key"),
|
|
58
|
+
|
|
59
|
+
# Return the run/execution id immediately instead of waiting.
|
|
60
|
+
wait=False,
|
|
61
|
+
|
|
62
|
+
# Only expose a subset of tools to the agent.
|
|
63
|
+
include=["script_to_video", "generate_image", "text_to_speech"],
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Option | Default | Description |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `client` | — | A pre-configured `VideoGen` client. |
|
|
70
|
+
| `api_key` | `VIDEOGEN_API_KEY` | API key used to build a client when `client` is omitted. |
|
|
71
|
+
| `base_url` | `VIDEOGEN_BASE_URL` or production | Override the API base URL. |
|
|
72
|
+
| `wait` | `True` | Block until the operation finishes and return the result. |
|
|
73
|
+
| `poll_interval_ms` | SDK default | Poll interval while waiting. |
|
|
74
|
+
| `timeout_ms` | SDK default | Maximum time to wait before giving up. |
|
|
75
|
+
| `include` | all tools | Restrict the returned tool set to these tool names. |
|
|
76
|
+
|
|
77
|
+
## Tools
|
|
78
|
+
|
|
79
|
+
<!-- BEGIN GENERATED PYTHON AGENT TOOLS -->
|
|
80
|
+
- Workflows: `cancel_workflow_run`, `get_workflow_run`, `list_workflow_runs`, `prompt_to_video_clip`, `script_to_video`, `slideshow_to_video`, `storyboard_to_video`, `video_to_video`, `voiceover_to_video`.
|
|
81
|
+
- Media generation: `cancel_tool_execution`, `generate_avatar`, `generate_image`, `generate_motion_graphic`, `generate_music`, `generate_sound_effect`, `generate_video_clip`, `get_tool_execution`, `image_3d_effect`, `list_tool_executions`, `remove_image_background`, `remove_video_background`, `text_to_speech`, `upscale_image`, `upscale_video`, `vectorize_image`.
|
|
82
|
+
- Projects: `export_project`, `get_project`, `list_project_remix_actions`, `list_projects`, `remix_project`.
|
|
83
|
+
- Files: `get_file`, `list_files`, `upload_file`.
|
|
84
|
+
- Resources and account: `get_me`, `list_languages`, `list_tts_voices`.
|
|
85
|
+
|
|
86
|
+
Avatar generation and supported video workflows use reusable actor entities. Pass `actor_entity_id` and set `avatar_quality` to `LOW`, `STANDARD`, `HIGH`, or `MAX`. Narrator changes are passed in `remix_actions` as `CHANGE_NARRATOR` action dictionaries.
|
|
87
|
+
<!-- END GENERATED PYTHON AGENT TOOLS -->
|
|
88
|
+
|
|
89
|
+
## Documentation
|
|
90
|
+
|
|
91
|
+
- [Use with AI agents](https://docs.videogen.io/use-with-ai-agents)
|
|
92
|
+
- [MCP server](https://docs.videogen.io/libraries/mcp)
|
|
93
|
+
- [API reference](https://docs.videogen.io)
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
98
|
+
|
|
99
|
+
## Account and permissions
|
|
100
|
+
|
|
101
|
+
Generation and editing use VideoGen account credits. Obtain user approval before credit-consuming calls, and restrict the `include` list for agents that only need read access. Keep API keys in environment variables and out of shared transcripts.
|
|
102
|
+
|
|
103
|
+
[VideoGen](https://videogen.io/) · [MCP setup](https://videogen.io/videogen-mcp)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "openai-agents-videogen"
|
|
7
|
+
version = "2.5.3"
|
|
8
|
+
description = "Official OpenAI Agents SDK tools for the VideoGen API. Generate videos, images, voiceovers, sound effects, music, and avatars from any OpenAI Agents SDK agent."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = [
|
|
13
|
+
"videogen",
|
|
14
|
+
"openai-agents",
|
|
15
|
+
"openai-agents-sdk",
|
|
16
|
+
"ai",
|
|
17
|
+
"agents",
|
|
18
|
+
"tools",
|
|
19
|
+
"text-to-video",
|
|
20
|
+
"ai-video-generation",
|
|
21
|
+
"text-to-speech",
|
|
22
|
+
"image-generation",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
dependencies = [
|
|
26
|
+
"videogen>=2.5.3",
|
|
27
|
+
"openai-agents>=0.1.0",
|
|
28
|
+
"pydantic>=2.0.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://videogen.io"
|
|
33
|
+
Documentation = "https://github.com/video-gen/video-workflow-recipes/tree/main/integrations/openai-agents-videogen#readme"
|
|
34
|
+
Repository = "https://github.com/video-gen/video-workflow-recipes"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/openai_agents_videogen"]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = ["pytest>=8.0.0"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
markers = [
|
|
44
|
+
"integration: live tests that call the VideoGen API (require VIDEOGEN_API_KEY)",
|
|
45
|
+
]
|
|
46
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Official OpenAI Agents SDK tools 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_tools
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"Controls",
|
|
11
|
+
"create_videogen_tools",
|
|
12
|
+
"resolve_client",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
__version__ = version("openai-agents-videogen")
|
|
17
|
+
except PackageNotFoundError:
|
|
18
|
+
__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 OpenAI Agents SDK 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="openai-agents",
|
|
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["workflowRunId"], **_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["toolExecutionId"], **_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["exportId"], **_poll_kwargs(controls)
|
|
87
|
+
)
|
|
88
|
+
return to_dict(project_export)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Factory for the VideoGen OpenAI Agents SDK integration."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Iterable, List, Optional
|
|
6
|
+
|
|
7
|
+
from agents import FunctionTool
|
|
8
|
+
from videogen import VideoGen
|
|
9
|
+
|
|
10
|
+
from .client import resolve_client
|
|
11
|
+
from .operations import Controls
|
|
12
|
+
from .tools import build_videogen_tools
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def create_videogen_tools(
|
|
16
|
+
client: Optional[VideoGen] = None,
|
|
17
|
+
*,
|
|
18
|
+
api_key: Optional[str] = None,
|
|
19
|
+
base_url: Optional[str] = None,
|
|
20
|
+
wait: bool = True,
|
|
21
|
+
poll_interval_ms: Optional[int] = None,
|
|
22
|
+
timeout_ms: Optional[int] = None,
|
|
23
|
+
include: Optional[Iterable[str]] = None,
|
|
24
|
+
) -> List[FunctionTool]:
|
|
25
|
+
"""Build VideoGen tools in OpenAI Agents SDK format, ready to pass to an ``Agent``.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
client: A pre-configured ``VideoGen`` client. When omitted, one is built
|
|
29
|
+
from ``api_key`` / ``base_url`` or the ``VIDEOGEN_API_KEY`` environment variable.
|
|
30
|
+
wait: When True (default), tools block until the workflow run or tool execution
|
|
31
|
+
finishes and return the completed result. Set False to return immediately
|
|
32
|
+
with the run/execution id for the caller to poll.
|
|
33
|
+
poll_interval_ms: Poll interval while waiting. Defaults to the SDK's default.
|
|
34
|
+
timeout_ms: Maximum time to wait before giving up. Defaults to the SDK's default.
|
|
35
|
+
include: Restrict the returned tool set to these tool names. Defaults to all tools.
|
|
36
|
+
"""
|
|
37
|
+
resolved_client = resolve_client(client, api_key=api_key, base_url=base_url)
|
|
38
|
+
controls = Controls(wait=wait, poll_interval_ms=poll_interval_ms, timeout_ms=timeout_ms)
|
|
39
|
+
|
|
40
|
+
tools = build_videogen_tools(resolved_client, controls)
|
|
41
|
+
|
|
42
|
+
if include is None:
|
|
43
|
+
return tools
|
|
44
|
+
|
|
45
|
+
included = set(include)
|
|
46
|
+
return [tool for tool in tools if tool.name in included]
|