intentkit 0.8.12.dev5__py3-none-any.whl → 0.8.12.dev6__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/core/asset.py +63 -16
- intentkit/core/scheduler.py +8 -8
- intentkit/models/llm.csv +1 -0
- {intentkit-0.8.12.dev5.dist-info → intentkit-0.8.12.dev6.dist-info}/METADATA +1 -1
- {intentkit-0.8.12.dev5.dist-info → intentkit-0.8.12.dev6.dist-info}/RECORD +8 -8
- {intentkit-0.8.12.dev5.dist-info → intentkit-0.8.12.dev6.dist-info}/WHEEL +0 -0
- {intentkit-0.8.12.dev5.dist-info → intentkit-0.8.12.dev6.dist-info}/licenses/LICENSE +0 -0
intentkit/__init__.py
CHANGED
intentkit/core/asset.py
CHANGED
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import json
|
|
5
6
|
import logging
|
|
6
7
|
from decimal import Decimal
|
|
7
8
|
from typing import Optional
|
|
8
9
|
|
|
9
10
|
import httpx
|
|
10
11
|
from pydantic import BaseModel, Field
|
|
12
|
+
from sqlalchemy import update
|
|
11
13
|
from web3 import Web3
|
|
12
14
|
|
|
13
15
|
from intentkit.clients.web3 import get_web3_client
|
|
14
16
|
from intentkit.config.config import config
|
|
15
|
-
from intentkit.models.agent import Agent
|
|
17
|
+
from intentkit.models.agent import Agent, AgentTable
|
|
16
18
|
from intentkit.models.agent_data import AgentData
|
|
19
|
+
from intentkit.models.db import get_session
|
|
20
|
+
from intentkit.models.redis import get_redis
|
|
17
21
|
from intentkit.utils.error import IntentKitAPIError
|
|
18
22
|
|
|
19
23
|
logger = logging.getLogger(__name__)
|
|
@@ -171,29 +175,72 @@ async def _build_assets_list(
|
|
|
171
175
|
|
|
172
176
|
async def agent_asset(agent_id: str) -> AgentAssets:
|
|
173
177
|
"""Fetch wallet net worth and token balances for an agent."""
|
|
178
|
+
|
|
179
|
+
cache_key = f"intentkit:agent_assets:{agent_id}"
|
|
180
|
+
redis_client = None
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
redis_client = get_redis()
|
|
184
|
+
except Exception as exc: # pragma: no cover - best effort fallback
|
|
185
|
+
logger.debug("Redis unavailable for agent assets: %s", exc)
|
|
186
|
+
|
|
174
187
|
agent = await Agent.get(agent_id)
|
|
175
188
|
if not agent:
|
|
176
189
|
raise IntentKitAPIError(404, "AgentNotFound", "Agent not found")
|
|
177
190
|
|
|
191
|
+
if redis_client:
|
|
192
|
+
try:
|
|
193
|
+
cached_raw = await redis_client.get(cache_key)
|
|
194
|
+
if cached_raw:
|
|
195
|
+
cached_data = json.loads(cached_raw)
|
|
196
|
+
cached_assets = AgentAssets.model_validate(cached_data)
|
|
197
|
+
return cached_assets
|
|
198
|
+
except Exception as exc: # pragma: no cover - cache read path only
|
|
199
|
+
logger.debug("Failed to read agent asset cache for %s: %s", agent_id, exc)
|
|
200
|
+
|
|
178
201
|
agent_data = await AgentData.get(agent_id)
|
|
179
202
|
if not agent_data or not agent_data.evm_wallet_address:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
203
|
+
assets_result = AgentAssets(net_worth="0", tokens=[])
|
|
204
|
+
elif not agent.network_id:
|
|
205
|
+
assets_result = AgentAssets(net_worth="0", tokens=[])
|
|
206
|
+
else:
|
|
207
|
+
try:
|
|
208
|
+
web3_client = get_web3_client(str(agent.network_id))
|
|
209
|
+
tokens = await _build_assets_list(agent, agent_data, web3_client)
|
|
210
|
+
net_worth = await _get_wallet_net_worth(agent_data.evm_wallet_address)
|
|
211
|
+
assets_result = AgentAssets(net_worth=net_worth, tokens=tokens)
|
|
212
|
+
except IntentKitAPIError:
|
|
213
|
+
raise
|
|
214
|
+
except Exception as exc:
|
|
215
|
+
logger.error("Error getting agent assets for %s: %s", agent_id, exc)
|
|
216
|
+
raise IntentKitAPIError(
|
|
217
|
+
500, "AgentAssetError", "Failed to retrieve agent assets"
|
|
218
|
+
) from exc
|
|
219
|
+
|
|
220
|
+
assets_payload = assets_result.model_dump(mode="json")
|
|
221
|
+
|
|
222
|
+
if redis_client:
|
|
223
|
+
try:
|
|
224
|
+
await redis_client.set(
|
|
225
|
+
cache_key,
|
|
226
|
+
json.dumps(assets_payload),
|
|
227
|
+
ex=3600,
|
|
228
|
+
)
|
|
229
|
+
except Exception as exc: # pragma: no cover - cache write path only
|
|
230
|
+
logger.debug("Failed to write agent asset cache for %s: %s", agent_id, exc)
|
|
184
231
|
|
|
185
232
|
try:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
233
|
+
async with get_session() as session:
|
|
234
|
+
await session.execute(
|
|
235
|
+
update(AgentTable)
|
|
236
|
+
.where(AgentTable.id == agent_id)
|
|
237
|
+
.values(assets=assets_payload)
|
|
238
|
+
)
|
|
239
|
+
await session.commit()
|
|
240
|
+
except Exception as exc: # pragma: no cover - db persistence path only
|
|
241
|
+
logger.error("Error updating agent assets cache for %s: %s", agent_id, exc)
|
|
242
|
+
|
|
243
|
+
return assets_result
|
|
197
244
|
|
|
198
245
|
|
|
199
246
|
__all__ = [
|
intentkit/core/scheduler.py
CHANGED
|
@@ -11,7 +11,6 @@ from apscheduler.triggers.cron import CronTrigger
|
|
|
11
11
|
from intentkit.core.agent import (
|
|
12
12
|
update_agent_action_cost,
|
|
13
13
|
update_agents_account_snapshot,
|
|
14
|
-
update_agents_assets,
|
|
15
14
|
update_agents_statistics,
|
|
16
15
|
)
|
|
17
16
|
from intentkit.core.credit import refill_all_free_credits
|
|
@@ -63,13 +62,14 @@ def create_scheduler(
|
|
|
63
62
|
)
|
|
64
63
|
|
|
65
64
|
# Update agent assets daily at UTC midnight
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
# This is too expensive to run daily, so it will only be triggered when detail page is visited
|
|
66
|
+
# scheduler.add_job(
|
|
67
|
+
# update_agents_assets,
|
|
68
|
+
# trigger=CronTrigger(hour=0, minute=0, timezone="UTC"),
|
|
69
|
+
# id="update_agent_assets",
|
|
70
|
+
# name="Update agent assets",
|
|
71
|
+
# replace_existing=True,
|
|
72
|
+
# )
|
|
73
73
|
|
|
74
74
|
# Update agent action costs hourly at minute 40
|
|
75
75
|
scheduler.add_job(
|
intentkit/models/llm.csv
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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
|
+
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
|
|
2
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
|
|
3
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
|
|
4
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: intentkit
|
|
3
|
-
Version: 0.8.12.
|
|
3
|
+
Version: 0.8.12.dev6
|
|
4
4
|
Summary: Intent-based AI Agent Platform - Core Package
|
|
5
5
|
Project-URL: Homepage, https://github.com/crestalnetwork/intentkit
|
|
6
6
|
Project-URL: Repository, https://github.com/crestalnetwork/intentkit
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
intentkit/__init__.py,sha256=-
|
|
1
|
+
intentkit/__init__.py,sha256=-kIFg9MyxWQgHhkHhd-6gez56EOxMztr2j7NbDtnYpw,384
|
|
2
2
|
intentkit/abstracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
intentkit/abstracts/agent.py,sha256=108gb5W8Q1Sy4G55F2_ZFv2-_CnY76qrBtpIr0Oxxqk,1489
|
|
4
4
|
intentkit/abstracts/api.py,sha256=ZUc24vaQvQVbbjznx7bV0lbbQxdQPfEV8ZxM2R6wZWo,166
|
|
@@ -15,14 +15,14 @@ intentkit/config/config.py,sha256=kw9F-uLsJd-knCKmYNb-hqR7x7HUXUkNg5FZCgOPH54,88
|
|
|
15
15
|
intentkit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
intentkit/core/agent.py,sha256=N90lIy1rJS1uCNWAc-dQiGrx1zF9vN5h56Wq6KlJCZo,27125
|
|
17
17
|
intentkit/core/api.py,sha256=WfoaHNquujYJIpNPuTR1dSaaxog0S3X2W4lG9Ehmkm4,3284
|
|
18
|
-
intentkit/core/asset.py,sha256=
|
|
18
|
+
intentkit/core/asset.py,sha256=8x8FN1B2PgisizPYS4XtihFMf8HAUTrAAjMHogXO2Y4,9140
|
|
19
19
|
intentkit/core/chat.py,sha256=YN20CnDazWLjiOZFOHgV6uHmA2DKkvPCsD5Q5sfNcZg,1685
|
|
20
20
|
intentkit/core/client.py,sha256=J5K7f08-ucszBKAbn9K3QNOFKIC__7amTbKYii1jFkI,3056
|
|
21
21
|
intentkit/core/credit.py,sha256=b4f4T6G6eeBTMe0L_r8awWtXgUnqiog4IUaymDPYym0,75587
|
|
22
22
|
intentkit/core/engine.py,sha256=stFQtRO_hGyb9SMNIZdO8dDAb3NRNUW9kQfoZzV0Y4M,39010
|
|
23
23
|
intentkit/core/node.py,sha256=-QVgmQuMnrzo6cF-4AECOIVT3R4gCnWfQ1EjTm2Sz1g,8791
|
|
24
24
|
intentkit/core/prompt.py,sha256=cf33qLpGozRc_aPdbnI_pDFREivSUhvUB9VboOKscXA,17212
|
|
25
|
-
intentkit/core/scheduler.py,sha256=
|
|
25
|
+
intentkit/core/scheduler.py,sha256=XK-VVGkUk1PSjiFc5va2T134cmzMYHH_eIzInLzjv8c,2929
|
|
26
26
|
intentkit/core/statistics.py,sha256=-IZmxIBzyzZuai7QyfPEY1tx8Q8ydmmcm6eqbSSy_6o,6366
|
|
27
27
|
intentkit/models/agent.py,sha256=CuUPPKSun4VVaiwEMMFpXMw0qkOCGmzcqDs3LBIuguI,69154
|
|
28
28
|
intentkit/models/agent_data.py,sha256=5zq3EPKnygT2P1OHc2IfEmL8hXkjeBND6sJ0JJsvQJg,28370
|
|
@@ -36,7 +36,7 @@ intentkit/models/credit.py,sha256=CM_oOhcpKHkdCVTe86osYsBM9vIo-9N65SWrNKEKy7Y,52
|
|
|
36
36
|
intentkit/models/db.py,sha256=1uX1DJZGMx9A3lq6WKSTSwpXhWgWaiki55-iiED8BYM,5082
|
|
37
37
|
intentkit/models/db_mig.py,sha256=vT6Tanm-BHC2T7dTztuB1UG494EFBAlHADKsNzR6xaQ,3577
|
|
38
38
|
intentkit/models/generator.py,sha256=lyZu9U9rZUGkqd_QT5SAhay9DY358JJY8EhDSpN8I1M,10298
|
|
39
|
-
intentkit/models/llm.csv,sha256=
|
|
39
|
+
intentkit/models/llm.csv,sha256=0NIGyo-6E9sKkPy-iCw4xl3KK8dFO5t45le1gwfg7Vs,3801
|
|
40
40
|
intentkit/models/llm.py,sha256=ZnM6qpk9ouTqFysQzzg8TcAfxXASD-H9f1eHsmVjYv8,22186
|
|
41
41
|
intentkit/models/redis.py,sha256=Vqb9pjeMQ85Az5GvUbqCsQ5stBpFg3n85p94TB40xEw,3727
|
|
42
42
|
intentkit/models/skill.py,sha256=vGJgKpUmjGsThFznEwMLipuZIlqtto_ovVELp1_AjB8,20709
|
|
@@ -451,7 +451,7 @@ intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
|
|
|
451
451
|
intentkit/utils/s3.py,sha256=A8Nsx5QJyLsxhj9g7oHNy2-m24tjQUhC9URm8Qb1jFw,10057
|
|
452
452
|
intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
|
|
453
453
|
intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
|
|
454
|
-
intentkit-0.8.12.
|
|
455
|
-
intentkit-0.8.12.
|
|
456
|
-
intentkit-0.8.12.
|
|
457
|
-
intentkit-0.8.12.
|
|
454
|
+
intentkit-0.8.12.dev6.dist-info/METADATA,sha256=nByKZWR9SCEC3HCfyKLk3xVGXSx4vCYaTOKJNsej374,6316
|
|
455
|
+
intentkit-0.8.12.dev6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
456
|
+
intentkit-0.8.12.dev6.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
|
|
457
|
+
intentkit-0.8.12.dev6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|