intentkit 0.8.16.dev1__py3-none-any.whl → 0.8.17.dev2__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.

Files changed (274) hide show
  1. intentkit/__init__.py +1 -1
  2. intentkit/abstracts/agent.py +4 -5
  3. intentkit/abstracts/engine.py +5 -5
  4. intentkit/abstracts/graph.py +6 -5
  5. intentkit/abstracts/skill.py +5 -5
  6. intentkit/abstracts/twitter.py +4 -5
  7. intentkit/clients/cdp.py +19 -77
  8. intentkit/clients/twitter.py +26 -34
  9. intentkit/clients/web3.py +1 -3
  10. intentkit/config/config.py +4 -0
  11. intentkit/core/agent.py +15 -15
  12. intentkit/core/asset.py +1 -2
  13. intentkit/core/client.py +1 -1
  14. intentkit/core/credit.py +19 -20
  15. intentkit/core/engine.py +2 -4
  16. intentkit/core/node.py +2 -1
  17. intentkit/core/prompt.py +3 -4
  18. intentkit/core/scheduler.py +1 -1
  19. intentkit/core/statistics.py +6 -7
  20. intentkit/models/agent.py +125 -92
  21. intentkit/models/agent_data.py +62 -36
  22. intentkit/models/app_setting.py +6 -6
  23. intentkit/models/chat.py +27 -24
  24. intentkit/models/conversation.py +8 -8
  25. intentkit/models/credit.py +62 -64
  26. intentkit/models/db.py +8 -7
  27. intentkit/models/db_mig.py +2 -2
  28. intentkit/models/llm.py +12 -14
  29. intentkit/models/redis.py +2 -3
  30. intentkit/models/skill.py +25 -27
  31. intentkit/models/skills.csv +29 -28
  32. intentkit/models/user.py +21 -22
  33. intentkit/skills/acolyt/ask.py +3 -4
  34. intentkit/skills/acolyt/base.py +1 -3
  35. intentkit/skills/aixbt/base.py +1 -3
  36. intentkit/skills/aixbt/projects.py +13 -13
  37. intentkit/skills/allora/base.py +1 -3
  38. intentkit/skills/allora/price.py +2 -3
  39. intentkit/skills/base.py +15 -22
  40. intentkit/skills/basename/__init__.py +3 -5
  41. intentkit/skills/carv/__init__.py +7 -8
  42. intentkit/skills/carv/base.py +6 -6
  43. intentkit/skills/carv/fetch_news.py +3 -3
  44. intentkit/skills/carv/onchain_query.py +4 -4
  45. intentkit/skills/carv/token_info_and_price.py +5 -5
  46. intentkit/skills/casino/base.py +1 -3
  47. intentkit/skills/casino/deck_draw.py +1 -2
  48. intentkit/skills/casino/deck_shuffle.py +1 -2
  49. intentkit/skills/casino/dice_roll.py +1 -2
  50. intentkit/skills/cdp/__init__.py +3 -5
  51. intentkit/skills/cdp/base.py +1 -3
  52. intentkit/skills/chainlist/base.py +1 -3
  53. intentkit/skills/chainlist/chain_lookup.py +18 -18
  54. intentkit/skills/common/base.py +1 -3
  55. intentkit/skills/common/current_time.py +1 -2
  56. intentkit/skills/cookiefun/base.py +1 -2
  57. intentkit/skills/cookiefun/get_account_details.py +7 -7
  58. intentkit/skills/cookiefun/get_account_feed.py +19 -19
  59. intentkit/skills/cookiefun/get_account_smart_followers.py +7 -7
  60. intentkit/skills/cookiefun/get_sectors.py +3 -3
  61. intentkit/skills/cookiefun/search_accounts.py +9 -9
  62. intentkit/skills/cryptocompare/api.py +2 -3
  63. intentkit/skills/cryptocompare/base.py +6 -6
  64. intentkit/skills/cryptocompare/fetch_news.py +3 -4
  65. intentkit/skills/cryptocompare/fetch_price.py +5 -6
  66. intentkit/skills/cryptocompare/fetch_top_exchanges.py +3 -4
  67. intentkit/skills/cryptocompare/fetch_top_market_cap.py +3 -4
  68. intentkit/skills/cryptocompare/fetch_top_volume.py +3 -4
  69. intentkit/skills/cryptocompare/fetch_trading_signals.py +4 -5
  70. intentkit/skills/cryptopanic/__init__.py +4 -4
  71. intentkit/skills/cryptopanic/base.py +1 -3
  72. intentkit/skills/cryptopanic/fetch_crypto_news.py +3 -5
  73. intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +3 -3
  74. intentkit/skills/dapplooker/base.py +1 -3
  75. intentkit/skills/dapplooker/dapplooker_token_data.py +7 -7
  76. intentkit/skills/defillama/api.py +6 -9
  77. intentkit/skills/defillama/base.py +5 -6
  78. intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +6 -8
  79. intentkit/skills/defillama/coins/fetch_block.py +4 -6
  80. intentkit/skills/defillama/coins/fetch_current_prices.py +6 -8
  81. intentkit/skills/defillama/coins/fetch_first_price.py +5 -7
  82. intentkit/skills/defillama/coins/fetch_historical_prices.py +7 -9
  83. intentkit/skills/defillama/coins/fetch_price_chart.py +7 -9
  84. intentkit/skills/defillama/coins/fetch_price_percentage.py +5 -7
  85. intentkit/skills/defillama/config/chains.py +1 -3
  86. intentkit/skills/defillama/fees/fetch_fees_overview.py +22 -24
  87. intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +14 -16
  88. intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +6 -8
  89. intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +3 -5
  90. intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +5 -7
  91. intentkit/skills/defillama/tests/api_integration.test.py +1 -1
  92. intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +2 -4
  93. intentkit/skills/defillama/tvl/fetch_chains.py +7 -9
  94. intentkit/skills/defillama/tvl/fetch_historical_tvl.py +2 -4
  95. intentkit/skills/defillama/tvl/fetch_protocol.py +30 -36
  96. intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +1 -3
  97. intentkit/skills/defillama/tvl/fetch_protocols.py +35 -43
  98. intentkit/skills/defillama/volumes/fetch_dex_overview.py +40 -46
  99. intentkit/skills/defillama/volumes/fetch_dex_summary.py +33 -35
  100. intentkit/skills/defillama/volumes/fetch_options_overview.py +22 -26
  101. intentkit/skills/defillama/yields/fetch_pool_chart.py +8 -10
  102. intentkit/skills/defillama/yields/fetch_pools.py +24 -28
  103. intentkit/skills/dexscreener/__init__.py +2 -2
  104. intentkit/skills/dexscreener/base.py +3 -3
  105. intentkit/skills/dexscreener/get_pair_info.py +2 -2
  106. intentkit/skills/dexscreener/get_token_pairs.py +2 -2
  107. intentkit/skills/dexscreener/get_tokens_info.py +5 -5
  108. intentkit/skills/dexscreener/model/search_token_response.py +80 -82
  109. intentkit/skills/dexscreener/search_token.py +182 -182
  110. intentkit/skills/dexscreener/utils.py +15 -14
  111. intentkit/skills/dune_analytics/__init__.py +4 -4
  112. intentkit/skills/dune_analytics/base.py +1 -3
  113. intentkit/skills/dune_analytics/fetch_kol_buys.py +4 -4
  114. intentkit/skills/dune_analytics/fetch_nation_metrics.py +5 -5
  115. intentkit/skills/elfa/base.py +1 -3
  116. intentkit/skills/elfa/mention.py +19 -21
  117. intentkit/skills/elfa/stats.py +4 -4
  118. intentkit/skills/elfa/tokens.py +12 -12
  119. intentkit/skills/elfa/utils.py +25 -27
  120. intentkit/skills/enso/__init__.py +2 -2
  121. intentkit/skills/enso/base.py +5 -8
  122. intentkit/skills/enso/best_yield.py +4 -6
  123. intentkit/skills/enso/networks.py +1 -2
  124. intentkit/skills/enso/prices.py +1 -3
  125. intentkit/skills/enso/route.py +1 -3
  126. intentkit/skills/enso/tokens.py +1 -3
  127. intentkit/skills/enso/wallet.py +5 -5
  128. intentkit/skills/erc20/__init__.py +4 -6
  129. intentkit/skills/erc721/__init__.py +4 -6
  130. intentkit/skills/firecrawl/base.py +1 -3
  131. intentkit/skills/firecrawl/clear.py +1 -2
  132. intentkit/skills/firecrawl/crawl.py +9 -10
  133. intentkit/skills/firecrawl/query.py +1 -2
  134. intentkit/skills/firecrawl/scrape.py +7 -8
  135. intentkit/skills/firecrawl/utils.py +13 -13
  136. intentkit/skills/github/base.py +1 -3
  137. intentkit/skills/github/github_search.py +1 -2
  138. intentkit/skills/heurist/base.py +1 -3
  139. intentkit/skills/heurist/image_generation_animagine_xl.py +7 -8
  140. intentkit/skills/heurist/image_generation_arthemy_comics.py +7 -8
  141. intentkit/skills/heurist/image_generation_arthemy_real.py +7 -8
  142. intentkit/skills/heurist/image_generation_braindance.py +7 -8
  143. intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +7 -8
  144. intentkit/skills/heurist/image_generation_flux_1_dev.py +7 -8
  145. intentkit/skills/heurist/image_generation_sdxl.py +7 -8
  146. intentkit/skills/http/base.py +1 -3
  147. intentkit/skills/http/get.py +7 -7
  148. intentkit/skills/http/post.py +9 -9
  149. intentkit/skills/http/put.py +9 -9
  150. intentkit/skills/lifi/__init__.py +4 -4
  151. intentkit/skills/lifi/base.py +1 -3
  152. intentkit/skills/lifi/token_execute.py +13 -13
  153. intentkit/skills/lifi/token_quote.py +6 -6
  154. intentkit/skills/lifi/utils.py +16 -16
  155. intentkit/skills/moralis/__init__.py +3 -3
  156. intentkit/skills/moralis/api.py +6 -7
  157. intentkit/skills/moralis/base.py +2 -4
  158. intentkit/skills/moralis/fetch_chain_portfolio.py +10 -11
  159. intentkit/skills/moralis/fetch_nft_portfolio.py +22 -22
  160. intentkit/skills/moralis/fetch_solana_portfolio.py +11 -12
  161. intentkit/skills/moralis/fetch_wallet_portfolio.py +8 -9
  162. intentkit/skills/morpho/__init__.py +4 -6
  163. intentkit/skills/nation/__init__.py +2 -2
  164. intentkit/skills/nation/base.py +1 -3
  165. intentkit/skills/nation/nft_check.py +3 -4
  166. intentkit/skills/onchain.py +2 -6
  167. intentkit/skills/openai/base.py +1 -3
  168. intentkit/skills/openai/dalle_image_generation.py +1 -3
  169. intentkit/skills/openai/gpt_image_generation.py +2 -3
  170. intentkit/skills/openai/gpt_image_to_image.py +2 -3
  171. intentkit/skills/openai/image_to_text.py +1 -2
  172. intentkit/skills/portfolio/base.py +6 -6
  173. intentkit/skills/portfolio/token_balances.py +21 -21
  174. intentkit/skills/portfolio/wallet_approvals.py +7 -7
  175. intentkit/skills/portfolio/wallet_defi_positions.py +3 -3
  176. intentkit/skills/portfolio/wallet_history.py +21 -21
  177. intentkit/skills/portfolio/wallet_net_worth.py +13 -13
  178. intentkit/skills/portfolio/wallet_nfts.py +19 -19
  179. intentkit/skills/portfolio/wallet_profitability.py +7 -7
  180. intentkit/skills/portfolio/wallet_profitability_summary.py +5 -5
  181. intentkit/skills/portfolio/wallet_stats.py +3 -3
  182. intentkit/skills/portfolio/wallet_swaps.py +19 -19
  183. intentkit/skills/pyth/__init__.py +3 -5
  184. intentkit/skills/slack/base.py +2 -4
  185. intentkit/skills/slack/get_channel.py +8 -8
  186. intentkit/skills/slack/get_message.py +9 -9
  187. intentkit/skills/slack/schedule_message.py +5 -5
  188. intentkit/skills/slack/send_message.py +3 -5
  189. intentkit/skills/supabase/base.py +1 -3
  190. intentkit/skills/supabase/delete_data.py +4 -4
  191. intentkit/skills/supabase/fetch_data.py +12 -12
  192. intentkit/skills/supabase/insert_data.py +4 -4
  193. intentkit/skills/supabase/invoke_function.py +6 -6
  194. intentkit/skills/supabase/update_data.py +6 -6
  195. intentkit/skills/supabase/upsert_data.py +4 -4
  196. intentkit/skills/superfluid/__init__.py +4 -6
  197. intentkit/skills/system/add_autonomous_task.py +8 -10
  198. intentkit/skills/system/edit_autonomous_task.py +12 -14
  199. intentkit/skills/system/list_autonomous_tasks.py +1 -3
  200. intentkit/skills/tavily/base.py +1 -3
  201. intentkit/skills/tavily/tavily_extract.py +1 -2
  202. intentkit/skills/tavily/tavily_search.py +1 -3
  203. intentkit/skills/token/base.py +5 -5
  204. intentkit/skills/token/erc20_transfers.py +19 -19
  205. intentkit/skills/token/token_analytics.py +3 -3
  206. intentkit/skills/token/token_price.py +13 -13
  207. intentkit/skills/token/token_search.py +9 -9
  208. intentkit/skills/twitter/base.py +3 -4
  209. intentkit/skills/twitter/follow_user.py +1 -2
  210. intentkit/skills/twitter/get_mentions.py +3 -4
  211. intentkit/skills/twitter/get_timeline.py +1 -2
  212. intentkit/skills/twitter/get_user_by_username.py +1 -2
  213. intentkit/skills/twitter/get_user_tweets.py +2 -3
  214. intentkit/skills/twitter/like_tweet.py +1 -2
  215. intentkit/skills/twitter/post_tweet.py +3 -4
  216. intentkit/skills/twitter/reply_tweet.py +3 -4
  217. intentkit/skills/twitter/retweet.py +1 -2
  218. intentkit/skills/twitter/search_tweets.py +1 -2
  219. intentkit/skills/unrealspeech/base.py +1 -3
  220. intentkit/skills/unrealspeech/text_to_speech.py +8 -8
  221. intentkit/skills/venice_audio/__init__.py +8 -9
  222. intentkit/skills/venice_audio/base.py +3 -4
  223. intentkit/skills/venice_audio/input.py +41 -41
  224. intentkit/skills/venice_audio/venice_audio.py +6 -6
  225. intentkit/skills/venice_image/__init__.py +5 -5
  226. intentkit/skills/venice_image/api.py +138 -138
  227. intentkit/skills/venice_image/base.py +3 -3
  228. intentkit/skills/venice_image/config.py +33 -35
  229. intentkit/skills/venice_image/image_enhance/image_enhance.py +2 -3
  230. intentkit/skills/venice_image/image_enhance/image_enhance_base.py +21 -23
  231. intentkit/skills/venice_image/image_enhance/image_enhance_input.py +38 -40
  232. intentkit/skills/venice_image/image_generation/image_generation_base.py +9 -9
  233. intentkit/skills/venice_image/image_generation/image_generation_fluently_xl.py +26 -26
  234. intentkit/skills/venice_image/image_generation/image_generation_flux_dev.py +27 -27
  235. intentkit/skills/venice_image/image_generation/image_generation_flux_dev_uncensored.py +26 -26
  236. intentkit/skills/venice_image/image_generation/image_generation_input.py +158 -158
  237. intentkit/skills/venice_image/image_generation/image_generation_lustify_sdxl.py +26 -26
  238. intentkit/skills/venice_image/image_generation/image_generation_pony_realism.py +26 -26
  239. intentkit/skills/venice_image/image_generation/image_generation_stable_diffusion_3_5.py +28 -28
  240. intentkit/skills/venice_image/image_generation/image_generation_venice_sd35.py +28 -28
  241. intentkit/skills/venice_image/image_upscale/image_upscale.py +3 -3
  242. intentkit/skills/venice_image/image_upscale/image_upscale_base.py +21 -23
  243. intentkit/skills/venice_image/image_upscale/image_upscale_input.py +22 -22
  244. intentkit/skills/venice_image/image_vision/image_vision.py +2 -2
  245. intentkit/skills/venice_image/image_vision/image_vision_base.py +17 -17
  246. intentkit/skills/venice_image/image_vision/image_vision_input.py +9 -9
  247. intentkit/skills/venice_image/utils.py +77 -78
  248. intentkit/skills/web_scraper/base.py +1 -3
  249. intentkit/skills/web_scraper/document_indexer.py +1 -2
  250. intentkit/skills/web_scraper/scrape_and_index.py +4 -5
  251. intentkit/skills/web_scraper/utils.py +25 -26
  252. intentkit/skills/web_scraper/website_indexer.py +10 -11
  253. intentkit/skills/weth/__init__.py +4 -6
  254. intentkit/skills/wow/__init__.py +4 -6
  255. intentkit/skills/x402/__init__.py +11 -3
  256. intentkit/skills/x402/ask_agent.py +12 -78
  257. intentkit/skills/x402/base.py +90 -0
  258. intentkit/skills/x402/http_request.py +117 -0
  259. intentkit/skills/x402/schema.json +15 -10
  260. intentkit/skills/xmtp/base.py +3 -3
  261. intentkit/skills/xmtp/price.py +2 -2
  262. intentkit/skills/xmtp/swap.py +2 -4
  263. intentkit/skills/xmtp/transfer.py +4 -6
  264. intentkit/utils/error.py +2 -2
  265. intentkit/utils/logging.py +2 -4
  266. intentkit/utils/s3.py +8 -9
  267. intentkit/utils/schema.py +5 -5
  268. intentkit/utils/slack_alert.py +7 -8
  269. {intentkit-0.8.16.dev1.dist-info → intentkit-0.8.17.dev2.dist-info}/METADATA +3 -4
  270. intentkit-0.8.17.dev2.dist-info/RECORD +464 -0
  271. intentkit/models/generator.py +0 -347
  272. intentkit-0.8.16.dev1.dist-info/RECORD +0 -464
  273. {intentkit-0.8.16.dev1.dist-info → intentkit-0.8.17.dev2.dist-info}/WHEEL +0 -0
  274. {intentkit-0.8.16.dev1.dist-info → intentkit-0.8.17.dev2.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,8 @@
1
1
  import logging
2
- from datetime import datetime, timezone
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, Dict, List, Optional, Tuple
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(timezone.utc),
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
- Optional[datetime],
224
+ datetime | None,
225
225
  Field(None, description="Timestamp of the last income transaction"),
226
226
  ]
