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    '#
async vs_transribe_video_screenshot(video_path: str, timestamp: float) str[source]#

在特定时间戳转录视频截图。

参数:
  • video_path (str) – 视频文件的路径。

  • timestamp (float) – 截图的时间戳。

返回:

str – 视频截图的转录。