intentkit 0.5.2__py3-none-any.whl → 0.6.0.dev5__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 CHANGED
@@ -3,7 +3,7 @@
3
3
  A powerful platform for building AI agents with blockchain and cryptocurrency capabilities.
4
4
  """
5
5
 
6
- __version__ = "0.5.1"
6
+ __version__ = "0.6.0-dev.5"
7
7
  __author__ = "hyacinthus"
8
8
  __email__ = "hyacinthus@gmail.com"
9
9
 
intentkit/core/engine.py CHANGED
@@ -187,8 +187,7 @@ async def create_agent(
187
187
  if config.admin_llm_skill_control:
188
188
  escaped_prompt = await explain_prompt(escaped_prompt)
189
189
  prompt_array = [
190
- ("system", escaped_prompt),
191
- ("placeholder", "{entrypoint_prompt}"),
190
+ ("placeholder", "{system_prompt}"),
192
191
  ("placeholder", "{messages}"),
193
192
  ]
194
193
  if agent.prompt_append:
@@ -201,18 +200,43 @@ async def create_agent(
201
200
 
202
201
  prompt_temp = ChatPromptTemplate.from_messages(prompt_array)
203
202
 
204
- def formatted_prompt(
203
+ async def formatted_prompt(
205
204
  state: AgentState, config: RunnableConfig
206
205
  ) -> list[BaseMessage]:
207
- entrypoint_prompt = []
208
- if config.get("configurable") and config["configurable"].get(
209
- "entrypoint_prompt"
210
- ):
211
- entrypoint_prompt = [
212
- ("system", config["configurable"]["entrypoint_prompt"])
213
- ]
206
+ final_system_prompt = escaped_prompt
207
+ if config.get("configurable") and config["configurable"].get("entrypoint"):
208
+ entrypoint = config["configurable"]["entrypoint"]
209
+ entrypoint_prompt = None
210
+ if (
211
+ agent.twitter_entrypoint_enabled
212
+ and agent.twitter_entrypoint_prompt
213
+ and entrypoint == AuthorType.TWITTER.value
214
+ ):
215
+ entrypoint_prompt = agent.twitter_entrypoint_prompt
216
+ logger.debug("twitter entrypoint prompt added")
217
+ elif (
218
+ agent.telegram_entrypoint_enabled
219
+ and agent.telegram_entrypoint_prompt
220
+ and entrypoint == AuthorType.TELEGRAM.value
221
+ ):
222
+ entrypoint_prompt = agent.telegram_entrypoint_prompt
223
+ logger.debug("telegram entrypoint prompt added")
224
+ if entrypoint_prompt:
225
+ entrypoint_prompt = await explain_prompt(entrypoint_prompt)
226
+ final_system_prompt = f"{final_system_prompt}## Entrypoint rules\n\n{entrypoint_prompt}\n\n"
227
+ if config.get("configurable"):
228
+ final_system_prompt = f"{final_system_prompt}## Internal Info\n\n"
229
+ "These are for your internal use. You can use them when querying or storing data, "
230
+ "but please do not directly share this information with users.\n\n"
231
+ chat_id = config["configurable"].get("chat_id")
232
+ if chat_id:
233
+ final_system_prompt = f"{final_system_prompt}chat_id: {chat_id}\n\n"
234
+ user_id = config["configurable"].get("user_id")
235
+ if user_id:
236
+ final_system_prompt = f"{final_system_prompt}user_id: {user_id}\n\n"
237
+ system_prompt = [("system", final_system_prompt)]
214
238
  return prompt_temp.invoke(
215
- {"messages": state["messages"], "entrypoint_prompt": entrypoint_prompt},
239
+ {"messages": state["messages"], "system_prompt": system_prompt},
216
240
  config,
217
241
  )
218
242
 
@@ -518,33 +542,16 @@ async def stream_agent(message: ChatMessageCreate):
518
542
  HumanMessage(content=content),
519
543
  ]
520
544
 
521
- entrypoint_prompt = None
522
- if (
523
- agent.twitter_entrypoint_enabled
524
- and agent.twitter_entrypoint_prompt
525
- and input.author_type == AuthorType.TWITTER
526
- ):
527
- entrypoint_prompt = agent.twitter_entrypoint_prompt
528
- logger.debug("twitter entrypoint prompt added")
529
- elif (
530
- agent.telegram_entrypoint_enabled
531
- and agent.telegram_entrypoint_prompt
532
- and input.author_type == AuthorType.TELEGRAM
533
- ):
534
- entrypoint_prompt = agent.telegram_entrypoint_prompt
535
- logger.debug("telegram entrypoint prompt added")
536
- if entrypoint_prompt and config.admin_llm_skill_control:
537
- entrypoint_prompt = await explain_prompt(entrypoint_prompt)
538
-
539
545
  # stream config
540
546
  thread_id = f"{input.agent_id}-{input.chat_id}"
541
547
  stream_config = {
542
548
  "configurable": {
543
549
  "agent": agent,
544
550
  "thread_id": thread_id,
551
+ "chat_id": input.chat_id,
545
552
  "user_id": input.user_id,
553
+ "app_id": input.app_id,
546
554
  "entrypoint": input.author_type,
547
- "entrypoint_prompt": entrypoint_prompt,
548
555
  "payer": payer if payment_enabled else None,
549
556
  },
550
557
  "recursion_limit": recursion_limit,
intentkit/core/node.py CHANGED
@@ -138,9 +138,11 @@ class PreModelNode(RunnableCallable):
138
138
  f"Too few messages after trim: {len(trimmed_messages)}"
139
139
  )
140
140
  return {}
141
- return {
142
- "messages": [RemoveMessage(REMOVE_ALL_MESSAGES)] + trimmed_messages,
143
- }
141
+ return {
142
+ "messages": [RemoveMessage(REMOVE_ALL_MESSAGES)] + trimmed_messages,
143
+ }
144
+ else:
145
+ return {}
144
146
  if self.short_term_memory_strategy == "summarize":
145
147
  # if last message is not human message, skip summarize
146
148
  if not isinstance(messages[-1], HumanMessage):
intentkit/models/chat.py CHANGED
@@ -8,6 +8,7 @@ from intentkit.models.base import Base
8
8
  from intentkit.models.db import get_session
9
9
  from pydantic import BaseModel, ConfigDict, Field
10
10
  from sqlalchemy import (
11
+ Boolean,
11
12
  Column,
12
13
  DateTime,
13
14
  Float,
@@ -101,6 +102,14 @@ class ChatMessageRequest(BaseModel):
101
102
  min_length=1,
102
103
  ),
103
104
  ]
105
+ app_id: Annotated[
106
+ Optional[str],
107
+ Field(
108
+ None,
109
+ description="Optional application identifier",
110
+ examples=["app-789"],
111
+ ),
112
+ ]
104
113
  user_id: Annotated[
105
114
  str,
106
115
  Field(
@@ -120,6 +129,20 @@ class ChatMessageRequest(BaseModel):
120
129
  max_length=65535,
121
130
  ),
122
131
  ]
132
+ search_mode: Annotated[
133
+ Optional[bool],
134
+ Field(
135
+ None,
136
+ description="Optional flag to enable search mode",
137
+ ),
138
+ ]
139
+ super_mode: Annotated[
140
+ Optional[bool],
141
+ Field(
142
+ None,
143
+ description="Optional flag to enable super mode",
144
+ ),
145
+ ]
123
146
  attachments: Annotated[
124
147
  Optional[List[ChatMessageAttachment]],
125
148
  Field(
@@ -134,8 +157,11 @@ class ChatMessageRequest(BaseModel):
134
157
  json_schema_extra={
135
158
  "example": {
136
159
  "chat_id": "chat-123",
160
+ "app_id": "app-789",
137
161
  "user_id": "user-456",
138
162
  "message": "Hello, how can you help me today?",
163
+ "search_mode": True,
164
+ "super_mode": False,
139
165
  "attachments": [
140
166
  {
141
167
  "type": "link",
@@ -229,6 +255,18 @@ class ChatMessageTable(Base):
229
255
  Float,
230
256
  default=0,
231
257
  )
258
+ app_id = Column(
259
+ String,
260
+ nullable=True,
261
+ )
262
+ search_mode = Column(
263
+ Boolean,
264
+ nullable=True,
265
+ )
266
+ super_mode = Column(
267
+ Boolean,
268
+ nullable=True,
269
+ )
232
270
  created_at = Column(
233
271
  DateTime(timezone=True),
234
272
  nullable=False,
@@ -302,6 +340,18 @@ class ChatMessageCreate(BaseModel):
302
340
  float,
303
341
  Field(0.0, description="Cost for the cold start of the message in seconds"),
304
342
  ]
343
+ app_id: Annotated[
344
+ Optional[str],
345
+ Field(None, description="Optional application identifier"),
346
+ ]
347
+ search_mode: Annotated[
348
+ Optional[bool],
349
+ Field(None, description="Optional flag to enable search mode"),
350
+ ]
351
+ super_mode: Annotated[
352
+ Optional[bool],
353
+ Field(None, description="Optional flag to enable super mode"),
354
+ ]
305
355
 
306
356
  async def save_in_session(self, db: AsyncSession) -> "ChatMessage":
307
357
  """Save the chat message to the database.
