Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,10 @@ 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
|
@@ -17,6 +21,22 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
17 |
arg2: the second argument
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -47,8 +67,7 @@ custom_role_conversions=None,
|
|
47 |
)
|
48 |
|
49 |
|
50 |
-
|
51 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
52 |
|
53 |
with open("prompts.yaml", 'r') as stream:
|
54 |
prompt_templates = yaml.safe_load(stream)
|
|
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
+
from gradio_client import Client
|
10 |
+
|
11 |
+
# Import tool from Hub
|
12 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
13 |
|
14 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
15 |
@tool
|
|
|
21 |
arg2: the second argument
|
22 |
"""
|
23 |
return "What magic will you build ?"
|
24 |
+
# -- my tool
|
25 |
+
@tool
|
26 |
+
def get_image(img_description:str)-> img: #it's import to specify the return type
|
27 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
28 |
+
"""A tool that generate an image from a textual description
|
29 |
+
Args:
|
30 |
+
img_description: a sting containing the description of the image the user wants to get
|
31 |
+
"""
|
32 |
+
client = Client("agents-course/text-to-image")
|
33 |
+
result = client.predict(
|
34 |
+
param_0="Hello!!",
|
35 |
+
api_name="/predict"
|
36 |
+
)
|
37 |
+
return result
|
38 |
+
# -- my tool end
|
39 |
+
|
40 |
|
41 |
@tool
|
42 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
67 |
)
|
68 |
|
69 |
|
70 |
+
|
|
|
71 |
|
72 |
with open("prompts.yaml", 'r') as stream:
|
73 |
prompt_templates = yaml.safe_load(stream)
|