Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -65,8 +65,10 @@ def process_tool_output(tool_output):
|
|
| 65 |
return str(tool_output)
|
| 66 |
|
| 67 |
class CustomDuckDuckGoSearchTool(Tool):
|
|
|
|
|
|
|
| 68 |
def __call__(self, query: str) -> str:
|
| 69 |
-
|
| 70 |
try:
|
| 71 |
with DDGS() as ddgs:
|
| 72 |
results = list(ddgs.text(query, max_results=3)) # Convert generator to list
|
|
@@ -77,8 +79,9 @@ class CustomDuckDuckGoSearchTool(Tool):
|
|
| 77 |
custome_duck_search = CustomDuckDuckGoSearchTool()
|
| 78 |
|
| 79 |
class CustomVisitWebpageTool(Tool):
|
|
|
|
|
|
|
| 80 |
def __call__(self, url: str) -> str:
|
| 81 |
-
"""Visit a webpage and extract content as a string."""
|
| 82 |
try:
|
| 83 |
response = requests.get(url, timeout=10)
|
| 84 |
response.raise_for_status()
|
|
|
|
| 65 |
return str(tool_output)
|
| 66 |
|
| 67 |
class CustomDuckDuckGoSearchTool(Tool):
|
| 68 |
+
name = "CustomDuckDuckGoSearchTool"
|
| 69 |
+
description = "Perform a DuckDuckGo search and return a string result."
|
| 70 |
def __call__(self, query: str) -> str:
|
| 71 |
+
|
| 72 |
try:
|
| 73 |
with DDGS() as ddgs:
|
| 74 |
results = list(ddgs.text(query, max_results=3)) # Convert generator to list
|
|
|
|
| 79 |
custome_duck_search = CustomDuckDuckGoSearchTool()
|
| 80 |
|
| 81 |
class CustomVisitWebpageTool(Tool):
|
| 82 |
+
name = "CustomVisitWebpageTool"
|
| 83 |
+
description = "Visit a webpage and extract content as a string."
|
| 84 |
def __call__(self, url: str) -> str:
|
|
|
|
| 85 |
try:
|
| 86 |
response = requests.get(url, timeout=10)
|
| 87 |
response.raise_for_status()
|