intentkit 0.8.6.dev2__py3-none-any.whl → 0.8.17__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/agent.py +4 -5
- intentkit/abstracts/engine.py +5 -5
- intentkit/abstracts/graph.py +10 -5
- intentkit/abstracts/skill.py +6 -144
- intentkit/abstracts/twitter.py +4 -5
- intentkit/clients/__init__.py +3 -2
- intentkit/clients/cdp.py +53 -92
- intentkit/clients/twitter.py +56 -57
- intentkit/clients/web3.py +1 -3
- intentkit/config/config.py +5 -0
- intentkit/core/agent.py +16 -388
- intentkit/core/asset.py +64 -18
- intentkit/core/client.py +1 -1
- intentkit/core/credit.py +19 -20
- intentkit/core/engine.py +26 -11
- intentkit/core/node.py +2 -1
- intentkit/core/prompt.py +53 -15
- intentkit/core/scheduler.py +9 -9
- intentkit/core/statistics.py +6 -7
- intentkit/models/agent.py +256 -176
- intentkit/models/agent_data.py +62 -36
- intentkit/models/agent_schema.json +6 -9
- intentkit/models/app_setting.py +6 -6
- intentkit/models/chat.py +28 -24
- intentkit/models/conversation.py +8 -8
- intentkit/models/credit.py +62 -64
- intentkit/models/db.py +8 -7
- intentkit/models/db_mig.py +2 -2
- intentkit/models/llm.csv +15 -12
- intentkit/models/llm.py +18 -16
- intentkit/models/redis.py +2 -3
- intentkit/models/skill.py +62 -66
- intentkit/models/skills.csv +30 -26
- intentkit/models/user.py +46 -21
- intentkit/skills/acolyt/__init__.py +2 -9
- intentkit/skills/acolyt/ask.py +3 -4
- intentkit/skills/acolyt/base.py +4 -9
- intentkit/skills/aixbt/__init__.py +2 -13
- intentkit/skills/aixbt/base.py +1 -7
- intentkit/skills/aixbt/projects.py +14 -15
- intentkit/skills/allora/__init__.py +2 -9
- intentkit/skills/allora/base.py +4 -9
- intentkit/skills/allora/price.py +3 -4
- intentkit/skills/base.py +175 -52
- intentkit/skills/basename/__init__.py +4 -8
- intentkit/skills/carv/__init__.py +115 -121
- intentkit/skills/carv/base.py +184 -185
- intentkit/skills/carv/fetch_news.py +3 -3
- intentkit/skills/carv/onchain_query.py +4 -4
- intentkit/skills/carv/token_info_and_price.py +5 -5
- intentkit/skills/casino/__init__.py +4 -15
- intentkit/skills/casino/base.py +1 -7
- intentkit/skills/casino/deck_draw.py +5 -8
- intentkit/skills/casino/deck_shuffle.py +6 -6
- intentkit/skills/casino/dice_roll.py +2 -4
- intentkit/skills/cdp/__init__.py +3 -10
- intentkit/skills/cdp/base.py +1 -7
- intentkit/skills/cdp/schema.json +1 -17
- intentkit/skills/chainlist/__init__.py +2 -7
- intentkit/skills/chainlist/base.py +1 -7
- intentkit/skills/chainlist/chain_lookup.py +18 -18
- intentkit/skills/common/__init__.py +2 -9
- intentkit/skills/common/base.py +1 -7
- intentkit/skills/common/current_time.py +1 -2
- intentkit/skills/cookiefun/__init__.py +6 -9
- intentkit/skills/cookiefun/base.py +2 -7
- intentkit/skills/cookiefun/get_account_details.py +7 -7
- intentkit/skills/cookiefun/get_account_feed.py +19 -19
- intentkit/skills/cookiefun/get_account_smart_followers.py +7 -7
- intentkit/skills/cookiefun/get_sectors.py +3 -3
- intentkit/skills/cookiefun/search_accounts.py +9 -9
- intentkit/skills/cryptocompare/__init__.py +7 -24
- intentkit/skills/cryptocompare/api.py +2 -3
- intentkit/skills/cryptocompare/base.py +10 -24
- intentkit/skills/cryptocompare/fetch_news.py +4 -5
- intentkit/skills/cryptocompare/fetch_price.py +6 -7
- intentkit/skills/cryptocompare/fetch_top_exchanges.py +4 -5
- intentkit/skills/cryptocompare/fetch_top_market_cap.py +4 -5
- intentkit/skills/cryptocompare/fetch_top_volume.py +4 -5
- intentkit/skills/cryptocompare/fetch_trading_signals.py +5 -6
- intentkit/skills/cryptopanic/__init__.py +7 -10
- intentkit/skills/cryptopanic/base.py +51 -55
- intentkit/skills/cryptopanic/fetch_crypto_news.py +4 -8
- intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +5 -7
- intentkit/skills/dapplooker/__init__.py +2 -9
- intentkit/skills/dapplooker/base.py +4 -9
- intentkit/skills/dapplooker/dapplooker_token_data.py +7 -7
- intentkit/skills/defillama/__init__.py +24 -74
- intentkit/skills/defillama/api.py +6 -9
- intentkit/skills/defillama/base.py +8 -19
- intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +8 -10
- intentkit/skills/defillama/coins/fetch_block.py +6 -8
- intentkit/skills/defillama/coins/fetch_current_prices.py +8 -10
- intentkit/skills/defillama/coins/fetch_first_price.py +7 -9
- intentkit/skills/defillama/coins/fetch_historical_prices.py +9 -11
- intentkit/skills/defillama/coins/fetch_price_chart.py +9 -11
- intentkit/skills/defillama/coins/fetch_price_percentage.py +7 -9
- intentkit/skills/defillama/config/chains.py +1 -3
- intentkit/skills/defillama/fees/fetch_fees_overview.py +24 -26
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +16 -18
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +8 -10
- intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +5 -7
- intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +7 -9
- intentkit/skills/defillama/tests/api_integration.test.py +1 -1
- intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +4 -6
- intentkit/skills/defillama/tvl/fetch_chains.py +9 -11
- intentkit/skills/defillama/tvl/fetch_historical_tvl.py +4 -6
- intentkit/skills/defillama/tvl/fetch_protocol.py +32 -38
- intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +3 -5
- intentkit/skills/defillama/tvl/fetch_protocols.py +37 -45
- intentkit/skills/defillama/volumes/fetch_dex_overview.py +42 -48
- intentkit/skills/defillama/volumes/fetch_dex_summary.py +35 -37
- intentkit/skills/defillama/volumes/fetch_options_overview.py +24 -28
- intentkit/skills/defillama/yields/fetch_pool_chart.py +10 -12
- intentkit/skills/defillama/yields/fetch_pools.py +26 -30
- intentkit/skills/dexscreener/__init__.py +97 -102
- intentkit/skills/dexscreener/base.py +125 -130
- intentkit/skills/dexscreener/get_pair_info.py +4 -5
- intentkit/skills/dexscreener/get_token_pairs.py +4 -5
- intentkit/skills/dexscreener/get_tokens_info.py +7 -8
- intentkit/skills/dexscreener/model/search_token_response.py +80 -82
- intentkit/skills/dexscreener/search_token.py +182 -184
- intentkit/skills/dexscreener/utils.py +15 -14
- intentkit/skills/dune_analytics/__init__.py +7 -9
- intentkit/skills/dune_analytics/base.py +48 -52
- intentkit/skills/dune_analytics/fetch_kol_buys.py +5 -7
- intentkit/skills/dune_analytics/fetch_nation_metrics.py +6 -8
- intentkit/skills/elfa/__init__.py +5 -18
- intentkit/skills/elfa/base.py +10 -14
- intentkit/skills/elfa/mention.py +19 -21
- intentkit/skills/elfa/stats.py +4 -4
- intentkit/skills/elfa/tokens.py +12 -12
- intentkit/skills/elfa/utils.py +26 -28
- intentkit/skills/enso/__init__.py +11 -31
- intentkit/skills/enso/base.py +9 -15
- intentkit/skills/enso/best_yield.py +5 -7
- intentkit/skills/enso/networks.py +3 -9
- intentkit/skills/enso/prices.py +2 -4
- intentkit/skills/enso/route.py +6 -12
- intentkit/skills/enso/tokens.py +4 -16
- intentkit/skills/enso/wallet.py +6 -6
- intentkit/skills/erc20/__init__.py +5 -11
- intentkit/skills/erc721/__init__.py +5 -9
- intentkit/skills/firecrawl/__init__.py +5 -18
- intentkit/skills/firecrawl/base.py +4 -9
- intentkit/skills/firecrawl/clear.py +4 -8
- intentkit/skills/firecrawl/crawl.py +19 -19
- intentkit/skills/firecrawl/query.py +4 -3
- intentkit/skills/firecrawl/scrape.py +17 -22
- intentkit/skills/firecrawl/utils.py +50 -42
- intentkit/skills/github/__init__.py +2 -7
- intentkit/skills/github/base.py +1 -7
- intentkit/skills/github/github_search.py +1 -2
- intentkit/skills/heurist/__init__.py +8 -27
- intentkit/skills/heurist/base.py +4 -9
- intentkit/skills/heurist/image_generation_animagine_xl.py +12 -13
- intentkit/skills/heurist/image_generation_arthemy_comics.py +12 -13
- intentkit/skills/heurist/image_generation_arthemy_real.py +12 -13
- intentkit/skills/heurist/image_generation_braindance.py +12 -13
- intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +12 -13
- intentkit/skills/heurist/image_generation_flux_1_dev.py +12 -13
- intentkit/skills/heurist/image_generation_sdxl.py +12 -13
- intentkit/skills/http/__init__.py +4 -15
- intentkit/skills/http/base.py +1 -7
- intentkit/skills/http/get.py +21 -16
- intentkit/skills/http/post.py +23 -18
- intentkit/skills/http/put.py +23 -18
- intentkit/skills/lifi/__init__.py +5 -10
- intentkit/skills/lifi/base.py +1 -7
- intentkit/skills/lifi/token_execute.py +14 -17
- intentkit/skills/lifi/token_quote.py +7 -9
- intentkit/skills/lifi/utils.py +16 -16
- intentkit/skills/moralis/__init__.py +6 -10
- intentkit/skills/moralis/api.py +6 -7
- intentkit/skills/moralis/base.py +5 -10
- intentkit/skills/moralis/fetch_chain_portfolio.py +10 -11
- intentkit/skills/moralis/fetch_nft_portfolio.py +22 -22
- intentkit/skills/moralis/fetch_solana_portfolio.py +11 -12
- intentkit/skills/moralis/fetch_wallet_portfolio.py +8 -9
- intentkit/skills/morpho/__init__.py +5 -9
- intentkit/skills/nation/__init__.py +4 -9
- intentkit/skills/nation/base.py +5 -10
- intentkit/skills/nation/nft_check.py +3 -4
- intentkit/skills/onchain.py +23 -0
- intentkit/skills/openai/__init__.py +17 -18
- intentkit/skills/openai/base.py +10 -14
- intentkit/skills/openai/dalle_image_generation.py +3 -8
- intentkit/skills/openai/gpt_avatar_generator.py +102 -0
- intentkit/skills/openai/gpt_image_generation.py +4 -8
- intentkit/skills/openai/gpt_image_mini_generator.py +91 -0
- intentkit/skills/openai/gpt_image_to_image.py +4 -8
- intentkit/skills/openai/image_to_text.py +3 -7
- intentkit/skills/openai/schema.json +32 -0
- intentkit/skills/portfolio/__init__.py +11 -35
- intentkit/skills/portfolio/base.py +33 -19
- intentkit/skills/portfolio/token_balances.py +21 -21
- intentkit/skills/portfolio/wallet_approvals.py +17 -18
- intentkit/skills/portfolio/wallet_defi_positions.py +3 -3
- intentkit/skills/portfolio/wallet_history.py +31 -31
- intentkit/skills/portfolio/wallet_net_worth.py +13 -13
- intentkit/skills/portfolio/wallet_nfts.py +19 -19
- intentkit/skills/portfolio/wallet_profitability.py +18 -18
- intentkit/skills/portfolio/wallet_profitability_summary.py +5 -5
- intentkit/skills/portfolio/wallet_stats.py +3 -3
- intentkit/skills/portfolio/wallet_swaps.py +19 -19
- intentkit/skills/pyth/__init__.py +4 -10
- intentkit/skills/skills.toml +4 -0
- intentkit/skills/slack/__init__.py +5 -17
- intentkit/skills/slack/base.py +3 -9
- intentkit/skills/slack/get_channel.py +8 -8
- intentkit/skills/slack/get_message.py +9 -9
- intentkit/skills/slack/schedule_message.py +5 -5
- intentkit/skills/slack/send_message.py +3 -5
- intentkit/skills/supabase/__init__.py +7 -23
- intentkit/skills/supabase/base.py +1 -7
- intentkit/skills/supabase/delete_data.py +4 -4
- intentkit/skills/supabase/fetch_data.py +12 -12
- intentkit/skills/supabase/insert_data.py +4 -4
- intentkit/skills/supabase/invoke_function.py +6 -6
- intentkit/skills/supabase/update_data.py +6 -6
- intentkit/skills/supabase/upsert_data.py +4 -4
- intentkit/skills/superfluid/__init__.py +5 -9
- intentkit/skills/system/__init__.py +7 -24
- intentkit/skills/system/add_autonomous_task.py +10 -12
- intentkit/skills/system/delete_autonomous_task.py +2 -2
- intentkit/skills/system/edit_autonomous_task.py +14 -18
- intentkit/skills/system/list_autonomous_tasks.py +3 -5
- 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 +4 -9
- intentkit/skills/tavily/tavily_extract.py +2 -4
- intentkit/skills/tavily/tavily_search.py +4 -6
- intentkit/skills/token/__init__.py +5 -10
- intentkit/skills/token/base.py +7 -11
- intentkit/skills/token/erc20_transfers.py +19 -19
- intentkit/skills/token/token_analytics.py +3 -3
- intentkit/skills/token/token_price.py +13 -13
- intentkit/skills/token/token_search.py +9 -9
- intentkit/skills/twitter/__init__.py +11 -35
- intentkit/skills/twitter/base.py +22 -34
- intentkit/skills/twitter/follow_user.py +2 -6
- intentkit/skills/twitter/get_mentions.py +5 -12
- intentkit/skills/twitter/get_timeline.py +4 -12
- intentkit/skills/twitter/get_user_by_username.py +2 -6
- intentkit/skills/twitter/get_user_tweets.py +5 -13
- intentkit/skills/twitter/like_tweet.py +2 -6
- intentkit/skills/twitter/post_tweet.py +6 -9
- intentkit/skills/twitter/reply_tweet.py +6 -9
- intentkit/skills/twitter/retweet.py +2 -6
- intentkit/skills/twitter/search_tweets.py +4 -12
- intentkit/skills/unrealspeech/__init__.py +2 -7
- intentkit/skills/unrealspeech/base.py +2 -8
- intentkit/skills/unrealspeech/text_to_speech.py +8 -8
- intentkit/skills/venice_audio/__init__.py +98 -106
- intentkit/skills/venice_audio/base.py +117 -121
- intentkit/skills/venice_audio/input.py +41 -41
- intentkit/skills/venice_audio/venice_audio.py +7 -11
- intentkit/skills/venice_image/__init__.py +147 -154
- intentkit/skills/venice_image/api.py +138 -138
- intentkit/skills/venice_image/base.py +185 -192
- intentkit/skills/venice_image/config.py +33 -35
- intentkit/skills/venice_image/image_enhance/image_enhance.py +2 -3
- intentkit/skills/venice_image/image_enhance/image_enhance_base.py +21 -23
- intentkit/skills/venice_image/image_enhance/image_enhance_input.py +38 -40
- intentkit/skills/venice_image/image_generation/image_generation_base.py +9 -9
- intentkit/skills/venice_image/image_generation/image_generation_fluently_xl.py +26 -26
- intentkit/skills/venice_image/image_generation/image_generation_flux_dev.py +27 -27
- intentkit/skills/venice_image/image_generation/image_generation_flux_dev_uncensored.py +26 -26
- intentkit/skills/venice_image/image_generation/image_generation_input.py +158 -158
- intentkit/skills/venice_image/image_generation/image_generation_lustify_sdxl.py +26 -26
- intentkit/skills/venice_image/image_generation/image_generation_pony_realism.py +26 -26
- intentkit/skills/venice_image/image_generation/image_generation_stable_diffusion_3_5.py +28 -28
- intentkit/skills/venice_image/image_generation/image_generation_venice_sd35.py +28 -28
- intentkit/skills/venice_image/image_upscale/image_upscale.py +3 -3
- intentkit/skills/venice_image/image_upscale/image_upscale_base.py +21 -23
- intentkit/skills/venice_image/image_upscale/image_upscale_input.py +22 -22
- intentkit/skills/venice_image/image_vision/image_vision.py +2 -2
- intentkit/skills/venice_image/image_vision/image_vision_base.py +17 -17
- intentkit/skills/venice_image/image_vision/image_vision_input.py +9 -9
- intentkit/skills/venice_image/utils.py +77 -78
- intentkit/skills/web_scraper/__init__.py +5 -18
- intentkit/skills/web_scraper/base.py +21 -7
- intentkit/skills/web_scraper/document_indexer.py +7 -6
- intentkit/skills/web_scraper/scrape_and_index.py +15 -15
- intentkit/skills/web_scraper/utils.py +62 -63
- intentkit/skills/web_scraper/website_indexer.py +17 -19
- intentkit/skills/weth/__init__.py +5 -11
- intentkit/skills/wow/__init__.py +5 -11
- intentkit/skills/x402/__init__.py +61 -0
- intentkit/skills/x402/ask_agent.py +98 -0
- intentkit/skills/x402/base.py +99 -0
- intentkit/skills/x402/http_request.py +117 -0
- intentkit/skills/x402/schema.json +45 -0
- intentkit/skills/x402/x402.webp +0 -0
- intentkit/skills/xmtp/__init__.py +4 -15
- intentkit/skills/xmtp/base.py +5 -5
- intentkit/skills/xmtp/price.py +6 -6
- intentkit/skills/xmtp/swap.py +6 -8
- intentkit/skills/xmtp/transfer.py +4 -6
- intentkit/utils/error.py +2 -2
- intentkit/utils/logging.py +2 -4
- intentkit/utils/s3.py +8 -9
- intentkit/utils/schema.py +100 -0
- intentkit/utils/slack_alert.py +7 -8
- {intentkit-0.8.6.dev2.dist-info → intentkit-0.8.17.dist-info}/METADATA +3 -4
- intentkit-0.8.17.dist-info/RECORD +466 -0
- intentkit/models/generator.py +0 -347
- intentkit-0.8.6.dev2.dist-info/RECORD +0 -457
- {intentkit-0.8.6.dev2.dist-info → intentkit-0.8.17.dist-info}/WHEEL +0 -0
- {intentkit-0.8.6.dev2.dist-info → intentkit-0.8.17.dist-info}/licenses/LICENSE +0 -0
intentkit/models/credit.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from datetime import
|
|
2
|
+
from datetime import UTC, datetime
|
|
3
3
|
from decimal import ROUND_HALF_UP, Decimal
|
|
4
4
|
from enum import Enum
|
|
5
|
-
from typing import Annotated, Any
|
|
5
|
+
from typing import Annotated, Any
|
|
6
6
|
|
|
7
7
|
from epyxid import XID
|
|
8
8
|
from fastapi import HTTPException
|
|
@@ -169,7 +169,7 @@ class CreditAccountTable(Base):
|
|
|
169
169
|
DateTime(timezone=True),
|
|
170
170
|
nullable=False,
|
|
171
171
|
server_default=func.now(),
|
|
172
|
-
onupdate=lambda: datetime.now(
|
|
172
|
+
onupdate=lambda: datetime.now(UTC),
|
|
173
173
|
)
|
|
174
174
|
|
|
175
175
|
|
|
@@ -221,15 +221,15 @@ class CreditAccount(BaseModel):
|
|
|
221
221
|
Field(default=Decimal("0"), description="Credits added through top-ups"),
|
|
222
222
|
]
|
|
223
223
|
income_at: Annotated[
|
|
224
|
-
|
|
224
|
+
datetime | None,
|
|
225
225
|
Field(None, description="Timestamp of the last income transaction"),
|
|
226
226
|
]
|
|
227
227
|
expense_at: Annotated[
|
|
228
|
-
|
|
228
|
+
datetime | None,
|
|
229
229
|
Field(None, description="Timestamp of the last expense transaction"),
|
|
230
230
|
]
|
|
231
231
|
last_event_id: Annotated[
|
|
232
|
-
|
|
232
|
+
str | None,
|
|
233
233
|
Field(None, description="ID of the last event that modified this account"),
|
|
234
234
|
]
|
|
235
235
|
# Total statistics fields
|
|
@@ -316,7 +316,7 @@ class CreditAccount(BaseModel):
|
|
|
316
316
|
"""Round decimal values to 4 decimal places."""
|
|
317
317
|
if isinstance(v, Decimal):
|
|
318
318
|
return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
319
|
-
elif isinstance(v,
|
|
319
|
+
elif isinstance(v, int | float):
|
|
320
320
|
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
321
321
|
return v
|
|
322
322
|
|
|
@@ -413,7 +413,7 @@ class CreditAccount(BaseModel):
|
|
|
413
413
|
owner_id: str,
|
|
414
414
|
credit_type: CreditType,
|
|
415
415
|
amount: Decimal,
|
|
416
|
-
event_id:
|
|
416
|
+
event_id: str | None = None,
|
|
417
417
|
) -> "CreditAccount":
|
|
418
418
|
"""Deduct credits from an account. Not checking balance"""
|
|
419
419
|
# check first, create if not exists
|
|
@@ -424,7 +424,7 @@ class CreditAccount(BaseModel):
|
|
|
424
424
|
values_dict = {
|
|
425
425
|
credit_type.value: getattr(CreditAccountTable, credit_type.value)
|
|
426
426
|
- quantized_amount,
|
|
427
|
-
"expense_at": datetime.now(
|
|
427
|
+
"expense_at": datetime.now(UTC),
|
|
428
428
|
# Update total expense statistics
|
|
429
429
|
"total_expense": CreditAccountTable.total_expense + quantized_amount,
|
|
430
430
|
}
|
|
@@ -470,8 +470,8 @@ class CreditAccount(BaseModel):
|
|
|
470
470
|
owner_type: OwnerType,
|
|
471
471
|
owner_id: str,
|
|
472
472
|
amount: Decimal,
|
|
473
|
-
event_id:
|
|
474
|
-
) ->
|
|
473
|
+
event_id: str | None = None,
|
|
474
|
+
) -> tuple["CreditAccount", dict[CreditType, Decimal]]:
|
|
475
475
|
"""Expense credits and return account and credit type.
|
|
476
476
|
We are not checking balance here, since a conversation may have
|
|
477
477
|
multiple expenses, we can't interrupt the conversation.
|
|
@@ -506,7 +506,7 @@ class CreditAccount(BaseModel):
|
|
|
506
506
|
|
|
507
507
|
# Create values dict based on what's in details, defaulting to 0 for missing keys
|
|
508
508
|
values_dict = {
|
|
509
|
-
"expense_at": datetime.now(
|
|
509
|
+
"expense_at": datetime.now(UTC),
|
|
510
510
|
}
|
|
511
511
|
if event_id:
|
|
512
512
|
values_dict["last_event_id"] = event_id
|
|
@@ -581,14 +581,14 @@ class CreditAccount(BaseModel):
|
|
|
581
581
|
session: AsyncSession,
|
|
582
582
|
owner_type: OwnerType,
|
|
583
583
|
owner_id: str,
|
|
584
|
-
amount_details:
|
|
585
|
-
event_id:
|
|
584
|
+
amount_details: dict[CreditType, Decimal],
|
|
585
|
+
event_id: str | None = None,
|
|
586
586
|
) -> "CreditAccount":
|
|
587
587
|
# check first, create if not exists
|
|
588
588
|
await cls.get_or_create_in_session(session, owner_type, owner_id)
|
|
589
589
|
# income
|
|
590
590
|
values_dict = {
|
|
591
|
-
"income_at": datetime.now(
|
|
591
|
+
"income_at": datetime.now(UTC),
|
|
592
592
|
}
|
|
593
593
|
if event_id:
|
|
594
594
|
values_dict["last_event_id"] = event_id
|
|
@@ -646,8 +646,8 @@ class CreditAccount(BaseModel):
|
|
|
646
646
|
session: AsyncSession,
|
|
647
647
|
owner_type: OwnerType,
|
|
648
648
|
owner_id: str,
|
|
649
|
-
free_quota:
|
|
650
|
-
refill_amount:
|
|
649
|
+
free_quota: Decimal | None = None,
|
|
650
|
+
refill_amount: Decimal | None = None,
|
|
651
651
|
) -> "CreditAccount":
|
|
652
652
|
"""Get an existing credit account or create a new one if it doesn't exist.
|
|
653
653
|
|
|
@@ -687,7 +687,7 @@ class CreditAccount(BaseModel):
|
|
|
687
687
|
free_credits=free_quota,
|
|
688
688
|
reward_credits=0.0,
|
|
689
689
|
credits=0.0,
|
|
690
|
-
income_at=datetime.now(
|
|
690
|
+
income_at=datetime.now(UTC),
|
|
691
691
|
expense_at=None,
|
|
692
692
|
last_event_id=event_id if owner_type == OwnerType.USER else None,
|
|
693
693
|
# Initialize new statistics fields
|
|
@@ -781,8 +781,8 @@ class CreditAccount(BaseModel):
|
|
|
781
781
|
cls,
|
|
782
782
|
session: AsyncSession,
|
|
783
783
|
user_id: str,
|
|
784
|
-
free_quota:
|
|
785
|
-
refill_amount:
|
|
784
|
+
free_quota: Decimal | None = None,
|
|
785
|
+
refill_amount: Decimal | None = None,
|
|
786
786
|
upstream_tx_id: str = "",
|
|
787
787
|
note: str = "",
|
|
788
788
|
) -> "CreditAccount":
|
|
@@ -1147,34 +1147,34 @@ class CreditEvent(BaseModel):
|
|
|
1147
1147
|
]
|
|
1148
1148
|
event_type: Annotated[EventType, Field(description="Type of the event")]
|
|
1149
1149
|
user_id: Annotated[
|
|
1150
|
-
|
|
1150
|
+
str | None, Field(None, description="ID of the user if applicable")
|
|
1151
1151
|
]
|
|
1152
1152
|
upstream_type: Annotated[
|
|
1153
1153
|
UpstreamType, Field(description="Type of upstream transaction")
|
|
1154
1154
|
]
|
|
1155
1155
|
upstream_tx_id: Annotated[str, Field(description="Upstream transaction ID if any")]
|
|
1156
1156
|
agent_id: Annotated[
|
|
1157
|
-
|
|
1157
|
+
str | None, Field(None, description="ID of the agent if applicable")
|
|
1158
1158
|
]
|
|
1159
1159
|
agent_wallet_address: Annotated[
|
|
1160
|
-
|
|
1160
|
+
str | None,
|
|
1161
1161
|
Field(None, description="Wallet address of the agent if applicable"),
|
|
1162
1162
|
]
|
|
1163
1163
|
start_message_id: Annotated[
|
|
1164
|
-
|
|
1164
|
+
str | None,
|
|
1165
1165
|
Field(None, description="ID of the starting message if applicable"),
|
|
1166
1166
|
]
|
|
1167
1167
|
message_id: Annotated[
|
|
1168
|
-
|
|
1168
|
+
str | None, Field(None, description="ID of the message if applicable")
|
|
1169
1169
|
]
|
|
1170
1170
|
model: Annotated[
|
|
1171
|
-
|
|
1171
|
+
str | None, Field(None, description="LLM model used if applicable")
|
|
1172
1172
|
]
|
|
1173
1173
|
skill_call_id: Annotated[
|
|
1174
|
-
|
|
1174
|
+
str | None, Field(None, description="ID of the skill call if applicable")
|
|
1175
1175
|
]
|
|
1176
1176
|
skill_name: Annotated[
|
|
1177
|
-
|
|
1177
|
+
str | None, Field(None, description="Name of the skill if applicable")
|
|
1178
1178
|
]
|
|
1179
1179
|
direction: Annotated[Direction, Field(description="Direction of the credit flow")]
|
|
1180
1180
|
total_amount: Annotated[
|
|
@@ -1186,11 +1186,11 @@ class CreditEvent(BaseModel):
|
|
|
1186
1186
|
]
|
|
1187
1187
|
credit_type: Annotated[CreditType, Field(description="Type of credits involved")]
|
|
1188
1188
|
credit_types: Annotated[
|
|
1189
|
-
|
|
1189
|
+
list[CreditType] | None,
|
|
1190
1190
|
Field(default=None, description="Array of credit types involved"),
|
|
1191
1191
|
]
|
|
1192
1192
|
balance_after: Annotated[
|
|
1193
|
-
|
|
1193
|
+
Decimal | None,
|
|
1194
1194
|
Field(None, description="Account total balance after the transaction"),
|
|
1195
1195
|
]
|
|
1196
1196
|
base_amount: Annotated[
|
|
@@ -1198,115 +1198,115 @@ class CreditEvent(BaseModel):
|
|
|
1198
1198
|
Field(default=Decimal("0"), description="Base amount of credits involved"),
|
|
1199
1199
|
]
|
|
1200
1200
|
base_discount_amount: Annotated[
|
|
1201
|
-
|
|
1201
|
+
Decimal | None,
|
|
1202
1202
|
Field(default=Decimal("0"), description="Base discount amount"),
|
|
1203
1203
|
]
|
|
1204
1204
|
base_original_amount: Annotated[
|
|
1205
|
-
|
|
1205
|
+
Decimal | None,
|
|
1206
1206
|
Field(default=Decimal("0"), description="Base original amount"),
|
|
1207
1207
|
]
|
|
1208
1208
|
base_llm_amount: Annotated[
|
|
1209
|
-
|
|
1209
|
+
Decimal | None,
|
|
1210
1210
|
Field(default=Decimal("0"), description="Base LLM cost amount"),
|
|
1211
1211
|
]
|
|
1212
1212
|
base_skill_amount: Annotated[
|
|
1213
|
-
|
|
1213
|
+
Decimal | None,
|
|
1214
1214
|
Field(default=Decimal("0"), description="Base skill cost amount"),
|
|
1215
1215
|
]
|
|
1216
1216
|
base_free_amount: Annotated[
|
|
1217
|
-
|
|
1217
|
+
Decimal | None,
|
|
1218
1218
|
Field(default=Decimal("0"), description="Base free credit amount"),
|
|
1219
1219
|
]
|
|
1220
1220
|
base_reward_amount: Annotated[
|
|
1221
|
-
|
|
1221
|
+
Decimal | None,
|
|
1222
1222
|
Field(default=Decimal("0"), description="Base reward credit amount"),
|
|
1223
1223
|
]
|
|
1224
1224
|
base_permanent_amount: Annotated[
|
|
1225
|
-
|
|
1225
|
+
Decimal | None,
|
|
1226
1226
|
Field(default=Decimal("0"), description="Base permanent credit amount"),
|
|
1227
1227
|
]
|
|
1228
1228
|
fee_platform_amount: Annotated[
|
|
1229
|
-
|
|
1229
|
+
Decimal | None,
|
|
1230
1230
|
Field(default=Decimal("0"), description="Platform fee amount"),
|
|
1231
1231
|
]
|
|
1232
1232
|
fee_platform_free_amount: Annotated[
|
|
1233
|
-
|
|
1233
|
+
Decimal | None,
|
|
1234
1234
|
Field(
|
|
1235
1235
|
default=Decimal("0"), description="Platform fee amount from free credits"
|
|
1236
1236
|
),
|
|
1237
1237
|
]
|
|
1238
1238
|
fee_platform_reward_amount: Annotated[
|
|
1239
|
-
|
|
1239
|
+
Decimal | None,
|
|
1240
1240
|
Field(
|
|
1241
1241
|
default=Decimal("0"), description="Platform fee amount from reward credits"
|
|
1242
1242
|
),
|
|
1243
1243
|
]
|
|
1244
1244
|
fee_platform_permanent_amount: Annotated[
|
|
1245
|
-
|
|
1245
|
+
Decimal | None,
|
|
1246
1246
|
Field(
|
|
1247
1247
|
default=Decimal("0"),
|
|
1248
1248
|
description="Platform fee amount from permanent credits",
|
|
1249
1249
|
),
|
|
1250
1250
|
]
|
|
1251
1251
|
fee_dev_account: Annotated[
|
|
1252
|
-
|
|
1252
|
+
str | None, Field(None, description="Developer account ID receiving fee")
|
|
1253
1253
|
]
|
|
1254
1254
|
fee_dev_amount: Annotated[
|
|
1255
|
-
|
|
1255
|
+
Decimal | None,
|
|
1256
1256
|
Field(default=Decimal("0"), description="Developer fee amount"),
|
|
1257
1257
|
]
|
|
1258
1258
|
fee_dev_free_amount: Annotated[
|
|
1259
|
-
|
|
1259
|
+
Decimal | None,
|
|
1260
1260
|
Field(
|
|
1261
1261
|
default=Decimal("0"), description="Developer fee amount from free credits"
|
|
1262
1262
|
),
|
|
1263
1263
|
]
|
|
1264
1264
|
fee_dev_reward_amount: Annotated[
|
|
1265
|
-
|
|
1265
|
+
Decimal | None,
|
|
1266
1266
|
Field(
|
|
1267
1267
|
default=Decimal("0"), description="Developer fee amount from reward credits"
|
|
1268
1268
|
),
|
|
1269
1269
|
]
|
|
1270
1270
|
fee_dev_permanent_amount: Annotated[
|
|
1271
|
-
|
|
1271
|
+
Decimal | None,
|
|
1272
1272
|
Field(
|
|
1273
1273
|
default=Decimal("0"),
|
|
1274
1274
|
description="Developer fee amount from permanent credits",
|
|
1275
1275
|
),
|
|
1276
1276
|
]
|
|
1277
1277
|
fee_agent_account: Annotated[
|
|
1278
|
-
|
|
1278
|
+
str | None, Field(None, description="Agent account ID receiving fee")
|
|
1279
1279
|
]
|
|
1280
1280
|
fee_agent_amount: Annotated[
|
|
1281
|
-
|
|
1281
|
+
Decimal | None, Field(default=Decimal("0"), description="Agent fee amount")
|
|
1282
1282
|
]
|
|
1283
1283
|
fee_agent_free_amount: Annotated[
|
|
1284
|
-
|
|
1284
|
+
Decimal | None,
|
|
1285
1285
|
Field(default=Decimal("0"), description="Agent fee amount from free credits"),
|
|
1286
1286
|
]
|
|
1287
1287
|
fee_agent_reward_amount: Annotated[
|
|
1288
|
-
|
|
1288
|
+
Decimal | None,
|
|
1289
1289
|
Field(default=Decimal("0"), description="Agent fee amount from reward credits"),
|
|
1290
1290
|
]
|
|
1291
1291
|
fee_agent_permanent_amount: Annotated[
|
|
1292
|
-
|
|
1292
|
+
Decimal | None,
|
|
1293
1293
|
Field(
|
|
1294
1294
|
default=Decimal("0"), description="Agent fee amount from permanent credits"
|
|
1295
1295
|
),
|
|
1296
1296
|
]
|
|
1297
1297
|
free_amount: Annotated[
|
|
1298
|
-
|
|
1298
|
+
Decimal | None,
|
|
1299
1299
|
Field(default=Decimal("0"), description="Free credit amount involved"),
|
|
1300
1300
|
]
|
|
1301
1301
|
reward_amount: Annotated[
|
|
1302
|
-
|
|
1302
|
+
Decimal | None,
|
|
1303
1303
|
Field(default=Decimal("0"), description="Reward credit amount involved"),
|
|
1304
1304
|
]
|
|
1305
1305
|
permanent_amount: Annotated[
|
|
1306
|
-
|
|
1306
|
+
Decimal | None,
|
|
1307
1307
|
Field(default=Decimal("0"), description="Permanent credit amount involved"),
|
|
1308
1308
|
]
|
|
1309
|
-
note: Annotated[
|
|
1309
|
+
note: Annotated[str | None, Field(None, description="Additional notes")]
|
|
1310
1310
|
created_at: Annotated[
|
|
1311
1311
|
datetime, Field(description="Timestamp when this event was created")
|
|
1312
1312
|
]
|
|
@@ -1339,13 +1339,13 @@ class CreditEvent(BaseModel):
|
|
|
1339
1339
|
"permanent_amount",
|
|
1340
1340
|
)
|
|
1341
1341
|
@classmethod
|
|
1342
|
-
def round_decimal(cls, v: Any) ->
|
|
1342
|
+
def round_decimal(cls, v: Any) -> Decimal | None:
|
|
1343
1343
|
"""Round decimal values to 4 decimal places."""
|
|
1344
1344
|
if v is None:
|
|
1345
1345
|
return None
|
|
1346
1346
|
if isinstance(v, Decimal):
|
|
1347
1347
|
return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1348
|
-
elif isinstance(v,
|
|
1348
|
+
elif isinstance(v, int | float):
|
|
1349
1349
|
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1350
1350
|
return v
|
|
1351
1351
|
|
|
@@ -1520,7 +1520,7 @@ class CreditTransaction(BaseModel):
|
|
|
1520
1520
|
"""Round decimal values to 4 decimal places."""
|
|
1521
1521
|
if isinstance(v, Decimal):
|
|
1522
1522
|
return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1523
|
-
elif isinstance(v,
|
|
1523
|
+
elif isinstance(v, int | float):
|
|
1524
1524
|
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1525
1525
|
return v
|
|
1526
1526
|
|
|
@@ -1585,7 +1585,7 @@ class CreditPriceTable(Base):
|
|
|
1585
1585
|
DateTime(timezone=True),
|
|
1586
1586
|
nullable=False,
|
|
1587
1587
|
server_default=func.now(),
|
|
1588
|
-
onupdate=lambda: datetime.now(
|
|
1588
|
+
onupdate=lambda: datetime.now(UTC),
|
|
1589
1589
|
)
|
|
1590
1590
|
|
|
1591
1591
|
|
|
@@ -1623,7 +1623,7 @@ class CreditPrice(BaseModel):
|
|
|
1623
1623
|
"""Round decimal values to 4 decimal places."""
|
|
1624
1624
|
if isinstance(v, Decimal):
|
|
1625
1625
|
return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1626
|
-
elif isinstance(v,
|
|
1626
|
+
elif isinstance(v, int | float):
|
|
1627
1627
|
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1628
1628
|
return v
|
|
1629
1629
|
|
|
@@ -1700,13 +1700,11 @@ class CreditPriceLog(BaseModel):
|
|
|
1700
1700
|
"""Round decimal values to 4 decimal places."""
|
|
1701
1701
|
if isinstance(v, Decimal):
|
|
1702
1702
|
return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1703
|
-
elif isinstance(v,
|
|
1703
|
+
elif isinstance(v, int | float):
|
|
1704
1704
|
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
|
|
1705
1705
|
return v
|
|
1706
1706
|
|
|
1707
|
-
note: Annotated[
|
|
1708
|
-
Optional[str], Field(None, description="Note about the modification")
|
|
1709
|
-
]
|
|
1707
|
+
note: Annotated[str | None, Field(None, description="Note about the modification")]
|
|
1710
1708
|
modified_by: Annotated[
|
|
1711
1709
|
str, Field(description="ID of the user who made the modification")
|
|
1712
1710
|
]
|
intentkit/models/db.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
from collections.abc import AsyncGenerator
|
|
1
2
|
from contextlib import asynccontextmanager
|
|
2
|
-
from typing import Annotated
|
|
3
|
+
from typing import Annotated
|
|
3
4
|
from urllib.parse import quote_plus
|
|
4
5
|
|
|
5
6
|
from intentkit.models.db_mig import safe_migrate
|
|
@@ -12,7 +13,7 @@ from pydantic import Field
|
|
|
12
13
|
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine
|
|
13
14
|
|
|
14
15
|
engine = None
|
|
15
|
-
_langgraph_checkpointer:
|
|
16
|
+
_langgraph_checkpointer: Checkpointer | None = None
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
async def check_connection(conn):
|
|
@@ -28,11 +29,11 @@ async def check_connection(conn):
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
async def init_db(
|
|
31
|
-
host:
|
|
32
|
-
username:
|
|
33
|
-
password:
|
|
34
|
-
dbname:
|
|
35
|
-
port: Annotated[
|
|
32
|
+
host: str | None,
|
|
33
|
+
username: str | None,
|
|
34
|
+
password: str | None,
|
|
35
|
+
dbname: str | None,
|
|
36
|
+
port: Annotated[str | None, Field(default="5432", description="Database port")],
|
|
36
37
|
auto_migrate: Annotated[
|
|
37
38
|
bool, Field(default=True, description="Whether to run migrations automatically")
|
|
38
39
|
],
|
intentkit/models/db_mig.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Database migration utilities."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
-
from
|
|
4
|
+
from collections.abc import Callable
|
|
5
5
|
|
|
6
6
|
from intentkit.models.base import Base
|
|
7
7
|
from sqlalchemy import Column, MetaData, inspect, text
|
|
@@ -40,7 +40,7 @@ async def add_column_if_not_exists(
|
|
|
40
40
|
default_value = str(default_value).lower()
|
|
41
41
|
elif isinstance(default_value, str):
|
|
42
42
|
default_value = f"'{default_value}'"
|
|
43
|
-
elif isinstance(default_value,
|
|
43
|
+
elif isinstance(default_value, list | dict):
|
|
44
44
|
default_value = "'{}'"
|
|
45
45
|
column_def += f" DEFAULT {default_value}"
|
|
46
46
|
|
intentkit/models/llm.csv
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
id,name,provider,enabled,input_price,output_price,price_level,context_length,output_length,intelligence,speed,supports_image_input,supports_skill_calls,supports_structured_output,has_reasoning,supports_search,supports_temperature,supports_frequency_penalty,supports_presence_penalty,api_base,timeout
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
minimax/minimax-m2:free,MiniMax M2,gatewayz,TRUE,0,0,1,204800,131000,4,2,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
3
|
+
qwen/qwen3-235b-a22b-2507,Qwen3 235B A22B Instruct 2507,gatewayz,TRUE,0.1,0.6,1,262000,262000,3,3,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
4
|
+
qwen/qwen3-max,Qwen3 Max,gatewayz,TRUE,1.2,6,4,128000,32000,4,2,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
5
|
+
google/gemini-2.5-flash,Gemini 2.5 Flash,gatewayz,TRUE,0.3,2.5,2,1050000,65000,3,4,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
6
|
+
google/gemini-2.5-pro,Gemini 2.5 Pro,gatewayz,TRUE,1.25,10,4,1050000,65000,4,2,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
7
|
+
anthropic/claude-sonnet-4.5,Anthropic Claude Sonnet 4.5,gatewayz,TRUE,3,15,5,200000,64000,5,1,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,https://api.gatewayz.ai/v1,300
|
|
8
|
+
gpt-5-nano,GPT-5 Nano,openai,TRUE,0.05,0.4,1,400000,128000,3,5,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
9
|
+
gpt-5-mini,GPT-5 Mini,openai,TRUE,0.25,2,2,400000,128000,4,4,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
10
|
+
gpt-5,GPT-5,openai,TRUE,1.25,10,4,400000,128000,5,3,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,,180
|
|
7
11
|
gpt-4o,GPT-4o,openai,FALSE,2.5,10,4,128000,4096,4,3,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,,180
|
|
8
12
|
gpt-4o-mini,GPT-4o Mini,openai,FALSE,0.15,0.6,1,128000,4096,3,4,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,,180
|
|
9
13
|
gpt-4.1-nano,GPT-4.1 Nano,openai,TRUE,0.1,0.4,1,128000,4096,3,5,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,,180
|
|
10
14
|
gpt-4.1-mini,GPT-4.1 Mini,openai,TRUE,0.4,1.6,2,128000,4096,4,4,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,,180
|
|
11
15
|
gpt-4.1,GPT-4.1,openai,TRUE,2,8,4,128000,4096,5,3,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,,180
|
|
12
|
-
gpt-5-nano,GPT-5 Nano,openai,TRUE,0.05,0.4,1,400000,128000,3,5,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
13
|
-
gpt-5-mini,GPT-5 Mini,openai,TRUE,0.25,2,2,400000,128000,4,4,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
14
|
-
gpt-5,GPT-5,openai,TRUE,1.25,10,4,400000,128000,5,3,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,,180
|
|
15
16
|
o3,OpenAI o3,openai,TRUE,2,8,4,200000,100000,5,1,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
16
17
|
o4-mini,OpenAI o4-mini,openai,TRUE,1.1,4.4,3,128000,4096,4,3,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,,180
|
|
17
|
-
deepseek-chat,Deepseek V3.
|
|
18
|
-
deepseek-reasoner,DeepSeek V3.
|
|
19
|
-
grok-
|
|
20
|
-
grok-
|
|
18
|
+
deepseek-chat,Deepseek V3.2 Exp,deepseek,TRUE,0.28,0.42,2,128000,4096,4,3,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,https://api.deepseek.com,300
|
|
19
|
+
deepseek-reasoner,DeepSeek V3.2 Exp (Thinking Mode),deepseek,TRUE,0.28,0.42,2,128000,32000,5,1,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,https://api.deepseek.com,300
|
|
20
|
+
grok-4,Grok 4,xai,TRUE,3,15,4,256000,4096,5,3,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,,180
|
|
21
|
+
grok-4-fast-non-reasoning,Grok 4 Fast,xai,TRUE,0.2,0.5,2,2000000,4096,3,4,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,,180
|
|
22
|
+
grok-code-fast-1,Grok Code Fast 1,xai,TRUE,0.2,1.5,3,256000,4096,4,4,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,,180
|
|
23
|
+
grok-3,Grok 3,xai,TRUE,3,15,4,131072,4096,5,3,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,,180
|
|
21
24
|
grok-3-mini,Grok 3 Mini,xai,TRUE,0.3,0.5,2,131072,4096,5,3,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,,180
|
|
22
25
|
eternalai,Eternal AI (Llama-3.3-70B),eternal,FALSE,0.25,0.75,2,64000,4096,4,3,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,https://api.eternalai.org/v1,300
|
|
23
26
|
reigent,REI Network,reigent,FALSE,0.5,1.5,3,32000,4096,4,3,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,https://api.reisearch.box/v1,300
|
intentkit/models/llm.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import csv
|
|
2
2
|
import json
|
|
3
3
|
import logging
|
|
4
|
-
from datetime import
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
5
|
from decimal import ROUND_HALF_UP, Decimal
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Annotated, Any
|
|
8
|
+
from typing import Annotated, Any
|
|
9
9
|
|
|
10
10
|
from intentkit.config.config import config
|
|
11
11
|
from intentkit.models.app_setting import AppSetting
|
|
12
12
|
from intentkit.models.base import Base
|
|
13
13
|
from intentkit.models.db import get_session
|
|
14
14
|
from intentkit.models.redis import get_redis
|
|
15
|
-
from intentkit.utils.error import
|
|
15
|
+
from intentkit.utils.error import IntentKitAPIError
|
|
16
16
|
from langchain.chat_models.base import BaseChatModel
|
|
17
17
|
from pydantic import BaseModel, ConfigDict, Field
|
|
18
18
|
from sqlalchemy import Boolean, Column, DateTime, Integer, Numeric, String, func, select
|
|
@@ -24,13 +24,13 @@ _credit_per_usdc = None
|
|
|
24
24
|
FOURPLACES = Decimal("0.0001")
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def _parse_bool(value:
|
|
27
|
+
def _parse_bool(value: str | None) -> bool:
|
|
28
28
|
if value is None:
|
|
29
29
|
return False
|
|
30
30
|
return value.strip().lower() in {"true", "1", "yes"}
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def _parse_optional_int(value:
|
|
33
|
+
def _parse_optional_int(value: str | None) -> int | None:
|
|
34
34
|
if value is None:
|
|
35
35
|
return None
|
|
36
36
|
value = value.strip()
|
|
@@ -45,12 +45,12 @@ def _load_default_llm_models() -> dict[str, "LLMModelInfo"]:
|
|
|
45
45
|
logger.warning("Default LLM CSV not found at %s", path)
|
|
46
46
|
return {}
|
|
47
47
|
|
|
48
|
-
defaults: dict[str,
|
|
48
|
+
defaults: dict[str, LLMModelInfo] = {}
|
|
49
49
|
with path.open(newline="", encoding="utf-8") as csvfile:
|
|
50
50
|
reader = csv.DictReader(csvfile)
|
|
51
51
|
for row in reader:
|
|
52
52
|
try:
|
|
53
|
-
timestamp = datetime.now(
|
|
53
|
+
timestamp = datetime.now(UTC)
|
|
54
54
|
model = LLMModelInfo(
|
|
55
55
|
id=row["id"],
|
|
56
56
|
name=row["name"],
|
|
@@ -154,7 +154,7 @@ class LLMModelInfoTable(Base):
|
|
|
154
154
|
DateTime(timezone=True),
|
|
155
155
|
nullable=False,
|
|
156
156
|
server_default=func.now(),
|
|
157
|
-
onupdate=lambda: datetime.now(
|
|
157
|
+
onupdate=lambda: datetime.now(UTC),
|
|
158
158
|
)
|
|
159
159
|
|
|
160
160
|
|
|
@@ -173,7 +173,7 @@ class LLMModelInfo(BaseModel):
|
|
|
173
173
|
enabled: bool = Field(default=True)
|
|
174
174
|
input_price: Decimal # Price per 1M input tokens in USD
|
|
175
175
|
output_price: Decimal # Price per 1M output tokens in USD
|
|
176
|
-
price_level:
|
|
176
|
+
price_level: int | None = Field(
|
|
177
177
|
default=None, ge=1, le=5
|
|
178
178
|
) # Price level rating from 1-5
|
|
179
179
|
context_length: int # Maximum context length in tokens
|
|
@@ -198,22 +198,20 @@ class LLMModelInfo(BaseModel):
|
|
|
198
198
|
supports_presence_penalty: bool = (
|
|
199
199
|
True # Whether the model supports presence_penalty parameter
|
|
200
200
|
)
|
|
201
|
-
api_base:
|
|
202
|
-
None # Custom API base URL if not using provider's default
|
|
203
|
-
)
|
|
201
|
+
api_base: str | None = None # Custom API base URL if not using provider's default
|
|
204
202
|
timeout: int = 180 # Default timeout in seconds
|
|
205
203
|
created_at: Annotated[
|
|
206
204
|
datetime,
|
|
207
205
|
Field(
|
|
208
206
|
description="Timestamp when this data was created",
|
|
209
|
-
default=datetime.now(
|
|
207
|
+
default=datetime.now(UTC),
|
|
210
208
|
),
|
|
211
209
|
]
|
|
212
210
|
updated_at: Annotated[
|
|
213
211
|
datetime,
|
|
214
212
|
Field(
|
|
215
213
|
description="Timestamp when this data was updated",
|
|
216
|
-
default=datetime.now(
|
|
214
|
+
default=datetime.now(UTC),
|
|
217
215
|
),
|
|
218
216
|
]
|
|
219
217
|
|
|
@@ -282,7 +280,11 @@ class LLMModelInfo(BaseModel):
|
|
|
282
280
|
return model_info
|
|
283
281
|
|
|
284
282
|
# Not found anywhere
|
|
285
|
-
raise
|
|
283
|
+
raise IntentKitAPIError(
|
|
284
|
+
400,
|
|
285
|
+
"ModelNotFound",
|
|
286
|
+
f"Model {model_id} not found, maybe deprecated, please change it in the agent configuration.",
|
|
287
|
+
)
|
|
286
288
|
|
|
287
289
|
@classmethod
|
|
288
290
|
async def get_all(cls, session: AsyncSession | None = None) -> list["LLMModelInfo"]:
|
|
@@ -292,7 +294,7 @@ class LLMModelInfo(BaseModel):
|
|
|
292
294
|
async with get_session() as db:
|
|
293
295
|
return await cls.get_all(session=db)
|
|
294
296
|
|
|
295
|
-
models: dict[str,
|
|
297
|
+
models: dict[str, LLMModelInfo] = {
|
|
296
298
|
model_id: model.model_copy(deep=True)
|
|
297
299
|
for model_id, model in AVAILABLE_MODELS.items()
|
|
298
300
|
}
|
intentkit/models/redis.py
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"""Redis client module for IntentKit."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
-
from typing import Optional
|
|
5
4
|
|
|
6
5
|
from redis.asyncio import Redis
|
|
7
6
|
|
|
8
7
|
logger = logging.getLogger(__name__)
|
|
9
8
|
|
|
10
9
|
# Global Redis client instance
|
|
11
|
-
_redis_client:
|
|
10
|
+
_redis_client: Redis | None = None
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
async def init_redis(
|
|
15
14
|
host: str,
|
|
16
15
|
port: int = 6379,
|
|
17
16
|
db: int = 0,
|
|
18
|
-
password:
|
|
17
|
+
password: str | None = None,
|
|
19
18
|
ssl: bool = False,
|
|
20
19
|
encoding: str = "utf-8",
|
|
21
20
|
decode_responses: bool = True,
|