intentkit 0.8.11.dev1__py3-none-any.whl → 0.8.12__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 +4 -0
- intentkit/abstracts/skill.py +2 -140
- intentkit/clients/twitter.py +35 -28
- intentkit/core/agent.py +2 -374
- intentkit/core/asset.py +63 -16
- intentkit/core/engine.py +16 -7
- intentkit/core/scheduler.py +8 -8
- intentkit/models/agent.py +109 -94
- intentkit/models/agent_schema.json +6 -9
- intentkit/models/llm.csv +15 -12
- intentkit/models/skill.py +38 -40
- 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 +168 -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 +4 -6
- intentkit/skills/casino/deck_shuffle.py +5 -4
- intentkit/skills/casino/dice_roll.py +1 -2
- intentkit/skills/cdp/__init__.py +0 -5
- intentkit/skills/cdp/base.py +0 -4
- intentkit/skills/cdp/schema.json +1 -17
- 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 +4 -18
- intentkit/skills/cryptocompare/fetch_news.py +1 -1
- intentkit/skills/cryptocompare/fetch_price.py +1 -1
- intentkit/skills/cryptocompare/fetch_top_exchanges.py +1 -1
- intentkit/skills/cryptocompare/fetch_top_market_cap.py +1 -1
- intentkit/skills/cryptocompare/fetch_top_volume.py +1 -1
- intentkit/skills/cryptocompare/fetch_trading_signals.py +1 -1
- 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 +3 -13
- 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/networks.py +1 -6
- intentkit/skills/enso/route.py +4 -8
- intentkit/skills/enso/tokens.py +2 -12
- 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/clear.py +3 -6
- intentkit/skills/firecrawl/crawl.py +10 -9
- intentkit/skills/firecrawl/query.py +3 -1
- intentkit/skills/firecrawl/scrape.py +10 -14
- intentkit/skills/firecrawl/utils.py +39 -31
- 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 +18 -29
- intentkit/skills/twitter/follow_user.py +1 -4
- intentkit/skills/twitter/get_mentions.py +2 -8
- intentkit/skills/twitter/get_timeline.py +3 -10
- intentkit/skills/twitter/get_user_by_username.py +1 -4
- intentkit/skills/twitter/get_user_tweets.py +3 -10
- intentkit/skills/twitter/like_tweet.py +1 -4
- intentkit/skills/twitter/post_tweet.py +3 -5
- intentkit/skills/twitter/reply_tweet.py +3 -5
- intentkit/skills/twitter/retweet.py +1 -4
- intentkit/skills/twitter/search_tweets.py +3 -10
- 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 -10
- intentkit/skills/web_scraper/utils.py +38 -38
- 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.11.dev1.dist-info → intentkit-0.8.12.dist-info}/METADATA +1 -1
- {intentkit-0.8.11.dev1.dist-info → intentkit-0.8.12.dist-info}/RECORD +183 -183
- {intentkit-0.8.11.dev1.dist-info → intentkit-0.8.12.dist-info}/WHEEL +0 -0
- {intentkit-0.8.11.dev1.dist-info → intentkit-0.8.12.dist-info}/licenses/LICENSE +0 -0
|
@@ -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.firecrawl.base import FirecrawlBaseTool
|
|
9
8
|
from intentkit.skills.firecrawl.clear import FirecrawlClearIndexedContent
|
|
@@ -37,7 +36,6 @@ class Config(SkillConfig):
|
|
|
37
36
|
async def get_skills(
|
|
38
37
|
config: "Config",
|
|
39
38
|
is_private: bool,
|
|
40
|
-
store: SkillStoreABC,
|
|
41
39
|
**_,
|
|
42
40
|
) -> list[FirecrawlBaseTool]:
|
|
43
41
|
"""Get all Firecrawl skills.
|
|
@@ -45,7 +43,6 @@ async def get_skills(
|
|
|
45
43
|
Args:
|
|
46
44
|
config: The configuration for Firecrawl skills.
|
|
47
45
|
is_private: Whether to include private skills.
|
|
48
|
-
store: The skill store for persisting data.
|
|
49
46
|
|
|
50
47
|
Returns:
|
|
51
48
|
A list of Firecrawl skills.
|
|
@@ -60,18 +57,16 @@ async def get_skills(
|
|
|
60
57
|
available_skills.append(skill_name)
|
|
61
58
|
|
|
62
59
|
# Get each skill using the cached getter
|
|
63
|
-
return [get_firecrawl_skill(name
|
|
60
|
+
return [get_firecrawl_skill(name) for name in available_skills]
|
|
64
61
|
|
|
65
62
|
|
|
66
63
|
def get_firecrawl_skill(
|
|
67
64
|
name: str,
|
|
68
|
-
store: SkillStoreABC,
|
|
69
65
|
) -> FirecrawlBaseTool:
|
|
70
66
|
"""Get a Firecrawl skill by name.
|
|
71
67
|
|
|
72
68
|
Args:
|
|
73
69
|
name: The name of the skill to get
|
|
74
|
-
store: The skill store for persisting data
|
|
75
70
|
|
|
76
71
|
Returns:
|
|
77
72
|
The requested Firecrawl skill
|
|
@@ -81,27 +76,19 @@ def get_firecrawl_skill(
|
|
|
81
76
|
"""
|
|
82
77
|
if name == "firecrawl_scrape":
|
|
83
78
|
if name not in _cache:
|
|
84
|
-
_cache[name] = FirecrawlScrape(
|
|
85
|
-
skill_store=store,
|
|
86
|
-
)
|
|
79
|
+
_cache[name] = FirecrawlScrape()
|
|
87
80
|
return _cache[name]
|
|
88
81
|
elif name == "firecrawl_crawl":
|
|
89
82
|
if name not in _cache:
|
|
90
|
-
_cache[name] = FirecrawlCrawl(
|
|
91
|
-
skill_store=store,
|
|
92
|
-
)
|
|
83
|
+
_cache[name] = FirecrawlCrawl()
|
|
93
84
|
return _cache[name]
|
|
94
85
|
elif name == "firecrawl_query_indexed_content":
|
|
95
86
|
if name not in _cache:
|
|
96
|
-
_cache[name] = FirecrawlQueryIndexedContent(
|
|
97
|
-
skill_store=store,
|
|
98
|
-
)
|
|
87
|
+
_cache[name] = FirecrawlQueryIndexedContent()
|
|
99
88
|
return _cache[name]
|
|
100
89
|
elif name == "firecrawl_clear_indexed_content":
|
|
101
90
|
if name not in _cache:
|
|
102
|
-
_cache[name] = FirecrawlClearIndexedContent(
|
|
103
|
-
skill_store=store,
|
|
104
|
-
)
|
|
91
|
+
_cache[name] = FirecrawlClearIndexedContent()
|
|
105
92
|
return _cache[name]
|
|
106
93
|
else:
|
|
107
94
|
raise ValueError(f"Unknown Firecrawl skill: {name}")
|
|
@@ -3,7 +3,7 @@ from typing import Type
|
|
|
3
3
|
from langchain_core.tools.base import ToolException
|
|
4
4
|
from pydantic import BaseModel, Field
|
|
5
5
|
|
|
6
|
-
from intentkit.
|
|
6
|
+
from intentkit.config.config import config
|
|
7
7
|
from intentkit.skills.base import IntentKitSkill
|
|
8
8
|
|
|
9
9
|
|
|
@@ -13,9 +13,6 @@ class FirecrawlBaseTool(IntentKitSkill):
|
|
|
13
13
|
name: str = Field(description="The name of the tool")
|
|
14
14
|
description: str = Field(description="A description of what the tool does")
|
|
15
15
|
args_schema: Type[BaseModel]
|
|
16
|
-
skill_store: SkillStoreABC = Field(
|
|
17
|
-
description="The skill store for persisting data"
|
|
18
|
-
)
|
|
19
16
|
|
|
20
17
|
def get_api_key(self) -> str:
|
|
21
18
|
"""Get the Firecrawl API key from configuration."""
|
|
@@ -29,7 +26,7 @@ class FirecrawlBaseTool(IntentKitSkill):
|
|
|
29
26
|
else:
|
|
30
27
|
raise ToolException("No api_key found in agent_owner configuration")
|
|
31
28
|
else:
|
|
32
|
-
return
|
|
29
|
+
return config.firecrawl_api_key
|
|
33
30
|
|
|
34
31
|
@property
|
|
35
32
|
def category(self) -> str:
|
|
@@ -3,6 +3,7 @@ from typing import Type
|
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, Field
|
|
5
5
|
|
|
6
|
+
from intentkit.models.skill import AgentSkillData
|
|
6
7
|
from intentkit.skills.firecrawl.base import FirecrawlBaseTool
|
|
7
8
|
|
|
8
9
|
logger = logging.getLogger(__name__)
|
|
@@ -62,15 +63,11 @@ class FirecrawlClearIndexedContent(FirecrawlBaseTool):
|
|
|
62
63
|
try:
|
|
63
64
|
# Delete vector store data (using web_scraper storage format for compatibility)
|
|
64
65
|
vector_store_key = f"vector_store_{agent_id}"
|
|
65
|
-
await
|
|
66
|
-
agent_id, "web_scraper", vector_store_key
|
|
67
|
-
)
|
|
66
|
+
await AgentSkillData.delete(agent_id, "web_scraper", vector_store_key)
|
|
68
67
|
|
|
69
68
|
# Delete metadata
|
|
70
69
|
metadata_key = f"indexed_urls_{agent_id}"
|
|
71
|
-
await
|
|
72
|
-
agent_id, "web_scraper", metadata_key
|
|
73
|
-
)
|
|
70
|
+
await AgentSkillData.delete(agent_id, "web_scraper", metadata_key)
|
|
74
71
|
|
|
75
72
|
logger.info(
|
|
76
73
|
f"firecrawl_clear: Successfully cleared all indexed content for agent {agent_id}"
|
|
@@ -137,9 +137,8 @@ class FirecrawlCrawl(FirecrawlBaseTool):
|
|
|
137
137
|
"rate_limit_minutes"
|
|
138
138
|
):
|
|
139
139
|
await self.user_rate_limit_by_category(
|
|
140
|
-
context.user_id,
|
|
141
140
|
skill_config["rate_limit_number"],
|
|
142
|
-
skill_config["rate_limit_minutes"],
|
|
141
|
+
skill_config["rate_limit_minutes"] * 60,
|
|
143
142
|
)
|
|
144
143
|
|
|
145
144
|
# Get the API key from the agent's configuration
|
|
@@ -279,6 +278,7 @@ class FirecrawlCrawl(FirecrawlBaseTool):
|
|
|
279
278
|
# Import indexing utilities from firecrawl utils
|
|
280
279
|
from intentkit.skills.firecrawl.utils import (
|
|
281
280
|
FirecrawlMetadataManager,
|
|
281
|
+
FirecrawlVectorStoreManager,
|
|
282
282
|
index_documents,
|
|
283
283
|
)
|
|
284
284
|
|
|
@@ -309,24 +309,25 @@ class FirecrawlCrawl(FirecrawlBaseTool):
|
|
|
309
309
|
# Get agent ID for indexing
|
|
310
310
|
agent_id = context.agent_id
|
|
311
311
|
if agent_id and documents:
|
|
312
|
+
vector_manager = FirecrawlVectorStoreManager()
|
|
313
|
+
|
|
312
314
|
# Index all documents
|
|
313
315
|
total_chunks, was_merged = await index_documents(
|
|
314
316
|
documents,
|
|
315
317
|
agent_id,
|
|
316
|
-
|
|
318
|
+
vector_manager,
|
|
317
319
|
chunk_size,
|
|
318
320
|
chunk_overlap,
|
|
319
321
|
)
|
|
320
322
|
|
|
321
323
|
# Update metadata
|
|
322
|
-
metadata_manager = FirecrawlMetadataManager(
|
|
323
|
-
self.skill_store
|
|
324
|
-
)
|
|
325
324
|
urls = [doc.metadata["source"] for doc in documents]
|
|
326
|
-
new_metadata =
|
|
327
|
-
|
|
325
|
+
new_metadata = (
|
|
326
|
+
FirecrawlMetadataManager.create_url_metadata(
|
|
327
|
+
urls, documents, "firecrawl_crawl"
|
|
328
|
+
)
|
|
328
329
|
)
|
|
329
|
-
await
|
|
330
|
+
await FirecrawlMetadataManager.update_metadata(
|
|
330
331
|
agent_id, new_metadata
|
|
331
332
|
)
|
|
332
333
|
|
|
@@ -62,12 +62,14 @@ class FirecrawlQueryIndexedContent(FirecrawlBaseTool):
|
|
|
62
62
|
# Import query utilities from firecrawl utils
|
|
63
63
|
from intentkit.skills.firecrawl.utils import (
|
|
64
64
|
FirecrawlDocumentProcessor,
|
|
65
|
+
FirecrawlVectorStoreManager,
|
|
65
66
|
query_indexed_content,
|
|
66
67
|
)
|
|
67
68
|
|
|
68
69
|
# Query the indexed content
|
|
70
|
+
vector_manager = FirecrawlVectorStoreManager()
|
|
69
71
|
docs = await query_indexed_content(
|
|
70
|
-
query, agent_id,
|
|
72
|
+
query, agent_id, vector_manager, max_results
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
if not docs:
|
|
@@ -124,9 +124,8 @@ class FirecrawlScrape(FirecrawlBaseTool):
|
|
|
124
124
|
"rate_limit_minutes"
|
|
125
125
|
):
|
|
126
126
|
await self.user_rate_limit_by_category(
|
|
127
|
-
context.user_id,
|
|
128
127
|
skill_config["rate_limit_number"],
|
|
129
|
-
skill_config["rate_limit_minutes"],
|
|
128
|
+
skill_config["rate_limit_minutes"] * 60,
|
|
130
129
|
)
|
|
131
130
|
|
|
132
131
|
# Get the API key from the agent's configuration
|
|
@@ -265,11 +264,8 @@ class FirecrawlScrape(FirecrawlBaseTool):
|
|
|
265
264
|
# Get agent ID for indexing
|
|
266
265
|
agent_id = context.agent_id
|
|
267
266
|
if agent_id:
|
|
268
|
-
# Initialize
|
|
269
|
-
vs_manager = FirecrawlVectorStoreManager(
|
|
270
|
-
metadata_manager = FirecrawlMetadataManager(
|
|
271
|
-
self.skill_store
|
|
272
|
-
)
|
|
267
|
+
# Initialize vector store manager
|
|
268
|
+
vs_manager = FirecrawlVectorStoreManager()
|
|
273
269
|
|
|
274
270
|
# Load existing vector store
|
|
275
271
|
existing_vector_store = await vs_manager.load_vector_store(
|
|
@@ -368,10 +364,8 @@ class FirecrawlScrape(FirecrawlBaseTool):
|
|
|
368
364
|
# Update metadata to track all URLs
|
|
369
365
|
# Get existing metadata to preserve other URLs
|
|
370
366
|
metadata_key = f"indexed_urls_{agent_id}"
|
|
371
|
-
existing_metadata = (
|
|
372
|
-
|
|
373
|
-
agent_id, "firecrawl", metadata_key
|
|
374
|
-
)
|
|
367
|
+
existing_metadata = await self.get_agent_skill_data_raw(
|
|
368
|
+
"firecrawl", metadata_key
|
|
375
369
|
)
|
|
376
370
|
|
|
377
371
|
if existing_metadata and existing_metadata.get("urls"):
|
|
@@ -388,11 +382,13 @@ class FirecrawlScrape(FirecrawlBaseTool):
|
|
|
388
382
|
}
|
|
389
383
|
else:
|
|
390
384
|
# Create new metadata
|
|
391
|
-
updated_metadata =
|
|
392
|
-
|
|
385
|
+
updated_metadata = (
|
|
386
|
+
FirecrawlMetadataManager.create_url_metadata(
|
|
387
|
+
[url], [document], "firecrawl_scrape"
|
|
388
|
+
)
|
|
393
389
|
)
|
|
394
390
|
|
|
395
|
-
await
|
|
391
|
+
await FirecrawlMetadataManager.update_metadata(
|
|
396
392
|
agent_id, updated_metadata
|
|
397
393
|
)
|
|
398
394
|
|
|
@@ -9,7 +9,8 @@ from langchain_community.vectorstores import FAISS
|
|
|
9
9
|
from langchain_core.documents import Document
|
|
10
10
|
from langchain_openai import OpenAIEmbeddings
|
|
11
11
|
|
|
12
|
-
from intentkit.
|
|
12
|
+
from intentkit.config.config import config
|
|
13
|
+
from intentkit.models.skill import AgentSkillData, AgentSkillDataCreate
|
|
13
14
|
|
|
14
15
|
logger = logging.getLogger(__name__)
|
|
15
16
|
|
|
@@ -62,15 +63,20 @@ class FirecrawlDocumentProcessor:
|
|
|
62
63
|
class FirecrawlVectorStoreManager:
|
|
63
64
|
"""Manages vector store operations for Firecrawl content."""
|
|
64
65
|
|
|
65
|
-
def __init__(self,
|
|
66
|
-
self.
|
|
66
|
+
def __init__(self, embedding_api_key: Optional[str] = None):
|
|
67
|
+
self._embedding_api_key = embedding_api_key
|
|
68
|
+
|
|
69
|
+
def _resolve_api_key(self) -> str:
|
|
70
|
+
"""Resolve the API key to use for embeddings."""
|
|
71
|
+
if self._embedding_api_key:
|
|
72
|
+
return self._embedding_api_key
|
|
73
|
+
if config.openai_api_key:
|
|
74
|
+
return config.openai_api_key
|
|
75
|
+
raise ValueError("OpenAI API key not found in system configuration")
|
|
67
76
|
|
|
68
77
|
def create_embeddings(self) -> OpenAIEmbeddings:
|
|
69
78
|
"""Create OpenAI embeddings instance."""
|
|
70
|
-
openai_api_key = self.
|
|
71
|
-
if not openai_api_key:
|
|
72
|
-
raise ValueError("OpenAI API key not found in system configuration")
|
|
73
|
-
|
|
79
|
+
openai_api_key = self._resolve_api_key()
|
|
74
80
|
return OpenAIEmbeddings(
|
|
75
81
|
openai_api_key=openai_api_key, model="text-embedding-3-small"
|
|
76
82
|
)
|
|
@@ -129,7 +135,7 @@ class FirecrawlVectorStoreManager:
|
|
|
129
135
|
"""Load existing vector store for an agent."""
|
|
130
136
|
try:
|
|
131
137
|
vector_store_key = f"vector_store_{agent_id}"
|
|
132
|
-
stored_data = await
|
|
138
|
+
stored_data = await AgentSkillData.get(
|
|
133
139
|
agent_id, "web_scraper", vector_store_key
|
|
134
140
|
)
|
|
135
141
|
|
|
@@ -162,9 +168,13 @@ class FirecrawlVectorStoreManager:
|
|
|
162
168
|
"chunk_overlap": chunk_overlap,
|
|
163
169
|
}
|
|
164
170
|
|
|
165
|
-
|
|
166
|
-
agent_id,
|
|
171
|
+
skill_data = AgentSkillDataCreate(
|
|
172
|
+
agent_id=agent_id,
|
|
173
|
+
skill="web_scraper",
|
|
174
|
+
key=vector_store_key,
|
|
175
|
+
data=storage_data,
|
|
167
176
|
)
|
|
177
|
+
await skill_data.save()
|
|
168
178
|
|
|
169
179
|
except Exception as e:
|
|
170
180
|
logger.error(f"Error saving vector store for agent {agent_id}: {e}")
|
|
@@ -174,11 +184,9 @@ class FirecrawlVectorStoreManager:
|
|
|
174
184
|
class FirecrawlMetadataManager:
|
|
175
185
|
"""Manages metadata for Firecrawl indexed content."""
|
|
176
186
|
|
|
177
|
-
|
|
178
|
-
self.skill_store = skill_store
|
|
179
|
-
|
|
187
|
+
@staticmethod
|
|
180
188
|
def create_url_metadata(
|
|
181
|
-
|
|
189
|
+
urls: List[str], documents: List[Document], source_type: str
|
|
182
190
|
) -> Dict[str, Any]:
|
|
183
191
|
"""Create metadata for indexed URLs."""
|
|
184
192
|
return {
|
|
@@ -188,15 +196,19 @@ class FirecrawlMetadataManager:
|
|
|
188
196
|
"indexed_at": str(len(urls)), # Simple counter
|
|
189
197
|
}
|
|
190
198
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
) -> None:
|
|
199
|
+
@staticmethod
|
|
200
|
+
@staticmethod
|
|
201
|
+
async def update_metadata(agent_id: str, new_metadata: Dict[str, Any]) -> None:
|
|
194
202
|
"""Update metadata for an agent."""
|
|
195
203
|
try:
|
|
196
204
|
metadata_key = f"indexed_urls_{agent_id}"
|
|
197
|
-
|
|
198
|
-
agent_id,
|
|
205
|
+
skill_data = AgentSkillDataCreate(
|
|
206
|
+
agent_id=agent_id,
|
|
207
|
+
skill="web_scraper",
|
|
208
|
+
key=metadata_key,
|
|
209
|
+
data=new_metadata,
|
|
199
210
|
)
|
|
211
|
+
await skill_data.save()
|
|
200
212
|
except Exception as e:
|
|
201
213
|
logger.error(f"Error updating metadata for agent {agent_id}: {e}")
|
|
202
214
|
raise
|
|
@@ -205,7 +217,7 @@ class FirecrawlMetadataManager:
|
|
|
205
217
|
async def index_documents(
|
|
206
218
|
documents: List[Document],
|
|
207
219
|
agent_id: str,
|
|
208
|
-
|
|
220
|
+
vector_manager: FirecrawlVectorStoreManager,
|
|
209
221
|
chunk_size: int = 1000,
|
|
210
222
|
chunk_overlap: int = 200,
|
|
211
223
|
) -> Tuple[int, bool]:
|
|
@@ -215,7 +227,7 @@ async def index_documents(
|
|
|
215
227
|
Args:
|
|
216
228
|
documents: List of documents to index
|
|
217
229
|
agent_id: Agent ID for storage
|
|
218
|
-
|
|
230
|
+
vector_manager: Vector store manager
|
|
219
231
|
chunk_size: Size of text chunks
|
|
220
232
|
chunk_overlap: Overlap between chunks
|
|
221
233
|
|
|
@@ -224,8 +236,6 @@ async def index_documents(
|
|
|
224
236
|
"""
|
|
225
237
|
try:
|
|
226
238
|
# Initialize managers
|
|
227
|
-
vs_manager = FirecrawlVectorStoreManager(skill_store)
|
|
228
|
-
|
|
229
239
|
# Split documents into chunks
|
|
230
240
|
split_docs = FirecrawlDocumentProcessor.split_documents(
|
|
231
241
|
documents, chunk_size, chunk_overlap
|
|
@@ -236,10 +246,10 @@ async def index_documents(
|
|
|
236
246
|
return 0, False
|
|
237
247
|
|
|
238
248
|
# Create embeddings
|
|
239
|
-
embeddings =
|
|
249
|
+
embeddings = vector_manager.create_embeddings()
|
|
240
250
|
|
|
241
251
|
# Try to load existing vector store
|
|
242
|
-
existing_vector_store = await
|
|
252
|
+
existing_vector_store = await vector_manager.load_vector_store(agent_id)
|
|
243
253
|
|
|
244
254
|
if existing_vector_store:
|
|
245
255
|
# Add to existing vector store
|
|
@@ -252,7 +262,7 @@ async def index_documents(
|
|
|
252
262
|
was_merged = False
|
|
253
263
|
|
|
254
264
|
# Save the vector store
|
|
255
|
-
await
|
|
265
|
+
await vector_manager.save_vector_store(
|
|
256
266
|
agent_id, vector_store, chunk_size, chunk_overlap
|
|
257
267
|
)
|
|
258
268
|
|
|
@@ -269,7 +279,7 @@ async def index_documents(
|
|
|
269
279
|
async def query_indexed_content(
|
|
270
280
|
query: str,
|
|
271
281
|
agent_id: str,
|
|
272
|
-
|
|
282
|
+
vector_manager: FirecrawlVectorStoreManager,
|
|
273
283
|
max_results: int = 4,
|
|
274
284
|
) -> List[Document]:
|
|
275
285
|
"""
|
|
@@ -278,7 +288,7 @@ async def query_indexed_content(
|
|
|
278
288
|
Args:
|
|
279
289
|
query: Search query
|
|
280
290
|
agent_id: Agent ID
|
|
281
|
-
|
|
291
|
+
vector_manager: Manager for vector store persistence
|
|
282
292
|
max_results: Maximum number of results to return
|
|
283
293
|
|
|
284
294
|
Returns:
|
|
@@ -286,10 +296,8 @@ async def query_indexed_content(
|
|
|
286
296
|
"""
|
|
287
297
|
try:
|
|
288
298
|
# Initialize vector store manager
|
|
289
|
-
vs_manager = FirecrawlVectorStoreManager(skill_store)
|
|
290
|
-
|
|
291
299
|
# Load vector store
|
|
292
|
-
vector_store = await
|
|
300
|
+
vector_store = await vector_manager.load_vector_store(agent_id)
|
|
293
301
|
|
|
294
302
|
if not vector_store:
|
|
295
303
|
logger.warning(f"No vector store found for agent {agent_id}")
|
|
@@ -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.github.base import GitHubBaseTool
|
|
6
5
|
from intentkit.skills.github.github_search import GitHubSearch
|
|
@@ -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[GitHubBaseTool]:
|
|
28
26
|
"""Get all GitHub 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_github_skill(name
|
|
37
|
+
return [get_github_skill(name) for name in available_skills]
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
def get_github_skill(
|
|
43
41
|
name: str,
|
|
44
|
-
store: SkillStoreABC,
|
|
45
42
|
) -> GitHubBaseTool:
|
|
46
43
|
"""Get a GitHub skill by name."""
|
|
47
44
|
if name == "github_search":
|
|
48
45
|
if name not in _cache:
|
|
49
|
-
_cache[name] = GitHubSearch(
|
|
50
|
-
skill_store=store,
|
|
51
|
-
)
|
|
46
|
+
_cache[name] = GitHubSearch()
|
|
52
47
|
return _cache[name]
|
|
53
48
|
else:
|
|
54
49
|
raise ValueError(f"Unknown GitHub skill: {name}")
|
intentkit/skills/github/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 GitHubBaseTool(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:
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import NotRequired, TypedDict
|
|
5
5
|
|
|
6
|
-
from intentkit.abstracts.skill import SkillStoreABC
|
|
7
6
|
from intentkit.skills.base import SkillConfig, SkillState
|
|
8
7
|
from intentkit.skills.heurist.base import HeuristBaseTool
|
|
9
8
|
from intentkit.skills.heurist.image_generation_animagine_xl import (
|
|
@@ -52,7 +51,6 @@ class Config(SkillConfig):
|
|
|
52
51
|
async def get_skills(
|
|
53
52
|
config: "Config",
|
|
54
53
|
is_private: bool,
|
|
55
|
-
store: SkillStoreABC,
|
|
56
54
|
**_,
|
|
57
55
|
) -> list[HeuristBaseTool]:
|
|
58
56
|
"""Get all Heurist AI skills.
|
|
@@ -60,7 +58,6 @@ async def get_skills(
|
|
|
60
58
|
Args:
|
|
61
59
|
config: The configuration for Heurist AI skills.
|
|
62
60
|
is_private: Whether to include private skills.
|
|
63
|
-
store: The skill store for persisting data.
|
|
64
61
|
|
|
65
62
|
Returns:
|
|
66
63
|
A list of Heurist AI skills.
|
|
@@ -77,7 +74,7 @@ async def get_skills(
|
|
|
77
74
|
# Get each skill using the cached getter
|
|
78
75
|
result = []
|
|
79
76
|
for name in available_skills:
|
|
80
|
-
skill = get_heurist_skill(name
|
|
77
|
+
skill = get_heurist_skill(name)
|
|
81
78
|
if skill:
|
|
82
79
|
result.append(skill)
|
|
83
80
|
return result
|
|
@@ -85,58 +82,42 @@ async def get_skills(
|
|
|
85
82
|
|
|
86
83
|
def get_heurist_skill(
|
|
87
84
|
name: str,
|
|
88
|
-
store: SkillStoreABC,
|
|
89
85
|
) -> HeuristBaseTool:
|
|
90
86
|
"""Get a Heurist AI skill by name.
|
|
91
87
|
|
|
92
88
|
Args:
|
|
93
89
|
name: The name of the skill to get
|
|
94
|
-
store: The skill store for persisting data
|
|
95
90
|
|
|
96
91
|
Returns:
|
|
97
92
|
The requested Heurist AI skill
|
|
98
93
|
"""
|
|
99
94
|
if name == "image_generation_animagine_xl":
|
|
100
95
|
if name not in _cache:
|
|
101
|
-
_cache[name] = ImageGenerationAnimagineXL(
|
|
102
|
-
skill_store=store,
|
|
103
|
-
)
|
|
96
|
+
_cache[name] = ImageGenerationAnimagineXL()
|
|
104
97
|
return _cache[name]
|
|
105
98
|
elif name == "image_generation_arthemy_comics":
|
|
106
99
|
if name not in _cache:
|
|
107
|
-
_cache[name] = ImageGenerationArthemyComics(
|
|
108
|
-
skill_store=store,
|
|
109
|
-
)
|
|
100
|
+
_cache[name] = ImageGenerationArthemyComics()
|
|
110
101
|
return _cache[name]
|
|
111
102
|
elif name == "image_generation_arthemy_real":
|
|
112
103
|
if name not in _cache:
|
|
113
|
-
_cache[name] = ImageGenerationArthemyReal(
|
|
114
|
-
skill_store=store,
|
|
115
|
-
)
|
|
104
|
+
_cache[name] = ImageGenerationArthemyReal()
|
|
116
105
|
return _cache[name]
|
|
117
106
|
elif name == "image_generation_braindance":
|
|
118
107
|
if name not in _cache:
|
|
119
|
-
_cache[name] = ImageGenerationBrainDance(
|
|
120
|
-
skill_store=store,
|
|
121
|
-
)
|
|
108
|
+
_cache[name] = ImageGenerationBrainDance()
|
|
122
109
|
return _cache[name]
|
|
123
110
|
elif name == "image_generation_cyber_realistic_xl":
|
|
124
111
|
if name not in _cache:
|
|
125
|
-
_cache[name] = ImageGenerationCyberRealisticXL(
|
|
126
|
-
skill_store=store,
|
|
127
|
-
)
|
|
112
|
+
_cache[name] = ImageGenerationCyberRealisticXL()
|
|
128
113
|
return _cache[name]
|
|
129
114
|
elif name == "image_generation_flux_1_dev":
|
|
130
115
|
if name not in _cache:
|
|
131
|
-
_cache[name] = ImageGenerationFlux1Dev(
|
|
132
|
-
skill_store=store,
|
|
133
|
-
)
|
|
116
|
+
_cache[name] = ImageGenerationFlux1Dev()
|
|
134
117
|
return _cache[name]
|
|
135
118
|
elif name == "image_generation_sdxl":
|
|
136
119
|
if name not in _cache:
|
|
137
|
-
_cache[name] = ImageGenerationSDXL(
|
|
138
|
-
skill_store=store,
|
|
139
|
-
)
|
|
120
|
+
_cache[name] = ImageGenerationSDXL()
|
|
140
121
|
return _cache[name]
|
|
141
122
|
else:
|
|
142
123
|
logger.warning(f"Unknown Heurist skill: {name}")
|
intentkit/skills/heurist/base.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Type
|
|
|
5
5
|
from langchain_core.tools.base import ToolException
|
|
6
6
|
from pydantic import BaseModel, Field
|
|
7
7
|
|
|
8
|
-
from intentkit.
|
|
8
|
+
from intentkit.config.config import config
|
|
9
9
|
from intentkit.skills.base import IntentKitSkill
|
|
10
10
|
|
|
11
11
|
|
|
@@ -18,16 +18,13 @@ class HeuristBaseTool(IntentKitSkill):
|
|
|
18
18
|
name: str = Field(description="The name of the tool")
|
|
19
19
|
description: str = Field(description="A description of what the tool does")
|
|
20
20
|
args_schema: Type[BaseModel]
|
|
21
|
-
skill_store: SkillStoreABC = Field(
|
|
22
|
-
description="The skill store for persisting data"
|
|
23
|
-
)
|
|
24
21
|
|
|
25
22
|
def get_api_key(self) -> str:
|
|
26
23
|
context = self.get_context()
|
|
27
24
|
skill_config = context.agent.skill_config(self.category)
|
|
28
25
|
api_key_provider = skill_config.get("api_key_provider")
|
|
29
26
|
if api_key_provider == "platform":
|
|
30
|
-
return
|
|
27
|
+
return config.heurist_api_key
|
|
31
28
|
# for backward compatibility, may only have api_key in skill_config
|
|
32
29
|
elif skill_config.get("api_key"):
|
|
33
30
|
return skill_config.get("api_key")
|
|
@@ -5,6 +5,7 @@ import httpx
|
|
|
5
5
|
from epyxid import XID
|
|
6
6
|
from pydantic import BaseModel, Field
|
|
7
7
|
|
|
8
|
+
from intentkit.config.config import config
|
|
8
9
|
from intentkit.skills.heurist.base import HeuristBaseTool
|
|
9
10
|
from intentkit.utils.s3 import store_image
|
|
10
11
|
|
|
@@ -79,20 +80,19 @@ class ImageGenerationAnimagineXL(HeuristBaseTool):
|
|
|
79
80
|
skill_config = context.agent.skill_config(self.category)
|
|
80
81
|
skill_config = skill_config
|
|
81
82
|
|
|
82
|
-
# Get the Heurist API key from
|
|
83
|
+
# Get the Heurist API key from configuration
|
|
83
84
|
if "api_key" in skill_config and skill_config["api_key"]:
|
|
84
85
|
api_key = skill_config["api_key"]
|
|
85
86
|
if skill_config.get("rate_limit_number") and skill_config.get(
|
|
86
87
|
"rate_limit_minutes"
|
|
87
88
|
):
|
|
88
89
|
await self.user_rate_limit_by_category(
|
|
89
|
-
context.user_id,
|
|
90
90
|
skill_config["rate_limit_number"],
|
|
91
|
-
skill_config["rate_limit_minutes"],
|
|
91
|
+
skill_config["rate_limit_minutes"] * 60,
|
|
92
92
|
)
|
|
93
93
|
else:
|
|
94
|
-
api_key =
|
|
95
|
-
await self.user_rate_limit_by_category(
|
|
94
|
+
api_key = config.heurist_api_key
|
|
95
|
+
await self.user_rate_limit_by_category(10, 1440 * 60)
|
|
96
96
|
|
|
97
97
|
# Generate a unique job ID
|
|
98
98
|
job_id = str(XID())
|