Spaces:
Runtime error
Runtime error
Used the image generation tool inside the custom tool
Browse files
app.py
CHANGED
@@ -4,19 +4,28 @@ 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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -40,10 +49,10 @@ final_answer = FinalAnswerTool()
|
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
41 |
|
42 |
model = HfApiModel(
|
43 |
-
max_tokens=2096,
|
44 |
-
temperature=0.5,
|
45 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
46 |
-
custom_role_conversions=None,
|
47 |
)
|
48 |
|
49 |
|
@@ -55,7 +64,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
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 image_generator(character:str, sceneDescription:str)-> Image: #it's important to specify the return type
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
+
"""A tool that returns an image base on a character and a scene setting
|
16 |
Args:
|
17 |
+
character: the character
|
18 |
+
sceneDescription: the description of the scene
|
19 |
+
|
20 |
+
Returns:
|
21 |
+
Image: The generated image of the character in the specified scene.
|
22 |
"""
|
23 |
+
try:
|
24 |
+
# call the image_generation_tool tool with a text prompt
|
25 |
+
image = image_generation_tool(f"{character} in {sceneDescription}")
|
26 |
+
return image
|
27 |
+
except Exception as e:
|
28 |
+
return f"Error fetching image for given inputs: {str(e)}"
|
29 |
|
30 |
@tool
|
31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
49 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
50 |
|
51 |
model = HfApiModel(
|
52 |
+
max_tokens=2096,
|
53 |
+
temperature=0.5,
|
54 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
55 |
+
custom_role_conversions=None,
|
56 |
)
|
57 |
|
58 |
|
|
|
64 |
|
65 |
agent = CodeAgent(
|
66 |
model=model,
|
67 |
+
tools=[final_answer, image_generator], ## add your tools here (don't remove final answer)
|
68 |
max_steps=6,
|
69 |
verbosity_level=1,
|
70 |
grammar=None,
|