VisionTool

描述

此工具用于从图像中提取文本。当传递给代理时,它将从图像中提取文本,然后使用它来生成响应、报告或任何其他输出。应将图像的 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字符串强制。需要从中提取文本的图像文件的路径。