227
227
  expense_at: Annotated[
228
- Optional[datetime],
228
+ datetime | None,
229
229
  Field(None, description="Timestamp of the last expense transaction"),
230
230
  ]
231
231
  last_event_id: Annotated[
232
- Optional[str],
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, (int, float)):
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: Optional[str] = None,
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(timezone.utc),
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: Optional[str] = None,
474
- ) -> Tuple["CreditAccount", Dict[CreditType, Decimal]]:
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(timezone.utc),
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: Dict[CreditType, Decimal],
585
- event_id: Optional[str] = None,
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(timezone.utc),
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: Optional[Decimal] = None,
650
- refill_amount: Optional[Decimal] = None,
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(timezone.utc),
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: Optional[Decimal] = None,
785
- refill_amount: Optional[Decimal] = None,
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
- Optional[str], Field(None, description="ID of the user if applicable")
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
- Optional[str], Field(None, description="ID of the agent if applicable")
1157
+ str | None, Field(None, description="ID of the agent if applicable")
1158
1158
  ]
1159
1159
  agent_wallet_address: Annotated[
1160
- Optional[str],
1160
+ str | None,
1161
1161
  Field(None, description="Wallet address of the agent if applicable"),
1162
1162
  ]
1163
1163
  start_message_id: Annotated[
1164
- Optional[str],
1164
+ str | None,
1165
1165
  Field(None, description="ID of the starting message if applicable"),
1166
1166
  ]
