geonode-scraper-crewai 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,2 @@
1
+ include README.md
2
+ recursive-include geonode_scraper_crewai py.typed
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: geonode-scraper-crewai
3
+ Version: 0.1.0
4
+ Summary: CrewAI tools for the Geonode Scraper API
5
+ Author: Geonode Team
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Typing :: Typed
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: geonode-scraper-tools-core>=0.1.0
14
+ Requires-Dist: crewai>=0.100
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=8.0; extra == "dev"
17
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
18
+ Requires-Dist: ruff>=0.12.11; extra == "dev"
19
+
20
+ # Geonode Scraper CrewAI Tools
21
+
22
+ CrewAI tools for the Geonode Scraper API.
23
+
24
+ This package depends on `geonode-scraper-tools-core` for the shared service,
25
+ schemas, and operation registry.
26
+
27
+ ## Installation
28
+
29
+ ```sh
30
+ pip install geonode-scraper-crewai
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from crewai import Agent
37
+
38
+ from geonode_scraper_crewai import build_crewai_tools
39
+ from geonode_scraper_tools_core import ScraperToolSettings
40
+
41
+ settings = ScraperToolSettings(
42
+ host="https://api.example.com",
43
+ api_key="your-api-key",
44
+ )
45
+
46
+ agent = Agent(
47
+ role="Web Researcher",
48
+ goal="Extract and inspect web content.",
49
+ backstory="Focused on pulling structured data from URLs.",
50
+ tools=build_crewai_tools(settings=settings),
51
+ )
52
+ ```
53
+
54
+ ## Exposed Tools
55
+
56
+ - `scraper_extract_content`
57
+ - `scraper_get_job_result`
58
+ - `scraper_wait_for_job`
59
+ - `scraper_list_jobs`
60
+ - `scraper_get_statistics`
61
+ - `scraper_check_health`
@@ -0,0 +1,42 @@
1
+ # Geonode Scraper CrewAI Tools
2
+
3
+ CrewAI tools for the Geonode Scraper API.
4
+
5
+ This package depends on `geonode-scraper-tools-core` for the shared service,
6
+ schemas, and operation registry.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ pip install geonode-scraper-crewai
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```python
17
+ from crewai import Agent
18
+
19
+ from geonode_scraper_crewai import build_crewai_tools
20
+ from geonode_scraper_tools_core import ScraperToolSettings
21
+
22
+ settings = ScraperToolSettings(
23
+ host="https://api.example.com",
24
+ api_key="your-api-key",
25
+ )
26
+
27
+ agent = Agent(
28
+ role="Web Researcher",
29
+ goal="Extract and inspect web content.",
30
+ backstory="Focused on pulling structured data from URLs.",
31
+ tools=build_crewai_tools(settings=settings),
32
+ )
33
+ ```
34
+
35
+ ## Exposed Tools
36
+
37
+ - `scraper_extract_content`
38
+ - `scraper_get_job_result`
39
+ - `scraper_wait_for_job`
40
+ - `scraper_list_jobs`
41
+ - `scraper_get_statistics`
42
+ - `scraper_check_health`
@@ -0,0 +1,5 @@
1
+ from .toolkit import ScraperCrewAIToolkit, build_crewai_tools
2
+
3
+ __all__ = ["ScraperCrewAIToolkit", "build_crewai_tools"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ from typing import Any, Sequence
5
+
6
+ from geonode_scraper_tools_core import ScraperToolService, ScraperToolSettings, get_operations
7
+ from geonode_scraper_tools_core.registry import OperationSpec
8
+
9
+
10
+ class ScraperCrewAIToolkit:
11
+ def __init__(self, service: ScraperToolService) -> None:
12
+ self.service = service
13
+
14
+ @classmethod
15
+ def from_settings(cls, settings: ScraperToolSettings) -> ScraperCrewAIToolkit:
16
+ return cls(ScraperToolService(settings))
17
+
18
+ def get_tools(self, operations: Sequence[str] | None = None) -> list[Any]:
19
+ from crewai.tools import BaseTool
20
+
21
+ return [self._build_tool(BaseTool=BaseTool, operation=operation) for operation in get_operations(operations)]
22
+
23
+ def _build_tool(self, *, BaseTool: type[Any], operation: OperationSpec) -> Any:
24
+ service = self.service
25
+
26
+ class _CrewAIScraperTool(BaseTool):
27
+ name: str
28
+ description: str
29
+ args_schema: type[Any]
30
+
31
+ def _run(self, **kwargs: Any) -> dict[str, Any]:
32
+ return operation.invoke(service, **kwargs)
33
+
34
+ async def _arun(self, **kwargs: Any) -> dict[str, Any]:
35
+ return await asyncio.to_thread(operation.invoke, service, **kwargs)
36
+
37
+ @staticmethod
38
+ def cache_function(_arguments: dict[str, Any], _result: Any) -> bool:
39
+ return False
40
+
41
+ return _CrewAIScraperTool(
42
+ name=operation.tool_name,
43
+ description=operation.description,
44
+ args_schema=operation.args_schema,
45
+ )
46
+
47
+
48
+ def build_crewai_tools(
49
+ *,
50
+ settings: ScraperToolSettings | None = None,
51
+ service: ScraperToolService | None = None,
52
+ operations: Sequence[str] | None = None,
53
+ ) -> list[Any]:
54
+ resolved_service = _resolve_service(settings=settings, service=service)
55
+ return ScraperCrewAIToolkit(resolved_service).get_tools(operations=operations)
56
+
57
+
58
+ def _resolve_service(
59
+ *,
60
+ settings: ScraperToolSettings | None,
61
+ service: ScraperToolService | None,
62
+ ) -> ScraperToolService:
63
+ if service is not None:
64
+ return service
65
+ if settings is None:
66
+ raise ValueError("Provide either settings or service to build CrewAI tools.")
67
+ return ScraperToolService(settings)
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: geonode-scraper-crewai
3
+ Version: 0.1.0
4
+ Summary: CrewAI tools for the Geonode Scraper API
5
+ Author: Geonode Team
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Typing :: Typed
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: geonode-scraper-tools-core>=0.1.0
14
+ Requires-Dist: crewai>=0.100
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=8.0; extra == "dev"
17
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
18
+ Requires-Dist: ruff>=0.12.11; extra == "dev"
19
+
20
+ # Geonode Scraper CrewAI Tools
21
+
22
+ CrewAI tools for the Geonode Scraper API.
23
+
24
+ This package depends on `geonode-scraper-tools-core` for the shared service,
25
+ schemas, and operation registry.
26
+
27
+ ## Installation
28
+
29
+ ```sh
30
+ pip install geonode-scraper-crewai
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from crewai import Agent
37
+
38
+ from geonode_scraper_crewai import build_crewai_tools
39
+ from geonode_scraper_tools_core import ScraperToolSettings
40
+
41
+ settings = ScraperToolSettings(
42
+ host="https://api.example.com",
43
+ api_key="your-api-key",
44
+ )
45
+
46
+ agent = Agent(
47
+ role="Web Researcher",
48
+ goal="Extract and inspect web content.",
49
+ backstory="Focused on pulling structured data from URLs.",
50
+ tools=build_crewai_tools(settings=settings),
51
+ )
52
+ ```
53
+
54
+ ## Exposed Tools
55
+
56
+ - `scraper_extract_content`
57
+ - `scraper_get_job_result`
58
+ - `scraper_wait_for_job`
59
+ - `scraper_list_jobs`
60
+ - `scraper_get_statistics`
61
+ - `scraper_check_health`
@@ -0,0 +1,12 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ geonode_scraper_crewai/__init__.py
5
+ geonode_scraper_crewai/py.typed
6
+ geonode_scraper_crewai/toolkit.py
7
+ geonode_scraper_crewai.egg-info/PKG-INFO
8
+ geonode_scraper_crewai.egg-info/SOURCES.txt
9
+ geonode_scraper_crewai.egg-info/dependency_links.txt
10
+ geonode_scraper_crewai.egg-info/requires.txt
11
+ geonode_scraper_crewai.egg-info/top_level.txt
12
+ tests/test_crewai_tools.py
@@ -0,0 +1,7 @@
1
+ geonode-scraper-tools-core>=0.1.0
2
+ crewai>=0.100
3
+
4
+ [dev]
5
+ pytest>=8.0
6
+ pytest-cov>=5.0
7
+ ruff>=0.12.11
@@ -0,0 +1 @@
1
+ geonode_scraper_crewai
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "geonode-scraper-crewai"
3
+ version = "0.1.0"
4
+ description = "CrewAI tools for the Geonode Scraper API"
5
+ authors = [
6
+ {name = "Geonode Team"},
7
+ ]
8
+ readme = "README.md"
9
+ license = "MIT"
10
+ requires-python = ">=3.10"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Typing :: Typed",
16
+ ]
17
+ dependencies = [
18
+ "geonode-scraper-tools-core>=0.1.0",
19
+ "crewai>=0.100",
20
+ ]
21
+
22
+ [project.optional-dependencies]
23
+ dev = [
24
+ "pytest>=8.0",
25
+ "pytest-cov>=5.0",
26
+ "ruff>=0.12.11",
27
+ ]
28
+
29
+ [build-system]
30
+ requires = ["setuptools"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [tool.setuptools.packages.find]
34
+ include = ["geonode_scraper_crewai*"]
35
+
36
+ [tool.setuptools.package-data]
37
+ geonode_scraper_crewai = ["py.typed"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+
42
+ [tool.ruff]
43
+ target-version = "py310"
44
+ line-length = 120
45
+
46
+ [tool.ruff.lint]
47
+ select = ["E", "W", "F", "I", "B"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ from __future__ import annotations
2
+
3
+ from geonode_scraper_crewai import build_crewai_tools
4
+
5
+
6
+ class StubService:
7
+ def extract(self, **kwargs):
8
+ return {"ok": True, "operation": "extract", "result": kwargs}
9
+
10
+ def get_job_result(self, **kwargs):
11
+ return {"ok": True, "operation": "get_job_result", "result": kwargs}
12
+
13
+ def wait_for_job(self, **kwargs):
14
+ return {"ok": True, "operation": "wait_for_job", "result": kwargs}
15
+
16
+ def list_jobs(self, **kwargs):
17
+ return {"ok": True, "operation": "list_jobs", "result": kwargs}
18
+
19
+ def get_statistics(self, **kwargs):
20
+ return {"ok": True, "operation": "get_statistics", "result": kwargs}
21
+
22
+ def health_check(self, **kwargs):
23
+ return {"ok": True, "operation": "health_check", "result": kwargs}
24
+
25
+
26
+ def test_build_crewai_tools_exposes_expected_names():
27
+ pytest = __import__("pytest")
28
+ pytest.importorskip("crewai.tools")
29
+
30
+ tools = build_crewai_tools(service=StubService())
31
+
32
+ assert [tool.name for tool in tools] == [
33
+ "scraper_extract_content",
34
+ "scraper_get_job_result",
35
+ "scraper_wait_for_job",
36
+ "scraper_list_jobs",
37
+ "scraper_get_statistics",
38
+ "scraper_check_health",
39
+ ]
40
+
41
+
42
+ def test_crewai_tool_run_dispatches_to_service():
43
+ pytest = __import__("pytest")
44
+ pytest.importorskip("crewai.tools")
45
+
46
+ tools = build_crewai_tools(service=StubService(), operations=["extract"])
47
+ result = tools[0]._run(url="https://example.com")
48
+
49
+ assert result["ok"] is True
50
+ assert result["result"]["url"] == "https://example.com"
51
+
52
+
53
+ def test_crewai_wait_for_job_tool_is_selectable():
54
+ pytest = __import__("pytest")
55
+ pytest.importorskip("crewai.tools")
56
+
57
+ tools = build_crewai_tools(service=StubService(), operations=["wait_for_job"])
58
+ result = tools[0]._run(job_id="test-job-uuid")
59
+
60
+ assert result["ok"] is True
61
+ assert result["operation"] == "wait_for_job"
62
+ assert result["result"]["job_id"] == "test-job-uuid"