intentkit 0.7.5.dev18__py3-none-any.whl → 0.7.5.dev19__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/graph.py +3 -3
- intentkit/core/engine.py +100 -102
- intentkit/core/node.py +11 -11
- intentkit/skills/venice_audio/input.py +1 -1
- intentkit/skills/venice_audio/venice_audio.py +3 -3
- {intentkit-0.7.5.dev18.dist-info → intentkit-0.7.5.dev19.dist-info}/METADATA +1 -1
- {intentkit-0.7.5.dev18.dist-info → intentkit-0.7.5.dev19.dist-info}/RECORD +10 -10
- {intentkit-0.7.5.dev18.dist-info → intentkit-0.7.5.dev19.dist-info}/WHEEL +0 -0
- {intentkit-0.7.5.dev18.dist-info → intentkit-0.7.5.dev19.dist-info}/licenses/LICENSE +0 -0
intentkit/__init__.py
CHANGED
intentkit/abstracts/graph.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import asyncio
|
|
2
1
|
from enum import Enum
|
|
3
|
-
from typing import Any, Dict, NotRequired, Optional
|
|
2
|
+
from typing import Any, Callable, Dict, NotRequired, Optional
|
|
4
3
|
|
|
5
4
|
from langgraph.prebuilt.chat_agent_executor import AgentState as BaseAgentState
|
|
6
5
|
from pydantic import BaseModel
|
|
@@ -29,6 +28,7 @@ class AgentState(BaseAgentState):
|
|
|
29
28
|
|
|
30
29
|
class AgentContext(BaseModel):
|
|
31
30
|
agent_id: str
|
|
31
|
+
get_agent: Callable[[], Agent]
|
|
32
32
|
chat_id: str
|
|
33
33
|
user_id: Optional[str] = None
|
|
34
34
|
app_id: Optional[str] = None
|
|
@@ -38,4 +38,4 @@ class AgentContext(BaseModel):
|
|
|
38
38
|
|
|
39
39
|
@property
|
|
40
40
|
def agent(self) -> Agent:
|
|
41
|
-
return
|
|
41
|
+
return self.get_agent()
|
intentkit/core/engine.py
CHANGED
|
@@ -65,11 +65,9 @@ logger = logging.getLogger(__name__)
|
|
|
65
65
|
|
|
66
66
|
# Global variable to cache all agent executors
|
|
67
67
|
_agents: dict[str, CompiledStateGraph] = {}
|
|
68
|
-
_private_agents: dict[str, CompiledStateGraph] = {}
|
|
69
68
|
|
|
70
69
|
# Global dictionaries to cache agent update times
|
|
71
70
|
_agents_updated: dict[str, datetime] = {}
|
|
72
|
-
_private_agents_updated: dict[str, datetime] = {}
|
|
73
71
|
|
|
74
72
|
|
|
75
73
|
async def build_agent(agent: Agent, agent_data: AgentData) -> CompiledStateGraph:
|
|
@@ -279,24 +277,30 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
279
277
|
Yields:
|
|
280
278
|
ChatMessage: Individual response messages including timing information
|
|
281
279
|
"""
|
|
280
|
+
agent = await Agent.get(message.agent_id)
|
|
281
|
+
executor, cold_start_cost = await agent_executor(message.agent_id)
|
|
282
|
+
message.cold_start_cost = cold_start_cost
|
|
283
|
+
async for chat_message in stream_agent_raw(message, agent, executor):
|
|
284
|
+
yield chat_message
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
async def stream_agent_raw(
|
|
288
|
+
message: ChatMessageCreate, agent: Agent, executor: CompiledStateGraph
|
|
289
|
+
):
|
|
282
290
|
start = time.perf_counter()
|
|
283
291
|
# make sure reply_to is set
|
|
284
292
|
message.reply_to = message.id
|
|
285
293
|
|
|
286
294
|
# save input message first
|
|
287
|
-
|
|
295
|
+
user_message = await message.save()
|
|
288
296
|
|
|
289
|
-
# agent
|
|
290
|
-
agent = await Agent.get(input.agent_id)
|
|
291
|
-
|
|
292
|
-
# model
|
|
293
297
|
model = await LLMModelInfo.get(agent.model)
|
|
294
298
|
|
|
295
299
|
payment_enabled = config.payment_enabled
|
|
296
300
|
|
|
297
301
|
# check user balance
|
|
298
302
|
if payment_enabled:
|
|
299
|
-
if not
|
|
303
|
+
if not user_message.user_id or not agent.owner:
|
|
300
304
|
raise IntentKitAPIError(
|
|
301
305
|
500,
|
|
302
306
|
"PaymentError",
|
|
@@ -307,20 +311,20 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
307
311
|
if owner and agent.fee_percentage > 100 + owner.nft_count * 10:
|
|
308
312
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
309
313
|
SystemMessageType.SERVICE_FEE_ERROR,
|
|
310
|
-
agent_id=
|
|
311
|
-
chat_id=
|
|
312
|
-
user_id=
|
|
313
|
-
author_id=
|
|
314
|
-
thread_type=
|
|
315
|
-
reply_to=
|
|
314
|
+
agent_id=user_message.agent_id,
|
|
315
|
+
chat_id=user_message.chat_id,
|
|
316
|
+
user_id=user_message.user_id,
|
|
317
|
+
author_id=user_message.agent_id,
|
|
318
|
+
thread_type=user_message.author_type,
|
|
319
|
+
reply_to=user_message.id,
|
|
316
320
|
time_cost=time.perf_counter() - start,
|
|
317
321
|
)
|
|
318
322
|
error_message = await error_message_create.save()
|
|
319
323
|
yield error_message
|
|
320
324
|
return
|
|
321
325
|
# payer
|
|
322
|
-
payer =
|
|
323
|
-
if
|
|
326
|
+
payer = user_message.user_id
|
|
327
|
+
if user_message.author_type in [
|
|
324
328
|
AuthorType.TELEGRAM,
|
|
325
329
|
AuthorType.TWITTER,
|
|
326
330
|
AuthorType.API,
|
|
@@ -343,12 +347,12 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
343
347
|
if quota and quota.free_income_daily > 24000:
|
|
344
348
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
345
349
|
SystemMessageType.DAILY_USAGE_LIMIT_EXCEEDED,
|
|
346
|
-
agent_id=
|
|
347
|
-
chat_id=
|
|
348
|
-
user_id=
|
|
349
|
-
author_id=
|
|
350
|
-
thread_type=
|
|
351
|
-
reply_to=
|
|
350
|
+
agent_id=user_message.agent_id,
|
|
351
|
+
chat_id=user_message.chat_id,
|
|
352
|
+
user_id=user_message.user_id,
|
|
353
|
+
author_id=user_message.agent_id,
|
|
354
|
+
thread_type=user_message.author_type,
|
|
355
|
+
reply_to=user_message.id,
|
|
352
356
|
time_cost=time.perf_counter() - start,
|
|
353
357
|
)
|
|
354
358
|
error_message = await error_message_create.save()
|
|
@@ -361,12 +365,12 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
361
365
|
if not user_account.has_sufficient_credits(avg_count):
|
|
362
366
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
363
367
|
SystemMessageType.INSUFFICIENT_BALANCE,
|
|
364
|
-
agent_id=
|
|
365
|
-
chat_id=
|
|
366
|
-
user_id=
|
|
367
|
-
author_id=
|
|
368
|
-
thread_type=
|
|
369
|
-
reply_to=
|
|
368
|
+
agent_id=user_message.agent_id,
|
|
369
|
+
chat_id=user_message.chat_id,
|
|
370
|
+
user_id=user_message.user_id,
|
|
371
|
+
author_id=user_message.agent_id,
|
|
372
|
+
thread_type=user_message.author_type,
|
|
373
|
+
reply_to=user_message.id,
|
|
370
374
|
time_cost=time.perf_counter() - start,
|
|
371
375
|
)
|
|
372
376
|
error_message = await error_message_create.save()
|
|
@@ -374,23 +378,22 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
374
378
|
return
|
|
375
379
|
|
|
376
380
|
is_private = False
|
|
377
|
-
if
|
|
381
|
+
if user_message.user_id == agent.owner:
|
|
378
382
|
is_private = True
|
|
379
383
|
|
|
380
|
-
|
|
381
|
-
last = start + cold_start_cost
|
|
384
|
+
last = start
|
|
382
385
|
|
|
383
386
|
# Extract images from attachments
|
|
384
387
|
image_urls = []
|
|
385
|
-
if
|
|
388
|
+
if user_message.attachments:
|
|
386
389
|
image_urls = [
|
|
387
390
|
att["url"]
|
|
388
|
-
for att in
|
|
391
|
+
for att in user_message.attachments
|
|
389
392
|
if "type" in att and att["type"] == "image" and "url" in att
|
|
390
393
|
]
|
|
391
394
|
|
|
392
395
|
# Process input message to handle @skill patterns
|
|
393
|
-
input_message = await explain_prompt(
|
|
396
|
+
input_message = await explain_prompt(user_message.message)
|
|
394
397
|
|
|
395
398
|
# super mode
|
|
396
399
|
recursion_limit = 30
|
|
@@ -446,7 +449,7 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
446
449
|
]
|
|
447
450
|
|
|
448
451
|
# stream config
|
|
449
|
-
thread_id = f"{
|
|
452
|
+
thread_id = f"{user_message.agent_id}-{user_message.chat_id}"
|
|
450
453
|
stream_config = {
|
|
451
454
|
"configurable": {
|
|
452
455
|
"thread_id": thread_id,
|
|
@@ -454,12 +457,16 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
454
457
|
"recursion_limit": recursion_limit,
|
|
455
458
|
}
|
|
456
459
|
|
|
460
|
+
def get_agent() -> Agent:
|
|
461
|
+
return agent
|
|
462
|
+
|
|
457
463
|
context = AgentContext(
|
|
458
|
-
agent_id=
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
464
|
+
agent_id=user_message.agent_id,
|
|
465
|
+
get_agent=get_agent,
|
|
466
|
+
chat_id=user_message.chat_id,
|
|
467
|
+
user_id=user_message.user_id,
|
|
468
|
+
app_id=user_message.app_id,
|
|
469
|
+
entrypoint=user_message.author_type,
|
|
463
470
|
is_private=is_private,
|
|
464
471
|
payer=payer if payment_enabled else None,
|
|
465
472
|
)
|
|
@@ -496,14 +503,14 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
496
503
|
# agent message
|
|
497
504
|
chat_message_create = ChatMessageCreate(
|
|
498
505
|
id=str(XID()),
|
|
499
|
-
agent_id=
|
|
500
|
-
chat_id=
|
|
501
|
-
user_id=
|
|
502
|
-
author_id=
|
|
506
|
+
agent_id=user_message.agent_id,
|
|
507
|
+
chat_id=user_message.chat_id,
|
|
508
|
+
user_id=user_message.user_id,
|
|
509
|
+
author_id=user_message.agent_id,
|
|
503
510
|
author_type=AuthorType.AGENT,
|
|
504
511
|
model=agent.model,
|
|
505
|
-
thread_type=
|
|
506
|
-
reply_to=
|
|
512
|
+
thread_type=user_message.author_type,
|
|
513
|
+
reply_to=user_message.id,
|
|
507
514
|
message=content,
|
|
508
515
|
input_tokens=(
|
|
509
516
|
msg.usage_metadata.get("input_tokens", 0)
|
|
@@ -518,9 +525,6 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
518
525
|
time_cost=this_time - last,
|
|
519
526
|
)
|
|
520
527
|
last = this_time
|
|
521
|
-
if cold_start_cost > 0:
|
|
522
|
-
chat_message_create.cold_start_cost = cold_start_cost
|
|
523
|
-
cold_start_cost = 0
|
|
524
528
|
# handle message and payment in one transaction
|
|
525
529
|
async with get_session() as session:
|
|
526
530
|
# payment
|
|
@@ -541,7 +545,7 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
541
545
|
for tool_output in tool_outputs:
|
|
542
546
|
if tool_output.get("type") == "web_search_call":
|
|
543
547
|
logger.info(
|
|
544
|
-
f"[{
|
|
548
|
+
f"[{user_message.agent_id}] Found web_search_call in additional_kwargs"
|
|
545
549
|
)
|
|
546
550
|
amount += 35
|
|
547
551
|
break
|
|
@@ -549,11 +553,13 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
549
553
|
session,
|
|
550
554
|
payer,
|
|
551
555
|
chat_message_create.id,
|
|
552
|
-
|
|
556
|
+
user_message.id,
|
|
553
557
|
amount,
|
|
554
558
|
agent,
|
|
555
559
|
)
|
|
556
|
-
logger.info(
|
|
560
|
+
logger.info(
|
|
561
|
+
f"[{user_message.agent_id}] expense message: {amount}"
|
|
562
|
+
)
|
|
557
563
|
chat_message_create.credit_event_id = credit_event.id
|
|
558
564
|
chat_message_create.credit_cost = credit_event.total_amount
|
|
559
565
|
chat_message = await chat_message_create.save_in_session(
|
|
@@ -604,14 +610,14 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
604
610
|
break
|
|
605
611
|
skill_message_create = ChatMessageCreate(
|
|
606
612
|
id=str(XID()),
|
|
607
|
-
agent_id=
|
|
608
|
-
chat_id=
|
|
609
|
-
user_id=
|
|
610
|
-
author_id=
|
|
613
|
+
agent_id=user_message.agent_id,
|
|
614
|
+
chat_id=user_message.chat_id,
|
|
615
|
+
user_id=user_message.user_id,
|
|
616
|
+
author_id=user_message.agent_id,
|
|
611
617
|
author_type=AuthorType.SKILL,
|
|
612
618
|
model=agent.model,
|
|
613
|
-
thread_type=
|
|
614
|
-
reply_to=
|
|
619
|
+
thread_type=user_message.author_type,
|
|
620
|
+
reply_to=user_message.id,
|
|
615
621
|
message="",
|
|
616
622
|
skill_calls=skill_calls,
|
|
617
623
|
attachments=cached_attachments,
|
|
@@ -632,9 +638,6 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
632
638
|
time_cost=this_time - last,
|
|
633
639
|
)
|
|
634
640
|
last = this_time
|
|
635
|
-
if cold_start_cost > 0:
|
|
636
|
-
skill_message_create.cold_start_cost = cold_start_cost
|
|
637
|
-
cold_start_cost = 0
|
|
638
641
|
# save message and credit in one transaction
|
|
639
642
|
async with get_session() as session:
|
|
640
643
|
if payment_enabled:
|
|
@@ -648,7 +651,7 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
648
651
|
session,
|
|
649
652
|
payer,
|
|
650
653
|
skill_message_create.id,
|
|
651
|
-
|
|
654
|
+
user_message.id,
|
|
652
655
|
message_amount,
|
|
653
656
|
agent,
|
|
654
657
|
)
|
|
@@ -666,7 +669,7 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
666
669
|
session,
|
|
667
670
|
payer,
|
|
668
671
|
skill_message_create.id,
|
|
669
|
-
|
|
672
|
+
user_message.id,
|
|
670
673
|
skill_call["id"],
|
|
671
674
|
skill_call["name"],
|
|
672
675
|
agent,
|
|
@@ -674,7 +677,7 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
674
677
|
skill_call["credit_event_id"] = payment_event.id
|
|
675
678
|
skill_call["credit_cost"] = payment_event.total_amount
|
|
676
679
|
logger.info(
|
|
677
|
-
f"[{
|
|
680
|
+
f"[{user_message.agent_id}] skill payment: {skill_call}"
|
|
678
681
|
)
|
|
679
682
|
skill_message_create.skill_calls = skill_calls
|
|
680
683
|
skill_message = await skill_message_create.save_in_session(session)
|
|
@@ -700,36 +703,31 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
700
703
|
content = msg.content[0]
|
|
701
704
|
post_model_message_create = ChatMessageCreate(
|
|
702
705
|
id=str(XID()),
|
|
703
|
-
agent_id=
|
|
704
|
-
chat_id=
|
|
705
|
-
user_id=
|
|
706
|
-
author_id=
|
|
706
|
+
agent_id=user_message.agent_id,
|
|
707
|
+
chat_id=user_message.chat_id,
|
|
708
|
+
user_id=user_message.user_id,
|
|
709
|
+
author_id=user_message.agent_id,
|
|
707
710
|
author_type=AuthorType.AGENT,
|
|
708
711
|
model=agent.model,
|
|
709
|
-
thread_type=
|
|
710
|
-
reply_to=
|
|
712
|
+
thread_type=user_message.author_type,
|
|
713
|
+
reply_to=user_message.id,
|
|
711
714
|
message=content,
|
|
712
715
|
input_tokens=0,
|
|
713
716
|
output_tokens=0,
|
|
714
717
|
time_cost=this_time - last,
|
|
715
718
|
)
|
|
716
719
|
last = this_time
|
|
717
|
-
if cold_start_cost > 0:
|
|
718
|
-
post_model_message_create.cold_start_cost = (
|
|
719
|
-
cold_start_cost
|
|
720
|
-
)
|
|
721
|
-
cold_start_cost = 0
|
|
722
720
|
post_model_message = await post_model_message_create.save()
|
|
723
721
|
yield post_model_message
|
|
724
722
|
error_message_create = (
|
|
725
723
|
await ChatMessageCreate.from_system_message(
|
|
726
724
|
SystemMessageType.INSUFFICIENT_BALANCE,
|
|
727
|
-
agent_id=
|
|
728
|
-
chat_id=
|
|
729
|
-
user_id=
|
|
730
|
-
author_id=
|
|
731
|
-
thread_type=
|
|
732
|
-
reply_to=
|
|
725
|
+
agent_id=user_message.agent_id,
|
|
726
|
+
chat_id=user_message.chat_id,
|
|
727
|
+
user_id=user_message.user_id,
|
|
728
|
+
author_id=user_message.agent_id,
|
|
729
|
+
thread_type=user_message.author_type,
|
|
730
|
+
reply_to=user_message.id,
|
|
733
731
|
time_cost=0,
|
|
734
732
|
)
|
|
735
733
|
)
|
|
@@ -749,12 +747,12 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
749
747
|
)
|
|
750
748
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
751
749
|
SystemMessageType.AGENT_INTERNAL_ERROR,
|
|
752
|
-
agent_id=
|
|
753
|
-
chat_id=
|
|
754
|
-
user_id=
|
|
755
|
-
author_id=
|
|
756
|
-
thread_type=
|
|
757
|
-
reply_to=
|
|
750
|
+
agent_id=user_message.agent_id,
|
|
751
|
+
chat_id=user_message.chat_id,
|
|
752
|
+
user_id=user_message.user_id,
|
|
753
|
+
author_id=user_message.agent_id,
|
|
754
|
+
thread_type=user_message.author_type,
|
|
755
|
+
reply_to=user_message.id,
|
|
758
756
|
time_cost=time.perf_counter() - start,
|
|
759
757
|
)
|
|
760
758
|
error_message = await error_message_create.save()
|
|
@@ -764,16 +762,16 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
764
762
|
error_traceback = traceback.format_exc()
|
|
765
763
|
logger.error(
|
|
766
764
|
f"reached recursion limit: {str(e)}\n{error_traceback}",
|
|
767
|
-
extra={"thread_id": thread_id, "agent_id":
|
|
765
|
+
extra={"thread_id": thread_id, "agent_id": user_message.agent_id},
|
|
768
766
|
)
|
|
769
767
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
770
768
|
SystemMessageType.STEP_LIMIT_EXCEEDED,
|
|
771
|
-
agent_id=
|
|
772
|
-
chat_id=
|
|
773
|
-
user_id=
|
|
774
|
-
author_id=
|
|
775
|
-
thread_type=
|
|
776
|
-
reply_to=
|
|
769
|
+
agent_id=user_message.agent_id,
|
|
770
|
+
chat_id=user_message.chat_id,
|
|
771
|
+
user_id=user_message.user_id,
|
|
772
|
+
author_id=user_message.agent_id,
|
|
773
|
+
thread_type=user_message.author_type,
|
|
774
|
+
reply_to=user_message.id,
|
|
777
775
|
time_cost=time.perf_counter() - start,
|
|
778
776
|
)
|
|
779
777
|
error_message = await error_message_create.save()
|
|
@@ -783,21 +781,21 @@ async def stream_agent(message: ChatMessageCreate):
|
|
|
783
781
|
error_traceback = traceback.format_exc()
|
|
784
782
|
logger.error(
|
|
785
783
|
f"failed to execute agent: {str(e)}\n{error_traceback}",
|
|
786
|
-
extra={"thread_id": thread_id, "agent_id":
|
|
784
|
+
extra={"thread_id": thread_id, "agent_id": user_message.agent_id},
|
|
787
785
|
)
|
|
788
786
|
error_message_create = await ChatMessageCreate.from_system_message(
|
|
789
787
|
SystemMessageType.AGENT_INTERNAL_ERROR,
|
|
790
|
-
agent_id=
|
|
791
|
-
chat_id=
|
|
792
|
-
user_id=
|
|
793
|
-
author_id=
|
|
794
|
-
thread_type=
|
|
795
|
-
reply_to=
|
|
788
|
+
agent_id=user_message.agent_id,
|
|
789
|
+
chat_id=user_message.chat_id,
|
|
790
|
+
user_id=user_message.user_id,
|
|
791
|
+
author_id=user_message.agent_id,
|
|
792
|
+
thread_type=user_message.author_type,
|
|
793
|
+
reply_to=user_message.id,
|
|
796
794
|
time_cost=time.perf_counter() - start,
|
|
797
795
|
)
|
|
798
796
|
error_message = await error_message_create.save()
|
|
799
797
|
yield error_message
|
|
800
|
-
await clear_thread_memory(
|
|
798
|
+
await clear_thread_memory(user_message.agent_id, user_message.chat_id)
|
|
801
799
|
return
|
|
802
800
|
|
|
803
801
|
|
intentkit/core/node.py
CHANGED
|
@@ -81,10 +81,10 @@ class PreModelNode(RunnableCallable):
|
|
|
81
81
|
self.func_accepts_config = True
|
|
82
82
|
|
|
83
83
|
def _parse_input(
|
|
84
|
-
self,
|
|
84
|
+
self, state: AgentState
|
|
85
85
|
) -> tuple[list[AnyMessage], dict[str, Any]]:
|
|
86
|
-
messages =
|
|
87
|
-
context =
|
|
86
|
+
messages = state.get("messages")
|
|
87
|
+
context = state.get("context", {})
|
|
88
88
|
if messages is None or not isinstance(messages, list) or len(messages) == 0:
|
|
89
89
|
raise ValueError("Missing required field `messages` in the input.")
|
|
90
90
|
return messages, context
|
|
@@ -107,13 +107,13 @@ class PreModelNode(RunnableCallable):
|
|
|
107
107
|
def _func(self, AgentState) -> dict[str, Any]:
|
|
108
108
|
raise NotImplementedError("Not implemented yet")
|
|
109
109
|
|
|
110
|
-
async def _afunc(self,
|
|
111
|
-
messages, context = self._parse_input(
|
|
110
|
+
async def _afunc(self, state: AgentState) -> dict[str, Any]:
|
|
111
|
+
messages, context = self._parse_input(state)
|
|
112
112
|
try:
|
|
113
113
|
_validate_chat_history(messages)
|
|
114
114
|
except ValueError as e:
|
|
115
115
|
logger.error(f"Invalid chat history: {e}")
|
|
116
|
-
logger.info(
|
|
116
|
+
logger.info(state)
|
|
117
117
|
# delete all messages
|
|
118
118
|
return {"messages": [RemoveMessage(REMOVE_ALL_MESSAGES)]}
|
|
119
119
|
if self.short_term_memory_strategy == "trim":
|
|
@@ -162,7 +162,7 @@ class PreModelNode(RunnableCallable):
|
|
|
162
162
|
return self._prepare_state_update(context, summarization_result)
|
|
163
163
|
except ValueError as e:
|
|
164
164
|
logger.error(f"Invalid chat history: {e}")
|
|
165
|
-
logger.info(
|
|
165
|
+
logger.info(state)
|
|
166
166
|
# delete all messages
|
|
167
167
|
return {"messages": [RemoveMessage(REMOVE_ALL_MESSAGES)]}
|
|
168
168
|
raise ValueError(
|
|
@@ -175,15 +175,15 @@ class PostModelNode(RunnableCallable):
|
|
|
175
175
|
super().__init__(self._func, self._afunc, name="post_model_node", trace=False)
|
|
176
176
|
self.func_accepts_config = True
|
|
177
177
|
|
|
178
|
-
def _func(self,
|
|
178
|
+
def _func(self, state: AgentState) -> dict[str, Any]:
|
|
179
179
|
raise NotImplementedError("Not implemented yet")
|
|
180
180
|
|
|
181
|
-
async def _afunc(self,
|
|
181
|
+
async def _afunc(self, state: AgentState) -> dict[str, Any]:
|
|
182
182
|
runtime = get_runtime(AgentContext)
|
|
183
183
|
context = runtime.context
|
|
184
|
-
logger.debug(f"Running PostModelNode, input: {
|
|
184
|
+
logger.debug(f"Running PostModelNode, input: {state}, context: {context}")
|
|
185
185
|
state_update = {}
|
|
186
|
-
messages =
|
|
186
|
+
messages = state.get("messages")
|
|
187
187
|
if messages is None or not isinstance(messages, list) or len(messages) == 0:
|
|
188
188
|
raise ValueError("Missing required field `messages` in the input.")
|
|
189
189
|
payer = context.payer
|
|
@@ -12,7 +12,7 @@ class VeniceAudioInput(BaseModel):
|
|
|
12
12
|
Defines parameters controllable by the user when invoking the tool.
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
voice_input: str = Field(
|
|
16
16
|
..., # Ellipsis (...) indicates this field is required
|
|
17
17
|
description="The text to generate audio for. Maximum length is 4096 characters.",
|
|
18
18
|
min_length=1, # As per API docs: Required string length: 1
|
|
@@ -40,7 +40,7 @@ class VeniceAudioTool(VeniceAudioBaseTool):
|
|
|
40
40
|
|
|
41
41
|
async def _arun(
|
|
42
42
|
self,
|
|
43
|
-
|
|
43
|
+
voice_input: str,
|
|
44
44
|
voice_model: str,
|
|
45
45
|
speed: Optional[float] = 1.0,
|
|
46
46
|
response_format: Optional[AllowedAudioFormat] = "mp3",
|
|
@@ -98,7 +98,7 @@ class VeniceAudioTool(VeniceAudioBaseTool):
|
|
|
98
98
|
# --- Prepare API Call ---
|
|
99
99
|
payload: Dict[str, Any] = {
|
|
100
100
|
"model": tts_model_id,
|
|
101
|
-
"input":
|
|
101
|
+
"input": voice_input,
|
|
102
102
|
"voice": voice_model,
|
|
103
103
|
"response_format": final_response_format,
|
|
104
104
|
"speed": speed if speed is not None else 1.0,
|
|
@@ -208,7 +208,7 @@ class VeniceAudioTool(VeniceAudioBaseTool):
|
|
|
208
208
|
"tts_engine": tts_model_id,
|
|
209
209
|
"speed": speed if speed is not None else 1.0,
|
|
210
210
|
"response_format": final_response_format,
|
|
211
|
-
"input_text_length": len(
|
|
211
|
+
"input_text_length": len(voice_input),
|
|
212
212
|
"error": False,
|
|
213
213
|
"status_code": response.status_code,
|
|
214
214
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: intentkit
|
|
3
|
-
Version: 0.7.5.
|
|
3
|
+
Version: 0.7.5.dev19
|
|
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,9 +1,9 @@
|
|
|
1
|
-
intentkit/__init__.py,sha256
|
|
1
|
+
intentkit/__init__.py,sha256=vC3AH1dexdHSEV7Bq6Rn5KTbRiLuFt0PZkhsTwoz-Qk,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
|
|
5
5
|
intentkit/abstracts/engine.py,sha256=C5C9d8vVMePhkKWURKIAbZSDZnmjxj5epL_04E6RpxQ,1449
|
|
6
|
-
intentkit/abstracts/graph.py,sha256=
|
|
6
|
+
intentkit/abstracts/graph.py,sha256=j43cNpWouXLmWl80gLDs8gCLcHkiaWAJNbT2vQuXcpg,1137
|
|
7
7
|
intentkit/abstracts/skill.py,sha256=cIJ6BkASD31U1IEkE8rdAawq99w_xsg0lt3oalqa1ZA,5071
|
|
8
8
|
intentkit/abstracts/twitter.py,sha256=cEtP7ygR_b-pHdc9i8kBuyooz1cPoGUGwsBHDpowJyY,1262
|
|
9
9
|
intentkit/clients/__init__.py,sha256=pT_4I7drnuiNWPvYAU_CUAv50PjyaqEAsm_kp-vMPW4,372
|
|
@@ -18,8 +18,8 @@ intentkit/core/api.py,sha256=WfoaHNquujYJIpNPuTR1dSaaxog0S3X2W4lG9Ehmkm4,3284
|
|
|
18
18
|
intentkit/core/chat.py,sha256=YN20CnDazWLjiOZFOHgV6uHmA2DKkvPCsD5Q5sfNcZg,1685
|
|
19
19
|
intentkit/core/client.py,sha256=J5K7f08-ucszBKAbn9K3QNOFKIC__7amTbKYii1jFkI,3056
|
|
20
20
|
intentkit/core/credit.py,sha256=b4f4T6G6eeBTMe0L_r8awWtXgUnqiog4IUaymDPYym0,75587
|
|
21
|
-
intentkit/core/engine.py,sha256=
|
|
22
|
-
intentkit/core/node.py,sha256=
|
|
21
|
+
intentkit/core/engine.py,sha256=SnYBwcZli2Sn0yRaoQ-Okc3zJt86hxhaXqjwIgTKKiw,37226
|
|
22
|
+
intentkit/core/node.py,sha256=P0LiBrjFtNBVC0JpQntTgDVfaLJM8aqhJZCJfPx6MJ0,8880
|
|
23
23
|
intentkit/core/prompt.py,sha256=idNx1ono4Maz2i6IBKfaKOBBbEQiWbaSxr2Eb1vZTI4,15482
|
|
24
24
|
intentkit/models/agent.py,sha256=yXulE5vlOOku6DSiid_Jp6OCfqy3-XN47rmKax5xX1w,67582
|
|
25
25
|
intentkit/models/agent_data.py,sha256=5zq3EPKnygT2P1OHc2IfEmL8hXkjeBND6sJ0JJsvQJg,28370
|
|
@@ -379,9 +379,9 @@ intentkit/skills/unrealspeech/text_to_speech.py,sha256=QsCeOdPtlObQKCVNm6A9jKK55
|
|
|
379
379
|
intentkit/skills/unrealspeech/unrealspeech.jpg,sha256=t-6RkYflJrL3Pvf5aA_VPAR_QlGyKUImXZBJLiyR3xY,8201
|
|
380
380
|
intentkit/skills/venice_audio/__init__.py,sha256=E39CeSUHRoGV9IxNUtwo-nCp0Yfq5rvcrq1N61ygwGc,3309
|
|
381
381
|
intentkit/skills/venice_audio/base.py,sha256=1oxHrmDXpBZbA7q2BqatlpuY-X3uwhK22T8QZjKmkqw,4845
|
|
382
|
-
intentkit/skills/venice_audio/input.py,sha256=
|
|
382
|
+
intentkit/skills/venice_audio/input.py,sha256=3pXfgkXuS4ezAVPJMY-XQwgd2Mas58BQnJph1Af8QkA,1893
|
|
383
383
|
intentkit/skills/venice_audio/schema.json,sha256=g3cb9zJvinnRrilvNIAdG8qivgGyB7sHCEC8392MXhY,5268
|
|
384
|
-
intentkit/skills/venice_audio/venice_audio.py,sha256=
|
|
384
|
+
intentkit/skills/venice_audio/venice_audio.py,sha256=h03Lf3t58CRDq2U6Lb1Y_Hp8oZ-FBlp0fxUF-hpxPbE,11323
|
|
385
385
|
intentkit/skills/venice_audio/venice_logo.jpg,sha256=XDnVdh3V8UuJjAeSmp4rbqhTKn0yjRI6M_6z1DSs8cA,13342
|
|
386
386
|
intentkit/skills/venice_image/README.md,sha256=79NWUOaYWeFLOhR7m424pLIZ7VT0fhkxSBcohoy8Oh0,5017
|
|
387
387
|
intentkit/skills/venice_image/__init__.py,sha256=fPq9OS8er67cn3zyo9H_7iEj5cSUu7nOmqhhjwG9xNs,5841
|
|
@@ -450,7 +450,7 @@ intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
|
|
|
450
450
|
intentkit/utils/s3.py,sha256=A8Nsx5QJyLsxhj9g7oHNy2-m24tjQUhC9URm8Qb1jFw,10057
|
|
451
451
|
intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
|
|
452
452
|
intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
|
|
453
|
-
intentkit-0.7.5.
|
|
454
|
-
intentkit-0.7.5.
|
|
455
|
-
intentkit-0.7.5.
|
|
456
|
-
intentkit-0.7.5.
|
|
453
|
+
intentkit-0.7.5.dev19.dist-info/METADATA,sha256=mKeFmE8ZlUdWm6hR1TGH2h2omjKJg6mOcT8DjpjkCiw,6360
|
|
454
|
+
intentkit-0.7.5.dev19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
455
|
+
intentkit-0.7.5.dev19.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
|
|
456
|
+
intentkit-0.7.5.dev19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|