crewai-datacircle 0.1.0__py3-none-any.whl
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_datacircle/__init__.py +15 -0
- crewai_datacircle/_api.py +101 -0
- crewai_datacircle/py.typed +0 -0
- crewai_datacircle/tools.py +173 -0
- crewai_datacircle-0.1.0.dist-info/METADATA +94 -0
- crewai_datacircle-0.1.0.dist-info/RECORD +8 -0
- crewai_datacircle-0.1.0.dist-info/WHEEL +4 -0
- crewai_datacircle-0.1.0.dist-info/licenses/LICENSE +9 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""CrewAI tools on Datacircle's open API (https://api.datacircle.dev/v1), no key: Agent(tools=datacircle_tools()), or
|
|
2
|
+
any of the four in an Agent's tools."""
|
|
3
|
+
|
|
4
|
+
from crewai_datacircle._api import DatacircleError
|
|
5
|
+
from crewai_datacircle.tools import (
|
|
6
|
+
DatacircleBestPlansTool,
|
|
7
|
+
DatacircleListApisTool,
|
|
8
|
+
DatacircleProviderTool,
|
|
9
|
+
DatacircleSearchPlansTool,
|
|
10
|
+
datacircle_tools,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
__all__ = ["DatacircleBestPlansTool", "DatacircleError", "DatacircleListApisTool", "DatacircleProviderTool",
|
|
15
|
+
"DatacircleSearchPlansTool", "datacircle_tools"]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""One HTTPS GET to Datacircle's open API (https://api.datacircle.dev/v1), no key, and what its answers are cut to for a model."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import math
|
|
5
|
+
import re
|
|
6
|
+
import time
|
|
7
|
+
import unicodedata
|
|
8
|
+
import urllib.error
|
|
9
|
+
import urllib.parse
|
|
10
|
+
import urllib.request
|
|
11
|
+
from typing import Any, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
BASE_URL = "https://api.datacircle.dev/v1"
|
|
14
|
+
TIMEOUT = 30.0
|
|
15
|
+
USER_AGENT = "crewai-datacircle/0.1.0"
|
|
16
|
+
|
|
17
|
+
# A plan holds about 90 keys (its terms of use, its aggregators...): the tools keep the ones that choose a plan, the rest is on its page.
|
|
18
|
+
PLAN_KEYS = ["api", "rank", "provider", "plan", "score", "perThousand", "notFoundPerThousand", "billing", "pay",
|
|
19
|
+
"currency", "units", "unit", "strengths", "latencyMs", "page", "pricingPage", "docs"]
|
|
20
|
+
API_KEYS = ["api", "slug", "plans", "providers", "best", "bestPage", "sheetPage"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DatacircleError(Exception):
|
|
24
|
+
"""The API's refusal in its own words, why it could not be reached, or an argument it can't take: a tool gives it to
|
|
25
|
+
the agent as its answer. status is the API's HTTP status, None when it gave none; retryable, whether the same call
|
|
26
|
+
may be answered later (the API out of reach, busy or failing)."""
|
|
27
|
+
|
|
28
|
+
def __init__(self, message: str, status: Optional[int] = None, retryable: bool = False):
|
|
29
|
+
super().__init__(message)
|
|
30
|
+
self.status = status
|
|
31
|
+
self.retryable = retryable
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def brief(item: Dict[str, Any], keys: List[str] = PLAN_KEYS) -> Dict[str, Any]:
|
|
35
|
+
return {key: item[key] for key in keys if item.get(key) is not None}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def slug(value: Any) -> str:
|
|
39
|
+
"""The API's rule for a slug: the name in lowercase letters and digits, the rest a hyphen."""
|
|
40
|
+
plain = unicodedata.normalize("NFKD", str(value or "").strip().lower())
|
|
41
|
+
plain = "".join(char for char in plain if not unicodedata.combining(char))
|
|
42
|
+
return re.sub(r"[^a-z0-9]+", "-", plain).strip("-")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def whole(name: str, value: Any, low: int, high: Optional[int] = None) -> Optional[int]:
|
|
46
|
+
"""A whole number from low to high, or None when left out: a plain call may send one as text."""
|
|
47
|
+
if value is None or value == "":
|
|
48
|
+
return None
|
|
49
|
+
try:
|
|
50
|
+
number = float(value)
|
|
51
|
+
except (TypeError, ValueError):
|
|
52
|
+
number = float("nan")
|
|
53
|
+
if isinstance(value, bool) or not math.isfinite(number) or number != int(number):
|
|
54
|
+
raise DatacircleError(f"{name} must be a whole number, not {value!r}")
|
|
55
|
+
if number < low or (high is not None and number > high):
|
|
56
|
+
raise DatacircleError(f"{name} must be from {low} to {high}, not {int(number)}" if high is not None
|
|
57
|
+
else f"{name} must be {low} or more, not {int(number)}")
|
|
58
|
+
return int(number)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _words(body: bytes) -> str:
|
|
62
|
+
"""A refusal's words: the API's error, with every slug when the slug was unknown."""
|
|
63
|
+
text = body.decode("utf-8", "replace")
|
|
64
|
+
try:
|
|
65
|
+
parsed = json.loads(text)
|
|
66
|
+
if parsed.get("slugs"):
|
|
67
|
+
return f"{parsed['error']}; the slugs: {', '.join(parsed['slugs'])}"
|
|
68
|
+
return str(parsed.get("error", text))
|
|
69
|
+
except (ValueError, KeyError, TypeError, AttributeError):
|
|
70
|
+
return text
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def get(path: str, params: Optional[Dict[str, Any]] = None) -> Any:
|
|
74
|
+
"""The API's JSON answer, or a DatacircleError with its words: waits once when it answers 429."""
|
|
75
|
+
query = urllib.parse.urlencode({key: value for key, value in (params or {}).items() if value not in (None, "")})
|
|
76
|
+
url = f"{BASE_URL.rstrip('/')}{path}" + (f"?{query}" if query else "")
|
|
77
|
+
request = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": USER_AGENT})
|
|
78
|
+
for attempt in range(2):
|
|
79
|
+
try:
|
|
80
|
+
with urllib.request.urlopen(request, timeout=TIMEOUT) as answer:
|
|
81
|
+
body = answer.read()
|
|
82
|
+
except urllib.error.HTTPError as error:
|
|
83
|
+
body = error.read()
|
|
84
|
+
if error.code == 429 and not attempt:
|
|
85
|
+
try:
|
|
86
|
+
wait = int(error.headers.get("Retry-After") or 30)
|
|
87
|
+
except ValueError:
|
|
88
|
+
wait = 30
|
|
89
|
+
time.sleep(min(max(wait, 1), 60))
|
|
90
|
+
continue
|
|
91
|
+
if error.code == 429:
|
|
92
|
+
raise DatacircleError("Datacircle's API answered 429 twice: wait a minute and call again", 429, True) from None
|
|
93
|
+
raise DatacircleError(f"Datacircle's API answered {error.code}: {_words(body)[:3000]}", error.code,
|
|
94
|
+
error.code >= 500) from None
|
|
95
|
+
except (urllib.error.URLError, OSError) as error:
|
|
96
|
+
raise DatacircleError(f"Datacircle's API could not be reached: {getattr(error, 'reason', error)}",
|
|
97
|
+
retryable=True) from None
|
|
98
|
+
try:
|
|
99
|
+
return json.loads(body)
|
|
100
|
+
except ValueError as error:
|
|
101
|
+
raise DatacircleError(f"Datacircle's API gave no JSON: {error}") from None
|
|
File without changes
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""CrewAI tools on Datacircle's open API, https://api.datacircle.dev/v1: no key, no account.
|
|
2
|
+
|
|
3
|
+
Each tool makes one HTTPS GET and gives the agent the API's answer as JSON text. A refusal (an unknown slug, the API out
|
|
4
|
+
of reach) comes back in the API's words: a ToolFailure on the CrewAI versions that have one, so the run records it as a
|
|
5
|
+
failed call, the words alone before them. The agent reads them and can call again. Arguments the schema refuses never
|
|
6
|
+
reach the API: CrewAI gives the agent its own words for them.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import json
|
|
11
|
+
import urllib.parse
|
|
12
|
+
from typing import Any, Callable, Dict, List, Literal, Optional, Type
|
|
13
|
+
|
|
14
|
+
from crewai.tools import BaseTool
|
|
15
|
+
from pydantic import BaseModel, Field
|
|
16
|
+
|
|
17
|
+
from crewai_datacircle import _api
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
from crewai.tools.tool_failure import ToolFailure
|
|
21
|
+
except ImportError: # CrewAI before ToolFailure: the refusal's words are the tool's answer
|
|
22
|
+
ToolFailure = None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _answered(_args: Any = None, result: Any = None) -> bool:
|
|
26
|
+
"""CrewAI's cache keeps an answer, never a refusal: the API may answer the same call a minute later."""
|
|
27
|
+
return isinstance(result, str) and result.startswith("{")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _best(plans: Any) -> Optional[Dict[str, Any]]:
|
|
31
|
+
"""A provider's best plan on an API: its lowest rank, a plan with no score having none."""
|
|
32
|
+
ranked = sorted(plans, key=lambda plan: plan.get("rank") if isinstance(plan.get("rank"), (int, float)) else float("inf"))
|
|
33
|
+
return _api.brief(ranked[0], ["plan", "score", "perThousand", "page"]) if ranked else None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def list_apis(query: Optional[str] = None, limit: Optional[int] = None) -> Dict[str, Any]:
|
|
37
|
+
count = _api.whole("limit", limit, 1, 200) or 20
|
|
38
|
+
apis = _api.get("/apis")
|
|
39
|
+
words = [word for word in str(query or "").lower().replace("-", " ").split() if word]
|
|
40
|
+
held = []
|
|
41
|
+
for index, api in enumerate(apis):
|
|
42
|
+
name = f"{api.get('api', '')} {str(api.get('slug', '')).replace('-', ' ')}".lower()
|
|
43
|
+
matched = sum(word in name for word in words)
|
|
44
|
+
if matched or not words:
|
|
45
|
+
held.append((-matched, index, api))
|
|
46
|
+
found = [_api.brief(api, _api.API_KEYS) for _, _, api in sorted(held, key=lambda h: h[:2])]
|
|
47
|
+
return {"total": len(found), "apis": found[:count]}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def best_plans(slug: str, limit: Optional[int] = None) -> Dict[str, Any]:
|
|
51
|
+
made = _api.slug(slug)
|
|
52
|
+
if not made:
|
|
53
|
+
raise _api.DatacircleError("Give an API's slug, like 'email-finder': datacircle_list_apis gives every slug")
|
|
54
|
+
answer = _api.get(f"/apis/{urllib.parse.quote(made)}/best", {"limit": _api.whole("limit", limit, 1, 50)})
|
|
55
|
+
return {**answer, "plans": [_api.brief(plan) for plan in answer.get("plans") or []]}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def search_plans(api: Optional[str] = None, query: Optional[str] = None, sort: Optional[str] = None,
|
|
59
|
+
limit: Optional[int] = None, offset: Optional[int] = None) -> Dict[str, Any]:
|
|
60
|
+
order = str(sort).strip().lower() if sort not in (None, "") else None
|
|
61
|
+
if order is not None and order not in ("score", "provider", "price"):
|
|
62
|
+
raise _api.DatacircleError(f"sort must be score, provider or price, not {sort!r}")
|
|
63
|
+
params = {"api": api, "query": query, "sort": order, "limit": _api.whole("limit", limit, 1, 50),
|
|
64
|
+
"offset": _api.whole("offset", offset, 0)}
|
|
65
|
+
answer = _api.get("/plans", params)
|
|
66
|
+
return {**answer, "plans": [_api.brief(plan) for plan in answer.get("plans") or []]}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def provider(slug: str) -> Dict[str, Any]:
|
|
70
|
+
made = _api.slug(slug)
|
|
71
|
+
if not made:
|
|
72
|
+
raise _api.DatacircleError("Give a provider's slug or name, like 'bright-data' or 'Bright Data'")
|
|
73
|
+
answer = _api.get(f"/providers/{urllib.parse.quote(made)}")
|
|
74
|
+
apis = [{**_api.brief(entry, ["api", "slug", "rank", "bestPage"]), "plans": len(entry.get("plans") or []),
|
|
75
|
+
"best": _best(entry.get("plans") or [])} for entry in answer.get("apis") or []]
|
|
76
|
+
return {**answer, "apis": apis}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class _DatacircleTool(BaseTool):
|
|
80
|
+
"""A tool of one call: its answer as JSON text, a refusal as a ToolFailure (or its words, before CrewAI had one)."""
|
|
81
|
+
|
|
82
|
+
def __init__(self, **data: Any):
|
|
83
|
+
data.setdefault("cache_function", _answered)
|
|
84
|
+
super().__init__(**data)
|
|
85
|
+
|
|
86
|
+
async def _arun(self, **arguments: Any) -> Any:
|
|
87
|
+
"""await tool.arun(...): the same call in a thread."""
|
|
88
|
+
return await asyncio.to_thread(self._run, **arguments)
|
|
89
|
+
|
|
90
|
+
def _answer(self, call: Callable[..., Dict[str, Any]], **arguments: Any) -> Any:
|
|
91
|
+
try:
|
|
92
|
+
return json.dumps(call(**arguments), ensure_ascii=False)
|
|
93
|
+
except _api.DatacircleError as error:
|
|
94
|
+
if ToolFailure is None:
|
|
95
|
+
return str(error)
|
|
96
|
+
return ToolFailure(message=str(error), retryable=error.retryable,
|
|
97
|
+
details={"status": error.status} if error.status else {})
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class ListApisInput(BaseModel):
|
|
101
|
+
query: Optional[str] = Field(None, description="Words of the API's name or slug, like 'email' or 'linkedin profile': "
|
|
102
|
+
"the APIs that hold the most of them come first. The sheet's order when left out.")
|
|
103
|
+
limit: Optional[int] = Field(None, ge=1, le=200, description="How many APIs to give, 1 to 200. 20 when left out: "
|
|
104
|
+
"the sheet has about 160.")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class DatacircleListApisTool(_DatacircleTool):
|
|
108
|
+
name: str = "datacircle_list_apis"
|
|
109
|
+
description: str = ("Lists the GTM APIs on Datacircle's sheet (https://datacircle.dev), with each API's slug, how many "
|
|
110
|
+
"plans and providers it has and its best plan. Call it first to find an API's slug. Gives total, "
|
|
111
|
+
"the APIs found, and apis, up to limit of them.")
|
|
112
|
+
args_schema: Type[BaseModel] = ListApisInput
|
|
113
|
+
|
|
114
|
+
def _run(self, query: Optional[str] = None, limit: Optional[int] = None) -> Any:
|
|
115
|
+
return self._answer(list_apis, query=query, limit=limit)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class BestPlansInput(BaseModel):
|
|
119
|
+
slug: str = Field(..., description="The API's slug, like 'email-finder' or 'linkedin-profile', as datacircle_list_apis gives it.")
|
|
120
|
+
limit: Optional[int] = Field(None, ge=1, le=50, description="How many plans to give, 1 to 50. 10 when left out.")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class DatacircleBestPlansTool(_DatacircleTool):
|
|
124
|
+
name: str = "datacircle_best_plans"
|
|
125
|
+
description: str = ("Gives an API's plans best first by their score out of 100 on Datacircle's benchmark "
|
|
126
|
+
"(https://datacircle.dev), each with its rank, provider, plan, $ per 1,000 calls and its page: the "
|
|
127
|
+
"best providers of an API. perThousand is a plan's price of 1,000 items in dollars, pay the plan's "
|
|
128
|
+
"whole price in its currency.")
|
|
129
|
+
args_schema: Type[BaseModel] = BestPlansInput
|
|
130
|
+
|
|
131
|
+
def _run(self, slug: str, limit: Optional[int] = None) -> Any:
|
|
132
|
+
return self._answer(best_plans, slug=slug, limit=limit)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class SearchPlansInput(BaseModel):
|
|
136
|
+
api: Optional[str] = Field(None, description="Only this API's plans: its name or slug, like 'email-finder'. A provider's "
|
|
137
|
+
"name goes in query, never here. Every API when left out.")
|
|
138
|
+
query: Optional[str] = Field(None, description="Words that must all appear in the provider's or plan's name, like 'bright data'.")
|
|
139
|
+
sort: Optional[Literal["score", "provider", "price"]] = Field(
|
|
140
|
+
None, description="score (best first, the default), provider (A to Z) or price ($ per 1,000, lowest first).")
|
|
141
|
+
limit: Optional[int] = Field(None, ge=1, le=50, description="How many plans to give, 1 to 50. 10 when left out.")
|
|
142
|
+
offset: Optional[int] = Field(None, ge=0, description="How many found plans to skip first. 0 when left out.")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class DatacircleSearchPlansTool(_DatacircleTool):
|
|
146
|
+
name: str = "datacircle_search_plans"
|
|
147
|
+
description: str = ("Searches every plan on Datacircle's sheet (https://datacircle.dev), or one API's, by provider or "
|
|
148
|
+
"plan name, sorted by score, provider or price. Gives total, offset and up to limit plans. "
|
|
149
|
+
"perThousand is a plan's price of 1,000 items in dollars, pay the plan's whole price in its currency.")
|
|
150
|
+
args_schema: Type[BaseModel] = SearchPlansInput
|
|
151
|
+
|
|
152
|
+
def _run(self, api: Optional[str] = None, query: Optional[str] = None, sort: Optional[str] = None,
|
|
153
|
+
limit: Optional[int] = None, offset: Optional[int] = None) -> Any:
|
|
154
|
+
return self._answer(search_plans, api=api, query=query, sort=sort, limit=limit, offset=offset)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class ProviderInput(BaseModel):
|
|
158
|
+
slug: str = Field(..., description="The provider's slug, like 'bright-data', or its name, like 'Bright Data': the name is made a slug.")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class DatacircleProviderTool(_DatacircleTool):
|
|
162
|
+
name: str = "datacircle_provider"
|
|
163
|
+
description: str = ("Gives each API one provider sells and its rank on each on Datacircle's benchmark "
|
|
164
|
+
"(https://datacircle.dev), with its best plan there.")
|
|
165
|
+
args_schema: Type[BaseModel] = ProviderInput
|
|
166
|
+
|
|
167
|
+
def _run(self, slug: str) -> Any:
|
|
168
|
+
return self._answer(provider, slug=slug)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def datacircle_tools() -> List[BaseTool]:
|
|
172
|
+
"""The four tools, one for each call of the API, for Agent(tools=datacircle_tools())."""
|
|
173
|
+
return [DatacircleListApisTool(), DatacircleBestPlansTool(), DatacircleSearchPlansTool(), DatacircleProviderTool()]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: crewai-datacircle
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CrewAI tools for the Datacircle API: find the best GTM APIs
|
|
5
|
+
Project-URL: Homepage, https://datacircle.dev
|
|
6
|
+
Project-URL: Documentation, https://api.datacircle.dev/v1/openapi.json
|
|
7
|
+
Project-URL: Repository, https://github.com/waynehamadi/crewai-datacircle
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agents,api,api-pricing,b2b-data,crewai,crewai-tools,datacircle,gtm,tools
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: crewai>=1.0.0
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# crewai-datacircle
|
|
19
|
+
|
|
20
|
+
Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.
|
|
21
|
+
|
|
22
|
+
Our website: https://datacircle.dev
|
|
23
|
+
|
|
24
|
+
This package gives [CrewAI](https://github.com/crewAIInc/crewAI) four tools that call Datacircle's public API, https://api.datacircle.dev/v1. You need no key and no account.
|
|
25
|
+
|
|
26
|
+
| Tool | Class | Gives | Call |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| `datacircle_list_apis` | `DatacircleListApisTool` | Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | `GET /apis` |
|
|
29
|
+
| `datacircle_best_plans` | `DatacircleBestPlansTool` | One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls | `GET /apis/{slug}/best` |
|
|
30
|
+
| `datacircle_search_plans` | `DatacircleSearchPlansTool` | Plans that match a provider or plan name, on all APIs or on one API. You can sort them by score, provider or price | `GET /plans` |
|
|
31
|
+
| `datacircle_provider` | `DatacircleProviderTool` | The APIs a provider sells, and the provider's rank on each API | `GET /providers/{slug}` |
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install crewai-datacircle
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The package needs CrewAI 1.0 or later and Python 3.10 or later.
|
|
40
|
+
|
|
41
|
+
## Give the tools to an agent
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from crewai import Agent, Crew, Task
|
|
45
|
+
from crewai_datacircle import datacircle_tools
|
|
46
|
+
|
|
47
|
+
analyst = Agent(
|
|
48
|
+
role="GTM API analyst",
|
|
49
|
+
goal="Pick the best API for a job",
|
|
50
|
+
backstory="You choose APIs from Datacircle's benchmark.",
|
|
51
|
+
tools=datacircle_tools(),
|
|
52
|
+
)
|
|
53
|
+
task = Task(
|
|
54
|
+
description="Which email finder API is best for under $5 per 1,000?",
|
|
55
|
+
expected_output="The provider, the plan and its price per 1,000",
|
|
56
|
+
agent=analyst,
|
|
57
|
+
)
|
|
58
|
+
print(Crew(agents=[analyst], tasks=[task]).kickoff())
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The agent runs on CrewAI's default model. To use a different model, pass `llm=` to `Agent`.
|
|
62
|
+
|
|
63
|
+
To give an agent one tool, pass a list with that one tool: `tools=[DatacircleBestPlansTool()]`.
|
|
64
|
+
|
|
65
|
+
## Call a tool yourself
|
|
66
|
+
|
|
67
|
+
Each tool returns our API's answer as JSON text:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from crewai_datacircle import DatacircleBestPlansTool
|
|
71
|
+
|
|
72
|
+
print(DatacircleBestPlansTool().run(slug="email-finder", limit=3))
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tool output for the agent
|
|
76
|
+
|
|
77
|
+
Each tool gives the agent a JSON object. Each plan comes with a rank, provider, plan, score, price per 1,000 (`perThousand`, in dollars) and a page on datacircle.dev. The page on datacircle.dev lists every field.
|
|
78
|
+
|
|
79
|
+
You can give a provider's name in place of a slug. The tool turns `Bright Data` into `bright-data`.
|
|
80
|
+
|
|
81
|
+
The agent gets the API's error message when the agent passes an unknown slug. For an unknown API slug, the message lists every valid slug. The agent can then call the tool again with a valid slug. On CrewAI versions that have `ToolFailure`, the tool returns a `ToolFailure`. CrewAI then counts the call as failed. CrewAI checks each number before the tool calls the API. On older CrewAI versions, the tool checks each number itself. If a number is out of range, the agent gets an error message. The tool does not call the API.
|
|
82
|
+
|
|
83
|
+
## Network
|
|
84
|
+
|
|
85
|
+
Each tool call makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds only the tool's own arguments. The API takes up to 60 calls a minute from one IP address. When the API asks the tool to wait, the tool waits up to a minute. The tool waits once per call at most. All plans are in one file at https://datacircle.dev/datacircle.json.
|
|
86
|
+
|
|
87
|
+
## Links
|
|
88
|
+
|
|
89
|
+
- Datacircle: https://datacircle.dev
|
|
90
|
+
- The API: https://datacircle.dev/api
|
|
91
|
+
- The API's spec: https://api.datacircle.dev/v1/openapi.json
|
|
92
|
+
- What each key means: https://datacircle.dev/fields
|
|
93
|
+
|
|
94
|
+
MIT license.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
crewai_datacircle/__init__.py,sha256=ihHpkdGlG1knLgGp4m4IMhECtACdaIPnUNXM-gvyKPY,580
|
|
2
|
+
crewai_datacircle/_api.py,sha256=-80p2Q0DNJWA5DhhPdJtljvug8nCfChopy9rWmvmPm4,4844
|
|
3
|
+
crewai_datacircle/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
crewai_datacircle/tools.py,sha256=E7zvmKjpwkdTBm_RqNDOwqdJtn9FheFsnRczXrNm7k4,9351
|
|
5
|
+
crewai_datacircle-0.1.0.dist-info/METADATA,sha256=BhwsgzaGWb2tIelBeIFZqO39rEMSjp4FfJR_mAQchpA,4323
|
|
6
|
+
crewai_datacircle-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
7
|
+
crewai_datacircle-0.1.0.dist-info/licenses/LICENSE,sha256=dpgF7zGxeOd9IpQ9yUGa4a-cTj8fI6ulHnuilZEonCo,1067
|
|
8
|
+
crewai_datacircle-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Datacircle
|
|
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.
|