Skip to content
CrewAI 文档版本 跟随上游 源快照 0147f230 更新于 2026-10-18

Vision Tool

VisionTool 用于从图像中提取文本。

VisionTool

描述

该工具用于从图像中提取文本。将它传给智能体后,它会从图像中提取文本,然后用这些文本来生成回复、报告或其他任何输出。 应将图像的 URL 或 PATH 传给智能体。

你也可以针对图像提出自定义 query,并选择 complexity_level,它会自动挑选最适合该请求的模型:

复杂度级别模型
easygpt-5.6-luna
medium(默认)gpt-5.6-terra
hardgpt-5.6-sol

当向工具显式传入 llm 或 model 时,它的优先级高于基于复杂度的模型选择。

安装

安装 crewai_tools 包

shell
pip install 'crewai[tools]'

用量

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

python
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_urlstring必填。需要从中提取文本的图像文件路径(或 URL)。
querystring可选。向模型提出的关于该图像的问题或指令。默认为 "What's in this image?"。
complexity_levelstring可选。请求的复杂度,用于选择模型:easy、medium 或 hard。默认为 medium。

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。