Skip to content

Commit a1de6cd

Browse files
committed
✨ Feat: Add BeautifulSoup to Python tool imports
- Adds `beautifulsoup4` as a dependency to `requirements.txt` and `pyproject.toml`. - Updates `.env.example` and `README.md` to reflect the inclusion of `bs4` in the default Python tool imports. - Modifies `simple_agent/tools/python_tool.py` to include `bs4` and `requests` in the default allowed imports for the Python tool.
1 parent 1ab63b7 commit a1de6cd

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ GEMINI_API_KEY=your-gemini-key
55
GEMINI_MODEL=gemini-2.5-flash
66
AGENT_SYSTEM_PROMPT=You are a concise assistant. Use tools when needed.
77
REQUEST_TIMEOUT=30
8-
PYTHON_TOOL_IMPORTS=os,sys,psutil
8+
PYTHON_TOOL_IMPORTS=os,sys,psutil,requests,bs4

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ All settings live in `.env` (loaded with `python-dotenv`):
5858
| `GEMINI_MODEL` | Defaults to `gemini-2.5-flash`. |
5959
| `AGENT_SYSTEM_PROMPT` | Optional custom system prompt. |
6060
| `REQUEST_TIMEOUT` | Request timeout in seconds (default `30`). |
61-
| `PYTHON_TOOL_IMPORTS` | Optional comma list of extra python-tool imports (`os,sys,psutil`). |
61+
| `PYTHON_TOOL_IMPORTS` | Optional comma list of extra python-tool imports (`os,sys,psutil,bs4`). |
6262

6363
The repository already contains `.env.example` with placeholders for these values.
6464

@@ -83,9 +83,9 @@ Tools live under `simple_agent/tools` and implement a tiny interface (`name`, `d
8383
- `time`: returns the current UTC timestamp.
8484
- `calculator`: evaluates small arithmetic expressions safely.
8585
- `file_reader`: dumps a snippet of a local text file (`path[:start-end]`).
86-
- `python`: runs a short Python snippet in a separate interpreter (default imports include `math`, `json`, `os`, `sys`, `psutil`; extend via `PYTHON_TOOL_IMPORTS`).
86+
- `python`: runs a short Python snippet in a separate interpreter (default imports include `math`, `json`, `os`, `sys`, `psutil`, `bs4`; extend via `PYTHON_TOOL_IMPORTS`).
8787

88-
The python tool executes with a module allowlist. By default it includes: `collections`, `datetime`, `functools`, `itertools`, `json`, `math`, `os`, `pathlib`, `psutil`, `random`, `statistics`, `sys`, `time`. Set `PYTHON_TOOL_IMPORTS` (comma separated) to append additional modules if needed.
88+
The python tool executes with a module allowlist. By default it includes: `collections`, `datetime`, `functools`, `itertools`, `json`, `math`, `os`, `pathlib`, `psutil`, `random`, `statistics`, `sys`, `time`, `bs4`. Set `PYTHON_TOOL_IMPORTS` (comma separated) to append additional modules if needed (e.g., `requests`).
8989

9090
Adding new tools only requires dropping a module next to the others and including it in `load_default_tools()`.
9191

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies = [
99
"python-dotenv>=1.0",
1010
"requests>=2.32",
1111
"psutil>=5.9",
12+
"beautifulsoup4>=4.12",
1213
]
1314

1415
[project.optional-dependencies]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
python-dotenv>=1.0
22
requests>=2.32
33
psutil>=5.9
4+
beautifulsoup4>=4.12

simple_agent/tools/python_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def __init__(
3737
"sys",
3838
"pathlib",
3939
"psutil",
40+
"requests",
41+
"bs4",
4042
}
4143
self.allowed_imports = default_allowed | (extra_allowed_imports or set())
4244

0 commit comments

Comments
 (0)