Skip to content

Commit ca33de9

Browse files
abrichrclaude
andcommitted
Implement lazy imports for BeautifulSoup and update OmniMCP dependencies
- Add lazy imports for BeautifulSoup in utils.py functions - Add jinja2 to OmniMCP dependencies - Simplify setup.py to use dependencies from pyproject.toml - Preserve OpenAdapt path handling in setup.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a058f63 commit ca33de9

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

omnimcp/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies = [
2222
"mcp>=0.9.0", # Model Control Protocol
2323
"requests>=2.31.0", # HTTP requests for OmniParser
2424
"mss>=6.1.0", # Screen capture
25+
"jinja2>=3.0.0", # For templating
2526
]
2627

2728
[project.scripts]

omnimcp/setup.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@
55
# Add the parent directory to sys.path to allow imports from OpenAdapt
66
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
77

8+
# The actual dependencies are defined in pyproject.toml
9+
# This setup.py file exists mainly to add OpenAdapt to the Python path
810
setup(
9-
name="omnimcp",
10-
version="0.1.0",
1111
packages=find_packages(),
12-
install_requires=[
13-
"pynput>=1.7.6",
14-
"pillow>=10.0.0",
15-
"fire>=0.4.0",
16-
"anthropic>=0.42.0",
17-
"loguru>=0.6.0",
18-
"mcp>=0.9.0",
19-
"requests>=2.31.0",
20-
"mss>=6.1.0",
21-
],
12+
# Entry point is required to create the 'omnimcp' command
2213
entry_points={
2314
'console_scripts': [
2415
'omnimcp=omnimcp.run_omnimcp:main',

openadapt/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import threading
1818
import time
1919

20-
from bs4 import BeautifulSoup
20+
# BeautifulSoup import moved to parse_html function
2121
from jinja2 import Environment, FileSystemLoader
2222
from PIL import Image, ImageEnhance
2323
from posthog import Posthog
@@ -1044,8 +1044,9 @@ def truncate_html(html_str: str, max_len: int) -> str:
10441044
return html_str
10451045

10461046

1047-
def parse_html(html: str, parser: str = "html.parser") -> BeautifulSoup:
1047+
def parse_html(html: str, parser: str = "html.parser") -> "BeautifulSoup":
10481048
"""Parse the visible HTML using BeautifulSoup."""
1049+
from bs4 import BeautifulSoup
10491050
soup = BeautifulSoup(html, parser)
10501051
return soup
10511052

@@ -1062,6 +1063,7 @@ def get_html_prompt(html: str, convert_to_markdown: bool = False) -> str:
10621063
If convert_to_markdown is True, the string is in Markdown format.
10631064
"""
10641065
# Parse HTML with BeautifulSoup
1066+
from bs4 import BeautifulSoup
10651067
soup = BeautifulSoup(html, "html.parser")
10661068

10671069
# Remove non-interactive and unnecessary elements

0 commit comments

Comments
 (0)