Update app.py
Browse files
app.py
CHANGED
|
@@ -36,28 +36,31 @@ Your output must be: a single clean answer string only.
|
|
| 36 |
|
| 37 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 38 |
|
|
|
|
|
|
|
| 39 |
class ImageCaptioningTool(Tool):
|
| 40 |
name = "image_captioner"
|
| 41 |
-
description = "Generate a caption for an image."
|
|
|
|
| 42 |
inputs = {
|
| 43 |
"image": {
|
| 44 |
-
"type": "
|
| 45 |
-
"description": "
|
| 46 |
},
|
| 47 |
"question": {
|
| 48 |
-
"type": "
|
| 49 |
-
"description": "A
|
| 50 |
}
|
| 51 |
}
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
def run(self, inputs: dict) -> str:
|
| 55 |
-
image = inputs
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
# class ImageCaptioningTool(Tool):
|
| 62 |
# name = "image_captioner"
|
| 63 |
# description = "Generate a caption for an image."
|
|
|
|
| 36 |
|
| 37 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 38 |
|
| 39 |
+
from smolagents.schema import Tool
|
| 40 |
+
|
| 41 |
class ImageCaptioningTool(Tool):
|
| 42 |
name = "image_captioner"
|
| 43 |
+
description = "Generate a caption for an image using a prompt or question."
|
| 44 |
+
|
| 45 |
inputs = {
|
| 46 |
"image": {
|
| 47 |
+
"type": "image",
|
| 48 |
+
"description": "An image file input."
|
| 49 |
},
|
| 50 |
"question": {
|
| 51 |
+
"type": "string",
|
| 52 |
+
"description": "A prompt or question about the image."
|
| 53 |
}
|
| 54 |
}
|
| 55 |
+
|
| 56 |
+
output_type = "string"
|
| 57 |
|
| 58 |
def run(self, inputs: dict) -> str:
|
| 59 |
+
image = inputs["image"]
|
| 60 |
+
question = inputs["question"]
|
| 61 |
+
# Dummy logic – replace with actual model
|
| 62 |
+
return f"Captioning image for: {question}"
|
| 63 |
+
|
|
|
|
| 64 |
# class ImageCaptioningTool(Tool):
|
| 65 |
# name = "image_captioner"
|
| 66 |
# description = "Generate a caption for an image."
|