Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,24 +15,25 @@ import time
|
|
15 |
|
16 |
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
#
|
35 |
-
|
|
|
36 |
|
37 |
|
38 |
@tool
|
@@ -209,7 +210,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
209 |
|
210 |
agent = CodeAgent(
|
211 |
model=gemini_model,
|
212 |
-
tools=[final_answer,get_current_time_in_timezone, search_tool, web_visit, image_generation_tool], ## add your tools here (don't remove final answer)
|
213 |
max_steps=6,
|
214 |
verbosity_level=1,
|
215 |
grammar=None,
|
|
|
15 |
|
16 |
|
17 |
|
18 |
+
@tool
|
19 |
+
def show_image(image : PIL.JpegImagePlugin.JpegImageFile ): #it's import to specify the return type
|
20 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
21 |
+
"""A tool that shows image generated by image_generation_tool
|
22 |
+
Args:
|
23 |
+
image: the input image with the original type
|
24 |
+
"""
|
25 |
+
# Assuming 'agent_image' is your smolagents.agent_types.AgentImage object
|
26 |
+
if isinstance(image, Image.Image):
|
27 |
+
pil_image = image
|
28 |
+
image.show()
|
29 |
+
elif hasattr(image, 'to_pil'):
|
30 |
+
pil_image = agent_image.to_pil()
|
31 |
+
elif hasattr(image, 'image') and isinstance(agent_image.image, Image.Image):
|
32 |
+
pil_image = agent_image.image
|
33 |
+
else:
|
34 |
+
# If none of the above, you'll need to investigate further
|
35 |
+
print("Could not directly convert. Check the object's attributes and methods.")
|
36 |
+
# For example, print(dir(agent_image)) to see what's available
|
37 |
|
38 |
|
39 |
@tool
|
|
|
210 |
|
211 |
agent = CodeAgent(
|
212 |
model=gemini_model,
|
213 |
+
tools=[final_answer,get_current_time_in_timezone, search_tool, web_visit, image_generation_tool, show_image], ## add your tools here (don't remove final answer)
|
214 |
max_steps=6,
|
215 |
verbosity_level=1,
|
216 |
grammar=None,
|