-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrewai_tool.py
More file actions
33 lines (24 loc) · 805 Bytes
/
Copy pathcrewai_tool.py
File metadata and controls
33 lines (24 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""CrewAI tool that fetches trading signals via x402 payments."""
import asyncio
from crewai.tools import BaseTool
from x402_agent_kit import SignalFuse
class SignalFuseTool(BaseTool):
name: str = "signalfuse_signal"
description: str = (
"Fetch the latest trading signal for a cryptocurrency symbol. "
"Pays for the API call with USDC on Base via the x402 protocol."
)
wallet_key: str
def _run(self, symbol: str) -> dict:
sf = SignalFuse(wallet_key=self.wallet_key)
return asyncio.run(sf.get_signal(symbol))
# Usage with a CrewAI agent:
#
# from crewai import Agent
#
# tool = SignalFuseTool(wallet_key="0xYOUR_KEY")
# agent = Agent(
# role="Trader",
# goal="Find high-conviction trading signals",
# tools=[tool],
# )