1167
1167
  message_id: Annotated[
1168
- Optional[str], Field(None, description="ID of the message if applicable")
1168
+ str | None, Field(None, description="ID of the message if applicable")
1169
1169
  ]
1170
1170
  model: Annotated[
1171
- Optional[str], Field(None, description="LLM model used if applicable")
1171
+ str | None, Field(None, description="LLM model used if applicable")
1172
1172
  ]
1173
1173
  skill_call_id: Annotated[
1174
- Optional[str], Field(None, description="ID of the skill call if applicable")
1174
+ str | None, Field(None, description="ID of the skill call if applicable")
1175
1175
  ]
1176
1176
  skill_name: Annotated[
1177
- Optional[str], Field(None, description="Name of the skill if applicable")
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
- Optional[List[CreditType]],
1189
+ list[CreditType] | None,
1190
1190
  Field(default=None, description="Array of credit types involved"),
1191
1191
  ]
1192
1192
  balance_after: Annotated[
1193
- Optional[Decimal],
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
- Optional[Decimal],
1201
+ Decimal | None,
1202
1202
  Field(default=Decimal("0"), description="Base discount amount"),
1203
1203
  ]
1204
1204
  base_original_amount: Annotated[
1205
- Optional[Decimal],
1205
+ Decimal | None,
1206
1206
  Field(default=Decimal("0"), description="Base original amount"),
1207
1207
  ]
