Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -7,16 +7,27 @@ 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_cutom_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:
@@ -51,7 +62,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ # Custom tool to fetch webpage title
11
  @tool
12
+ def fetch_webpage_title(url: str) -> str:
13
+ """A tool that fetches the title of a webpage.
14
+
15
  Args:
16
+ url: The URL of the webpage to fetch.
17
+
18
+ Returns:
19
+ The title of the webpage.
20
  """
21
+ try:
22
+ response = requests.get(url)
23
+ response.raise_for_status() # Raise an exception for invalid responses
24
+ # Extract title from the HTML
25
+ from bs4 import BeautifulSoup
26
+ soup = BeautifulSoup(response.text, 'html.parser')
27
+ title = soup.title.string if soup.title else "No title found"
28
+ return f"The title of the webpage at {url} is: {title}"
29
+ except Exception as e:
30
+ return f"Error fetching webpage title: {str(e)}"
31
 
32
  @tool
33
  def get_current_time_in_timezone(timezone: str) -> str:
 
62
 
63
  agent = CodeAgent(
64
  model=model,
65
+ tools=[final_answer, DuckDuckGoSearchTool(), image_generation_tool, fetch_webpage_title],
66
  max_steps=6,
67
  verbosity_level=1,
68
  grammar=None,