Vision Tool
VisionTool
Section titled “VisionTool”这个工具用于从图片中提取文本。传给 agent 后,它会先从图片中提取文本,再基于这些内容生成响应、报告或其他输出。 需要将图片的 URL 或 PATH 传给 Agent。
安装 crewai_tools 包
pip install 'crewai[tools]'要使用 VisionTool,需要将 OpenAI API key 设置到环境变量 OPENAI_API_KEY 中。
from crewai_tools import VisionTool
vision_tool = VisionTool()
@agentdef 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 需要以下参数:
| Argument | Type | Description |
|---|---|---|
| image_path_url | string | 必填。需要从中提取文本的图片文件路径。 |