intentkit 0.6.7.dev6__py3-none-any.whl → 0.6.7.dev8__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 CHANGED
@@ -3,7 +3,7 @@
3
3
  A powerful platform for building AI agents with blockchain and cryptocurrency capabilities.
4
4
  """
5
5
 
6
- __version__ = "0.6.7-dev6"
6
+ __version__ = "0.6.7-dev8"
7
7
  __author__ = "hyacinthus"
8
8
  __email__ = "hyacinthus@gmail.com"
9
9
 
@@ -179,3 +179,20 @@ class SkillStoreABC(ABC):
179
179
  task_id: ID of the task to delete
180
180
  """
181
181
  pass
182
+
183
+ @staticmethod
184
+ @abstractmethod
185
+ async def update_autonomous_task(
186
+ agent_id: str, task_id: str, task_updates: dict
187
+ ) -> AgentAutonomous:
188
+ """Update an autonomous task for an agent.
189
+
190
+ Args:
191
+ agent_id: ID of the agent
192
+ task_id: ID of the task to update
193
+ task_updates: Dictionary containing fields to update
194
+
195
+ Returns:
196
+ AgentAutonomous: The updated task
197
+ """
198
+ pass
intentkit/core/agent.py CHANGED
@@ -396,3 +396,69 @@ async def delete_autonomous_task(agent_id: str, task_id: str) -> None:
396
396
  await session.commit()
397
397
 
398
398
  logger.info(f"Deleted autonomous task {task_id} from agent {agent_id}")
