Add tools.py
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
from virtual_file_system import VirtualFileSystem
|
||||||
|
|
||||||
|
# Web search tool: fetch DuckDuckGo search results page
|
||||||
|
|
||||||
|
def web_search(query: str) -> str:
|
||||||
|
"""Search the web for the given query using DuckDuckGo.
|
||||||
|
|
||||||
|
Returns the raw HTML of the search results page.
|
||||||
|
"""
|
||||||
|
url = f"https://duckduckgo.com/html/?q={query}"
|
||||||
|
try:
|
||||||
|
response = requests.get(url, timeout=10)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.text
|
||||||
|
except Exception as e:
|
||||||
|
return f"Error during web search: {e}"
|
||||||
|
|
||||||
|
# File system tools will be wrapped in agent.py with access to a VirtualFileSystem instance.
|
||||||
Reference in New Issue
Block a user