1208
1208
  base_llm_amount: Annotated[
1209
- Optional[Decimal],
1209
+ Decimal | None,
1210
1210
  Field(default=Decimal("0"), description="Base LLM cost amount"),
1211
1211
  ]
1212
1212
  base_skill_amount: Annotated[
1213
- Optional[Decimal],
1213
+ Decimal | None,
1214
1214
  Field(default=Decimal("0"), description="Base skill cost amount"),
1215
1215
  ]
1216
1216
  base_free_amount: Annotated[
1217
- Optional[Decimal],
1217
+ Decimal | None,
1218
1218
  Field(default=Decimal("0"), description="Base free credit amount"),
1219
1219
  ]
1220
1220
  base_reward_amount: Annotated[
1221
- Optional[Decimal],
1221
+ Decimal | None,
1222
1222
  Field(default=Decimal("0"), description="Base reward credit amount"),
1223
1223
  ]
1224
1224
  base_permanent_amount: Annotated[
1225
- Optional[Decimal],
1225
+ Decimal | None,
1226
1226
  Field(default=Decimal("0"), description="Base permanent credit amount"),
1227
1227
  ]
1228
1228
  fee_platform_amount: Annotated[
1229
- Optional[Decimal],
1229
+ Decimal | None,
1230
1230
  Field(default=Decimal("0"), description="Platform fee amount"),
1231
1231
  ]
