跳转到主要内容

视觉工具

描述

此工具用于从图像中提取文本。当传递给代理时,它将从图像中提取文本,然后使用它来生成响应、报告或任何其他输出。图像的 URL 或 PATH 应传递给代理。

安装

安装 crewai_tools 包
pip install 'crewai[tools]'

用法

要使用 VisionTool,应在环境变量 OPENAI_API_KEY 中设置 OpenAI API 密钥。
代码
from crewai_tools import VisionTool

vision_tool = VisionTool()

@agent
def researcher(self) -> Agent:
    '''
    This agent uses the VisionTool to extract text from images.
    '''
    return Agent(
        config=self.agents_config["researcher"],
        allow_delegation=False,
        tools=[vision_tool]
    )

参数

VisionTool 需要以下参数
参数类型描述
image_path_url字符串必需。需要从中提取文本的图像文件的路径。