autogen_ext.agents.video_surfer#
- class VideoSurfer(name: str, model_client: ChatCompletionClient, *, tools: List[BaseTool[BaseModel, BaseModel] | Callable[[...], Any] | Callable[[...], Awaitable[Any]]] | None = None, description: str | None = None, system_message: str | None = None)[source]#
基类:
AssistantAgent
VideoSurfer 是一种专门设计的代理,用于回答有关本地视频文件的问题。
安装
pip install "autogen-ext[video-surfer]"
此代理利用各种工具从视频中提取信息,例如视频长度、特定时间戳的屏幕截图和音频转录。它处理这些元素,以提供对用户查询的详细解答。
可用工具
- 参数:
name (str) – 代理的名称。
model_client (ChatCompletionClient) – 用于生成响应的模型客户端。
tools (List[BaseTool[BaseModel, BaseModel] | Callable[..., Any] | Callable[..., Awaitable[Any]]] | None, optional) – 代理可以使用的工具或函数的列表。如果未提供,则默认为操作空间中的所有视频工具。
description (str, optional) – 代理的简要描述。默认为“一个可以回答有关本地视频问题的代理。”。
system_message (str | None, optional) – 指导代理行为的系统消息。默认为预定义的消息。
使用示例
以下示例演示如何使用模型客户端创建视频浏览代理,并生成对关于名为 video.mp4 的本地视频的简单查询的响应。
import asyncio from autogen_agentchat.ui import Console from autogen_agentchat.conditions import TextMentionTermination from autogen_agentchat.teams import RoundRobinGroupChat from autogen_ext.models.openai import OpenAIChatCompletionClient from autogen_ext.agents.video_surfer import VideoSurfer async def main() -> None: """ Main function to run the video agent. """ # Define an agent video_agent = VideoSurfer( name="VideoSurfer", model_client=OpenAIChatCompletionClient(model="gpt-4o-2024-08-06") ) # Define termination condition termination = TextMentionTermination("TERMINATE") # Define a team agent_team = RoundRobinGroupChat([video_agent], termination_condition=termination) # Run the team and stream messages to the console stream = agent_team.run_stream(task="How does Adam define complex tasks in video.mp4? What concrete example of complex does his use? Can you save this example to disk as well?") await Console(stream) asyncio.run(main())
以下示例演示如何创建和使用带有 MagenticOneGroupChat 的 VideoSurfer 和 UserProxyAgent。
import asyncio from autogen_agentchat.ui import Console from autogen_agentchat.teams import MagenticOneGroupChat from autogen_agentchat.agents import UserProxyAgent from autogen_ext.models.openai import OpenAIChatCompletionClient from autogen_ext.agents.video_surfer import VideoSurfer async def main() -> None: """ Main function to run the video agent. """ model_client = OpenAIChatCompletionClient(model="gpt-4o-2024-08-06") # Define an agent video_agent = VideoSurfer( name="VideoSurfer", model_client=model_client ) web_surfer_agent = UserProxyAgent( name="User" ) # Define a team agent_team = MagenticOneGroupChat([web_surfer_agent, video_agent], model_client=model_client,) # Run the team and stream messages to the console stream = agent_team.run_stream(task="Find a latest video about magentic one on youtube and extract quotes from it that make sense.") await Console(stream) asyncio.run(main())
- DEFAULT_DESCRIPTION = '一个可以回答有关本地视频问题的代理。'#
- DEFAULT_SYSTEM_MESSAGE = '\n 你是一个有用的代理,是回答视频问题的专家。\n 当被要求回答关于视频的问题时,你应该:\n 1. 检查该视频是否在本地可用。\n 2. 使用转录来找到问题所指的视频部分。\n 3. (可选)使用来自那些时间戳的屏幕截图\n 4. 提供对问题的详细解答。\n 当任务完成时,回复 TERMINATE。\n '#