Spaces:
Sleeping
Sleeping
Updated my image generator function tool
Browse files
app.py
CHANGED
|
@@ -4,12 +4,13 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
"""A tool that generates an image based on the image_description variable
|
| 14 |
Args:
|
| 15 |
image_description: the description of the image to be generated
|
|
@@ -20,9 +21,9 @@ def my_custom_tool(image_description:str)-> None: #it's import to specify the re
|
|
| 20 |
|
| 21 |
image = image_generation_tool(image_description)
|
| 22 |
|
| 23 |
-
image.show()
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
@tool
|
| 28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -58,7 +59,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
-
tools=[final_answer,
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from PIL import Image
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def generate_image_by_description(image_description:str)-> Image.Image: #it's import to specify the return type
|
| 14 |
"""A tool that generates an image based on the image_description variable
|
| 15 |
Args:
|
| 16 |
image_description: the description of the image to be generated
|
|
|
|
| 21 |
|
| 22 |
image = image_generation_tool(image_description)
|
| 23 |
|
| 24 |
+
# image.show()
|
| 25 |
|
| 26 |
+
return image
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
+
tools=[final_answer, generate_image_by_description], ## add your tools here (don't remove final answer)
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|