agent0-sdk 1.4.2__py3-none-any.whl → 1.5.1b1__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.
- agent0_sdk/__init__.py +7 -3
- agent0_sdk/core/contracts.py +1 -0
- agent0_sdk/core/feedback_manager.py +75 -78
- agent0_sdk/core/indexer.py +645 -635
- agent0_sdk/core/models.py +91 -12
- agent0_sdk/core/sdk.py +26 -314
- agent0_sdk/core/semantic_search_client.py +70 -0
- agent0_sdk/core/subgraph_client.py +182 -239
- {agent0_sdk-1.4.2.dist-info → agent0_sdk-1.5.1b1.dist-info}/METADATA +163 -9
- agent0_sdk-1.5.1b1.dist-info/RECORD +22 -0
- agent0_sdk-1.4.2.dist-info/RECORD +0 -21
- {agent0_sdk-1.4.2.dist-info → agent0_sdk-1.5.1b1.dist-info}/WHEEL +0 -0
- {agent0_sdk-1.4.2.dist-info → agent0_sdk-1.5.1b1.dist-info}/licenses/LICENSE +0 -0
- {agent0_sdk-1.4.2.dist-info → agent0_sdk-1.5.1b1.dist-info}/top_level.txt +0 -0
agent0_sdk/__init__.py
CHANGED
|
@@ -16,7 +16,9 @@ from .core.models import (
|
|
|
16
16
|
RegistrationFile,
|
|
17
17
|
AgentSummary,
|
|
18
18
|
Feedback,
|
|
19
|
-
|
|
19
|
+
SearchFilters,
|
|
20
|
+
SearchOptions,
|
|
21
|
+
FeedbackFilters,
|
|
20
22
|
SearchFeedbackParams,
|
|
21
23
|
)
|
|
22
24
|
|
|
@@ -33,7 +35,7 @@ except ImportError:
|
|
|
33
35
|
TransactionMined = None
|
|
34
36
|
_sdk_available = False
|
|
35
37
|
|
|
36
|
-
__version__ = "1.
|
|
38
|
+
__version__ = "1.5.1b1"
|
|
37
39
|
__all__ = [
|
|
38
40
|
"SDK",
|
|
39
41
|
"Agent",
|
|
@@ -52,6 +54,8 @@ __all__ = [
|
|
|
52
54
|
"RegistrationFile",
|
|
53
55
|
"AgentSummary",
|
|
54
56
|
"Feedback",
|
|
55
|
-
"
|
|
57
|
+
"SearchFilters",
|
|
58
|
+
"SearchOptions",
|
|
59
|
+
"FeedbackFilters",
|
|
56
60
|
"SearchFeedbackParams",
|
|
57
61
|
]
|
agent0_sdk/core/contracts.py
CHANGED
|
@@ -547,6 +547,7 @@ DEFAULT_REGISTRIES: Dict[int, Dict[str, str]] = {
|
|
|
547
547
|
DEFAULT_SUBGRAPH_URLS: Dict[int, str] = {
|
|
548
548
|
1: "https://gateway.thegraph.com/api/7fd2e7d89ce3ef24cd0d4590298f0b2c/subgraphs/id/FV6RR6y13rsnCxBAicKuQEwDp8ioEGiNaWaZUmvr1F8k", # Ethereum Mainnet
|
|
549
549
|
11155111: "https://gateway.thegraph.com/api/00a452ad3cd1900273ea62c1bf283f93/subgraphs/id/6wQRC7geo9XYAhckfmfo8kbMRLeWU8KQd3XsJqFKmZLT", # Ethereum Sepolia
|
|
550
|
+
137: "https://gateway.thegraph.com/api/782d61ed390e625b8867995389699b4c/subgraphs/id/9q16PZv1JudvtnCAf44cBoxg82yK9SSsFvrjCY9xnneF", # Polygon Mainnet
|
|
550
551
|
# Other chains temporarily disabled - subgraphs to be updated
|
|
551
552
|
# 84532: "https://gateway.thegraph.com/api/...", # Base Sepolia - To be updated
|
|
552
553
|
# 80002: "https://gateway.thegraph.com/api/...", # Polygon Amoy - To be updated
|
|
@@ -422,8 +422,6 @@ class FeedbackManager:
|
|
|
422
422
|
minValue: Optional[float] = None,
|
|
423
423
|
maxValue: Optional[float] = None,
|
|
424
424
|
include_revoked: bool = False,
|
|
425
|
-
first: int = 100,
|
|
426
|
-
skip: int = 0,
|
|
427
425
|
agents: Optional[List[AgentId]] = None,
|
|
428
426
|
) -> List[Feedback]:
|
|
429
427
|
"""Search feedback.
|
|
@@ -451,8 +449,6 @@ class FeedbackManager:
|
|
|
451
449
|
minValue,
|
|
452
450
|
maxValue,
|
|
453
451
|
include_revoked,
|
|
454
|
-
first,
|
|
455
|
-
skip,
|
|
456
452
|
agents=agents,
|
|
457
453
|
)
|
|
458
454
|
|
|
@@ -469,8 +465,6 @@ class FeedbackManager:
|
|
|
469
465
|
minValue,
|
|
470
466
|
maxValue,
|
|
471
467
|
include_revoked,
|
|
472
|
-
first,
|
|
473
|
-
skip,
|
|
474
468
|
agents=agents,
|
|
475
469
|
)
|
|
476
470
|
|
|
@@ -558,8 +552,6 @@ class FeedbackManager:
|
|
|
558
552
|
minValue: Optional[float],
|
|
559
553
|
maxValue: Optional[float],
|
|
560
554
|
include_revoked: bool,
|
|
561
|
-
first: int,
|
|
562
|
-
skip: int,
|
|
563
555
|
agents: Optional[List[AgentId]] = None,
|
|
564
556
|
) -> List[Feedback]:
|
|
565
557
|
"""Search feedback using subgraph."""
|
|
@@ -583,79 +575,84 @@ class FeedbackManager:
|
|
|
583
575
|
includeRevoked=include_revoked
|
|
584
576
|
)
|
|
585
577
|
|
|
586
|
-
# Query subgraph
|
|
587
|
-
feedbacks_data = self.subgraph_client.search_feedback(
|
|
588
|
-
params=params,
|
|
589
|
-
first=first,
|
|
590
|
-
skip=skip,
|
|
591
|
-
order_by="createdAt",
|
|
592
|
-
order_direction="desc"
|
|
593
|
-
)
|
|
594
|
-
|
|
595
|
-
# Map to Feedback objects
|
|
596
578
|
feedbacks = []
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
579
|
+
batch = 1000
|
|
580
|
+
skip = 0
|
|
581
|
+
while True:
|
|
582
|
+
feedbacks_data = self.subgraph_client.search_feedback(
|
|
583
|
+
params=params,
|
|
584
|
+
first=batch,
|
|
585
|
+
skip=skip,
|
|
586
|
+
order_by="createdAt",
|
|
587
|
+
order_direction="desc",
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
for fb_data in feedbacks_data:
|
|
591
|
+
feedback_file = fb_data.get('feedbackFile') or {}
|
|
592
|
+
if not isinstance(feedback_file, dict):
|
|
593
|
+
feedback_file = {}
|
|
594
|
+
|
|
595
|
+
# Map responses
|
|
596
|
+
responses_data = fb_data.get('responses', [])
|
|
597
|
+
answers = []
|
|
598
|
+
for resp in responses_data:
|
|
599
|
+
answers.append({
|
|
600
|
+
'responder': resp.get('responder'),
|
|
601
|
+
'responseUri': resp.get('responseUri'),
|
|
602
|
+
'responseHash': resp.get('responseHash'),
|
|
603
|
+
'createdAt': resp.get('createdAt')
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
# Map tags: rely on whatever the subgraph returns (may be legacy bytes/hash-like values)
|
|
607
|
+
tags_list: List[str] = []
|
|
608
|
+
tag1 = fb_data.get('tag1') or feedback_file.get('tag1')
|
|
609
|
+
tag2 = fb_data.get('tag2') or feedback_file.get('tag2')
|
|
610
|
+
if isinstance(tag1, str) and tag1:
|
|
618
611
|
tags_list.append(tag1)
|
|
619
|
-
|
|
612
|
+
if isinstance(tag2, str) and tag2:
|
|
620
613
|
tags_list.append(tag2)
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
614
|
+
|
|
615
|
+
# Parse agentId from feedback ID
|
|
616
|
+
feedback_id = fb_data['id']
|
|
617
|
+
parts = feedback_id.split(':')
|
|
618
|
+
if len(parts) >= 2:
|
|
619
|
+
agent_id_str = f"{parts[0]}:{parts[1]}"
|
|
620
|
+
client_addr = parts[2] if len(parts) > 2 else ""
|
|
621
|
+
feedback_idx = int(parts[3]) if len(parts) > 3 else 1
|
|
622
|
+
else:
|
|
623
|
+
agent_id_str = feedback_id
|
|
624
|
+
client_addr = ""
|
|
625
|
+
feedback_idx = 1
|
|
626
|
+
|
|
627
|
+
feedback = Feedback(
|
|
628
|
+
id=Feedback.create_id(agent_id_str, client_addr, feedback_idx),
|
|
629
|
+
agentId=agent_id_str,
|
|
630
|
+
reviewer=client_addr,
|
|
631
|
+
value=float(fb_data.get("value")) if fb_data.get("value") is not None else None,
|
|
632
|
+
tags=tags_list,
|
|
633
|
+
text=feedback_file.get('text'),
|
|
634
|
+
capability=feedback_file.get('capability'),
|
|
635
|
+
context=feedback_file.get('context'),
|
|
636
|
+
proofOfPayment={
|
|
637
|
+
'fromAddress': feedback_file.get('proofOfPaymentFromAddress'),
|
|
638
|
+
'toAddress': feedback_file.get('proofOfPaymentToAddress'),
|
|
639
|
+
'chainId': feedback_file.get('proofOfPaymentChainId'),
|
|
640
|
+
'txHash': feedback_file.get('proofOfPaymentTxHash'),
|
|
641
|
+
} if feedback_file.get('proofOfPaymentFromAddress') else None,
|
|
642
|
+
fileURI=fb_data.get('feedbackURI') or fb_data.get('feedbackUri'), # Handle both old and new field names
|
|
643
|
+
endpoint=fb_data.get('endpoint'),
|
|
644
|
+
createdAt=fb_data.get('createdAt', int(time.time())),
|
|
645
|
+
answers=answers,
|
|
646
|
+
isRevoked=fb_data.get('isRevoked', False),
|
|
647
|
+
name=feedback_file.get('name'),
|
|
648
|
+
skill=feedback_file.get('skill'),
|
|
649
|
+
task=feedback_file.get('task'),
|
|
650
|
+
)
|
|
651
|
+
feedbacks.append(feedback)
|
|
652
|
+
|
|
653
|
+
if len(feedbacks_data) < batch:
|
|
654
|
+
break
|
|
655
|
+
skip += batch
|
|
659
656
|
|
|
660
657
|
return feedbacks
|
|
661
658
|
|