1232
1232
  fee_platform_free_amount: Annotated[
1233
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[str], Field(None, description="Developer account ID receiving fee")
1252
+ str | None, Field(None, description="Developer account ID receiving fee")
1253
1253
  ]
1254
1254
  fee_dev_amount: Annotated[
1255
- Optional[Decimal],
1255
+ Decimal | None,
1256
1256
  Field(default=Decimal("0"), description="Developer fee amount"),
1257
1257
  ]
1258
1258
  fee_dev_free_amount: Annotated[
1259
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[str], Field(None, description="Agent account ID receiving fee")
1278
+ str | None, Field(None, description="Agent account ID receiving fee")
1279
1279
  ]
1280
1280
  fee_agent_amount: Annotated[
1281
- Optional[Decimal], Field(default=Decimal("0"), description="Agent fee amount")
1281
+ Decimal | None, Field(default=Decimal("0"), description="Agent fee amount")
1282
1282
  ]
1283
1283
  fee_agent_free_amount: Annotated[
1284
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[Decimal],
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
- Optional[Decimal],
1298
+ Decimal | None,
1299
1299
  Field(default=Decimal("0"), description="Free credit amount involved"),
1300
1300
  ]
1301
1301
  reward_amount: Annotated[
1302
- Optional[Decimal],
1302
+ Decimal | None,
1303
1303
  Field(default=Decimal("0"), description="Reward credit amount involved"),
1304
1304
  ]