@@ -43,7 +43,7 @@ def setup_logging(env: str, debug: bool = False):
43
43
  debug: Debug mode flag
44
44
  """
45
45
 
46
- if env == "local" or debug:
46
+ if debug:
47
47
  # Set up logging configuration for local/debug
48
48
  logging.basicConfig(
49
49
  level=logging.DEBUG,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: intentkit
3
- Version: 0.5.2
3
+ Version: 0.6.0.dev5
4
4
  Summary: Intent-based AI Agent Platform - Core Package
5
5
  Project-URL: Homepage, https://github.com/crestal-network/intentkit
6
6
  Project-URL: Repository, https://github.com/crestal-network/intentkit
@@ -1,4 +1,4 @@
1
- intentkit/__init__.py,sha256=OEwQR6p5VXkEANCAdLRcg2bOK1kVrn6SoZeQpP3FUtE,378
1
+ intentkit/__init__.py,sha256=cS9nwSRx1rI1GJ3SyNpnwTmqo_ziSVO0Mpi9ecGnYeI,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
@@ -17,8 +17,8 @@ intentkit/core/agent.py,sha256=PTHsFV_EbsfPUcTI0ErkebWurjxVykP9ISbNUsqV44Q,7764
17
17
  intentkit/core/api.py,sha256=3GIMJpwduLUSbVPNW6mQVxZncYHH3OlLwdiqFtYtEAE,1208
18
18
  intentkit/core/client.py,sha256=rIwtJVVm-7piXtFNDbeykt9vWdNTecgjW0aA3N-lHnM,1495
19
19
  intentkit/core/credit.py,sha256=fpRe8BRNGGaumAvJFgce1T2zkclExSFWQdoUVnl6k5g,60789
20
- intentkit/core/engine.py,sha256=cNzHJLlObDRrOtLUmNPgjaHRaR17JBbMwd2wzv4Eqi4,40344
21
- intentkit/core/node.py,sha256=36lKDi3Lil_arYMelry8Hb0tu3yG_2VVjc8YdcRZHRY,9010
20
+ intentkit/core/engine.py,sha256=elCKe-NzllJDkE9M8uyzb5w3mozEY7TL4tIslF0HjUA,41148
21
+ intentkit/core/node.py,sha256=ULIyJvVFu9gHuBfSLXe_qV6BMgGOFyAKPx0m8oScC8E,9066
22
22
  intentkit/core/prompt.py,sha256=9jxRYUUqSdBj8bdmCUAa-5yTbiQFVInOJsDqbAuUcfo,3512
23
23
  intentkit/core/skill.py,sha256=rE37qwDmpnHnIG0MwKxuonVO_lOq47gy-tvXMOz9VZs,3498
24
24
  intentkit/models/agent.py,sha256=2HlJLlJShEjhjDR290ndFaaVqv94FXzqdIKPBTuwpn4,57477
@@ -26,7 +26,7 @@ intentkit/models/agent_data.py,sha256=h__b3658ZOclV1Pwpp3UCCu0Nt49CKYfc2JZKG1dKe
26
26
  intentkit/models/agent_schema.json,sha256=kacuFT9gPuj16vhZg8Yg1kBJ-3La4uCzBa__uTnQmfY,21368
27
27
  intentkit/models/app_setting.py,sha256=WgW-9t0EbiVemRLrVaC6evdfRU5QFSDK0elsnUU5nIo,5008
28
28
  intentkit/models/base.py,sha256=o-zRjVrak-f5Jokdvj8BjLm8gcC3yYiYMCTLegwT2lA,185
29
- intentkit/models/chat.py,sha256=59S7pYGrQGi3a7_4EWBQT0JNkpTcHz0wKI8aX0ZOqkA,16785
29
+ intentkit/models/chat.py,sha256=H4fKBgrseOaFIp83sYYiuyYpYufQAvnoca6V4TVbibE,18013
30
30
  intentkit/models/conversation.py,sha256=nrbDIw-3GK5BYi_xkI15FLdx4a6SNrFK8wfAGLCsrqk,9032
31
31
  intentkit/models/credit.py,sha256=tHydPpGk8c8p9TLyIb7kvII4vo2WiXvI_i6xzv9PwaQ,42091
32
32
  intentkit/models/db.py,sha256=2OpdTjQWUM9FkDP8Ni0mGLeVJ5q9ah3bGlGe9-IzDp0,3999
@@ -353,13 +353,13 @@ intentkit/skills/web_scraper/scrape_and_index.py,sha256=9_U67U8bu36zmHo4C0gyoqLi
353
353
  intentkit/utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
354
354
  intentkit/utils/chain.py,sha256=3GBHuAbXxQr_HlOvkbB2kruYSkweucfxI5u-swXzY40,15135
355
355
  intentkit/utils/error.py,sha256=JxnzDdKjwZX6Pa-bt_qaibcrWAeF6QAoHsu2uYPmqu4,4483
356
- intentkit/utils/logging.py,sha256=xqPi9WSCWhyHlDVqsx5DoL5RgRhnMgviDzF4IhNiF8k,2407
356
+ intentkit/utils/logging.py,sha256=bhwZi5vscjBTd9kaNp_L6ijrfv9Sl3lsr4ARaUB4Iec,2389
357
357
  intentkit/utils/middleware.py,sha256=bh6rrbm2oT7d0A0ypUwp-I3jsr_98rtYIUlS5foootE,1842
358
358
  intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
359
359
  intentkit/utils/s3.py,sha256=9trQNkKQ5VgxWsewVsV8Y0q_pXzGRvsCYP8xauyUYkg,8549
360
360
  intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
361
361
  intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
362
- intentkit-0.5.2.dist-info/METADATA,sha256=0PYXP_QLsNLIoQlTjj6XEvEbXK52fkIoGgEf5Mli5Tc,7280
363
- intentkit-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
364
- intentkit-0.5.2.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
365
- intentkit-0.5.2.dist-info/RECORD,,
362
+ intentkit-0.6.0.dev5.dist-info/METADATA,sha256=FyJOQ3Cuy_6lmt0SRb_GuaRCrqDc2GGN0DcNcLPQ-B4,7285
363
+ intentkit-0.6.0.dev5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
364
+ intentkit-0.6.0.dev5.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
365
+ intentkit-0.6.0.dev5.dist-info/RECORD,,