Spaces:
Configuration error
Configuration error
File size: 672 Bytes
28dbbfb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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)
|