crewai-llpro 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,35 @@
1
+ Metadata-Version: 2.1
2
+ Name: crewai-llpro
3
+ Version: 0.1.0
4
+ Summary: CrewAI tools for LLPRO: cited public facts, signed checks of agent work and public agent records. Free daily allowance, no sign-up.
5
+ Keywords: crewai,tools,agents,verification,llpro
6
+ Author-email: LLPRO LLC <support@llpro.ai>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Dist: crewai>=0.80
12
+ Project-URL: Homepage, https://llpro.ai/connect?via=pypi
13
+
14
+ # crewai-llpro
15
+
16
+ CrewAI tools for LLPRO: cited public facts (Ground Truth), independent signed checks of agent work (Countersign) and public records of agents and MCP servers (Agent Record). By LLPRO LLC, https://llpro.ai. Free daily allowance, no sign-up.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pip install crewai-llpro
22
+ ```
23
+
24
+ ## Use
25
+
26
+ ```python
27
+ from llpro_crewai import get_tools, agent_key
28
+ k = agent_key("my-crew") # optional, free: named agent, double allowance, public record + badge
29
+ agent = Agent(role="Researcher", goal="...", backstory="...", tools=get_tools(agent_key=k["key"], agent_id=k["agent_id"]))
30
+ ```
31
+
32
+ Past the free allowance a tool returns a message saying how to get a prepaid credit key (`get_tools(api_key=...)` or `LLPRO_API_KEY`). Stamps are logged publicly: never send private text.
33
+
34
+ More: https://llpro.ai/connect?via=pypi
35
+
@@ -0,0 +1,21 @@
1
+ # crewai-llpro
2
+
3
+ CrewAI tools for LLPRO: cited public facts (Ground Truth), independent signed checks of agent work (Countersign) and public records of agents and MCP servers (Agent Record). By LLPRO LLC, https://llpro.ai. Free daily allowance, no sign-up.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install crewai-llpro
9
+ ```
10
+
11
+ ## Use
12
+
13
+ ```python
14
+ from llpro_crewai import get_tools, agent_key
15
+ k = agent_key("my-crew") # optional, free: named agent, double allowance, public record + badge
16
+ agent = Agent(role="Researcher", goal="...", backstory="...", tools=get_tools(agent_key=k["key"], agent_id=k["agent_id"]))
17
+ ```
18
+
19
+ Past the free allowance a tool returns a message saying how to get a prepaid credit key (`get_tools(api_key=...)` or `LLPRO_API_KEY`). Stamps are logged publicly: never send private text.
20
+
21
+ More: https://llpro.ai/connect?via=pypi
@@ -0,0 +1,4 @@
1
+ from llpro_crewai.tools import LLPROGroundTruth, LLPROCountersign, LLPROAgentRecord, get_tools
2
+ from llpro_crewai.client import agent_key
3
+
4
+ __all__ = ["LLPROGroundTruth", "LLPROCountersign", "LLPROAgentRecord", "get_tools", "agent_key"]
@@ -0,0 +1,103 @@
1
+ """Small stdlib client for LLPRO's agent tools: Ground Truth (cited public facts), Countersign (signed checks of agent work),
2
+ Agent Record (public records of agents and MCP servers) and the free agent key.
3
+
4
+ No sign-up is needed for the free daily allowance. Get a free agent key with agent_key(): send it on later calls (agent_key=...) and you
5
+ count as a named agent with double the free daily limit and a public Agent Record. Past the free limit, pass a prepaid credit key
6
+ (llk_..., api_key=... or LLPRO_API_KEY): the call is then taken from the key's balance. The only network addresses used are the ones below.
7
+ """
8
+ import http.client
9
+ import json
10
+ import os
11
+ import urllib.error
12
+ import urllib.request
13
+
14
+ __version__ = "0.1.0"
15
+ VIA = "crewai"
16
+ UA = "crewai-llpro/" + __version__
17
+ ENDPOINTS = {
18
+ "ground_truth": "https://gt.llpro.ai/v1/ask",
19
+ "countersign": "https://countersign.llpro.ai/v1/stamp",
20
+ "agent_record": "https://agentrecord.llpro.ai/v1/lookup",
21
+ "agent_key": "https://llpro.ai/agents/key",
22
+ }
23
+
24
+
25
+ class LLPROError(Exception):
26
+ """A call that did not return an answer. status is the HTTP status (0 = no response)."""
27
+
28
+ def __init__(self, message, status=0, body=None):
29
+ super().__init__(message)
30
+ self.status = status
31
+ self.body = body if isinstance(body, dict) else {}
32
+
33
+
34
+ class PaymentRequired(LLPROError):
35
+ """The free daily allowance is used up (HTTP 402). The message says how to pay."""
36
+
37
+
38
+ def _tagged(url):
39
+ if not isinstance(url, str) or not url.startswith("https://"):
40
+ return ""
41
+ if "via=" in url:
42
+ return url
43
+ return url + ("&" if "?" in url else "?") + "via=" + VIA
44
+
45
+
46
+ def _payment_message(body):
47
+ first = str(body.get("error") or "The free daily allowance for this tool is used up.").strip()
48
+ buy = _tagged(body.get("get_a_key") or (body.get("credit") or {}).get("buy"))
49
+ how = (" Get a prepaid credit key (card, no wallet needed): %s, then pass it as api_key or set LLPRO_API_KEY."
50
+ % buy) if buy else " Pass a prepaid credit key as api_key or set LLPRO_API_KEY."
51
+ return first + how + " Pay-per-call with x402 (USDC on Base) also works on this endpoint."
52
+
53
+
54
+ def call(tool, payload, api_key=None, agent_id=None, agent_key=None, timeout=60.0):
55
+ """POST payload (a dict) to one tool and return the JSON answer as a dict. Raises LLPROError / PaymentRequired.
56
+ agent_key: the free key from agent_key() (header X-Agent-Key). api_key: prepaid credit key (else LLPRO_API_KEY)."""
57
+ if tool not in ENDPOINTS:
58
+ raise ValueError("unknown tool %r (use one of %s)" % (tool, ", ".join(sorted(ENDPOINTS))))
59
+ if not isinstance(payload, dict):
60
+ raise ValueError("payload must be a dict")
61
+ if tool != "agent_key" and not payload:
62
+ raise ValueError("payload must be a non-empty dict")
63
+ key = api_key if api_key is not None else os.environ.get("LLPRO_API_KEY", "")
64
+ headers = {"Content-Type": "application/json", "Accept": "application/json", "User-Agent": UA, "X-LLPRO-Via": VIA}
65
+ if key and tool != "agent_key":
66
+ headers["Authorization"] = "Bearer " + key.strip()
67
+ if agent_key and tool != "agent_key":
68
+ headers["X-Agent-Key"] = str(agent_key).strip()
69
+ if agent_id:
70
+ headers["X-Agent-Id"] = str(agent_id)
71
+ req = urllib.request.Request(ENDPOINTS[tool], data=json.dumps(payload).encode("utf-8"), headers=headers, method="POST")
72
+ try:
73
+ with urllib.request.urlopen(req, timeout=timeout) as r:
74
+ raw = r.read()
75
+ except urllib.error.HTTPError as e:
76
+ try:
77
+ body = json.loads(e.read() or b"{}")
78
+ except ValueError:
79
+ body = {}
80
+ if not isinstance(body, dict):
81
+ body = {}
82
+ if e.code == 402:
83
+ raise PaymentRequired(_payment_message(body), 402, body)
84
+ err = body.get("error")
85
+ msg = str((err.get("message") if isinstance(err, dict) else err) or body.get("message") or e.reason or "request failed")
86
+ if e.code == 400:
87
+ msg = "Bad input, nothing was charged: " + msg
88
+ elif e.code == 429:
89
+ msg = "Daily ceiling reached, try again later: " + msg
90
+ raise LLPROError(msg, e.code, body)
91
+ except (urllib.error.URLError, OSError, http.client.HTTPException) as e:
92
+ raise LLPROError("Could not reach %s: %s" % (ENDPOINTS[tool], getattr(e, "reason", e)), 0)
93
+ try:
94
+ out = json.loads(raw or b"{}")
95
+ except ValueError:
96
+ raise LLPROError("The answer was not JSON", 200)
97
+ return out if isinstance(out, dict) else {"answer": out}
98
+
99
+
100
+ def agent_key(name=None, timeout=30.0):
101
+ """Get a free agent key (no sign-up, no email). Returns {agent_id, key, record, badge, ...}. The key is shown once: keep it.
102
+ Send it on later calls as agent_key=..., and paste result['badge']['markdown'] into your README to show your public Agent Record."""
103
+ return call("agent_key", {"name": name} if name else {}, timeout=timeout)
@@ -0,0 +1,73 @@
1
+ """CrewAI tools for LLPRO: cited public facts, signed checks of agent work, public agent records."""
2
+ import json
3
+ from typing import Any, List, Optional, Type
4
+
5
+ from crewai.tools import BaseTool
6
+ from pydantic import BaseModel, Field
7
+
8
+ from . import client
9
+
10
+
11
+ class _Base(BaseTool):
12
+ api_key: Optional[str] = Field(default=None, repr=False, exclude=True)
13
+ agent_key: Optional[str] = Field(default=None, repr=False, exclude=True)
14
+ agent_id: Optional[str] = None
15
+ timeout: float = 60.0
16
+ _endpoint: str = ""
17
+
18
+ def _post(self, payload: dict) -> str:
19
+ try:
20
+ out = client.call(self._endpoint, payload, api_key=self.api_key, agent_id=self.agent_id, agent_key=self.agent_key, timeout=self.timeout)
21
+ except client.LLPROError as e: # the crew gets the reason as text
22
+ return "LLPRO error: " + str(e)
23
+ return json.dumps(out, ensure_ascii=False)
24
+
25
+
26
+ class GroundTruthInput(BaseModel):
27
+ topic: str = Field(description="weather, weather_alerts, river_level, flood, earthquakes, disasters, air_quality, road_closures, power_outages or burn_ban")
28
+ place: Optional[str] = Field(default=None, description="Place name, e.g. 'Lafayette, LA'")
29
+
30
+
31
+ class LLPROGroundTruth(_Base):
32
+ name: str = "llpro_ground_truth"
33
+ description: str = "One cited, time-stamped public fact for a place (weather, river level, earthquakes, air quality, road closures and more)."
34
+ args_schema: Type[BaseModel] = GroundTruthInput
35
+ _endpoint: str = "ground_truth"
36
+
37
+ def _run(self, topic: str, place: Optional[str] = None, **_: Any) -> str:
38
+ return self._post({k: v for k, v in {"topic": topic, "place": place}.items() if v is not None})
39
+
40
+
41
+ class CountersignInput(BaseModel):
42
+ output: str = Field(description="The work to check, as short claims ('12 * 4 = 48'), a date, unit conversion or citation. Stamps are logged publicly: no private text.")
43
+
44
+
45
+ class LLPROCountersign(_Base):
46
+ name: str = "llpro_countersign"
47
+ description: str = ("An independent signed check of an agent's work. Returns a verdict and a stamp logged publicly, with a share_url anyone can open to verify it. "
48
+ "Do not send private or personal text.")
49
+ args_schema: Type[BaseModel] = CountersignInput
50
+ _endpoint: str = "countersign"
51
+
52
+ def _run(self, output: str, **_: Any) -> str:
53
+ return self._post({"output": output, "producer": {"agent_id": self.agent_id or "crewai-agent"}})
54
+
55
+
56
+ class AgentRecordInput(BaseModel):
57
+ target: str = Field(description="URL, registry name or agent id of an agent or MCP server")
58
+
59
+
60
+ class LLPROAgentRecord(_Base):
61
+ name: str = "llpro_agent_record"
62
+ description: str = "The public record of an agent or MCP server before you rely on it: listings, daily checks, receipts and disputes."
63
+ args_schema: Type[BaseModel] = AgentRecordInput
64
+ _endpoint: str = "agent_record"
65
+
66
+ def _run(self, target: str, **_: Any) -> str:
67
+ return self._post({"target": target})
68
+
69
+
70
+ def get_tools(api_key: Optional[str] = None, agent_key: Optional[str] = None, agent_id: Optional[str] = None, timeout: float = 60.0) -> List[BaseTool]:
71
+ """All three tools. api_key: prepaid credit key (else LLPRO_API_KEY). agent_key: the free key from llpro_crewai.client.agent_key()."""
72
+ kw = {"api_key": api_key, "agent_key": agent_key, "agent_id": agent_id, "timeout": timeout}
73
+ return [LLPROGroundTruth(**kw), LLPROCountersign(**kw), LLPROAgentRecord(**kw)]
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["flit_core==3.9.0"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "crewai-llpro"
7
+ version = "0.1.0"
8
+ description = "CrewAI tools for LLPRO: cited public facts, signed checks of agent work and public agent records. Free daily allowance, no sign-up."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = ["crewai>=0.80"]
12
+ authors = [{ name = "LLPRO LLC", email = "support@llpro.ai" }]
13
+ keywords = ["crewai", "tools", "agents", "verification", "llpro"]
14
+ classifiers = ["Programming Language :: Python :: 3", "Operating System :: OS Independent"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://llpro.ai/connect?via=pypi"
18
+
19
+ [tool.flit.module]
20
+ name = "llpro_crewai"