intentkit 0.6.9.dev2__py3-none-any.whl → 0.6.10.dev2__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.

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