langchain-nomad 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-nomad
3
+ Version: 0.1.0
4
+ Summary: LangChain integration for Nomad headless browser engine — 700× cheaper than Chrome
5
+ License: AGPL-3.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: langchain>=0.1.0
9
+ Requires-Dist: nomad-sdk>=0.2.0
10
+ Dynamic: requires-python
11
+
12
+ # LangChain Nomad
13
+
14
+ LangChain tool for the Nomad headless browser engine.
15
+ 10× cheaper, 10× faster, 100× less memory than Playwright/Chrome.
16
+
17
+ ```python
18
+ from langchain_nomad import NomadBrowserTool
19
+
20
+ # Single tool — works with any LangChain agent
21
+ tools = [NomadBrowserTool()]
22
+
23
+ # Or direct use
24
+ result = NomadBrowserTool().run("https://example.com")
25
+ # Returns structured page content as string
26
+ ```
@@ -0,0 +1,15 @@
1
+ # LangChain Nomad
2
+
3
+ LangChain tool for the Nomad headless browser engine.
4
+ 10× cheaper, 10× faster, 100× less memory than Playwright/Chrome.
5
+
6
+ ```python
7
+ from langchain_nomad import NomadBrowserTool
8
+
9
+ # Single tool — works with any LangChain agent
10
+ tools = [NomadBrowserTool()]
11
+
12
+ # Or direct use
13
+ result = NomadBrowserTool().run("https://example.com")
14
+ # Returns structured page content as string
15
+ ```
@@ -0,0 +1,15 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "langchain-nomad"
7
+ version = "0.1.0"
8
+ description = "LangChain integration for Nomad headless browser engine — 700× cheaper than Chrome"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "AGPL-3.0"}
12
+ dependencies = [
13
+ "langchain>=0.1.0",
14
+ "nomad-sdk>=0.2.0",
15
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="langchain-nomad",
5
+ version="0.1.0",
6
+ description="LangChain integration for Nomad headless browser engine",
7
+ long_description=open("README.md").read() if __import__("os").path.exists("README.md") else "",
8
+ packages=find_packages("src"),
9
+ package_dir={"": "src"},
10
+ install_requires=[
11
+ "langchain>=0.1.0",
12
+ "nomad-sdk>=0.2.0",
13
+ ],
14
+ python_requires=">=3.10",
15
+ )
@@ -0,0 +1,12 @@
1
+ # ── LangChain Nomad: Web browsing tool for LangChain agents ──
2
+ #
3
+ # pip install langchain-nomad
4
+ #
5
+ # Usage:
6
+ # from langchain_nomad import NomadBrowserTool
7
+ # tools = [NomadBrowserTool()]
8
+ # # Feed to any LangChain agent
9
+
10
+ from .tool import NomadBrowserTool, NomadBrowser
11
+
12
+ __all__ = ["NomadBrowserTool", "NomadBrowser"]
@@ -0,0 +1,81 @@
1
+ # ── Nomad Browser Tool for LangChain ──
2
+
3
+ from typing import Optional, Type, Any
4
+ from pydantic import BaseModel, Field
5
+
6
+ from nomad_sdk import NomadClient
7
+
8
+ try:
9
+ from langchain.tools import BaseTool
10
+ from langchain.callbacks.manager import CallbackManagerForToolRun
11
+ HAS_LANGCHAIN = True
12
+ except ImportError:
13
+ HAS_LANGCHAIN = False
14
+
15
+
16
+ class NomadBrowserInput(BaseModel):
17
+ url: str = Field(description="The URL to browse")
18
+ query: Optional[str] = Field(None, description="Optional question to answer about the page")
19
+
20
+
21
+ class NomadBrowser:
22
+ """Thin wrapper around Nomad SDK's NomadClient."""
23
+
24
+ def __init__(self, socket_path: str = "/tmp/nomad-daemon.sock"):
25
+ self._client = NomadClient(socket_path=socket_path, debug=False)
26
+ self._client._connect()
27
+
28
+ def navigate(self, url: str, fmt: int = 12) -> str:
29
+ """Navigate to URL and return structured page content.
30
+ fmt=12 = CleanContent (RAG-ready markdown, nav stripped, word_count)."""
31
+ page = self._client.navigate(url, fmt=fmt)
32
+ if not page.entities:
33
+ return f"Title: {page.title}\nURL: {page.url}\nNo structured content extracted."
34
+ # Format as readable text
35
+ lines = [f"Title: {page.title}", f"URL: {page.url}"]
36
+ for e in page.entities[:50]:
37
+ tag = e.tag or ""
38
+ text = e.text or ""
39
+ href = e.href or ""
40
+ if tag and text:
41
+ if href:
42
+ lines.append(f" - [{text}]({href})")
43
+ else:
44
+ lines.append(f" - {text}")
45
+ return "\n".join(lines)
46
+
47
+ def close(self):
48
+ self._client._close()
49
+
50
+
51
+ if HAS_LANGCHAIN:
52
+ class NomadBrowserTool(BaseTool):
53
+ """LangChain tool that uses Nomad to browse the web and extract structured content.
54
+
55
+ 10× cheaper than Playwright/Chrome — 16MB RSS vs 150MB.
56
+ Returns clean, structured text ready for LLM consumption.
57
+ """
58
+ name = "nomad_browse"
59
+ description = (
60
+ "Browse a URL and return structured page content. "
61
+ "Use this for fetching web pages, reading articles, checking documentation. "
62
+ "Returns clean text with headings, paragraphs, and links preserved."
63
+ )
64
+ args_schema: Type[BaseModel] = NomadBrowserInput
65
+
66
+ def _run(
67
+ self, url: str, query: Optional[str] = None,
68
+ run_manager: Optional[CallbackManagerForToolRun] = None,
69
+ ) -> str:
70
+ browser = NomadBrowser()
71
+ try:
72
+ return browser.navigate(url)
73
+ finally:
74
+ browser.close()
75
+ else:
76
+ class NomadBrowserTool:
77
+ """Fallback when LangChain is not installed."""
78
+ def __init__(self):
79
+ raise ImportError(
80
+ "LangChain is not installed. Run: pip install langchain"
81
+ )
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-nomad
3
+ Version: 0.1.0
4
+ Summary: LangChain integration for Nomad headless browser engine — 700× cheaper than Chrome
5
+ License: AGPL-3.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: langchain>=0.1.0
9
+ Requires-Dist: nomad-sdk>=0.2.0
10
+ Dynamic: requires-python
11
+
12
+ # LangChain Nomad
13
+
14
+ LangChain tool for the Nomad headless browser engine.
15
+ 10× cheaper, 10× faster, 100× less memory than Playwright/Chrome.
16
+
17
+ ```python
18
+ from langchain_nomad import NomadBrowserTool
19
+
20
+ # Single tool — works with any LangChain agent
21
+ tools = [NomadBrowserTool()]
22
+
23
+ # Or direct use
24
+ result = NomadBrowserTool().run("https://example.com")
25
+ # Returns structured page content as string
26
+ ```
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ src/langchain_nomad/__init__.py
5
+ src/langchain_nomad/tool.py
6
+ src/langchain_nomad.egg-info/PKG-INFO
7
+ src/langchain_nomad.egg-info/SOURCES.txt
8
+ src/langchain_nomad.egg-info/dependency_links.txt
9
+ src/langchain_nomad.egg-info/requires.txt
10
+ src/langchain_nomad.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ langchain>=0.1.0
2
+ nomad-sdk>=0.2.0
@@ -0,0 +1 @@
1
+ langchain_nomad