Spaces:
Configuration error
Configuration error
| from langchain_core.tools import BaseTool | |
| from image_question_answer import ImageQuestionAnswer | |
| from pydantic import BaseModel, Field | |
| from typing import Type | |
| class ImageQuestionAnswerToolArgs(BaseModel): | |
| file_path: str = Field(description="The path to the image file") | |
| question: str = Field(description="The question to answer") | |
| class ImageQuestionAnswerTool(BaseTool): | |
| name: str = "image_question_answer" | |
| description: str = "Answer the question based on the image." | |
| args_schema: Type[BaseModel] = ImageQuestionAnswerToolArgs | |
| def _run(self, file_path: str, question: str) -> str: | |
| return ImageQuestionAnswer().answer(file_path, question) | |