Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,20 @@ def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
23 |
"""A tool that fetches the current local time in a specified timezone.
|
@@ -51,7 +65,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
51 |
|
52 |
agent = CodeAgent(
|
53 |
model=model,
|
54 |
-
tools=[
|
55 |
max_steps=6,
|
56 |
verbosity_level=1,
|
57 |
grammar=None,
|
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
+
@tool
|
22 |
+
def webpage_summarizer(url: str) -> str:
|
23 |
+
"""Extracts and summarizes main content from a webpage
|
24 |
+
Args:
|
25 |
+
url: URL of the webpage to summarize
|
26 |
+
"""
|
27 |
+
from bs4 import BeautifulSoup
|
28 |
+
response = requests.get(url)
|
29 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
30 |
+
# Extract main content (this is a simple example)
|
31 |
+
text = ' '.join([p.text for p in soup.find_all('p')])
|
32 |
+
return text[:500] + "..." # Return first 500 characters
|
33 |
+
|
34 |
+
|
35 |
@tool
|
36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
37 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
65 |
|
66 |
agent = CodeAgent(
|
67 |
model=model,
|
68 |
+
tools=[webpage_summarizer], ## add your tools here (don't remove final answer)
|
69 |
max_steps=6,
|
70 |
verbosity_level=1,
|
71 |
grammar=None,
|