crewai-fastaf 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.
- crewai_fastaf-0.1.0/LICENSE +9 -0
- crewai_fastaf-0.1.0/PKG-INFO +45 -0
- crewai_fastaf-0.1.0/README.md +26 -0
- crewai_fastaf-0.1.0/pyproject.toml +26 -0
- crewai_fastaf-0.1.0/src/crewai_fastaf/__init__.py +7 -0
- crewai_fastaf-0.1.0/src/crewai_fastaf/tools.py +123 -0
- crewai_fastaf-0.1.0/tests/test_tools.py +48 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FastAF
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: crewai-fastaf
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CrewAI tools for FastAF: SERP, news, jobs, Amazon, eBay and page-to-markdown APIs for AI agents.
|
|
5
|
+
Project-URL: Homepage, https://fastaf.co
|
|
6
|
+
Project-URL: Documentation, https://fastaf.co/docs/
|
|
7
|
+
Project-URL: Source, https://github.com/fastaf-co/fastaf-integrations
|
|
8
|
+
Author-email: FastAF <dev@fastaf.co>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-agents,crewai,fastaf,scraping,serp,web-search,x402
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: crewai>=0.100
|
|
14
|
+
Requires-Dist: fastaf-sdk<0.2,>=0.1.0
|
|
15
|
+
Requires-Dist: httpx>=0.27
|
|
16
|
+
Provides-Extra: test
|
|
17
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# crewai-fastaf
|
|
21
|
+
|
|
22
|
+
[CrewAI](https://crewai.com) tools for [FastAF](https://fastaf.co): Google SERP, News, Jobs, Amazon, eBay and page-to-Markdown APIs for AI agents.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install crewai-fastaf
|
|
26
|
+
export FASTAF_API_KEY="your-key" # https://fastaf.co/signup
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Free tier: 2 calls after email verification; pay per call with x402 from $0.003.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from crewai import Agent, Task, Crew
|
|
33
|
+
from crewai_fastaf import FastAFSearchTool, FastAFPageToMarkdownTool
|
|
34
|
+
|
|
35
|
+
researcher = Agent(
|
|
36
|
+
role="Researcher", goal="Find and summarize sources", backstory="Web researcher",
|
|
37
|
+
tools=[FastAFSearchTool(), FastAFPageToMarkdownTool()],
|
|
38
|
+
)
|
|
39
|
+
task = Task(description="Summarize what x402 is", expected_output="5 bullets", agent=researcher)
|
|
40
|
+
print(Crew(agents=[researcher], tasks=[task]).kickoff())
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Tools: `FastAFSearchTool`, `FastAFNewsTool`, `FastAFJobsTool`, `FastAFAmazonTool`, `FastAFEbayTool`, `FastAFPageToMarkdownTool`.
|
|
44
|
+
|
|
45
|
+
Docs: https://fastaf.co/docs/ · License: MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# crewai-fastaf
|
|
2
|
+
|
|
3
|
+
[CrewAI](https://crewai.com) tools for [FastAF](https://fastaf.co): Google SERP, News, Jobs, Amazon, eBay and page-to-Markdown APIs for AI agents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install crewai-fastaf
|
|
7
|
+
export FASTAF_API_KEY="your-key" # https://fastaf.co/signup
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Free tier: 2 calls after email verification; pay per call with x402 from $0.003.
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from crewai import Agent, Task, Crew
|
|
14
|
+
from crewai_fastaf import FastAFSearchTool, FastAFPageToMarkdownTool
|
|
15
|
+
|
|
16
|
+
researcher = Agent(
|
|
17
|
+
role="Researcher", goal="Find and summarize sources", backstory="Web researcher",
|
|
18
|
+
tools=[FastAFSearchTool(), FastAFPageToMarkdownTool()],
|
|
19
|
+
)
|
|
20
|
+
task = Task(description="Summarize what x402 is", expected_output="5 bullets", agent=researcher)
|
|
21
|
+
print(Crew(agents=[researcher], tasks=[task]).kickoff())
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Tools: `FastAFSearchTool`, `FastAFNewsTool`, `FastAFJobsTool`, `FastAFAmazonTool`, `FastAFEbayTool`, `FastAFPageToMarkdownTool`.
|
|
25
|
+
|
|
26
|
+
Docs: https://fastaf.co/docs/ · License: MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "crewai-fastaf"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CrewAI tools for FastAF: SERP, news, jobs, Amazon, eBay and page-to-markdown APIs for AI agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [{ name = "FastAF", email = "dev@fastaf.co" }]
|
|
14
|
+
keywords = ["crewai", "fastaf", "serp", "web-search", "scraping", "x402", "ai-agents"]
|
|
15
|
+
dependencies = ["crewai>=0.100", "fastaf-sdk>=0.1.0,<0.2", "httpx>=0.27"]
|
|
16
|
+
|
|
17
|
+
[project.optional-dependencies]
|
|
18
|
+
test = ["pytest>=8"]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://fastaf.co"
|
|
22
|
+
Documentation = "https://fastaf.co/docs/"
|
|
23
|
+
Source = "https://github.com/fastaf-co/fastaf-integrations"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["src/crewai_fastaf"]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""CrewAI tools for FastAF (https://fastaf.co)."""
|
|
2
|
+
from crewai_fastaf.tools import (FastAFAmazonTool, FastAFEbayTool, FastAFJobsTool,
|
|
3
|
+
FastAFNewsTool, FastAFPageToMarkdownTool, FastAFSearchTool)
|
|
4
|
+
|
|
5
|
+
__all__ = ["FastAFSearchTool", "FastAFNewsTool", "FastAFJobsTool", "FastAFAmazonTool",
|
|
6
|
+
"FastAFEbayTool", "FastAFPageToMarkdownTool"]
|
|
7
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""CrewAI tools for the FastAF API (https://fastaf.co)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
from typing import Any, Dict, List, Optional, Type
|
|
7
|
+
|
|
8
|
+
from crewai.tools import BaseTool, EnvVar
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
10
|
+
|
|
11
|
+
_ENV = [EnvVar(name="FASTAF_API_KEY", description="FastAF API key (https://fastaf.co/signup)",
|
|
12
|
+
required=True)]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _FastAFTool(BaseTool):
|
|
16
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
17
|
+
api_key: Optional[str] = Field(default=None, exclude=True, repr=False)
|
|
18
|
+
base_url: str = "https://api.fastaf.co"
|
|
19
|
+
client: Any = Field(default=None, exclude=True, repr=False)
|
|
20
|
+
env_vars: List[EnvVar] = _ENV
|
|
21
|
+
package_dependencies: List[str] = ["fastaf-sdk"]
|
|
22
|
+
endpoint: str = Field(default="", exclude=True)
|
|
23
|
+
defaults: Dict[str, Any] = Field(default_factory=dict, exclude=True)
|
|
24
|
+
|
|
25
|
+
def _get_client(self) -> Any:
|
|
26
|
+
if self.client is None:
|
|
27
|
+
key = self.api_key or os.environ.get("FASTAF_API_KEY")
|
|
28
|
+
if not key:
|
|
29
|
+
raise ValueError("FastAF API key missing. Set FASTAF_API_KEY or pass api_key=. "
|
|
30
|
+
"Get one at https://fastaf.co/signup")
|
|
31
|
+
from fastaf import FastAF
|
|
32
|
+
self.client = FastAF(key, base_url=self.base_url)
|
|
33
|
+
return self.client
|
|
34
|
+
|
|
35
|
+
def _call(self, params: Dict[str, Any]) -> str:
|
|
36
|
+
merged = {**self.defaults, **{k: v for k, v in params.items() if v is not None}}
|
|
37
|
+
data = self._get_client().request(self.endpoint, merged)
|
|
38
|
+
return data if isinstance(data, str) else json.dumps(data, ensure_ascii=False)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SearchSchema(BaseModel):
|
|
42
|
+
query: str = Field(..., description="Search query")
|
|
43
|
+
results: int = Field(5, ge=1, le=100, description="Number of results")
|
|
44
|
+
country: Optional[str] = Field(None, description="Two-letter country code")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class FastAFSearchTool(_FastAFTool):
|
|
48
|
+
name: str = "FastAF Google Search"
|
|
49
|
+
description: str = "Search Google and return organic results as JSON."
|
|
50
|
+
args_schema: Type[BaseModel] = SearchSchema
|
|
51
|
+
endpoint: str = "serp"
|
|
52
|
+
|
|
53
|
+
def _run(self, query: str, results: int = 5, country: Optional[str] = None) -> str:
|
|
54
|
+
return self._call({"query": query, "results": results, "country": country})
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class FastAFNewsTool(_FastAFTool):
|
|
58
|
+
name: str = "FastAF Google News"
|
|
59
|
+
description: str = "Search Google News for recent articles."
|
|
60
|
+
args_schema: Type[BaseModel] = SearchSchema
|
|
61
|
+
endpoint: str = "news"
|
|
62
|
+
|
|
63
|
+
def _run(self, query: str, results: int = 5, country: Optional[str] = None) -> str:
|
|
64
|
+
return self._call({"query": query, "results": results, "country": country})
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class JobsSchema(BaseModel):
|
|
68
|
+
query: str = Field(..., description="Job title/keywords and optional location")
|
|
69
|
+
country: Optional[str] = Field(None, description="Two-letter country code")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class FastAFJobsTool(_FastAFTool):
|
|
73
|
+
name: str = "FastAF Google Jobs"
|
|
74
|
+
description: str = "Search Google Jobs listings."
|
|
75
|
+
args_schema: Type[BaseModel] = JobsSchema
|
|
76
|
+
endpoint: str = "jobs"
|
|
77
|
+
|
|
78
|
+
def _run(self, query: str, country: Optional[str] = None) -> str:
|
|
79
|
+
return self._call({"query": query, "country": country})
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class AmazonSchema(BaseModel):
|
|
83
|
+
query: Optional[str] = Field(None, description="Product search query")
|
|
84
|
+
asin: Optional[str] = Field(None, description="Amazon ASIN for one product")
|
|
85
|
+
domain: Optional[str] = Field(None, description="Amazon domain, e.g. 'com', 'it'")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class FastAFAmazonTool(_FastAFTool):
|
|
89
|
+
name: str = "FastAF Amazon"
|
|
90
|
+
description: str = "Get Amazon products and prices by search query or ASIN."
|
|
91
|
+
args_schema: Type[BaseModel] = AmazonSchema
|
|
92
|
+
endpoint: str = "amazon"
|
|
93
|
+
|
|
94
|
+
def _run(self, query: Optional[str] = None, asin: Optional[str] = None,
|
|
95
|
+
domain: Optional[str] = None) -> str:
|
|
96
|
+
if not query and not asin:
|
|
97
|
+
raise ValueError("Provide either query or asin")
|
|
98
|
+
return self._call({"query": query, "asin": asin, "domain": domain})
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class UrlSchema(BaseModel):
|
|
102
|
+
url: str = Field(..., description="Absolute https URL")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class FastAFEbayTool(_FastAFTool):
|
|
106
|
+
name: str = "FastAF eBay"
|
|
107
|
+
description: str = "Extract structured data from an eBay URL (search, sold listings, item)."
|
|
108
|
+
args_schema: Type[BaseModel] = UrlSchema
|
|
109
|
+
endpoint: str = "ebay"
|
|
110
|
+
|
|
111
|
+
def _run(self, url: str) -> str:
|
|
112
|
+
return self._call({"url": url})
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class FastAFPageToMarkdownTool(_FastAFTool):
|
|
116
|
+
name: str = "FastAF Page to Markdown"
|
|
117
|
+
description: str = "Fetch a web page and return its content as LLM-ready Markdown."
|
|
118
|
+
args_schema: Type[BaseModel] = UrlSchema
|
|
119
|
+
endpoint: str = "scrape"
|
|
120
|
+
defaults: Dict[str, Any] = Field(default_factory=lambda: {"formats": "markdown"}, exclude=True)
|
|
121
|
+
|
|
122
|
+
def _run(self, url: str) -> str:
|
|
123
|
+
return self._call({"url": url})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
import pytest
|
|
5
|
+
from fastaf import FastAF
|
|
6
|
+
|
|
7
|
+
from crewai_fastaf import (FastAFAmazonTool, FastAFEbayTool, FastAFJobsTool, FastAFNewsTool,
|
|
8
|
+
FastAFPageToMarkdownTool, FastAFSearchTool)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _client():
|
|
12
|
+
def handler(req):
|
|
13
|
+
assert req.headers["authorization"] == "Bearer k"
|
|
14
|
+
return httpx.Response(200, json={"path": req.url.path, "params": dict(req.url.params)})
|
|
15
|
+
return FastAF("k", transport=httpx.MockTransport(handler))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.parametrize("cls,args,path", [
|
|
19
|
+
(FastAFSearchTool, {"query": "x402"}, "/v1/serp"),
|
|
20
|
+
(FastAFNewsTool, {"query": "ai"}, "/v1/news"),
|
|
21
|
+
(FastAFJobsTool, {"query": "python"}, "/v1/jobs"),
|
|
22
|
+
(FastAFAmazonTool, {"query": "ssd"}, "/v1/amazon"),
|
|
23
|
+
(FastAFEbayTool, {"url": "https://www.ebay.com/itm/1"}, "/v1/ebay"),
|
|
24
|
+
(FastAFPageToMarkdownTool, {"url": "https://example.com"}, "/v1/scrape"),
|
|
25
|
+
])
|
|
26
|
+
def test_run(cls, args, path):
|
|
27
|
+
out = json.loads(cls(client=_client()).run(**args))
|
|
28
|
+
assert out["path"] == path
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_markdown_default():
|
|
32
|
+
out = json.loads(FastAFPageToMarkdownTool(client=_client()).run(url="https://e.com"))
|
|
33
|
+
assert out["params"]["formats"] == "markdown"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_missing_key(monkeypatch):
|
|
37
|
+
monkeypatch.delenv("FASTAF_API_KEY", raising=False)
|
|
38
|
+
with pytest.raises(ValueError):
|
|
39
|
+
FastAFSearchTool()._get_client()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_env_vars_declared():
|
|
43
|
+
assert FastAFSearchTool().env_vars[0].name == "FASTAF_API_KEY"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_amazon_needs_input():
|
|
47
|
+
with pytest.raises(ValueError):
|
|
48
|
+
FastAFAmazonTool(client=_client())._run()
|