agent0-sdk 0.31__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 +52 -0
- agent0_sdk/core/agent.py +992 -0
- agent0_sdk/core/contracts.py +497 -0
- agent0_sdk/core/endpoint_crawler.py +330 -0
- agent0_sdk/core/feedback_manager.py +1023 -0
- agent0_sdk/core/indexer.py +1754 -0
- agent0_sdk/core/ipfs_client.py +355 -0
- agent0_sdk/core/models.py +313 -0
- agent0_sdk/core/oasf_validator.py +98 -0
- agent0_sdk/core/sdk.py +1045 -0
- agent0_sdk/core/subgraph_client.py +833 -0
- agent0_sdk/core/web3_client.py +192 -0
- agent0_sdk/taxonomies/all_domains.json +1565 -0
- agent0_sdk/taxonomies/all_skills.json +1030 -0
- agent0_sdk-0.31.dist-info/METADATA +367 -0
- agent0_sdk-0.31.dist-info/RECORD +33 -0
- agent0_sdk-0.31.dist-info/WHEEL +5 -0
- agent0_sdk-0.31.dist-info/licenses/LICENSE +22 -0
- agent0_sdk-0.31.dist-info/top_level.txt +2 -0
- tests/__init__.py +1 -0
- tests/config.py +46 -0
- tests/conftest.py +22 -0
- tests/discover_test_data.py +445 -0
- tests/test_feedback.py +417 -0
- tests/test_models.py +224 -0
- tests/test_multi_chain.py +588 -0
- tests/test_oasf_management.py +404 -0
- tests/test_real_public_servers.py +103 -0
- tests/test_registration.py +267 -0
- tests/test_registrationIpfs.py +227 -0
- tests/test_sdk.py +240 -0
- tests/test_search.py +415 -0
- tests/test_transfer.py +255 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OASF taxonomy validation utilities.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
# Cache for loaded taxonomy data
|
|
11
|
+
_skills_cache: Optional[dict] = None
|
|
12
|
+
_domains_cache: Optional[dict] = None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_taxonomy_path(filename: str) -> Path:
|
|
16
|
+
"""Get the path to a taxonomy file."""
|
|
17
|
+
# Get the directory where this file is located
|
|
18
|
+
current_dir = Path(__file__).parent
|
|
19
|
+
# Go up one level to agent0_sdk, then into taxonomies
|
|
20
|
+
taxonomy_dir = current_dir.parent / "taxonomies"
|
|
21
|
+
return taxonomy_dir / filename
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _load_skills() -> dict:
|
|
25
|
+
"""Load skills taxonomy file with caching."""
|
|
26
|
+
global _skills_cache
|
|
27
|
+
if _skills_cache is None:
|
|
28
|
+
skills_path = _get_taxonomy_path("all_skills.json")
|
|
29
|
+
try:
|
|
30
|
+
with open(skills_path, "r", encoding="utf-8") as f:
|
|
31
|
+
_skills_cache = json.load(f)
|
|
32
|
+
except FileNotFoundError:
|
|
33
|
+
raise FileNotFoundError(
|
|
34
|
+
f"Skills taxonomy file not found: {skills_path}"
|
|
35
|
+
)
|
|
36
|
+
except json.JSONDecodeError as e:
|
|
37
|
+
raise ValueError(
|
|
38
|
+
f"Invalid JSON in skills taxonomy file: {e}"
|
|
39
|
+
)
|
|
40
|
+
return _skills_cache
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _load_domains() -> dict:
|
|
44
|
+
"""Load domains taxonomy file with caching."""
|
|
45
|
+
global _domains_cache
|
|
46
|
+
if _domains_cache is None:
|
|
47
|
+
domains_path = _get_taxonomy_path("all_domains.json")
|
|
48
|
+
try:
|
|
49
|
+
with open(domains_path, "r", encoding="utf-8") as f:
|
|
50
|
+
_domains_cache = json.load(f)
|
|
51
|
+
except FileNotFoundError:
|
|
52
|
+
raise FileNotFoundError(
|
|
53
|
+
f"Domains taxonomy file not found: {domains_path}"
|
|
54
|
+
)
|
|
55
|
+
except json.JSONDecodeError as e:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
f"Invalid JSON in domains taxonomy file: {e}"
|
|
58
|
+
)
|
|
59
|
+
return _domains_cache
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def validate_skill(slug: str) -> bool:
|
|
63
|
+
"""
|
|
64
|
+
Validate if a skill slug exists in the OASF taxonomy.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
slug: The skill slug to validate (e.g., "natural_language_processing/summarization")
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
True if the skill exists in the taxonomy, False otherwise
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
FileNotFoundError: If the taxonomy file cannot be found
|
|
74
|
+
ValueError: If the taxonomy file is invalid JSON
|
|
75
|
+
"""
|
|
76
|
+
skills_data = _load_skills()
|
|
77
|
+
skills = skills_data.get("skills", {})
|
|
78
|
+
return slug in skills
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def validate_domain(slug: str) -> bool:
|
|
82
|
+
"""
|
|
83
|
+
Validate if a domain slug exists in the OASF taxonomy.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
slug: The domain slug to validate (e.g., "finance_and_business/investment_services")
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
True if the domain exists in the taxonomy, False otherwise
|
|
90
|
+
|
|
91
|
+
Raises:
|
|
92
|
+
FileNotFoundError: If the taxonomy file cannot be found
|
|
93
|
+
ValueError: If the taxonomy file is invalid JSON
|
|
94
|
+
"""
|
|
95
|
+
domains_data = _load_domains()
|
|
96
|
+
domains = domains_data.get("domains", {})
|
|
97
|
+
return slug in domains
|
|
98
|
+
|