intentkit 0.6.9.dev2__py3-none-any.whl → 0.6.10.dev1__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/graph.py +17 -2
- intentkit/core/engine.py +29 -30
- intentkit/core/node.py +10 -20
- intentkit/models/agent.py +3 -0
- intentkit/models/chat.py +9 -1
- intentkit/skills/acolyt/ask.py +2 -5
- intentkit/skills/acolyt/base.py +16 -6
- intentkit/skills/aixbt/__init__.py +3 -7
- intentkit/skills/aixbt/projects.py +12 -36
- intentkit/skills/allora/base.py +16 -6
- intentkit/skills/allora/price.py +2 -4
- intentkit/skills/base.py +8 -1
- intentkit/skills/carv/base.py +12 -10
- intentkit/skills/carv/fetch_news.py +90 -92
- intentkit/skills/carv/onchain_query.py +162 -164
- intentkit/skills/carv/token_info_and_price.py +108 -110
- intentkit/skills/chainlist/chain_lookup.py +1 -2
- intentkit/skills/common/current_time.py +1 -2
- intentkit/skills/cookiefun/base.py +20 -12
- intentkit/skills/cookiefun/get_account_details.py +1 -3
- intentkit/skills/cookiefun/get_account_feed.py +1 -3
- intentkit/skills/cookiefun/get_account_smart_followers.py +1 -3
- intentkit/skills/cookiefun/get_sectors.py +2 -3
- intentkit/skills/cookiefun/search_accounts.py +1 -3
- intentkit/skills/cryptocompare/fetch_news.py +3 -4
- intentkit/skills/cryptocompare/fetch_price.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_exchanges.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_market_cap.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_volume.py +3 -4
- intentkit/skills/cryptocompare/fetch_trading_signals.py +3 -4
- intentkit/skills/cryptopanic/base.py +13 -9
- intentkit/skills/cryptopanic/fetch_crypto_news.py +150 -153
- intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +133 -136
- intentkit/skills/dapplooker/base.py +16 -6
- intentkit/skills/dapplooker/dapplooker_token_data.py +2 -4
- intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +2 -3
- intentkit/skills/defillama/coins/fetch_block.py +2 -3
- intentkit/skills/defillama/coins/fetch_current_prices.py +2 -5
- intentkit/skills/defillama/coins/fetch_first_price.py +2 -5
- intentkit/skills/defillama/coins/fetch_historical_prices.py +2 -3
- intentkit/skills/defillama/coins/fetch_price_chart.py +2 -5
- intentkit/skills/defillama/coins/fetch_price_percentage.py +2 -5
- intentkit/skills/defillama/fees/fetch_fees_overview.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +2 -3
- intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +2 -5
- intentkit/skills/defillama/tvl/fetch_chains.py +2 -3
- intentkit/skills/defillama/tvl/fetch_historical_tvl.py +2 -3
- intentkit/skills/defillama/tvl/fetch_protocol.py +2 -5
- intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +2 -5
- intentkit/skills/defillama/tvl/fetch_protocols.py +2 -3
- intentkit/skills/defillama/volumes/fetch_dex_overview.py +2 -3
- intentkit/skills/defillama/volumes/fetch_dex_summary.py +2 -5
- intentkit/skills/defillama/volumes/fetch_options_overview.py +2 -3
- intentkit/skills/defillama/yields/fetch_pool_chart.py +2 -5
- intentkit/skills/defillama/yields/fetch_pools.py +2 -3
- intentkit/skills/dune_analytics/base.py +15 -9
- intentkit/skills/dune_analytics/fetch_kol_buys.py +125 -128
- intentkit/skills/dune_analytics/fetch_nation_metrics.py +234 -237
- intentkit/skills/elfa/base.py +16 -6
- intentkit/skills/elfa/mention.py +2 -7
- intentkit/skills/elfa/stats.py +2 -6
- intentkit/skills/elfa/tokens.py +1 -4
- intentkit/skills/enso/base.py +25 -13
- intentkit/skills/enso/best_yield.py +1 -4
- intentkit/skills/enso/networks.py +2 -5
- intentkit/skills/enso/prices.py +1 -5
- intentkit/skills/enso/route.py +2 -5
- intentkit/skills/enso/tokens.py +1 -4
- intentkit/skills/enso/wallet.py +3 -9
- intentkit/skills/firecrawl/base.py +16 -6
- intentkit/skills/firecrawl/clear.py +1 -3
- intentkit/skills/firecrawl/crawl.py +7 -8
- intentkit/skills/firecrawl/query.py +7 -9
- intentkit/skills/firecrawl/scrape.py +7 -8
- intentkit/skills/github/github_search.py +1 -3
- intentkit/skills/heurist/base.py +15 -0
- intentkit/skills/heurist/image_generation_animagine_xl.py +3 -4
- intentkit/skills/heurist/image_generation_arthemy_comics.py +3 -4
- intentkit/skills/heurist/image_generation_arthemy_real.py +3 -4
- intentkit/skills/heurist/image_generation_braindance.py +3 -4
- intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +3 -4
- intentkit/skills/heurist/image_generation_flux_1_dev.py +3 -4
- intentkit/skills/heurist/image_generation_sdxl.py +3 -4
- intentkit/skills/http/get.py +0 -2
- intentkit/skills/http/post.py +0 -2
- intentkit/skills/http/put.py +0 -2
- intentkit/skills/lifi/token_execute.py +1 -3
- intentkit/skills/lifi/token_quote.py +0 -2
- intentkit/skills/moralis/base.py +15 -1
- intentkit/skills/nation/nft_check.py +2 -5
- intentkit/skills/openai/base.py +14 -5
- intentkit/skills/openai/dalle_image_generation.py +6 -5
- intentkit/skills/openai/gpt_image_generation.py +6 -5
- intentkit/skills/openai/gpt_image_to_image.py +6 -5
- intentkit/skills/openai/image_to_text.py +6 -6
- intentkit/skills/portfolio/base.py +4 -3
- intentkit/skills/portfolio/token_balances.py +2 -4
- intentkit/skills/portfolio/wallet_approvals.py +2 -4
- intentkit/skills/portfolio/wallet_defi_positions.py +3 -4
- intentkit/skills/portfolio/wallet_history.py +2 -4
- intentkit/skills/portfolio/wallet_net_worth.py +2 -4
- intentkit/skills/portfolio/wallet_nfts.py +2 -4
- intentkit/skills/portfolio/wallet_profitability.py +2 -4
- intentkit/skills/portfolio/wallet_profitability_summary.py +2 -4
- intentkit/skills/portfolio/wallet_stats.py +2 -4
- intentkit/skills/portfolio/wallet_swaps.py +2 -4
- intentkit/skills/slack/base.py +18 -0
- intentkit/skills/slack/get_channel.py +3 -4
- intentkit/skills/slack/get_message.py +3 -4
- intentkit/skills/slack/schedule_message.py +3 -4
- intentkit/skills/slack/send_message.py +3 -4
- intentkit/skills/supabase/delete_data.py +3 -6
- intentkit/skills/supabase/fetch_data.py +3 -6
- intentkit/skills/supabase/insert_data.py +3 -6
- intentkit/skills/supabase/invoke_function.py +3 -6
- intentkit/skills/supabase/update_data.py +3 -6
- intentkit/skills/supabase/upsert_data.py +3 -6
- intentkit/skills/system/add_autonomous_task.py +1 -3
- intentkit/skills/system/delete_autonomous_task.py +1 -3
- intentkit/skills/system/edit_autonomous_task.py +1 -3
- intentkit/skills/system/list_autonomous_tasks.py +1 -3
- intentkit/skills/system/read_agent_api_key.py +2 -3
- intentkit/skills/system/regenerate_agent_api_key.py +2 -5
- intentkit/skills/tavily/base.py +14 -5
- intentkit/skills/tavily/tavily_extract.py +7 -8
- intentkit/skills/tavily/tavily_search.py +11 -9
- intentkit/skills/token/base.py +4 -6
- intentkit/skills/token/erc20_transfers.py +2 -4
- intentkit/skills/token/token_analytics.py +2 -4
- intentkit/skills/token/token_price.py +2 -4
- intentkit/skills/token/token_search.py +2 -4
- intentkit/skills/twitter/base.py +41 -0
- intentkit/skills/twitter/follow_user.py +4 -4
- intentkit/skills/twitter/get_mentions.py +4 -4
- intentkit/skills/twitter/get_timeline.py +4 -4
- intentkit/skills/twitter/get_user_by_username.py +4 -4
- intentkit/skills/twitter/get_user_tweets.py +4 -4
- intentkit/skills/twitter/like_tweet.py +4 -4
- intentkit/skills/twitter/post_tweet.py +3 -4
- intentkit/skills/twitter/reply_tweet.py +3 -4
- intentkit/skills/twitter/retweet.py +4 -4
- intentkit/skills/twitter/search_tweets.py +4 -4
- intentkit/skills/unrealspeech/base.py +16 -0
- intentkit/skills/unrealspeech/text_to_speech.py +4 -4
- intentkit/skills/venice_audio/base.py +11 -9
- intentkit/skills/venice_audio/venice_audio.py +238 -240
- intentkit/skills/venice_image/base.py +23 -19
- intentkit/skills/venice_image/image_enhance/image_enhance.py +78 -80
- intentkit/skills/venice_image/image_generation/image_generation_base.py +115 -117
- intentkit/skills/venice_image/image_upscale/image_upscale.py +88 -90
- intentkit/skills/venice_image/image_vision/image_vision.py +98 -100
- intentkit/skills/web_scraper/document_indexer.py +3 -5
- intentkit/skills/web_scraper/scrape_and_index.py +14 -17
- intentkit/skills/web_scraper/website_indexer.py +8 -10
- intentkit/skills/xmtp/README.md +110 -0
- intentkit/skills/xmtp/__init__.py +82 -0
- intentkit/skills/xmtp/base.py +13 -0
- intentkit/skills/xmtp/schema.json +41 -0
- intentkit/skills/xmtp/transfer.py +170 -0
- intentkit/skills/xmtp/xmtp.svg +26 -0
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/METADATA +3 -3
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/RECORD +168 -162
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/WHEEL +0 -0
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,7 +9,7 @@ from langchain.tools.base import ToolException
|
|
|
9
9
|
from pydantic import BaseModel, Field
|
|
10
10
|
|
|
11
11
|
from intentkit.abstracts.skill import SkillStoreABC
|
|
12
|
-
from intentkit.skills.base import IntentKitSkill
|
|
12
|
+
from intentkit.skills.base import IntentKitSkill
|
|
13
13
|
|
|
14
14
|
base_url = "https://cryptopanic.com/api/v1/posts/"
|
|
15
15
|
|
|
@@ -26,24 +26,28 @@ class CryptopanicBaseTool(IntentKitSkill):
|
|
|
26
26
|
args_schema: Type[BaseModel]
|
|
27
27
|
skill_store: SkillStoreABC = Field(description="Skill store for data persistence")
|
|
28
28
|
|
|
29
|
-
def get_api_key(self
|
|
29
|
+
def get_api_key(self) -> str:
|
|
30
30
|
"""Retrieve the CryptoPanic API key from context.
|
|
31
31
|
|
|
32
|
-
Args:
|
|
33
|
-
context: Skill context containing configuration.
|
|
34
|
-
|
|
35
32
|
Returns:
|
|
36
33
|
API key string.
|
|
37
34
|
|
|
38
35
|
Raises:
|
|
39
36
|
ToolException: If the API key is not found.
|
|
40
37
|
"""
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
api_key = skill_config.get("api_key")
|
|
43
|
+
if api_key:
|
|
44
|
+
return api_key
|
|
45
|
+
else:
|
|
46
|
+
raise ToolException("No api_key found in agent_owner configuration")
|
|
47
|
+
else:
|
|
43
48
|
raise ToolException(
|
|
44
|
-
"
|
|
49
|
+
f"Invalid API key provider: {api_key_provider}. Only 'agent_owner' is supported for CryptoPanic."
|
|
45
50
|
)
|
|
46
|
-
return api_key
|
|
47
51
|
|
|
48
52
|
@property
|
|
49
53
|
def category(self) -> str:
|
|
@@ -1,153 +1,150 @@
|
|
|
1
|
-
"""Skill to fetch the latest crypto market news from CryptoPanic API.
|
|
2
|
-
|
|
3
|
-
Fetches all news posts for BTC or ETH, sorted by publication date (newest first).
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from typing import List, Type
|
|
7
|
-
|
|
8
|
-
import httpx
|
|
9
|
-
from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
from intentkit.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
response
|
|
87
|
-
response.
|
|
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
|
-
def _run(self, question: str):
|
|
153
|
-
raise NotImplementedError("Use _arun for async execution")
|
|
1
|
+
"""Skill to fetch the latest crypto market news from CryptoPanic API.
|
|
2
|
+
|
|
3
|
+
Fetches all news posts for BTC or ETH, sorted by publication date (newest first).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import List, Type
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
from pydantic import BaseModel, Field
|
|
10
|
+
|
|
11
|
+
from intentkit.abstracts.skill import SkillStoreABC
|
|
12
|
+
from intentkit.skills.cryptopanic.base import CryptopanicBaseTool
|
|
13
|
+
|
|
14
|
+
SUPPORTED_CURRENCIES = ["BTC", "ETH"]
|
|
15
|
+
BASE_URL = "https://cryptopanic.com/api/v1/posts/"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CryptopanicNewsInput(BaseModel):
|
|
19
|
+
"""Input schema for fetching crypto news."""
|
|
20
|
+
|
|
21
|
+
query: str = Field(description="Query to specify currency (e.g., 'btc news')")
|
|
22
|
+
currency: str = Field(
|
|
23
|
+
default="BTC", description="Currency to fetch news for (BTC or ETH)"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class NewsItem(BaseModel):
|
|
28
|
+
"""Data model for a single news item."""
|
|
29
|
+
|
|
30
|
+
title: str = Field(description="News headline")
|
|
31
|
+
published_at: str = Field(description="Publication timestamp")
|
|
32
|
+
source: str = Field(description="News source domain")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class CryptopanicNewsOutput(BaseModel):
|
|
36
|
+
"""Output schema for fetching crypto news."""
|
|
37
|
+
|
|
38
|
+
currency: str = Field(description="Currency news was fetched for")
|
|
39
|
+
news_items: List[NewsItem] = Field(description="List of news items")
|
|
40
|
+
summary: str = Field(description="Summary of fetched news")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class FetchCryptoNews(CryptopanicBaseTool):
|
|
44
|
+
"""Skill to fetch the latest crypto market news from CryptoPanic API."""
|
|
45
|
+
|
|
46
|
+
name: str = "fetch_crypto_news"
|
|
47
|
+
description: str = (
|
|
48
|
+
"Fetches all crypto market news posts from CryptoPanic for BTC or ETH, "
|
|
49
|
+
"sorted by publication date (newest first). Defaults to BTC."
|
|
50
|
+
)
|
|
51
|
+
args_schema: Type[BaseModel] = CryptopanicNewsInput
|
|
52
|
+
skill_store: SkillStoreABC = Field(description="Skill store for data persistence")
|
|
53
|
+
|
|
54
|
+
async def fetch_news(
|
|
55
|
+
self,
|
|
56
|
+
currency: str,
|
|
57
|
+
api_key: str,
|
|
58
|
+
) -> List[NewsItem]:
|
|
59
|
+
"""Fetch the latest news for a specific currency from CryptoPanic API.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
currency: Currency to fetch news for (BTC or ETH).
|
|
63
|
+
api_key: CryptoPanic API key.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
List of NewsItem objects, sorted by publication date (newest first).
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
ToolException: If the API request fails or data is invalid.
|
|
70
|
+
"""
|
|
71
|
+
from langchain.tools.base import ToolException
|
|
72
|
+
|
|
73
|
+
if currency not in SUPPORTED_CURRENCIES:
|
|
74
|
+
raise ToolException(f"Unsupported currency: {currency}")
|
|
75
|
+
|
|
76
|
+
params = {
|
|
77
|
+
"auth_token": api_key,
|
|
78
|
+
"public": "true",
|
|
79
|
+
"currencies": currency.upper(),
|
|
80
|
+
"sort": "-published_at", # Sort by newest first
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async with httpx.AsyncClient() as client:
|
|
84
|
+
try:
|
|
85
|
+
response = await client.get(BASE_URL, params=params, timeout=10)
|
|
86
|
+
response.raise_for_status()
|
|
87
|
+
data = response.json().get("results", [])
|
|
88
|
+
return [
|
|
89
|
+
NewsItem(
|
|
90
|
+
title=post["title"],
|
|
91
|
+
published_at=post.get("published_at", "Unknown"),
|
|
92
|
+
source=post.get("source", {}).get("domain", "CryptoPanic"),
|
|
93
|
+
)
|
|
94
|
+
for post in data
|
|
95
|
+
]
|
|
96
|
+
except (httpx.RequestError, httpx.HTTPStatusError) as e:
|
|
97
|
+
raise ToolException(f"Error fetching news from CryptoPanic: {e}")
|
|
98
|
+
|
|
99
|
+
async def _arun(
|
|
100
|
+
self,
|
|
101
|
+
query: str = "",
|
|
102
|
+
currency: str = "BTC",
|
|
103
|
+
**kwargs,
|
|
104
|
+
) -> CryptopanicNewsOutput:
|
|
105
|
+
"""Fetch the latest crypto news asynchronously.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
query: Query to specify currency (e.g., 'btc news').
|
|
109
|
+
currency: Currency to fetch news for (defaults to BTC).
|
|
110
|
+
config: Runnable configuration.
|
|
111
|
+
**kwargs: Additional keyword arguments.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
CryptopanicNewsOutput with news items and summary.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ToolException: If the API key is missing or request fails.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
currency = currency.upper() if currency else "BTC"
|
|
121
|
+
if currency not in SUPPORTED_CURRENCIES:
|
|
122
|
+
currency = "BTC"
|
|
123
|
+
|
|
124
|
+
api_key = self.get_api_key()
|
|
125
|
+
|
|
126
|
+
news_items = await self.fetch_news(currency, api_key)
|
|
127
|
+
|
|
128
|
+
# Deduplicate news items by title
|
|
129
|
+
seen_titles = set()
|
|
130
|
+
unique_news_items = [
|
|
131
|
+
item
|
|
132
|
+
for item in news_items
|
|
133
|
+
if item.title not in seen_titles and not seen_titles.add(item.title)
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
total_items = len(unique_news_items)
|
|
137
|
+
summary = (
|
|
138
|
+
f"Fetched {total_items} unique news posts for {currency}, sorted by recency."
|
|
139
|
+
if unique_news_items
|
|
140
|
+
else f"No news posts found for {currency}."
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
return CryptopanicNewsOutput(
|
|
144
|
+
currency=currency,
|
|
145
|
+
news_items=unique_news_items,
|
|
146
|
+
summary=summary,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def _run(self, question: str):
|
|
150
|
+
raise NotImplementedError("Use _arun for async execution")
|
|
@@ -1,136 +1,133 @@
|
|
|
1
|
-
"""Skill to provide AI-driven insights on crypto market conditions using CryptoPanic news."""
|
|
2
|
-
|
|
3
|
-
from typing import ClassVar, List, Type
|
|
4
|
-
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
from intentkit.
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
from
|
|
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
|
-
headlines = [
|
|
111
|
-
summary = f"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
def _run(self, question: str):
|
|
136
|
-
raise NotImplementedError("Use _arun for async execution")
|
|
1
|
+
"""Skill to provide AI-driven insights on crypto market conditions using CryptoPanic news."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar, List, Type
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
from intentkit.abstracts.skill import SkillStoreABC
|
|
8
|
+
from intentkit.skills.cryptopanic.base import CryptopanicBaseTool
|
|
9
|
+
|
|
10
|
+
SUPPORTED_CURRENCIES = ["BTC", "ETH"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CryptopanicSentimentInput(BaseModel):
|
|
14
|
+
"""Input schema for fetching crypto market insights."""
|
|
15
|
+
|
|
16
|
+
currency: str = Field(default="BTC", description="Currency to analyze (BTC or ETH)")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CryptopanicSentimentOutput(BaseModel):
|
|
20
|
+
"""Output schema for crypto market insights."""
|
|
21
|
+
|
|
22
|
+
currency: str = Field(description="Currency analyzed")
|
|
23
|
+
total_posts: int = Field(description="Number of news items analyzed")
|
|
24
|
+
headlines: list[str] = Field(description="List of news headlines")
|
|
25
|
+
prompt: str = Field(description="Formatted prompt for LLM insights")
|
|
26
|
+
summary: str = Field(description="Summary of analysis process")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CryptopanicNewsOutput(BaseModel):
|
|
30
|
+
"""Output schema for fetching crypto news (used internally)."""
|
|
31
|
+
|
|
32
|
+
currency: str = Field(description="Currency news was fetched for")
|
|
33
|
+
news_items: List[BaseModel] = Field(description="List of news items")
|
|
34
|
+
summary: str = Field(description="Summary of fetched news")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FetchCryptoSentiment(CryptopanicBaseTool):
|
|
38
|
+
"""Skill to provide AI-driven insights on crypto market conditions using CryptoPanic news."""
|
|
39
|
+
|
|
40
|
+
name: str = "fetch_crypto_sentiment"
|
|
41
|
+
description: str = (
|
|
42
|
+
"Provides AI-driven insights on market conditions for BTC or ETH, including trends, "
|
|
43
|
+
"opportunities, risks, and outlook, based on news fetched from fetch_crypto_news "
|
|
44
|
+
"with all posts sorted by recency. Triggered by 'sentiment' or 'market state' queries. "
|
|
45
|
+
"Defaults to BTC."
|
|
46
|
+
)
|
|
47
|
+
args_schema: Type[BaseModel] = CryptopanicSentimentInput
|
|
48
|
+
skill_store: SkillStoreABC = Field(description="Skill store for data persistence")
|
|
49
|
+
|
|
50
|
+
INSIGHTS_PROMPT: ClassVar[str] = """
|
|
51
|
+
CryptoPanic Headlines for {currency}:
|
|
52
|
+
{headlines}
|
|
53
|
+
|
|
54
|
+
Total Posts: {total_posts}
|
|
55
|
+
Currency: {currency}
|
|
56
|
+
|
|
57
|
+
Based on these headlines, provide AI-driven insights into the market conditions for {currency}.
|
|
58
|
+
Summarize key trends (e.g., price movements, adoption, network developments) inferred from the news.
|
|
59
|
+
Identify significant opportunities (e.g., growth potential) and risks (e.g., negative sentiment, competition).
|
|
60
|
+
Classify the overall market outlook as Bullish, Bearish and provide opinion on wether to buy, sell or hold.
|
|
61
|
+
Conclude with a short-term outlook for {currency}. Provide a concise, professional analysis without headings.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
async def _arun(
|
|
65
|
+
self,
|
|
66
|
+
currency: str = "BTC",
|
|
67
|
+
**kwargs,
|
|
68
|
+
) -> CryptopanicSentimentOutput:
|
|
69
|
+
"""Generate AI-driven market insights asynchronously.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
currency: Currency to analyze (defaults to BTC).
|
|
73
|
+
config: Runnable configuration.
|
|
74
|
+
**kwargs: Additional keyword arguments.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
CryptopanicSentimentOutput with market insights.
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
ToolException: If news fetching fails.
|
|
81
|
+
"""
|
|
82
|
+
from langchain.tools.base import ToolException
|
|
83
|
+
|
|
84
|
+
from intentkit.skills.cryptopanic.fetch_crypto_news import (
|
|
85
|
+
FetchCryptoNews,
|
|
86
|
+
) # Import here to avoid circular import
|
|
87
|
+
|
|
88
|
+
currency = currency.upper() if currency else "BTC"
|
|
89
|
+
if currency not in SUPPORTED_CURRENCIES:
|
|
90
|
+
currency = "BTC"
|
|
91
|
+
|
|
92
|
+
# Instantiate FetchCryptoNews
|
|
93
|
+
news_skill = FetchCryptoNews(skill_store=self.skill_store)
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
news_output: CryptopanicNewsOutput = await news_skill._arun(
|
|
97
|
+
query=f"insights for {currency}",
|
|
98
|
+
currency=currency,
|
|
99
|
+
)
|
|
100
|
+
except Exception as e:
|
|
101
|
+
raise ToolException(f"Failed to fetch news for analysis: {e}")
|
|
102
|
+
|
|
103
|
+
news_items = news_output.news_items
|
|
104
|
+
total_posts = len(news_items)
|
|
105
|
+
|
|
106
|
+
if total_posts == 0:
|
|
107
|
+
headlines = ["No recent news available"]
|
|
108
|
+
summary = f"No news found for {currency} to analyze."
|
|
109
|
+
else:
|
|
110
|
+
headlines = [item.title for item in news_items[:5]] # Limit to 5
|
|
111
|
+
summary = f"Generated insights for {currency} based on {total_posts} news items sorted by recency."
|
|
112
|
+
|
|
113
|
+
# Format headlines as numbered list
|
|
114
|
+
formatted_headlines = "\n".join(
|
|
115
|
+
f"{i + 1}. {headline}" for i, headline in enumerate(headlines)
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
prompt = self.INSIGHTS_PROMPT.format(
|
|
119
|
+
total_posts=total_posts,
|
|
120
|
+
currency=currency,
|
|
121
|
+
headlines=formatted_headlines,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
return CryptopanicSentimentOutput(
|
|
125
|
+
currency=currency,
|
|
126
|
+
total_posts=total_posts,
|
|
127
|
+
headlines=headlines,
|
|
128
|
+
prompt=prompt,
|
|
129
|
+
summary=summary,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def _run(self, question: str):
|
|
133
|
+
raise NotImplementedError("Use _arun for async execution")
|