AlexTrinityBlock commited on
Commit
c36efba
·
1 Parent(s): 7a0b5ad

feat(tools): add http_get tool for web content fetching

Browse files

- Import http_get module in agent.py
- Register http_get in supervisor agent tools list
- Provide HTTP GET capability for retrieving remote resources

Files changed (2) hide show
  1. agent/agent.py +2 -1
  2. agent/tools/http_get.py +35 -0
agent/agent.py CHANGED
@@ -7,6 +7,7 @@ from agent.tools.math_solver import math_solver
7
  from agent.tools.file_downloader import file_downloader
8
  from agent.tools.ocr_reader import ocr_reader
9
  from agent.tools.list_files import list_files
 
10
 
11
  from agent.agents.websearchagents import web_search_agents
12
 
@@ -21,7 +22,7 @@ def supervisor_agent():
21
  return create_agent(
22
  model="google_genai:gemini-3-flash-preview",
23
  # tools=[math_solver, websearch_agent, web_search_agents],
24
- tools=[math_solver, web_search_agents, file_downloader, ocr_reader, list_files],
25
  system_prompt=(
26
  f"You are a supervisor agent. "
27
  f"Current time is: {datetime.now(timezone.utc).isoformat()}. "
 
7
  from agent.tools.file_downloader import file_downloader
8
  from agent.tools.ocr_reader import ocr_reader
9
  from agent.tools.list_files import list_files
10
+ from agent.tools.http_get import http_get
11
 
12
  from agent.agents.websearchagents import web_search_agents
13
 
 
22
  return create_agent(
23
  model="google_genai:gemini-3-flash-preview",
24
  # tools=[math_solver, websearch_agent, web_search_agents],
25
+ tools=[math_solver, web_search_agents, file_downloader, ocr_reader, list_files, http_get],
26
  system_prompt=(
27
  f"You are a supervisor agent. "
28
  f"Current time is: {datetime.now(timezone.utc).isoformat()}. "
agent/tools/http_get.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import httpx
2
+ from colorama import Fore, Style # type: ignore[import]
3
+ from langchain_core.tools import tool
4
+
5
+ HTTP_HEADERS = {
6
+ "User-Agent": (
7
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
8
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
9
+ "Chrome/120.0.0.0 Safari/537.36"
10
+ )
11
+ }
12
+
13
+
14
+ @tool
15
+ def http_get(url: str) -> str:
16
+ """Send an HTTP GET request to the given URL and return the response text.
17
+
18
+ Useful for fetching web pages, API responses, or any text-based content
19
+ from the internet.
20
+
21
+ Args:
22
+ url: The URL to send the GET request to.
23
+
24
+ Returns:
25
+ The response body as text, or an error message on failure.
26
+ """
27
+ try:
28
+ print(f"{Fore.CYAN}[HTTP GET] {url}{Style.RESET_ALL}")
29
+ resp = httpx.get(url, headers=HTTP_HEADERS, follow_redirects=True, timeout=60)
30
+ resp.raise_for_status()
31
+ print(f"{Fore.CYAN}[HTTP GET] Status: {resp.status_code} | "
32
+ f"Length: {len(resp.text)} chars{Style.RESET_ALL}")
33
+ return resp.text
34
+ except Exception as e:
35
+ return f"Error fetching URL: {e}"