399
+
400
+
401
+ async def update_autonomous_task(
402
+ agent_id: str, task_id: str, task_updates: dict
403
+ ) -> AgentAutonomous:
404
+ """
405
+ Update an autonomous task for an agent.
406
+
407
+ Args:
408
+ agent_id: ID of the agent
409
+ task_id: ID of the task to update
410
+ task_updates: Dictionary containing fields to update
411
+
412
+ Returns:
413
+ AgentAutonomous: The updated task
414
+
415
+ Raises:
416
+ IntentKitAPIError: If agent is not found or task is not found
417
+ """
418
+ agent = await Agent.get(agent_id)
419
+ if not agent:
420
+ raise IntentKitAPIError(
421
+ 400, "AgentNotFound", f"Agent with ID {agent_id} does not exist."
422
+ )
423
+
424
+ # Get current autonomous tasks
425
+ current_tasks: List[AgentAutonomous] = agent.autonomous or []
426
+
427
+ # Find and update the task
428
+ task_found = False
429
+ updated_tasks: List[AgentAutonomous] = []
430
+ updated_task = None
431
+
432
+ for task_data in current_tasks:
433
+ if task_data.id == task_id:
434
+ task_found = True
435
+ # Create a dictionary with current task data
436
+ task_dict = task_data.model_dump()
437
+ # Update with provided fields
438
+ task_dict.update(task_updates)
439
+ # Create new AgentAutonomous instance
440
+ updated_task = AgentAutonomous.model_validate(task_dict)
441
+ updated_tasks.append(updated_task)
442
+ else:
443
+ updated_tasks.append(task_data)
444
+
445
+ if not task_found:
446
+ raise IntentKitAPIError(
447
+ 404, "TaskNotFound", f"Autonomous task with ID {task_id} not found."
448
+ )
449
+
450
+ # Convert all AgentAutonomous objects to dictionaries for JSON serialization
451
+ serializable_tasks = [task_item.model_dump() for task_item in updated_tasks]
452
+
453
+ # Update the agent in the database
454
+ async with get_session() as session:
455
+ update_stmt = (
456
+ update(AgentTable)
457
+ .where(AgentTable.id == agent_id)
458
+ .values(autonomous=serializable_tasks)
459
+ )
460
+ await session.execute(update_stmt)
461
+ await session.commit()
462
+
463
+ logger.info(f"Updated autonomous task {task_id} for agent {agent_id}")
464
+ return updated_task
intentkit/core/skill.py CHANGED
@@ -11,6 +11,9 @@ from intentkit.core.agent import (
11
11
  from intentkit.core.agent import (
12
12
  list_autonomous_tasks as _list_autonomous_tasks,
13
13
  )
14
+ from intentkit.core.agent import (
15
+ update_autonomous_task as _update_autonomous_task,
16
+ )
14
17
  from intentkit.models.agent import Agent, AgentAutonomous
15
18
  from intentkit.models.agent_data import AgentData, AgentQuota
16
19
  from intentkit.models.skill import (
@@ -177,5 +180,21 @@ class SkillStore(SkillStoreABC):
177
180
  """
178
181
  await _delete_autonomous_task(agent_id, task_id)
179
182
 
183
+ @staticmethod
184
+ async def update_autonomous_task(
185
+ agent_id: str, task_id: str, task_updates: dict
186
+ ) -> AgentAutonomous:
187
+ """Update an autonomous task for an agent.
188
+
189
+ Args:
190
+ agent_id: ID of the agent
191
+ task_id: ID of the task to update
192
+ task_updates: Dictionary containing fields to update
193
+
194
+ Returns:
195
+ AgentAutonomous: The updated task
196
+ """
197
+ return await _update_autonomous_task(agent_id, task_id, task_updates)
198
+
180
199
 
181
200
  skill_store = SkillStore()
@@ -1,6 +1,12 @@
1
1
  # Elfa Skills - Social Media Intelligence
2
2
 
3
- Integration with [Elfa AI API](https://api.elfa.ai) providing real-time social media data analysis and processing capabilities for crypto and stock market sentiment tracking.
3
+ Integration with [Elfa AI API v2](https://api.elfa.ai/v2) providing real-time social media data analysis and processing capabilities for crypto and stock market sentiment tracking.
4
+
5
+ **Important: V2 API Changes**
6
+ - **No Raw Content**: V2 API removes raw tweet content for platform compliance
7
+ - **Sanitized Data**: Returns engagement metrics, timestamps, and account metadata only
8
+ - **New Endpoints**: Updated endpoints with consistent response format
9
+ - **Enhanced Pagination**: Different pagination patterns for search vs aggregation endpoints
4
10
 
5
11
  ## Setup
6
12
 
@@ -15,86 +21,132 @@ ELFA_API_KEY=your_elfa_api_key_here
15
21
 
16
22
  Ranks the most discussed tokens based on smart mentions count for a given period, updated every 5 minutes.
17
23
 
24
+ **Endpoint**: `v2/aggregations/trending-tokens` - Direct Migration
25
+
18
26
  **Example Prompts:**
19
27
  ```
20
28
  "What are the trending crypto tokens in the last 24 hours?"
21
- "Show me the most discussed tokens today with at least 10 mentions"
22
- "Get trending tokens for the past week"
23
- "Which tokens are gaining attention on social media?"
29
+ "Get trending tokens with minimum 50 mentions in the past week"
24
30
  ```
25
31
 
26
32
  **Parameters:**
27
- - `timeWindow`: "1h", "24h", "7d" (default: "24h")
33
+ - `timeWindow`: "30m", "1h", "4h", "24h", "7d", "30d" (default: "7d")
34
+ - `page`: Page number for pagination (default: 1)
35
+ - `pageSize`: Number of items per page (default: 50)
28
36
  - `minMentions`: Minimum mentions required (default: 5)
29
37
 
38
+ **V2 Changes:**
39
+ - Same functionality and parameters
40
+ - Enhanced response format with metadata
41
+ - Uses page+pageSize pagination for aggregations
42
+
30
43
  ---
31
44
 
32
45
  ### 2. Get Top Mentions (`get_top_mentions`)
33
46
 
34
47
  Queries tweets mentioning a specific stock/crypto ticker, ranked by view count for market sentiment analysis.
35
48
 
49
+ **Endpoint**: `v2/data/top-mentions` - Breaking Changes
50
+
36
51
  **Example Prompts:**
37
52
  ```
38
53
  "Get the top mentions for Bitcoin in the last 24 hours"
39
- "Show me the most viewed tweets about $ETH today"
40
- "What are people saying about TSLA stock on Twitter?"
41
- "Find viral tweets mentioning $SOL with account details"
54
+ "Show me engagement metrics for tweets about $ETH today"
42
55
  ```
43
56
 
44
57
  **Parameters:**
45
- - `ticker`: Stock/crypto symbol (e.g., "BTC", "$ETH", "AAPL")
46
- - `timeWindow`: "24h", "7d" (default: "24h")
47
- - `includeAccountDetails`: Include account info (default: false)
58
+ - `ticker`: Stock/crypto symbol (e.g., "BTC", "$ETH", "AAPL") - required
59
+ - `timeWindow`: "1h", "24h", "7d" (default: "1h")
60
+ - `page`: Page number for pagination (default: 1)
61
+ - `pageSize`: Number of items per page (default: 10)
62
+
63
+ **V2 Changes:**
64
+ - **Removed**: Raw tweet content/text
65
+ - **Removed**: `includeAccountDetails` parameter (always included)
66
+ - **Preserved**: Engagement metrics (view_count, like_count, etc.)
67
+ - **Preserved**: Account information and verification status
68
+ - **Enhanced**: Account tags (e.g., "smart" accounts)
48
69
 
49
70
  ---
50
71
 
51
72
  ### 3. Search Mentions (`search_mentions`)
52
73
 
53
- Searches tweets mentioning up to 5 keywords. Can access 30 days of recent data (updated every 5 minutes) or 6 months of historical data.
54
-
55
- **Example Prompts:**
56
- ```
57
- "Search for tweets mentioning 'DeFi, NFT, blockchain'"
58
- "Find recent mentions of 'AI, artificial intelligence, machine learning'"
59
- "Search historical tweets about 'bitcoin, cryptocurrency' from last month"
60
- "Look for discussions about 'climate change, renewable energy'"
61
- ```
62
-
63
- **Parameters:**
64
- - `keywords`: Up to 5 keywords (comma-separated, phrases accepted)
65
- - `from_`: Start timestamp (default: 24 hours ago)
66
- - `to`: End timestamp (default: yesterday)
67
-
68
- ---
69
-
70
- ### 4. Get Mentions (`get_mentions`)
74
+ Searches tweets mentioning up to 5 keywords or from specific accounts with sanitized engagement data.
71
75
 
72
- Retrieves hourly-updated tweets from "smart accounts" (influential accounts) that have received at least 10 interactions.
76
+ **Endpoint**: `v2/data/keyword-mentions` - Breaking Changes
73
77
 
74
78
  **Example Prompts:**
75
79
  ```
76
- "Get the latest mentions from smart accounts"
77
- "Show me recent tweets from influential crypto accounts"
78
- "What are the smart accounts talking about?"
79
- "Get the latest buzz from verified influencers"
80
+ "Search for engagement metrics of tweets mentioning 'DeFi, NFT, blockchain'"
81
+ "Find tweets from account 'elonmusk' about cryptocurrency"
80
82
  ```
81
83
 
82
- **Parameters:** None (uses default limits)
84
+ **Parameters:**
85
+ - `keywords`: Up to 5 keywords (comma-separated, phrases accepted) - optional if accountName provided
86
+ - `accountName`: Account username to filter by - optional if keywords provided
87
+ - `timeWindow`: Time window for search (default: "7d")
88
+ - `limit`: Number of results to return, max 30 (default: 20)
89
+ - `searchType`: Type of search - "and" or "or" (default: "or")
90
+ - `cursor`: Cursor for pagination (optional)
91
+
92
+ **V2 Changes:**
93
+ - **Removed**: Raw tweet content/text
94
+ - **Preserved**: Engagement metrics and sentiment analysis
95
+ - **Enhanced**: Account filtering with `accountName` parameter
96
+ - **Updated**: Uses limit+cursor pagination for search
97
+ - **Added**: Account tags and metadata
83
98
 
84
99
  ---
85
100
 
86
- ### 5. Get Smart Stats (`get_smart_stats`)
101
+ ### 4. Get Smart Stats (`get_smart_stats`)
87
102
 
88
103
  Retrieves key social media metrics for a specific username including engagement ratios and smart following count.
89
104
 
105
+ **Endpoint**: `v2/account/smart-stats` - Direct Migration
106
+
90
107
  **Example Prompts:**
91
108
  ```
92
109
  "Get smart stats for @elonmusk"
93
110
  "Analyze the social metrics for username 'VitalikButerin'"
94
- "Show me engagement stats for @cz_binance"
95
- "What are the social media metrics for @jack?"
96
111
  ```
97
112
 
98
113
  **Parameters:**
99
- - `username`: Twitter username (with or without @)
114
+ - `username`: Twitter username (with or without @) - required
115
+
116
+ **V2 Changes:**
117
+ - Same functionality and parameters
118
+ - Consistent response format with metadata
119
+
120
+ ## V2 Response Format
121
+
122
+ All V2 endpoints return a consistent format:
123
+
124
+ ```json
125
+ {
126
+ "success": boolean,
127
+ "data": [...], // Array or object with actual data
128
+ "metadata": { // Pagination and additional info
129
+ "total": number,
130
+ "page": number,
131
+ "pageSize": number,
132
+ "cursor": "string" // For search endpoints
133
+ }
134
+ }
135
+ ```
136
+
137
+ ## Migration Notes
138
+
139
+ ### What's Removed in V2:
140
+ - Raw tweet content/text (compliance requirement)
141
+ - Direct access to tweet body/message content
142
+ - `includeAccountDetails` parameter (always included)
143
+ - **Deprecated**: `get_mentions` skill (no v2 equivalent)
144
+
145
+ ### What's Preserved:
146
+ - Engagement metrics (likes, views, reposts, replies)
147
+ - Account information and verification status
148
+ - Timestamps and metadata
149
+ - Sentiment analysis
150
+ - Core functionality for trend analysis
151
+
100
152
 
@@ -7,7 +7,6 @@ from intentkit.abstracts.skill import SkillStoreABC
7
7
  from intentkit.skills.base import SkillConfig, SkillState
8
8
  from intentkit.skills.elfa.base import ElfaBaseTool
9
9
  from intentkit.skills.elfa.mention import (
10
- ElfaGetMentions,
11
10
  ElfaGetTopMentions,
12
11
  ElfaSearchMentions,
13
12
  )
@@ -21,7 +20,6 @@ logger = logging.getLogger(__name__)
21
20
 
22
21
 
23
22
  class SkillStates(TypedDict):
24
- get_mentions: SkillState
25
23
  get_top_mentions: SkillState
26
24
  search_mentions: SkillState
27
25
  get_trending_tokens: SkillState
@@ -83,14 +81,7 @@ def get_elfa_skill(
83
81
  The requested Elfa skill
84
82
  """
85
83
 
86
- if name == "get_mentions":
87
- if name not in _cache:
88
- _cache[name] = ElfaGetMentions(
89
- skill_store=store,
90
- )
91
- return _cache[name]
92
-
93
- elif name == "get_top_mentions":
84
+ if name == "get_top_mentions":
94
85
  if name not in _cache:
95
86
  _cache[name] = ElfaGetTopMentions(
96
87
  skill_store=store,
@@ -5,7 +5,7 @@ from pydantic import BaseModel, Field
5
5
  from intentkit.abstracts.skill import SkillStoreABC
6
6
  from intentkit.skills.base import IntentKitSkill, SkillContext
7
7
 
8
- base_url = "https://api.elfa.ai"
8
+ base_url = "https://api.elfa.ai/v2"
9
9
 
10
10
 
11
11
  class ElfaBaseTool(IntentKitSkill):