amantandon30 commited on
Commit
0ad71d5
·
verified ·
1 Parent(s): 60fb1d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -19
app.py CHANGED
@@ -7,27 +7,16 @@ from tools.final_answer import FinalAnswerTool
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:
@@ -46,6 +35,10 @@ def get_current_time_in_timezone(timezone: str) -> str:
46
 
47
 
48
  final_answer = FinalAnswerTool()
 
 
 
 
49
  model = HfApiModel(
50
  max_tokens=2096,
51
  temperature=0.5,
@@ -62,7 +55,7 @@ with open("prompts.yaml", 'r') as stream:
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,
 
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:
 
35
 
36
 
37
  final_answer = FinalAnswerTool()
38
+
39
+ # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
40
+ # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
+
42
  model = HfApiModel(
43
  max_tokens=2096,
44
  temperature=0.5,
 
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,