intentkit 0.6.7.dev7__py3-none-any.whl → 0.6.7.dev9__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/config/config.py +1 -0
- intentkit/models/db.py +8 -4
- intentkit/skills/elfa/README.md +91 -39
- intentkit/skills/elfa/__init__.py +1 -10
- intentkit/skills/elfa/base.py +1 -1
- intentkit/skills/elfa/mention.py +143 -424
- intentkit/skills/elfa/schema.json +1 -17
- intentkit/skills/elfa/stats.py +53 -86
- intentkit/skills/elfa/tokens.py +76 -80
- intentkit/skills/elfa/utils.py +129 -0
- intentkit/skills/twitter/get_mentions.py +1 -1
- intentkit/skills/twitter/get_timeline.py +1 -1
- intentkit/skills/twitter/get_user_by_username.py +1 -1
- intentkit/skills/twitter/get_user_tweets.py +1 -1
- intentkit/skills/twitter/search_tweets.py +1 -1
- {intentkit-0.6.7.dev7.dist-info → intentkit-0.6.7.dev9.dist-info}/METADATA +1 -1
- {intentkit-0.6.7.dev7.dist-info → intentkit-0.6.7.dev9.dist-info}/RECORD +20 -19
- {intentkit-0.6.7.dev7.dist-info → intentkit-0.6.7.dev9.dist-info}/WHEEL +0 -0
- {intentkit-0.6.7.dev7.dist-info → intentkit-0.6.7.dev9.dist-info}/licenses/LICENSE +0 -0
intentkit/__init__.py
CHANGED
intentkit/config/config.py
CHANGED
|
@@ -59,6 +59,7 @@ class Config:
|
|
|
59
59
|
}
|
|
60
60
|
# ==== this part can be load from env or aws secrets manager
|
|
61
61
|
self.db["auto_migrate"] = self.load("DB_AUTO_MIGRATE", "true") == "true"
|
|
62
|
+
self.db["pool_size"] = int(self.load("DB_POOL_SIZE", "3"))
|
|
62
63
|
self.debug = self.load("DEBUG") == "true"
|
|
63
64
|
self.debug_checkpoint = (
|
|
64
65
|
self.load("DEBUG_CHECKPOINT", "false") == "true"
|
intentkit/models/db.py
CHANGED
|
@@ -23,6 +23,9 @@ async def init_db(
|
|
|
23
23
|
auto_migrate: Annotated[
|
|
24
24
|
bool, Field(default=True, description="Whether to run migrations automatically")
|
|
25
25
|
],
|
|
26
|
+
pool_size: Annotated[
|
|
27
|
+
int, Field(default=3, description="Database connection pool size")
|
|
28
|
+
] = 3,
|
|
26
29
|
) -> None:
|
|
27
30
|
"""Initialize the database and handle schema updates.
|
|
28
31
|
|
|
@@ -33,6 +36,7 @@ async def init_db(
|
|
|
33
36
|
dbname: Database name
|
|
34
37
|
port: Database port (default: 5432)
|
|
35
38
|
auto_migrate: Whether to run migrations automatically (default: True)
|
|
39
|
+
pool_size: Database connection pool size (default: 3)
|
|
36
40
|
"""
|
|
37
41
|
global engine, _langgraph_checkpointer
|
|
38
42
|
# Initialize psycopg pool and AsyncPostgresSaver if not already initialized
|
|
@@ -43,8 +47,8 @@ async def init_db(
|
|
|
43
47
|
)
|
|
44
48
|
pool = AsyncConnectionPool(
|
|
45
49
|
conninfo=conn_string,
|
|
46
|
-
min_size=
|
|
47
|
-
max_size=
|
|
50
|
+
min_size=pool_size,
|
|
51
|
+
max_size=pool_size * 2,
|
|
48
52
|
timeout=60,
|
|
49
53
|
max_idle=30 * 60,
|
|
50
54
|
)
|
|
@@ -60,8 +64,8 @@ async def init_db(
|
|
|
60
64
|
if host:
|
|
61
65
|
engine = create_async_engine(
|
|
62
66
|
f"postgresql+asyncpg://{username}:{quote_plus(password)}@{host}:{port}/{dbname}",
|
|
63
|
-
pool_size=
|
|
64
|
-
max_overflow=
|
|
67
|
+
pool_size=pool_size,
|
|
68
|
+
max_overflow=pool_size * 2, # Set overflow to 2x pool size
|
|
65
69
|
pool_timeout=60, # Increase timeout
|
|
66
70
|
pool_pre_ping=True, # Enable connection health checks
|
|
67
71
|
pool_recycle=3600, # Recycle connections after 1 hour
|
intentkit/skills/elfa/README.md
CHANGED
|
@@ -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
|
-
"
|
|
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: "
|
|
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
|
|
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: "
|
|
47
|
-
- `
|
|
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
|
|
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
|
-
|
|
76
|
+
**Endpoint**: `v2/data/keyword-mentions` - Breaking Changes
|
|
73
77
|
|
|
74
78
|
**Example Prompts:**
|
|
75
79
|
```
|
|
76
|
-
"
|
|
77
|
-
"
|
|
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:**
|
|
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
|
-
###
|
|
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 == "
|
|
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,
|
intentkit/skills/elfa/base.py
CHANGED
|
@@ -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):
|