intentkit 0.8.12.dev6__py3-none-any.whl → 0.8.13.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of intentkit might be problematic. Click here for more details.
- intentkit/__init__.py +1 -1
- intentkit/config/config.py +1 -0
- intentkit/core/engine.py +2 -0
- intentkit/models/agent.py +29 -0
- intentkit/models/chat.py +1 -0
- intentkit/utils/schema.py +100 -0
- {intentkit-0.8.12.dev6.dist-info → intentkit-0.8.13.dev1.dist-info}/METADATA +1 -1
- {intentkit-0.8.12.dev6.dist-info → intentkit-0.8.13.dev1.dist-info}/RECORD +10 -9
- {intentkit-0.8.12.dev6.dist-info → intentkit-0.8.13.dev1.dist-info}/WHEEL +0 -0
- {intentkit-0.8.12.dev6.dist-info → intentkit-0.8.13.dev1.dist-info}/licenses/LICENSE +0 -0
intentkit/__init__.py
CHANGED
intentkit/config/config.py
CHANGED
|
@@ -79,6 +79,7 @@ class Config:
|
|
|
79
79
|
self.debug_password = self.load("DEBUG_PASSWORD")
|
|
80
80
|
# Payment
|
|
81
81
|
self.payment_enabled = self.load("PAYMENT_ENABLED", "false") == "true"
|
|
82
|
+
self.x402_fee_address = self.load("X402_FEE_ADDRESS")
|
|
82
83
|
# Open API for agent
|
|
83
84
|
self.open_api_base_url = self.load("OPEN_API_BASE_URL", "http://localhost:8000")
|
|
84
85
|
# CDP - AgentKit 0.7.x Configuration
|
intentkit/core/engine.py
CHANGED
|
@@ -332,6 +332,8 @@ async def stream_agent_raw(
|
|
|
332
332
|
model = await LLMModelInfo.get(agent.model)
|
|
333
333
|
|
|
334
334
|
payment_enabled = config.payment_enabled
|
|
335
|
+
if user_message.author_type == AuthorType.X402:
|
|
336
|
+
payment_enabled = False
|
|
335
337
|
|
|
336
338
|
# check user balance
|
|
337
339
|
if payment_enabled:
|
intentkit/models/agent.py
CHANGED
|
@@ -1288,6 +1288,35 @@ class Agent(AgentCreate, AgentPublicInfo):
|
|
|
1288
1288
|
return None
|
|
1289
1289
|
return cls.model_validate(item)
|
|
1290
1290
|
|
|
1291
|
+
@classmethod
|
|
1292
|
+
async def get_by_id_or_slug(cls, agent_id: str) -> Optional["Agent"]:
|
|
1293
|
+
"""Get agent by ID or slug.
|
|
1294
|
+
|
|
1295
|
+
First tries to get by ID if agent_id length <= 20,
|
|
1296
|
+
then falls back to searching by slug if not found.
|
|
1297
|
+
|
|
1298
|
+
Args:
|
|
1299
|
+
agent_id: Agent ID or slug to search for
|
|
1300
|
+
|
|
1301
|
+
Returns:
|
|
1302
|
+
Agent if found, None otherwise
|
|
1303
|
+
"""
|
|
1304
|
+
async with get_session() as db:
|
|
1305
|
+
agent = None
|
|
1306
|
+
|
|
1307
|
+
# Try to get by ID if length <= 20
|
|
1308
|
+
if len(agent_id) <= 20:
|
|
1309
|
+
agent = await Agent.get(agent_id)
|
|
1310
|
+
|
|
1311
|
+
# If not found, try to get by slug
|
|
1312
|
+
if agent is None:
|
|
1313
|
+
slug_stmt = select(AgentTable).where(AgentTable.slug == agent_id)
|
|
1314
|
+
agent_row = await db.scalar(slug_stmt)
|
|
1315
|
+
if agent_row is not None:
|
|
1316
|
+
agent = Agent.model_validate(agent_row)
|
|
1317
|
+
|
|
1318
|
+
return agent
|
|
1319
|
+
|
|
1291
1320
|
@staticmethod
|
|
1292
1321
|
def _deserialize_autonomous(
|
|
1293
1322
|
autonomous_data: Optional[List[Any]],
|
intentkit/models/chat.py
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""JSON Schema utilities for IntentKit.
|
|
2
|
+
|
|
3
|
+
This module provides utilities for working with JSON schemas, including
|
|
4
|
+
resolving $defs references and generating nested schemas.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import copy
|
|
8
|
+
from typing import Any, Dict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def resolve_schema_refs(schema: Dict[str, Any]) -> Dict[str, Any]:
|
|
12
|
+
"""Recursively resolve $defs references in a JSON schema.
|
|
13
|
+
|
|
14
|
+
This function takes a JSON schema with $defs references and returns
|
|
15
|
+
a fully nested schema without any $ref pointers. This is useful for
|
|
16
|
+
creating schemas that can be easily consumed by external systems
|
|
17
|
+
that don't support JSON Schema references.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
schema: The JSON schema dictionary that may contain $defs and $ref
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
dict: A new schema with all $ref resolved to nested objects
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
>>> schema = {
|
|
27
|
+
... "type": "object",
|
|
28
|
+
... "properties": {
|
|
29
|
+
... "user": {"$ref": "#/$defs/User"}
|
|
30
|
+
... },
|
|
31
|
+
... "$defs": {
|
|
32
|
+
... "User": {
|
|
33
|
+
... "type": "object",
|
|
34
|
+
... "properties": {"name": {"type": "string"}}
|
|
35
|
+
... }
|
|
36
|
+
... }
|
|
37
|
+
... }
|
|
38
|
+
>>> resolved = resolve_schema_refs(schema)
|
|
39
|
+
>>> # resolved will have the User definition inlined
|
|
40
|
+
"""
|
|
41
|
+
# Deep copy to avoid modifying the original
|
|
42
|
+
resolved_schema = copy.deepcopy(schema)
|
|
43
|
+
|
|
44
|
+
# Extract $defs if they exist
|
|
45
|
+
defs = resolved_schema.pop("$defs", {})
|
|
46
|
+
|
|
47
|
+
def resolve_refs(obj: Any, defs_dict: Dict[str, Any]) -> Any:
|
|
48
|
+
"""Recursively resolve $ref in an object."""
|
|
49
|
+
if isinstance(obj, dict):
|
|
50
|
+
if "$ref" in obj:
|
|
51
|
+
ref_path = obj["$ref"]
|
|
52
|
+
if ref_path.startswith("#/$defs/"):
|
|
53
|
+
def_name = ref_path.replace("#/$defs/", "")
|
|
54
|
+
if def_name in defs_dict:
|
|
55
|
+
# Recursively resolve the referenced definition
|
|
56
|
+
resolved_def = resolve_refs(defs_dict[def_name], defs_dict)
|
|
57
|
+
return resolved_def
|
|
58
|
+
else:
|
|
59
|
+
# Keep the reference if definition not found
|
|
60
|
+
return obj
|
|
61
|
+
else:
|
|
62
|
+
# Keep non-$defs references as is
|
|
63
|
+
return obj
|
|
64
|
+
else:
|
|
65
|
+
# Recursively process all values in the dictionary
|
|
66
|
+
return {
|
|
67
|
+
key: resolve_refs(value, defs_dict) for key, value in obj.items()
|
|
68
|
+
}
|
|
69
|
+
elif isinstance(obj, list):
|
|
70
|
+
# Recursively process all items in the list
|
|
71
|
+
return [resolve_refs(item, defs_dict) for item in obj]
|
|
72
|
+
else:
|
|
73
|
+
# Return primitive values as is
|
|
74
|
+
return obj
|
|
75
|
+
|
|
76
|
+
# Resolve all references in the schema
|
|
77
|
+
return resolve_refs(resolved_schema, defs)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def create_array_schema(
|
|
81
|
+
item_schema: Dict[str, Any], resolve_refs: bool = True
|
|
82
|
+
) -> Dict[str, Any]:
|
|
83
|
+
"""Create an array schema with the given item schema.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
item_schema: The schema for array items
|
|
87
|
+
resolve_refs: Whether to resolve $defs references in the item schema
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
dict: Array schema with resolved item schema
|
|
91
|
+
"""
|
|
92
|
+
if resolve_refs:
|
|
93
|
+
resolved_item_schema = resolve_schema_refs(item_schema)
|
|
94
|
+
else:
|
|
95
|
+
resolved_item_schema = item_schema
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
"type": "array",
|
|
99
|
+
"items": resolved_item_schema,
|
|
100
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: intentkit
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.13.dev1
|
|
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=IQcA48M2AGddMCj2tAqWrmb2YmKxzSbBMMLcL4oZ-j8,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
|
|
@@ -11,7 +11,7 @@ intentkit/clients/cdp.py,sha256=A-cczpek9iPw6dDxKub_BOjCAtpIbUP_MYYP06fYW90,5791
|
|
|
11
11
|
intentkit/clients/twitter.py,sha256=dMyskssmnxns31RoCr3c2sJTaR3xm8RkI5-8yYz1pGo,19975
|
|
12
12
|
intentkit/clients/web3.py,sha256=iFjjingL9Aqh3kwUUKN8Tw5N66o2SE_bfo6OhqI-6SU,890
|
|
13
13
|
intentkit/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
intentkit/config/config.py,sha256=
|
|
14
|
+
intentkit/config/config.py,sha256=W1WCfk3RrCHG68wuV-eQ6jhvrncLh52x61fxluHedAE,8930
|
|
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
|
|
@@ -19,18 +19,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
|
-
intentkit/core/engine.py,sha256=
|
|
22
|
+
intentkit/core/engine.py,sha256=mDiUmo1eE3er3vU630v89FYq5MBildNUzRBg4P53o30,39094
|
|
23
23
|
intentkit/core/node.py,sha256=-QVgmQuMnrzo6cF-4AECOIVT3R4gCnWfQ1EjTm2Sz1g,8791
|
|
24
24
|
intentkit/core/prompt.py,sha256=cf33qLpGozRc_aPdbnI_pDFREivSUhvUB9VboOKscXA,17212
|
|
25
25
|
intentkit/core/scheduler.py,sha256=XK-VVGkUk1PSjiFc5va2T134cmzMYHH_eIzInLzjv8c,2929
|
|
26
26
|
intentkit/core/statistics.py,sha256=-IZmxIBzyzZuai7QyfPEY1tx8Q8ydmmcm6eqbSSy_6o,6366
|
|
27
|
-
intentkit/models/agent.py,sha256=
|
|
27
|
+
intentkit/models/agent.py,sha256=DRIdPVngXgITObUnRjrJGLr5W_7b7ZRg8eqPFsChyKY,70084
|
|
28
28
|
intentkit/models/agent_data.py,sha256=5zq3EPKnygT2P1OHc2IfEmL8hXkjeBND6sJ0JJsvQJg,28370
|
|
29
29
|
intentkit/models/agent_public.json,sha256=0X8Bd2WOobDJLsok8avWNzmzu4uvKSGEyy6Myn53eT4,2802
|
|
30
30
|
intentkit/models/agent_schema.json,sha256=_-oviPLPCdveQ3H4wTuoxC2PF5tOhFXuG7BUsmhUJG8,11829
|
|
31
31
|
intentkit/models/app_setting.py,sha256=iYbW63QD91bt4oEYV3wOXHuRFav2b4VXLwb_StgUQtQ,8230
|
|
32
32
|
intentkit/models/base.py,sha256=o-zRjVrak-f5Jokdvj8BjLm8gcC3yYiYMCTLegwT2lA,185
|
|
33
|
-
intentkit/models/chat.py,sha256=
|
|
33
|
+
intentkit/models/chat.py,sha256=K4ufFrZyIjpXImukaX2GnXo1PwXWETrk55Sa9vCzAmk,20487
|
|
34
34
|
intentkit/models/conversation.py,sha256=nrbDIw-3GK5BYi_xkI15FLdx4a6SNrFK8wfAGLCsrqk,9032
|
|
35
35
|
intentkit/models/credit.py,sha256=CM_oOhcpKHkdCVTe86osYsBM9vIo-9N65SWrNKEKy7Y,52614
|
|
36
36
|
intentkit/models/db.py,sha256=1uX1DJZGMx9A3lq6WKSTSwpXhWgWaiki55-iiED8BYM,5082
|
|
@@ -449,9 +449,10 @@ intentkit/utils/error.py,sha256=fZOZ9CPrU08veSyDBoNf44UjkojpsyFMEr2SxEdlSZA,4898
|
|
|
449
449
|
intentkit/utils/logging.py,sha256=bhwZi5vscjBTd9kaNp_L6ijrfv9Sl3lsr4ARaUB4Iec,2389
|
|
450
450
|
intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
|
|
451
451
|
intentkit/utils/s3.py,sha256=A8Nsx5QJyLsxhj9g7oHNy2-m24tjQUhC9URm8Qb1jFw,10057
|
|
452
|
+
intentkit/utils/schema.py,sha256=ATeTskEO2Y-MLFcOJEm5BoFJvxqc_zqQwiRS3rO4XDQ,3428
|
|
452
453
|
intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
|
|
453
454
|
intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
|
|
454
|
-
intentkit-0.8.
|
|
455
|
-
intentkit-0.8.
|
|
456
|
-
intentkit-0.8.
|
|
457
|
-
intentkit-0.8.
|
|
455
|
+
intentkit-0.8.13.dev1.dist-info/METADATA,sha256=0flvNmswhgSdNhxO-AfM7A9TEGDvw2Jeh9OnOvJ7YcM,6316
|
|
456
|
+
intentkit-0.8.13.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
457
|
+
intentkit-0.8.13.dev1.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
|
|
458
|
+
intentkit-0.8.13.dev1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|