roger33303 commited on
Commit
60432f6
·
verified ·
1 Parent(s): ead9cf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -7,16 +7,15 @@ 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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
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:
@@ -33,6 +32,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
@@ -48,15 +64,13 @@ custom_role_conversions=None,
48
  )
49
 
50
 
51
- # Import tool from Hub
52
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
53
 
54
  with open("prompts.yaml", 'r') as stream:
55
  prompt_templates = yaml.safe_load(stream)
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ search_tool = DuckDuckGoSearchTool()
11
+ def web_search_tool(arg1:str)-> str: #it's import to specify the return type
 
12
  #Keep this format for the description / args / args description but feel free to modify the tool
13
+ """A tool that can search diffrent websites and give back the contents of the webpage
14
  Args:
15
+ arg1: Direct question to search the web.
 
16
  """
17
+ search_result = search_tool(arg1)
18
+ return search_result
19
 
20
  @tool
21
  def get_current_time_in_timezone(timezone: str) -> str:
 
32
  except Exception as e:
33
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
34
 
35
+ # Import tool from Hub
36
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
37
+
38
+
39
+ @tool
40
+ def get_generated_image(image_prompt: str) -> image:
41
+ """ A tool that can generate an image at a time.
42
+ Args:
43
+ image_prompt: A prompt with the discription of the image that is needed to be generated.
44
+ """
45
+ image_result = image_generation_tool(image_prompt)
46
+ return image_result
47
+
48
+
49
+
50
+
51
+
52
 
53
  final_answer = FinalAnswerTool()
54
 
 
64
  )
65
 
66
 
 
 
67
 
68
  with open("prompts.yaml", 'r') as stream:
69
  prompt_templates = yaml.safe_load(stream)
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer,get_current_time_in_timezone,image_generation_tool,web_search_tool], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,