intentkit 0.6.9.dev2__py3-none-any.whl → 0.6.10.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of intentkit might be problematic. Click here for more details.
- intentkit/__init__.py +1 -1
- intentkit/abstracts/graph.py +17 -2
- intentkit/core/engine.py +29 -30
- intentkit/core/node.py +10 -20
- intentkit/models/agent.py +3 -0
- intentkit/models/chat.py +9 -1
- intentkit/skills/acolyt/ask.py +2 -5
- intentkit/skills/acolyt/base.py +16 -6
- intentkit/skills/aixbt/__init__.py +3 -7
- intentkit/skills/aixbt/projects.py +12 -36
- intentkit/skills/allora/base.py +16 -6
- intentkit/skills/allora/price.py +2 -4
- intentkit/skills/base.py +8 -1
- intentkit/skills/carv/base.py +12 -10
- intentkit/skills/carv/fetch_news.py +90 -92
- intentkit/skills/carv/onchain_query.py +162 -164
- intentkit/skills/carv/token_info_and_price.py +108 -110
- intentkit/skills/chainlist/chain_lookup.py +1 -2
- intentkit/skills/common/current_time.py +1 -2
- intentkit/skills/cookiefun/base.py +20 -12
- intentkit/skills/cookiefun/get_account_details.py +1 -3
- intentkit/skills/cookiefun/get_account_feed.py +1 -3
- intentkit/skills/cookiefun/get_account_smart_followers.py +1 -3
- intentkit/skills/cookiefun/get_sectors.py +2 -3
- intentkit/skills/cookiefun/search_accounts.py +1 -3
- intentkit/skills/cryptocompare/fetch_news.py +3 -4
- intentkit/skills/cryptocompare/fetch_price.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_exchanges.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_market_cap.py +3 -4
- intentkit/skills/cryptocompare/fetch_top_volume.py +3 -4
- intentkit/skills/cryptocompare/fetch_trading_signals.py +3 -4
- intentkit/skills/cryptopanic/base.py +13 -9
- intentkit/skills/cryptopanic/fetch_crypto_news.py +150 -153
- intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +133 -136
- intentkit/skills/dapplooker/base.py +16 -6
- intentkit/skills/dapplooker/dapplooker_token_data.py +2 -4
- intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +2 -3
- intentkit/skills/defillama/coins/fetch_block.py +2 -3
- intentkit/skills/defillama/coins/fetch_current_prices.py +2 -5
- intentkit/skills/defillama/coins/fetch_first_price.py +2 -5
- intentkit/skills/defillama/coins/fetch_historical_prices.py +2 -3
- intentkit/skills/defillama/coins/fetch_price_chart.py +2 -5
- intentkit/skills/defillama/coins/fetch_price_percentage.py +2 -5
- intentkit/skills/defillama/fees/fetch_fees_overview.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +2 -3
- intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +2 -3
- intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +2 -5
- intentkit/skills/defillama/tvl/fetch_chains.py +2 -3
- intentkit/skills/defillama/tvl/fetch_historical_tvl.py +2 -3
- intentkit/skills/defillama/tvl/fetch_protocol.py +2 -5
- intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +2 -5
- intentkit/skills/defillama/tvl/fetch_protocols.py +2 -3
- intentkit/skills/defillama/volumes/fetch_dex_overview.py +2 -3
- intentkit/skills/defillama/volumes/fetch_dex_summary.py +2 -5
- intentkit/skills/defillama/volumes/fetch_options_overview.py +2 -3
- intentkit/skills/defillama/yields/fetch_pool_chart.py +2 -5
- intentkit/skills/defillama/yields/fetch_pools.py +2 -3
- intentkit/skills/dune_analytics/base.py +15 -9
- intentkit/skills/dune_analytics/fetch_kol_buys.py +125 -128
- intentkit/skills/dune_analytics/fetch_nation_metrics.py +234 -237
- intentkit/skills/elfa/base.py +16 -6
- intentkit/skills/elfa/mention.py +2 -7
- intentkit/skills/elfa/stats.py +2 -6
- intentkit/skills/elfa/tokens.py +1 -4
- intentkit/skills/enso/base.py +25 -13
- intentkit/skills/enso/best_yield.py +1 -4
- intentkit/skills/enso/networks.py +2 -5
- intentkit/skills/enso/prices.py +1 -5
- intentkit/skills/enso/route.py +2 -5
- intentkit/skills/enso/tokens.py +1 -4
- intentkit/skills/enso/wallet.py +3 -9
- intentkit/skills/firecrawl/base.py +16 -6
- intentkit/skills/firecrawl/clear.py +1 -3
- intentkit/skills/firecrawl/crawl.py +7 -8
- intentkit/skills/firecrawl/query.py +7 -9
- intentkit/skills/firecrawl/scrape.py +7 -8
- intentkit/skills/github/github_search.py +1 -3
- intentkit/skills/heurist/base.py +15 -0
- intentkit/skills/heurist/image_generation_animagine_xl.py +3 -4
- intentkit/skills/heurist/image_generation_arthemy_comics.py +3 -4
- intentkit/skills/heurist/image_generation_arthemy_real.py +3 -4
- intentkit/skills/heurist/image_generation_braindance.py +3 -4
- intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +3 -4
- intentkit/skills/heurist/image_generation_flux_1_dev.py +3 -4
- intentkit/skills/heurist/image_generation_sdxl.py +3 -4
- intentkit/skills/http/get.py +0 -2
- intentkit/skills/http/post.py +0 -2
- intentkit/skills/http/put.py +0 -2
- intentkit/skills/lifi/token_execute.py +1 -3
- intentkit/skills/lifi/token_quote.py +0 -2
- intentkit/skills/moralis/base.py +15 -1
- intentkit/skills/nation/nft_check.py +2 -5
- intentkit/skills/openai/base.py +14 -5
- intentkit/skills/openai/dalle_image_generation.py +6 -5
- intentkit/skills/openai/gpt_image_generation.py +6 -5
- intentkit/skills/openai/gpt_image_to_image.py +6 -5
- intentkit/skills/openai/image_to_text.py +6 -6
- intentkit/skills/portfolio/base.py +4 -3
- intentkit/skills/portfolio/token_balances.py +2 -4
- intentkit/skills/portfolio/wallet_approvals.py +2 -4
- intentkit/skills/portfolio/wallet_defi_positions.py +3 -4
- intentkit/skills/portfolio/wallet_history.py +2 -4
- intentkit/skills/portfolio/wallet_net_worth.py +2 -4
- intentkit/skills/portfolio/wallet_nfts.py +2 -4
- intentkit/skills/portfolio/wallet_profitability.py +2 -4
- intentkit/skills/portfolio/wallet_profitability_summary.py +2 -4
- intentkit/skills/portfolio/wallet_stats.py +2 -4
- intentkit/skills/portfolio/wallet_swaps.py +2 -4
- intentkit/skills/slack/base.py +18 -0
- intentkit/skills/slack/get_channel.py +3 -4
- intentkit/skills/slack/get_message.py +3 -4
- intentkit/skills/slack/schedule_message.py +3 -4
- intentkit/skills/slack/send_message.py +3 -4
- intentkit/skills/supabase/delete_data.py +3 -6
- intentkit/skills/supabase/fetch_data.py +3 -6
- intentkit/skills/supabase/insert_data.py +3 -6
- intentkit/skills/supabase/invoke_function.py +3 -6
- intentkit/skills/supabase/update_data.py +3 -6
- intentkit/skills/supabase/upsert_data.py +3 -6
- intentkit/skills/system/add_autonomous_task.py +1 -3
- intentkit/skills/system/delete_autonomous_task.py +1 -3
- intentkit/skills/system/edit_autonomous_task.py +1 -3
- intentkit/skills/system/list_autonomous_tasks.py +1 -3
- intentkit/skills/system/read_agent_api_key.py +2 -3
- intentkit/skills/system/regenerate_agent_api_key.py +2 -5
- intentkit/skills/tavily/base.py +14 -5
- intentkit/skills/tavily/tavily_extract.py +7 -8
- intentkit/skills/tavily/tavily_search.py +11 -9
- intentkit/skills/token/base.py +4 -6
- intentkit/skills/token/erc20_transfers.py +2 -4
- intentkit/skills/token/token_analytics.py +2 -4
- intentkit/skills/token/token_price.py +2 -4
- intentkit/skills/token/token_search.py +2 -4
- intentkit/skills/twitter/base.py +41 -0
- intentkit/skills/twitter/follow_user.py +4 -4
- intentkit/skills/twitter/get_mentions.py +4 -4
- intentkit/skills/twitter/get_timeline.py +4 -4
- intentkit/skills/twitter/get_user_by_username.py +4 -4
- intentkit/skills/twitter/get_user_tweets.py +4 -4
- intentkit/skills/twitter/like_tweet.py +4 -4
- intentkit/skills/twitter/post_tweet.py +3 -4
- intentkit/skills/twitter/reply_tweet.py +3 -4
- intentkit/skills/twitter/retweet.py +4 -4
- intentkit/skills/twitter/search_tweets.py +4 -4
- intentkit/skills/unrealspeech/base.py +16 -0
- intentkit/skills/unrealspeech/text_to_speech.py +4 -4
- intentkit/skills/venice_audio/base.py +11 -9
- intentkit/skills/venice_audio/venice_audio.py +238 -240
- intentkit/skills/venice_image/base.py +23 -19
- intentkit/skills/venice_image/image_enhance/image_enhance.py +78 -80
- intentkit/skills/venice_image/image_generation/image_generation_base.py +115 -117
- intentkit/skills/venice_image/image_upscale/image_upscale.py +88 -90
- intentkit/skills/venice_image/image_vision/image_vision.py +98 -100
- intentkit/skills/web_scraper/document_indexer.py +3 -5
- intentkit/skills/web_scraper/scrape_and_index.py +14 -17
- intentkit/skills/web_scraper/website_indexer.py +8 -10
- intentkit/skills/xmtp/README.md +110 -0
- intentkit/skills/xmtp/__init__.py +82 -0
- intentkit/skills/xmtp/base.py +13 -0
- intentkit/skills/xmtp/schema.json +41 -0
- intentkit/skills/xmtp/transfer.py +170 -0
- intentkit/skills/xmtp/xmtp.svg +26 -0
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/METADATA +3 -3
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/RECORD +168 -162
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/WHEEL +0 -0
- {intentkit-0.6.9.dev2.dist-info → intentkit-0.6.10.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,80 +1,78 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from intentkit.skills.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
except
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
)
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import HttpUrl
|
|
5
|
+
|
|
6
|
+
from intentkit.skills.base import ToolException
|
|
7
|
+
from intentkit.skills.venice_image.image_enhance.image_enhance_base import (
|
|
8
|
+
VeniceImageEnhanceBaseTool,
|
|
9
|
+
)
|
|
10
|
+
from intentkit.skills.venice_image.utils import fetch_image_as_base64
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ImageEnhance(VeniceImageEnhanceBaseTool):
|
|
16
|
+
"""
|
|
17
|
+
Enhances an existing image provided via URL using the Venice AI enhancer (not upscaling).
|
|
18
|
+
Useful for improving visual quality, adding style, or refining image features.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
name: str = "venice_image_enhance"
|
|
22
|
+
description: str = (
|
|
23
|
+
"Enhances an existing image from a URL using Venice AI.\n"
|
|
24
|
+
"Provide the public URL of the image to enhance.\n"
|
|
25
|
+
"Specify enhancement creativity level and a required prompt for style.\n"
|
|
26
|
+
"Returns the URL of the enhanced image."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
async def _arun(
|
|
30
|
+
self,
|
|
31
|
+
image_url: HttpUrl,
|
|
32
|
+
enhancePrompt: str,
|
|
33
|
+
replication: Optional[float] = 0.35,
|
|
34
|
+
enhanceCreativity: Optional[float] = 0.5,
|
|
35
|
+
**kwargs,
|
|
36
|
+
) -> dict:
|
|
37
|
+
"""
|
|
38
|
+
Applies AI enhancement to an image without changing its size.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
context = self.get_context()
|
|
43
|
+
|
|
44
|
+
await self.apply_venice_rate_limit(context)
|
|
45
|
+
|
|
46
|
+
image_base64 = await fetch_image_as_base64(image_url)
|
|
47
|
+
if not image_base64:
|
|
48
|
+
error_msg = f"Failed to fetch or validate image from URL: {image_url}"
|
|
49
|
+
logger.error(error_msg)
|
|
50
|
+
raise ToolException(
|
|
51
|
+
str({"success": False, "error": error_msg, "result": None})
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
payload = {
|
|
55
|
+
"image": image_base64,
|
|
56
|
+
"scale": 1,
|
|
57
|
+
"enhance": True,
|
|
58
|
+
"replication": replication,
|
|
59
|
+
"enhanceCreativity": enhanceCreativity,
|
|
60
|
+
"enhancePrompt": enhancePrompt,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
result, error = await self.post("api/v1/image/upscale", payload, context)
|
|
64
|
+
if error:
|
|
65
|
+
raise ToolException(f"Venice Image Enhance API error: {error}")
|
|
66
|
+
return result
|
|
67
|
+
except ToolException as e:
|
|
68
|
+
raise e
|
|
69
|
+
except Exception as e:
|
|
70
|
+
logger.error(f"Error in {self.name}: {str(e)}")
|
|
71
|
+
raise ToolException(
|
|
72
|
+
str(
|
|
73
|
+
{
|
|
74
|
+
"success": False,
|
|
75
|
+
"error": f"An unexpected error occurred: {str(e)}",
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
)
|
|
@@ -1,117 +1,115 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import hashlib
|
|
3
|
-
import logging
|
|
4
|
-
from typing import Any, Dict, Literal, Optional, Type
|
|
5
|
-
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from intentkit.skills.base import
|
|
11
|
-
from intentkit.skills.venice_image.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
result
|
|
108
|
-
|
|
109
|
-
result
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
except
|
|
113
|
-
raise
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"An unexpected error occurred during the image generation process."
|
|
117
|
-
) from e
|
|
1
|
+
import base64
|
|
2
|
+
import hashlib
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any, Dict, Literal, Optional, Type
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
# Import the generic base
|
|
9
|
+
from intentkit.skills.base import ToolException
|
|
10
|
+
from intentkit.skills.venice_image.base import VeniceImageBaseTool
|
|
11
|
+
from intentkit.skills.venice_image.image_generation.image_generation_input import (
|
|
12
|
+
VeniceImageGenerationInput,
|
|
13
|
+
)
|
|
14
|
+
from intentkit.utils.s3 import store_image_bytes
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class VeniceImageGenerationBaseTool(VeniceImageBaseTool):
|
|
20
|
+
"""
|
|
21
|
+
Base class for Venice AI *Image Generation* tools.
|
|
22
|
+
Inherits from VeniceAIBaseTool and handles specifics of the
|
|
23
|
+
/image/generate endpoint.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
# --- Attributes specific to Image Generation ---
|
|
27
|
+
args_schema: Type[BaseModel] = VeniceImageGenerationInput
|
|
28
|
+
|
|
29
|
+
# --- Attributes Subclasses MUST Define ---
|
|
30
|
+
name: str = Field(description="The unique name of the image generation tool/model.")
|
|
31
|
+
description: str = Field(
|
|
32
|
+
description="A description of what the image generation tool/model does."
|
|
33
|
+
)
|
|
34
|
+
model_id: str = Field(
|
|
35
|
+
description="The specific model ID used in the Venice Image API call."
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
async def _arun(
|
|
39
|
+
self,
|
|
40
|
+
prompt: str,
|
|
41
|
+
seed: Optional[int] = None,
|
|
42
|
+
negative_prompt: Optional[str] = None,
|
|
43
|
+
width: Optional[int] = 1024,
|
|
44
|
+
height: Optional[int] = 1024,
|
|
45
|
+
format: Literal["png", "jpeg", "webp"] = "png",
|
|
46
|
+
cfg_scale: Optional[float] = 7.5,
|
|
47
|
+
style_preset: Optional[str] = "Photographic",
|
|
48
|
+
**kwargs,
|
|
49
|
+
) -> Dict[str, Any]:
|
|
50
|
+
try:
|
|
51
|
+
context = self.get_context()
|
|
52
|
+
skillConfig = self.getSkillConfig(context)
|
|
53
|
+
await self.apply_venice_rate_limit(context)
|
|
54
|
+
|
|
55
|
+
final_negative_prompt = negative_prompt or skillConfig.negative_prompt
|
|
56
|
+
|
|
57
|
+
payload = {
|
|
58
|
+
"model": self.model_id,
|
|
59
|
+
"prompt": prompt,
|
|
60
|
+
"width": width,
|
|
61
|
+
"height": height,
|
|
62
|
+
"seed": seed,
|
|
63
|
+
"format": format,
|
|
64
|
+
"steps": 30,
|
|
65
|
+
"safe_mode": skillConfig.safe_mode,
|
|
66
|
+
"hide_watermark": skillConfig.hide_watermark,
|
|
67
|
+
"embed_exif_metadata": skillConfig.embed_exif_metadata,
|
|
68
|
+
"cfg_scale": cfg_scale or 7.0,
|
|
69
|
+
"style_preset": style_preset,
|
|
70
|
+
"negative_prompt": final_negative_prompt,
|
|
71
|
+
"return_binary": False,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Strip out None values
|
|
75
|
+
payload = {k: v for k, v in payload.items() if v is not None}
|
|
76
|
+
|
|
77
|
+
result, error = await self.post("/api/v1/image/generate", payload, context)
|
|
78
|
+
|
|
79
|
+
if error:
|
|
80
|
+
raise ToolException(f"Venice Image Generation API error: {error}")
|
|
81
|
+
|
|
82
|
+
base64_image_string = result.get("images", [None])[0]
|
|
83
|
+
if not base64_image_string:
|
|
84
|
+
raise ToolException("No image data found in Venice Image API response.")
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
image_bytes = base64.b64decode(base64_image_string)
|
|
88
|
+
except Exception as decode_error:
|
|
89
|
+
raise ToolException("Invalid base64 image data.") from decode_error
|
|
90
|
+
|
|
91
|
+
response_format = (
|
|
92
|
+
result.get("request", {}).get("data", {}).get("format", format)
|
|
93
|
+
)
|
|
94
|
+
file_extension = response_format or format
|
|
95
|
+
content_type = f"image/{file_extension}"
|
|
96
|
+
|
|
97
|
+
image_hash = hashlib.sha256(image_bytes).hexdigest()
|
|
98
|
+
key = f"{self.category}/{self.model_id}/{image_hash}.{file_extension}"
|
|
99
|
+
|
|
100
|
+
stored_url = await store_image_bytes(
|
|
101
|
+
image_bytes, key, content_type=content_type
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Cleanup & enrich the response
|
|
105
|
+
result.pop("images", None)
|
|
106
|
+
result["image_url"] = stored_url
|
|
107
|
+
result["image_bytes_sha256"] = image_hash
|
|
108
|
+
|
|
109
|
+
return result
|
|
110
|
+
except ToolException as e:
|
|
111
|
+
raise e
|
|
112
|
+
except Exception as e:
|
|
113
|
+
raise ToolException(
|
|
114
|
+
"An unexpected error occurred during the image generation process."
|
|
115
|
+
) from e
|
|
@@ -1,90 +1,88 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Literal, Optional
|
|
3
|
-
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from intentkit.skills.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
except
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
)
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Literal, Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import HttpUrl
|
|
5
|
+
|
|
6
|
+
from intentkit.skills.base import ToolException
|
|
7
|
+
from intentkit.skills.venice_image.image_upscale.image_upscale_base import (
|
|
8
|
+
VeniceImageUpscaleBaseTool,
|
|
9
|
+
)
|
|
10
|
+
from intentkit.skills.venice_image.utils import fetch_image_as_base64
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ImageUpscale(VeniceImageUpscaleBaseTool):
|
|
16
|
+
"""
|
|
17
|
+
Upscales an existing image provided via URL by a factor of 2 or 4 using the Venice AI API.
|
|
18
|
+
Ideal for enhancing the resolution of previously generated or existing images.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
# --- Tool Specific Configuration ---
|
|
22
|
+
name: str = "venice_image_upscale"
|
|
23
|
+
description: str = (
|
|
24
|
+
"Upscales an existing image from a URL using Venice AI.\n"
|
|
25
|
+
"Provide the public URL of the image to upscale.\n"
|
|
26
|
+
"Specify the desired scale factor: 2 (for 2x upscale) or 4 (for 4x upscale).\n"
|
|
27
|
+
"Returns the URL of the upscaled image."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# No model_id needed for the generic upscale endpoint currently
|
|
31
|
+
async def _arun(
|
|
32
|
+
self,
|
|
33
|
+
image_url: HttpUrl,
|
|
34
|
+
scale: Literal[2, 4],
|
|
35
|
+
replication: Optional[float] = 0.35,
|
|
36
|
+
**kwargs,
|
|
37
|
+
) -> dict:
|
|
38
|
+
"""
|
|
39
|
+
Asynchronously upscales an image from the provided URL using the Venice AI API.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
image_url (HttpUrl): The public URL of the image to upscale.
|
|
43
|
+
scale (Literal[2, 4]): The scale factor for upscaling (2x or 4x).
|
|
44
|
+
replication (Optional[float]): The replication factor for the upscale process, defaults to 0.35.
|
|
45
|
+
config (RunnableConfig, optional): Configuration for the runnable, if any.
|
|
46
|
+
**kwargs: Additional keyword arguments.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
dict: The API response containing the URL of the upscaled image.
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
ToolException: If the image cannot be fetched, validated, or upscaled, or if an API error occurs.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
context = self.get_context()
|
|
57
|
+
|
|
58
|
+
await self.apply_venice_rate_limit(context)
|
|
59
|
+
|
|
60
|
+
image_base64 = await fetch_image_as_base64(image_url)
|
|
61
|
+
if not image_base64:
|
|
62
|
+
error_msg = f"Failed to fetch or validate image from URL: {image_url}"
|
|
63
|
+
logger.error(error_msg)
|
|
64
|
+
raise ToolException(
|
|
65
|
+
str({"success": False, "error": error_msg, "result": None})
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
payload = {
|
|
69
|
+
"image": image_base64,
|
|
70
|
+
"scale": scale,
|
|
71
|
+
"replication": replication,
|
|
72
|
+
}
|
|
73
|
+
result, error = await self.post("api/v1/image/upscale", payload, context)
|
|
74
|
+
if error:
|
|
75
|
+
raise ToolException(f"Venice Image Upscale API error: {error}")
|
|
76
|
+
return result
|
|
77
|
+
except ToolException as e:
|
|
78
|
+
raise e
|
|
79
|
+
except Exception as e:
|
|
80
|
+
logger.error(f"Error in {self.name}: {str(e)}")
|
|
81
|
+
raise ToolException(
|
|
82
|
+
str(
|
|
83
|
+
{
|
|
84
|
+
"success": False,
|
|
85
|
+
"error": f"An unexpected error occurred: {str(e)}",
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
)
|