diff --git a/config.yaml.full b/config.yaml.full index 37dc8cd0..fd18f751 100644 --- a/config.yaml.full +++ b/config.yaml.full @@ -61,6 +61,10 @@ tool: tool_id: #https://console.volcengine.com/ACEP - # `product_id`-`pod_id_1` - # `product_id`-`pod_id_1` + # [optional] for Vod Tool https://console.volcengine.com/vod + vod: + groups: + timeout: 10.0 las: url: #mcp sse url diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 2fd22f8e..5428060d 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -51,17 +51,20 @@ volcengine: 统一前缀: `TOOL_` -| 子类 | 环境变量名称 | 释义 | -| ---------- | ---------------------- | ---- | -| VeSearch | `TOOL_VESEARCH_ENDPOINT` | 火山引擎搜索机器人 ID(bot_id) | -| | `TOOL_VESEARCH_API_KEY` | 火山引擎搜索服务密钥 | -| WebScraper | `TOOL_WEB_SCRAPER_ENDPOINT` | WebScraper 端点 | -| | `TOOL_WEB_SCRAPER_API_KEY` | WebScraper 密钥(token) | -| Lark | `TOOL_LARK_ENDPOINT` | Lark 应用 ID(app_id) | +| 子类 | 环境变量名称 | 释义 | +|------------| ---------------------- |-----------------------| +| VeSearch | `TOOL_VESEARCH_ENDPOINT` | 火山引擎搜索机器人 ID(bot_id) | +| | `TOOL_VESEARCH_API_KEY` | 火山引擎搜索服务密钥 | +| WebScraper | `TOOL_WEB_SCRAPER_ENDPOINT` | WebScraper 端点 | +| | `TOOL_WEB_SCRAPER_API_KEY` | WebScraper 密钥(token) | +| Lark | `TOOL_LARK_ENDPOINT` | Lark 应用 ID(app_id) | | | `TOOL_LARK_API_KEY` | Lark 应用密钥(app_secret) | -| | `TOOL_LARK_TOKEN` | Lark 用户 token | +| | `TOOL_LARK_TOKEN` | Lark 用户 token | | LAS | `TOOL_LAS_URL` | LAS SSE 服务地址(含 token) | -| | `TOOL_LAS_DATASET_ID` | LAS 数据集 ID | +| | `TOOL_LAS_DATASET_ID` | LAS 数据集 ID | +| VOD | `TOOL_VOD_GROUPS` | 视频编辑能力组 | +| | `TOOL_VOD_TIMEOUT` | VOD工具连接超时时长 | + ### 数据库类 diff --git a/docs/docs/tools/builtin.md b/docs/docs/tools/builtin.md index 6038d286..aa857444 100644 --- a/docs/docs/tools/builtin.md +++ b/docs/docs/tools/builtin.md @@ -70,6 +70,7 @@ VeADK 集成了以下火山引擎工具: | `lark` | 集成[飞书开放能力](https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_installation),实现文档处理、会话管理等。 | `from veadk.tools.builtin_tools.lark import lark` | | `las` | 基于[火山引擎 AI 多模态数据湖服务 LAS](https://www.volcengine.com/mcp-marketplace) 进行数据管理。 | `from veadk.tools.builtin_tools.las import las` | | `mobile_run` | 手机指令执行 | `from veadk.tools.builtin_tools.mobile_run import create_mobile_use_tool` | +| `vod` | 视频剪辑助手 | `from veadk.tools.builtin_tools.vod import vod_tools` | ### 公域搜索 (Web Search) @@ -592,7 +593,82 @@ VeADK 集成了以下火山引擎工具: 运行结果: ![img_2.png](../assets/images/tools/mua_3.png) +### 视频云MCP工具(Vod MCP Tool) +`vod_tools`允许Agent通过调用火山引擎的视频云MCP来进行视频剪辑处理,详情请参考[VOD MCP Server](https://github.com/volcengine/mcp-server/blob/main/server/mcp_server_vod/README_zh.md) + +!!! warning "使用 `vod_tools` 的附加要求" + 1. 需要配置火山引擎 AK、SK + 2. (可选)可以配置`TOOL_VOD_GROUPS`选择多样化的视频剪辑能力。可选范围为: + - `edit`:视频剪辑相关tools + - `intelligent_slicing`: 智能切片相关tools + - `intelligent_matting`: 智能抠图相关tools + - `subtitle_processing`: 字幕处理相关tools + - `audio_processing`: 音频处理相关tools + - `video_enhancement`: 视频增强相关tools + - `upload`: 上传相关 + - `video_play`: 视频播放相关 + 3. (可选)工具连接超时时长`TOOL_VOD_TIMEOUT`,默认为10秒 + - 注:如果需要多个工具组,请使用逗号进行连接,如果不进行配置,则默认为`edit,video_play` + - 注:视频云工具不支持Space的创建,请在火山视频云控制台提前创建[视频云空间](https://console.volcengine.com/vod/region:vod+cn-north-1/overview/) + + +=== "Python" + + ```python + import asyncio + from veadk import Agent, Runner + from veadk.tools.builtin_tools.vod import vod_tools + agent = Agent(tools=[vod_tools]) + runner = Runner(agent) + result = asyncio.run( + runner.run( + messages="将这两个视频合并:, , space_name为 +- **视频时长**:x秒 +- **分辨率**:xxxxx +- **文件名称**:xxxxx.mp4 +(注:播放地址有效期为60分钟,若过期可重新生成) +``` + +注:有些视频编辑任务可能时间开销较大,该类任务会直接返回一个task_id,可以继续询问agent,让其查询task是否完成,从而获得任务后续。 ## 系统工具 diff --git a/veadk/tools/builtin_tools/vod.py b/veadk/tools/builtin_tools/vod.py new file mode 100644 index 00000000..15f41a47 --- /dev/null +++ b/veadk/tools/builtin_tools/vod.py @@ -0,0 +1,71 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from google.adk.tools.mcp_tool import StdioConnectionParams +from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters, McpToolset + +from veadk.config import getenv +from veadk.utils.logger import get_logger + +logger = get_logger(__name__) + + +def _get_vod_envs() -> dict[str, str]: + """ + note, available `TOOL_VOD_GROUPS`: + "edit", # Tools related to video editing + "intelligent_slicing", # Tools related to intelligent slicing + "intelligent_matting", # Tools related to intelligent matting + "subtitle_processing", # Tools related to subtitle processing + "audio_processing", # Tools related to audio processing + "video_enhancement", # Tools related to video enhancement + 'upload', # Related to upload + "video_play" # Related to video playback + https://github.com/volcengine/mcp-server/blob/main/server/mcp_server_vod/src/vod/mcp_server.py#L14 + """ + + ak = getenv("VOLCENGINE_ACCESS_KEY", None) + sk = getenv("VOLCENGINE_SECRET_KEY", None) + + if os.getenv("TOOL_VOD_GROUPS", None): + return { + "VOLCENGINE_ACCESS_KEY": ak, + "VOLCENGINE_SECRET_KEY": sk, + "MCP_TOOL_GROUPS": getenv("TOOL_VOD_GROUPS"), + } + else: + return { + "VOLCENGINE_ACCESS_KEY": ak, + "VOLCENGINE_SECRET_KEY": sk, + } + + +_vod_envs = _get_vod_envs() + +vod_tools = McpToolset( + connection_params=StdioConnectionParams( + server_params=StdioServerParameters( + command="uvx", + args=[ + "--from", + "git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_vod", + "mcp-server-vod", + ], + env=_vod_envs, + ), + timeout=float(os.getenv("TOOL_VOD_TIMEOUT", 10.0)), + ) +)