intentkit 0.8.12.dev2__py3-none-any.whl → 0.8.12.dev4__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.
Potentially problematic release.
This version of intentkit might be problematic. Click here for more details.
- intentkit/__init__.py +1 -1
- intentkit/abstracts/skill.py +2 -59
- intentkit/clients/twitter.py +35 -28
- intentkit/core/agent.py +2 -279
- intentkit/core/engine.py +6 -4
- intentkit/models/agent.py +109 -89
- intentkit/models/agent_schema.json +4 -2
- intentkit/skills/acolyt/__init__.py +2 -9
- intentkit/skills/acolyt/base.py +2 -5
- intentkit/skills/aixbt/__init__.py +2 -13
- intentkit/skills/aixbt/base.py +0 -4
- intentkit/skills/aixbt/projects.py +1 -2
- intentkit/skills/allora/__init__.py +2 -9
- intentkit/skills/allora/base.py +2 -5
- intentkit/skills/base.py +101 -27
- intentkit/skills/basename/__init__.py +1 -3
- intentkit/skills/carv/__init__.py +116 -121
- intentkit/skills/carv/base.py +184 -185
- intentkit/skills/casino/__init__.py +4 -15
- intentkit/skills/casino/base.py +0 -4
- intentkit/skills/casino/deck_draw.py +1 -2
- intentkit/skills/casino/deck_shuffle.py +1 -2
- intentkit/skills/casino/dice_roll.py +1 -2
- intentkit/skills/cdp/__init__.py +0 -4
- intentkit/skills/cdp/base.py +0 -4
- intentkit/skills/chainlist/__init__.py +2 -7
- intentkit/skills/chainlist/base.py +0 -4
- intentkit/skills/common/__init__.py +2 -9
- intentkit/skills/common/base.py +0 -4
- intentkit/skills/cookiefun/__init__.py +6 -9
- intentkit/skills/cookiefun/base.py +0 -4
- intentkit/skills/cryptocompare/__init__.py +7 -24
- intentkit/skills/cryptocompare/base.py +0 -5
- intentkit/skills/cryptopanic/__init__.py +3 -6
- intentkit/skills/cryptopanic/base.py +53 -55
- intentkit/skills/cryptopanic/fetch_crypto_news.py +0 -2
- intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +1 -3
- intentkit/skills/dapplooker/__init__.py +2 -9
- intentkit/skills/dapplooker/base.py +2 -5
- intentkit/skills/defillama/__init__.py +24 -74
- intentkit/skills/defillama/base.py +0 -4
- intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +2 -2
- intentkit/skills/defillama/coins/fetch_block.py +2 -2
- intentkit/skills/defillama/coins/fetch_current_prices.py +2 -2
- intentkit/skills/defillama/coins/fetch_first_price.py +2 -2
- intentkit/skills/defillama/coins/fetch_historical_prices.py +2 -2
- intentkit/skills/defillama/coins/fetch_price_chart.py +2 -2
- intentkit/skills/defillama/coins/fetch_price_percentage.py +2 -2
- intentkit/skills/defillama/fees/fetch_fees_overview.py +2 -2
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +2 -2
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +2 -2
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +2 -2
- intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +2 -2
- intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +2 -2
- intentkit/skills/defillama/tvl/fetch_chains.py +2 -2
- intentkit/skills/defillama/tvl/fetch_historical_tvl.py +2 -2
- intentkit/skills/defillama/tvl/fetch_protocol.py +2 -2
- intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +2 -2
- intentkit/skills/defillama/tvl/fetch_protocols.py +2 -2
- intentkit/skills/defillama/volumes/fetch_dex_overview.py +2 -2
- intentkit/skills/defillama/volumes/fetch_dex_summary.py +2 -2
- intentkit/skills/defillama/volumes/fetch_options_overview.py +2 -2
- intentkit/skills/defillama/yields/fetch_pool_chart.py +2 -2
- intentkit/skills/defillama/yields/fetch_pools.py +2 -2
- intentkit/skills/dexscreener/__init__.py +97 -102
- intentkit/skills/dexscreener/base.py +125 -130
- intentkit/skills/dexscreener/get_pair_info.py +2 -3
- intentkit/skills/dexscreener/get_token_pairs.py +2 -3
- intentkit/skills/dexscreener/get_tokens_info.py +2 -3
- intentkit/skills/dexscreener/search_token.py +2 -4
- intentkit/skills/dune_analytics/__init__.py +4 -6
- intentkit/skills/dune_analytics/base.py +50 -52
- intentkit/skills/dune_analytics/fetch_kol_buys.py +0 -2
- intentkit/skills/dune_analytics/fetch_nation_metrics.py +0 -2
- intentkit/skills/elfa/__init__.py +5 -18
- intentkit/skills/elfa/base.py +8 -10
- intentkit/skills/enso/__init__.py +9 -29
- intentkit/skills/enso/base.py +3 -6
- intentkit/skills/enso/route.py +1 -3
- intentkit/skills/erc20/__init__.py +1 -5
- intentkit/skills/erc721/__init__.py +1 -3
- intentkit/skills/firecrawl/__init__.py +5 -18
- intentkit/skills/firecrawl/base.py +2 -5
- intentkit/skills/firecrawl/crawl.py +10 -9
- intentkit/skills/firecrawl/query.py +3 -1
- intentkit/skills/firecrawl/scrape.py +8 -10
- intentkit/skills/firecrawl/utils.py +25 -26
- intentkit/skills/github/__init__.py +2 -7
- intentkit/skills/github/base.py +0 -4
- intentkit/skills/heurist/__init__.py +8 -27
- intentkit/skills/heurist/base.py +2 -5
- intentkit/skills/heurist/image_generation_animagine_xl.py +5 -5
- intentkit/skills/heurist/image_generation_arthemy_comics.py +5 -5
- intentkit/skills/heurist/image_generation_arthemy_real.py +5 -5
- intentkit/skills/heurist/image_generation_braindance.py +5 -5
- intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +5 -5
- intentkit/skills/heurist/image_generation_flux_1_dev.py +5 -5
- intentkit/skills/heurist/image_generation_sdxl.py +5 -5
- intentkit/skills/http/__init__.py +4 -15
- intentkit/skills/http/base.py +0 -4
- intentkit/skills/lifi/__init__.py +1 -6
- intentkit/skills/lifi/base.py +0 -4
- intentkit/skills/lifi/token_execute.py +1 -4
- intentkit/skills/lifi/token_quote.py +1 -3
- intentkit/skills/moralis/__init__.py +3 -7
- intentkit/skills/moralis/base.py +2 -5
- intentkit/skills/morpho/__init__.py +1 -3
- intentkit/skills/nation/__init__.py +2 -7
- intentkit/skills/nation/base.py +4 -7
- intentkit/skills/openai/__init__.py +5 -18
- intentkit/skills/openai/base.py +8 -10
- intentkit/skills/openai/dalle_image_generation.py +2 -5
- intentkit/skills/openai/gpt_image_generation.py +2 -5
- intentkit/skills/openai/gpt_image_to_image.py +2 -5
- intentkit/skills/openai/image_to_text.py +2 -5
- intentkit/skills/portfolio/__init__.py +11 -35
- intentkit/skills/portfolio/base.py +2 -5
- intentkit/skills/pyth/__init__.py +1 -5
- intentkit/skills/slack/__init__.py +5 -17
- intentkit/skills/slack/base.py +0 -4
- intentkit/skills/supabase/__init__.py +7 -23
- intentkit/skills/supabase/base.py +0 -4
- intentkit/skills/superfluid/__init__.py +1 -3
- intentkit/skills/system/__init__.py +7 -24
- intentkit/skills/system/add_autonomous_task.py +2 -2
- intentkit/skills/system/delete_autonomous_task.py +2 -2
- intentkit/skills/system/edit_autonomous_task.py +2 -4
- intentkit/skills/system/list_autonomous_tasks.py +2 -2
- intentkit/skills/system/read_agent_api_key.py +6 -4
- intentkit/skills/system/regenerate_agent_api_key.py +6 -4
- intentkit/skills/tavily/__init__.py +3 -12
- intentkit/skills/tavily/base.py +2 -5
- intentkit/skills/tavily/tavily_extract.py +1 -2
- intentkit/skills/tavily/tavily_search.py +3 -3
- intentkit/skills/token/__init__.py +5 -10
- intentkit/skills/token/base.py +2 -6
- intentkit/skills/twitter/__init__.py +11 -35
- intentkit/skills/twitter/base.py +14 -16
- intentkit/skills/twitter/follow_user.py +0 -1
- intentkit/skills/twitter/get_mentions.py +0 -1
- intentkit/skills/twitter/get_timeline.py +0 -1
- intentkit/skills/twitter/get_user_by_username.py +0 -1
- intentkit/skills/twitter/get_user_tweets.py +0 -1
- intentkit/skills/twitter/like_tweet.py +0 -1
- intentkit/skills/twitter/post_tweet.py +2 -2
- intentkit/skills/twitter/reply_tweet.py +2 -2
- intentkit/skills/twitter/retweet.py +0 -1
- intentkit/skills/twitter/search_tweets.py +0 -1
- intentkit/skills/unrealspeech/__init__.py +2 -7
- intentkit/skills/unrealspeech/base.py +0 -4
- intentkit/skills/venice_audio/__init__.py +99 -106
- intentkit/skills/venice_audio/base.py +118 -121
- intentkit/skills/venice_audio/venice_audio.py +1 -5
- intentkit/skills/venice_image/__init__.py +147 -154
- intentkit/skills/venice_image/base.py +185 -192
- intentkit/skills/web_scraper/__init__.py +5 -18
- intentkit/skills/web_scraper/base.py +20 -4
- intentkit/skills/web_scraper/document_indexer.py +6 -4
- intentkit/skills/web_scraper/scrape_and_index.py +11 -8
- intentkit/skills/web_scraper/utils.py +31 -27
- intentkit/skills/web_scraper/website_indexer.py +7 -8
- intentkit/skills/weth/__init__.py +1 -5
- intentkit/skills/wow/__init__.py +1 -5
- intentkit/skills/xmtp/__init__.py +4 -15
- {intentkit-0.8.12.dev2.dist-info → intentkit-0.8.12.dev4.dist-info}/METADATA +1 -1
- {intentkit-0.8.12.dev2.dist-info → intentkit-0.8.12.dev4.dist-info}/RECORD +168 -168
- {intentkit-0.8.12.dev2.dist-info → intentkit-0.8.12.dev4.dist-info}/WHEEL +0 -0
- {intentkit-0.8.12.dev2.dist-info → intentkit-0.8.12.dev4.dist-info}/licenses/LICENSE +0 -0
intentkit/skills/carv/base.py
CHANGED
|
@@ -1,185 +1,184 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Any, Dict, Optional, Tuple, Type
|
|
3
|
-
|
|
4
|
-
import httpx # Ensure httpx is installed: pip install httpx
|
|
5
|
-
from langchain_core.tools.base import ToolException
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
from intentkit.
|
|
9
|
-
from intentkit.skills.base import IntentKitSkill
|
|
10
|
-
|
|
11
|
-
logger = logging.getLogger(__name__)
|
|
12
|
-
|
|
13
|
-
CARV_API_BASE_URL = "https://interface.carv.io"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class CarvBaseTool(IntentKitSkill):
|
|
17
|
-
"""Base class for CARV API tools."""
|
|
18
|
-
|
|
19
|
-
name: str = Field(description="Tool name") # type: ignore
|
|
20
|
-
description: str = Field(description="Tool description")
|
|
21
|
-
args_schema: Type[BaseModel] # type: ignore
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
api_key_provider
|
|
42
|
-
|
|
43
|
-
agent_api_key:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
system_api_key
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
err_msg
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
|
|
185
|
-
}
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Any, Dict, Optional, Tuple, Type
|
|
3
|
+
|
|
4
|
+
import httpx # Ensure httpx is installed: pip install httpx
|
|
5
|
+
from langchain_core.tools.base import ToolException
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from intentkit.config.config import config
|
|
9
|
+
from intentkit.skills.base import IntentKitSkill
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
CARV_API_BASE_URL = "https://interface.carv.io"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CarvBaseTool(IntentKitSkill):
|
|
17
|
+
"""Base class for CARV API tools."""
|
|
18
|
+
|
|
19
|
+
name: str = Field(description="Tool name") # type: ignore
|
|
20
|
+
description: str = Field(description="Tool description")
|
|
21
|
+
args_schema: Type[BaseModel] # type: ignore
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def category(self) -> str:
|
|
25
|
+
return "carv"
|
|
26
|
+
|
|
27
|
+
def get_api_key(self) -> str:
|
|
28
|
+
"""
|
|
29
|
+
Retrieves the CARV API key based on the api_key_provider setting.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
The API key if found.
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
ToolException: If the API key is not found or provider is invalid.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
context = self.get_context()
|
|
39
|
+
skill_config = context.agent.skill_config(self.category)
|
|
40
|
+
api_key_provider = skill_config.get("api_key_provider")
|
|
41
|
+
if api_key_provider == "agent_owner":
|
|
42
|
+
agent_api_key: Optional[str] = skill_config.get("api_key")
|
|
43
|
+
if agent_api_key:
|
|
44
|
+
logger.debug(
|
|
45
|
+
f"Using agent-specific CARV API key for skill {self.name} in category {self.category}"
|
|
46
|
+
)
|
|
47
|
+
return agent_api_key
|
|
48
|
+
raise ToolException(
|
|
49
|
+
f"No agent-owned CARV API key found for skill '{self.name}' in category '{self.category}'."
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
elif api_key_provider == "platform":
|
|
53
|
+
system_api_key = config.carv_api_key
|
|
54
|
+
if system_api_key:
|
|
55
|
+
logger.debug(
|
|
56
|
+
f"Using system CARV API key for skill {self.name} in category {self.category}"
|
|
57
|
+
)
|
|
58
|
+
return system_api_key
|
|
59
|
+
raise ToolException(
|
|
60
|
+
f"No platform-hosted CARV API key found for skill '{self.name}' in category '{self.category}'."
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
else:
|
|
64
|
+
raise ToolException(
|
|
65
|
+
f"Invalid API key provider '{api_key_provider}' for skill '{self.name}'"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
except Exception as e:
|
|
69
|
+
# Re-raise ToolException if it's already one, otherwise wrap
|
|
70
|
+
if isinstance(e, ToolException):
|
|
71
|
+
raise
|
|
72
|
+
raise ToolException(f"Failed to retrieve CARV API key: {str(e)}") from e
|
|
73
|
+
|
|
74
|
+
async def apply_rate_limit(self, context) -> None:
|
|
75
|
+
"""
|
|
76
|
+
Applies rate limiting ONLY if specified in the agent's config ('skill_config').
|
|
77
|
+
Checks for 'rate_limit_number' and 'rate_limit_minutes'.
|
|
78
|
+
If not configured, NO rate limiting is applied.
|
|
79
|
+
Raises ConnectionAbortedError if the configured limit is exceeded.
|
|
80
|
+
"""
|
|
81
|
+
skill_config = context.agent.skill_config(self.category)
|
|
82
|
+
user_id = context.agent.id
|
|
83
|
+
|
|
84
|
+
limit_num = skill_config.get("rate_limit_number")
|
|
85
|
+
limit_min = skill_config.get("rate_limit_minutes")
|
|
86
|
+
|
|
87
|
+
# Apply limit ONLY if both values are present and valid (truthy check handles None and 0)
|
|
88
|
+
if limit_num and limit_min:
|
|
89
|
+
logger.debug(
|
|
90
|
+
f"Applying rate limit ({limit_num}/{limit_min} min) for user {user_id} on {self.name}"
|
|
91
|
+
)
|
|
92
|
+
if user_id:
|
|
93
|
+
await self.user_rate_limit_by_category(limit_num, limit_min * 60)
|
|
94
|
+
else:
|
|
95
|
+
# No valid agent configuration found, so do nothing.
|
|
96
|
+
logger.debug(
|
|
97
|
+
f"No agent rate limits configured for category '{self.category}'. Skipping rate limit for user {user_id}."
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
async def _call_carv_api(
|
|
101
|
+
self,
|
|
102
|
+
context,
|
|
103
|
+
endpoint: str,
|
|
104
|
+
method: str = "GET",
|
|
105
|
+
params: Optional[Dict[str, Any]] = None,
|
|
106
|
+
payload: Optional[Dict[str, Any]] = None,
|
|
107
|
+
) -> Tuple[Optional[Dict[str, Any]], Optional[Dict[str, Any]]]:
|
|
108
|
+
"""
|
|
109
|
+
Makes a call to the CARV API and returns a tuple of (success, error).
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
context: The skill context.
|
|
113
|
+
endpoint: The API endpoint path (e.g., "/ai-agent-backend/token_info").
|
|
114
|
+
method: HTTP method ("GET", "POST", etc.).
|
|
115
|
+
params: Query parameters for the request.
|
|
116
|
+
payload: JSON payload for POST/PUT requests.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Tuple where the first element is the response data if successful,
|
|
120
|
+
and the second element is an error dict if an error occurred.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
url = f"{CARV_API_BASE_URL}{endpoint}"
|
|
124
|
+
|
|
125
|
+
try:
|
|
126
|
+
api_key = self.get_api_key()
|
|
127
|
+
|
|
128
|
+
headers = {
|
|
129
|
+
"Authorization": api_key,
|
|
130
|
+
"Content-Type": "application/json",
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
logger.debug(
|
|
134
|
+
f"Calling CARV API: {method} {url} with params {params}, payload {payload}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
138
|
+
if method == "GET":
|
|
139
|
+
response = await client.get(url, headers=headers, params=params)
|
|
140
|
+
elif method == "POST":
|
|
141
|
+
response = await client.post(
|
|
142
|
+
url, headers=headers, json=payload, params=params
|
|
143
|
+
)
|
|
144
|
+
else:
|
|
145
|
+
return None, {"error": f"Unsupported HTTP method: {method}"}
|
|
146
|
+
|
|
147
|
+
# Do NOT raise for status here; always parse JSON
|
|
148
|
+
try:
|
|
149
|
+
response_json: dict[str, Any] = response.json()
|
|
150
|
+
except Exception as json_err:
|
|
151
|
+
err_msg = f"Failed to parse JSON response: {json_err}"
|
|
152
|
+
logger.error(err_msg)
|
|
153
|
+
return None, {"error": err_msg}
|
|
154
|
+
|
|
155
|
+
logger.debug(
|
|
156
|
+
f"CARV API Response (status {response.status_code}): {response_json}"
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# Check if response_json signals an error explicitly (custom API error)
|
|
160
|
+
if response.status_code >= 400 or "error" in response_json:
|
|
161
|
+
# Return full error info (including status code, body, etc.)
|
|
162
|
+
return None, {
|
|
163
|
+
"error": response_json.get("error", "Unknown API error"),
|
|
164
|
+
"status_code": response.status_code,
|
|
165
|
+
"response": response_json,
|
|
166
|
+
"url": url,
|
|
167
|
+
"method": method,
|
|
168
|
+
"params": params,
|
|
169
|
+
"payload": payload,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
# Otherwise return the 'data' field if present, else full response
|
|
173
|
+
return response_json.get("data", response_json), None
|
|
174
|
+
|
|
175
|
+
except Exception as e:
|
|
176
|
+
logger.error(
|
|
177
|
+
f"Error calling CARV API to {method} > {url}: {e}", exc_info=True
|
|
178
|
+
)
|
|
179
|
+
return None, {
|
|
180
|
+
"error": str(e),
|
|
181
|
+
"url": url,
|
|
182
|
+
"method": method,
|
|
183
|
+
"params": params,
|
|
184
|
+
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import TypedDict
|
|
5
5
|
|
|
6
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
7
6
|
from intentkit.skills.base import SkillConfig, SkillState
|
|
8
7
|
from intentkit.skills.casino.base import CasinoBaseTool
|
|
9
8
|
from intentkit.skills.casino.deck_draw import CasinoDeckDraw
|
|
@@ -31,7 +30,6 @@ class Config(SkillConfig):
|
|
|
31
30
|
async def get_skills(
|
|
32
31
|
config: "Config",
|
|
33
32
|
is_private: bool,
|
|
34
|
-
store: SkillStoreABC,
|
|
35
33
|
**_,
|
|
36
34
|
) -> list[CasinoBaseTool]:
|
|
37
35
|
"""Get all Casino skills.
|
|
@@ -39,7 +37,6 @@ async def get_skills(
|
|
|
39
37
|
Args:
|
|
40
38
|
config: The configuration for Casino skills.
|
|
41
39
|
is_private: Whether to include private skills.
|
|
42
|
-
store: The skill store for persisting data.
|
|
43
40
|
|
|
44
41
|
Returns:
|
|
45
42
|
A list of Casino skills.
|
|
@@ -56,7 +53,7 @@ async def get_skills(
|
|
|
56
53
|
# Get each skill using the cached getter
|
|
57
54
|
result = []
|
|
58
55
|
for name in available_skills:
|
|
59
|
-
skill = get_casino_skill(name
|
|
56
|
+
skill = get_casino_skill(name)
|
|
60
57
|
if skill:
|
|
61
58
|
result.append(skill)
|
|
62
59
|
return result
|
|
@@ -64,34 +61,26 @@ async def get_skills(
|
|
|
64
61
|
|
|
65
62
|
def get_casino_skill(
|
|
66
63
|
name: str,
|
|
67
|
-
store: SkillStoreABC,
|
|
68
64
|
) -> CasinoBaseTool:
|
|
69
65
|
"""Get a Casino skill by name.
|
|
70
66
|
|
|
71
67
|
Args:
|
|
72
68
|
name: The name of the skill to get
|
|
73
|
-
store: The skill store for persisting data
|
|
74
69
|
|
|
75
70
|
Returns:
|
|
76
71
|
The requested Casino skill
|
|
77
72
|
"""
|
|
78
73
|
if name == "deck_shuffle":
|
|
79
74
|
if name not in _cache:
|
|
80
|
-
_cache[name] = CasinoDeckShuffle(
|
|
81
|
-
skill_store=store,
|
|
82
|
-
)
|
|
75
|
+
_cache[name] = CasinoDeckShuffle()
|
|
83
76
|
return _cache[name]
|
|
84
77
|
elif name == "deck_draw":
|
|
85
78
|
if name not in _cache:
|
|
86
|
-
_cache[name] = CasinoDeckDraw(
|
|
87
|
-
skill_store=store,
|
|
88
|
-
)
|
|
79
|
+
_cache[name] = CasinoDeckDraw()
|
|
89
80
|
return _cache[name]
|
|
90
81
|
elif name == "dice_roll":
|
|
91
82
|
if name not in _cache:
|
|
92
|
-
_cache[name] = CasinoDiceRoll(
|
|
93
|
-
skill_store=store,
|
|
94
|
-
)
|
|
83
|
+
_cache[name] = CasinoDiceRoll()
|
|
95
84
|
return _cache[name]
|
|
96
85
|
else:
|
|
97
86
|
raise ValueError(f"Unknown Casino skill: {name}")
|
intentkit/skills/casino/base.py
CHANGED
|
@@ -4,7 +4,6 @@ from typing import Type
|
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, Field
|
|
6
6
|
|
|
7
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
8
7
|
from intentkit.skills.base import IntentKitSkill
|
|
9
8
|
|
|
10
9
|
|
|
@@ -14,9 +13,6 @@ class CasinoBaseTool(IntentKitSkill):
|
|
|
14
13
|
name: str = Field(description="The name of the tool")
|
|
15
14
|
description: str = Field(description="A description of what the tool does")
|
|
16
15
|
args_schema: Type[BaseModel]
|
|
17
|
-
skill_store: SkillStoreABC = Field(
|
|
18
|
-
description="The skill store for persisting data"
|
|
19
|
-
)
|
|
20
16
|
|
|
21
17
|
@property
|
|
22
18
|
def category(self) -> str:
|
|
@@ -58,9 +58,8 @@ class CasinoDeckDraw(CasinoBaseTool):
|
|
|
58
58
|
# Apply rate limit using built-in user_rate_limit method
|
|
59
59
|
rate_config = RATE_LIMITS["deck_draw"]
|
|
60
60
|
await self.user_rate_limit(
|
|
61
|
-
context.user_id or context.agent_id,
|
|
62
61
|
rate_config["max_requests"],
|
|
63
|
-
rate_config["interval"]
|
|
62
|
+
rate_config["interval"],
|
|
64
63
|
"deck_draw",
|
|
65
64
|
)
|
|
66
65
|
|
|
@@ -64,9 +64,8 @@ class CasinoDeckShuffle(CasinoBaseTool):
|
|
|
64
64
|
# Apply rate limit using built-in user_rate_limit method
|
|
65
65
|
rate_config = RATE_LIMITS["deck_shuffle"]
|
|
66
66
|
await self.user_rate_limit(
|
|
67
|
-
context.user_id or context.agent_id,
|
|
68
67
|
rate_config["max_requests"],
|
|
69
|
-
rate_config["interval"]
|
|
68
|
+
rate_config["interval"],
|
|
70
69
|
"deck_shuffle",
|
|
71
70
|
)
|
|
72
71
|
|
|
@@ -57,9 +57,8 @@ class CasinoDiceRoll(CasinoBaseTool):
|
|
|
57
57
|
# Apply rate limit using built-in user_rate_limit method
|
|
58
58
|
rate_config = RATE_LIMITS["dice_roll"]
|
|
59
59
|
await self.user_rate_limit(
|
|
60
|
-
context.user_id or context.agent_id,
|
|
61
60
|
rate_config["max_requests"],
|
|
62
|
-
rate_config["interval"]
|
|
61
|
+
rate_config["interval"],
|
|
63
62
|
"dice_roll",
|
|
64
63
|
)
|
|
65
64
|
|
intentkit/skills/cdp/__init__.py
CHANGED
|
@@ -8,7 +8,6 @@ from coinbase_agentkit import (
|
|
|
8
8
|
wallet_action_provider,
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
12
11
|
from intentkit.skills.base import (
|
|
13
12
|
SkillConfig,
|
|
14
13
|
SkillState,
|
|
@@ -41,7 +40,6 @@ class Config(SkillConfig):
|
|
|
41
40
|
async def get_skills(
|
|
42
41
|
config: "Config",
|
|
43
42
|
is_private: bool,
|
|
44
|
-
store: SkillStoreABC,
|
|
45
43
|
agent_id: str,
|
|
46
44
|
agent: Optional["Agent"] = None,
|
|
47
45
|
**_,
|
|
@@ -51,7 +49,6 @@ async def get_skills(
|
|
|
51
49
|
Args:
|
|
52
50
|
config: The configuration for CDP skills.
|
|
53
51
|
is_private: Whether to include private skills.
|
|
54
|
-
store: The skill store for persisting data.
|
|
55
52
|
agent_id: The ID of the agent using the skills.
|
|
56
53
|
|
|
57
54
|
Returns:
|
|
@@ -69,7 +66,6 @@ async def get_skills(
|
|
|
69
66
|
# Initialize CDP client
|
|
70
67
|
actions = await get_agentkit_actions(
|
|
71
68
|
agent_id,
|
|
72
|
-
store,
|
|
73
69
|
[
|
|
74
70
|
wallet_action_provider,
|
|
75
71
|
cdp_api_action_provider,
|
intentkit/skills/cdp/base.py
CHANGED
|
@@ -2,7 +2,6 @@ from typing import Type
|
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, Field
|
|
4
4
|
|
|
5
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
6
5
|
from intentkit.skills.base import IntentKitSkill
|
|
7
6
|
|
|
8
7
|
|
|
@@ -12,9 +11,6 @@ class CDPBaseTool(IntentKitSkill):
|
|
|
12
11
|
name: str = Field(description="The name of the tool")
|
|
13
12
|
description: str = Field(description="A description of what the tool does")
|
|
14
13
|
args_schema: Type[BaseModel]
|
|
15
|
-
skill_store: SkillStoreABC = Field(
|
|
16
|
-
description="The skill store for persisting data"
|
|
17
|
-
)
|
|
18
14
|
|
|
19
15
|
@property
|
|
20
16
|
def category(self) -> str:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import TypedDict
|
|
2
2
|
|
|
3
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
4
3
|
from intentkit.skills.base import SkillConfig, SkillState
|
|
5
4
|
from intentkit.skills.chainlist.base import ChainlistBaseTool
|
|
6
5
|
from intentkit.skills.chainlist.chain_lookup import ChainLookup
|
|
@@ -22,7 +21,6 @@ class Config(SkillConfig):
|
|
|
22
21
|
async def get_skills(
|
|
23
22
|
config: "Config",
|
|
24
23
|
is_private: bool,
|
|
25
|
-
store: SkillStoreABC,
|
|
26
24
|
**_,
|
|
27
25
|
) -> list[ChainlistBaseTool]:
|
|
28
26
|
"""Get all chainlist skills."""
|
|
@@ -36,19 +34,16 @@ async def get_skills(
|
|
|
36
34
|
available_skills.append(skill_name)
|
|
37
35
|
|
|
38
36
|
# Get each skill using the cached getter
|
|
39
|
-
return [get_chainlist_skill(name
|
|
37
|
+
return [get_chainlist_skill(name) for name in available_skills]
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
def get_chainlist_skill(
|
|
43
41
|
name: str,
|
|
44
|
-
store: SkillStoreABC,
|
|
45
42
|
) -> ChainlistBaseTool:
|
|
46
43
|
"""Get a chainlist skill by name."""
|
|
47
44
|
if name == "chain_lookup":
|
|
48
45
|
if name not in _cache:
|
|
49
|
-
_cache[name] = ChainLookup(
|
|
50
|
-
skill_store=store,
|
|
51
|
-
)
|
|
46
|
+
_cache[name] = ChainLookup()
|
|
52
47
|
return _cache[name]
|
|
53
48
|
else:
|
|
54
49
|
raise ValueError(f"Unknown chainlist skill: {name}")
|
|
@@ -2,7 +2,6 @@ from typing import Type
|
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, Field
|
|
4
4
|
|
|
5
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
6
5
|
from intentkit.skills.base import IntentKitSkill
|
|
7
6
|
|
|
8
7
|
|
|
@@ -12,9 +11,6 @@ class ChainlistBaseTool(IntentKitSkill):
|
|
|
12
11
|
name: str = Field(description="The name of the tool")
|
|
13
12
|
description: str = Field(description="A description of what the tool does")
|
|
14
13
|
args_schema: Type[BaseModel]
|
|
15
|
-
skill_store: SkillStoreABC = Field(
|
|
16
|
-
description="The skill store for persisting data"
|
|
17
|
-
)
|
|
18
14
|
|
|
19
15
|
@property
|
|
20
16
|
def category(self) -> str:
|