1305
1305
  permanent_amount: Annotated[
1306
- Optional[Decimal],
1306
+ Decimal | None,
1307
1307
  Field(default=Decimal("0"), description="Permanent credit amount involved"),
1308
1308
  ]
1309
- note: Annotated[Optional[str], Field(None, description="Additional notes")]
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) -> Optional[Decimal]:
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, (int, float)):
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, (int, float)):
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(timezone.utc),
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, (int, float)):
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, (int, float)):
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, AsyncGenerator, Optional
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: Optional[Checkpointer] = None
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: Optional[str],
32
- username: Optional[str],
33
- password: Optional[str],
34
- dbname: Optional[str],
35
- port: Annotated[Optional[str], Field(default="5432", description="Database port")],
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
  ],
@@ -1,7 +1,7 @@
1
1
  """Database migration utilities."""
2
2
 
3
3
  import logging
4
- from typing import Callable
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, (list, dict)):
43
+ elif isinstance(default_value, list | dict):
44
44
  default_value = "'{}'"
45
45
  column_def += f" DEFAULT {default_value}"
46
46
 
intentkit/models/llm.py CHANGED
@@ -1,11 +1,11 @@
1
1
  import csv
2
2
  import json
3
3
  import logging
4
- from datetime import datetime, timezone
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, Optional
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
@@ -24,13 +24,13 @@ _credit_per_usdc = None
24
24
  FOURPLACES = Decimal("0.0001")
25
25
 
26
26
 
27
- def _parse_bool(value: Optional[str]) -> bool:
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: Optional[str]) -> Optional[int]:
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, "LLMModelInfo"] = {}
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(timezone.utc)
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(timezone.utc),
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: Optional[int] = Field(
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: Optional[str] = (
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(timezone.utc),
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(timezone.utc),
214
+ default=datetime.now(UTC),
217
215
  ),
218
216
  ]
219
217
 
@@ -296,7 +294,7 @@ class LLMModelInfo(BaseModel):
296
294
  async with get_session() as db:
297
295
  return await cls.get_all(session=db)
298
296
 
299
- models: dict[str, "LLMModelInfo"] = {
297
+ models: dict[str, LLMModelInfo] = {
300
298
  model_id: model.model_copy(deep=True)
301
299
  for model_id, model in AVAILABLE_MODELS.items()
302
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: Optional[Redis] = None
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: Optional[str] = None,
17
+ password: str | None = None,
19
18
  ssl: bool = False,
20
19
  encoding: str = "utf-8",
21
20
  decode_responses: bool = True,