afferens 0.1.0__tar.gz
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.
- afferens-0.1.0/PKG-INFO +8 -0
- afferens-0.1.0/afferens/__init__.py +4 -0
- afferens-0.1.0/afferens/client.py +109 -0
- afferens-0.1.0/afferens.egg-info/PKG-INFO +8 -0
- afferens-0.1.0/afferens.egg-info/SOURCES.txt +8 -0
- afferens-0.1.0/afferens.egg-info/dependency_links.txt +1 -0
- afferens-0.1.0/afferens.egg-info/requires.txt +1 -0
- afferens-0.1.0/afferens.egg-info/top_level.txt +1 -0
- afferens-0.1.0/pyproject.toml +14 -0
- afferens-0.1.0/setup.cfg +4 -0
afferens-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: afferens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Afferens Python SDK — Universal Sensory Layer for AI agents
|
|
5
|
+
Project-URL: Homepage, https://afferens.vercel.app
|
|
6
|
+
Project-URL: Documentation, https://afferens.vercel.app/docs
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Requires-Dist: requests>=2.28
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Optional, Literal
|
|
3
|
+
|
|
4
|
+
BASE_URL = "https://afferens.vercel.app"
|
|
5
|
+
|
|
6
|
+
Modality = Literal["VISION", "SPATIAL", "ACOUSTIC", "ENVIRONMENTAL", "MOLECULAR", "INTEROCEPTION"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AfferensError(Exception):
|
|
10
|
+
def __init__(self, status: int, message: str):
|
|
11
|
+
self.status = status
|
|
12
|
+
self.message = message
|
|
13
|
+
super().__init__(f"[{status}] {message}")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Afferens:
|
|
17
|
+
"""
|
|
18
|
+
Afferens Python SDK — Universal Sensory Layer for AI agents.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
from afferens import Afferens
|
|
22
|
+
client = Afferens(api_key="AFF-77-YOURNAME")
|
|
23
|
+
data = client.perceive(modality="VISION")
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, api_key: str, base_url: str = BASE_URL):
|
|
27
|
+
self.api_key = api_key
|
|
28
|
+
self.base_url = base_url.rstrip("/")
|
|
29
|
+
self._session = requests.Session()
|
|
30
|
+
self._session.headers.update({"X-API-KEY": self.api_key})
|
|
31
|
+
|
|
32
|
+
def perceive(
|
|
33
|
+
self,
|
|
34
|
+
modality: Optional[Modality] = None,
|
|
35
|
+
limit: int = 1,
|
|
36
|
+
) -> dict:
|
|
37
|
+
"""
|
|
38
|
+
Query the Afferens sensory API.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
modality: One of VISION, SPATIAL, ACOUSTIC, ENVIRONMENTAL, MOLECULAR, INTEROCEPTION.
|
|
42
|
+
Omit to retrieve all modalities.
|
|
43
|
+
limit: Number of events to return (max 10).
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
dict with keys: status, data, count, api_version
|
|
47
|
+
"""
|
|
48
|
+
params = {"limit": min(limit, 10)}
|
|
49
|
+
if modality:
|
|
50
|
+
params["modality"] = modality.upper()
|
|
51
|
+
|
|
52
|
+
response = self._session.get(f"{self.base_url}/api/perception", params=params)
|
|
53
|
+
result = response.json()
|
|
54
|
+
|
|
55
|
+
if response.status_code != 200:
|
|
56
|
+
raise AfferensError(result.get("status", response.status_code), result.get("error", "Unknown error"))
|
|
57
|
+
|
|
58
|
+
return result
|
|
59
|
+
|
|
60
|
+
def ingest(
|
|
61
|
+
self,
|
|
62
|
+
modality: Modality,
|
|
63
|
+
data: dict,
|
|
64
|
+
classification: Optional[str] = None,
|
|
65
|
+
) -> dict:
|
|
66
|
+
"""
|
|
67
|
+
Push live sensor data into the Afferens API from this node.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
modality: Sensor type — VISION, SPATIAL, etc.
|
|
71
|
+
data: Raw sensor payload as a dict.
|
|
72
|
+
classification: Optional label for this reading.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
dict with entity_id, modality, sense_tokens_consumed
|
|
76
|
+
"""
|
|
77
|
+
body = {"modality": modality.upper(), "data": data}
|
|
78
|
+
if classification:
|
|
79
|
+
body["classification"] = classification
|
|
80
|
+
|
|
81
|
+
response = self._session.post(
|
|
82
|
+
f"{self.base_url}/api/ingest",
|
|
83
|
+
json=body,
|
|
84
|
+
headers={"Content-Type": "application/json"},
|
|
85
|
+
)
|
|
86
|
+
result = response.json()
|
|
87
|
+
|
|
88
|
+
if response.status_code != 200:
|
|
89
|
+
raise AfferensError(result.get("status", response.status_code), result.get("error", "Unknown error"))
|
|
90
|
+
|
|
91
|
+
return result
|
|
92
|
+
|
|
93
|
+
def vision(self, limit: int = 1) -> dict:
|
|
94
|
+
return self.perceive(modality="VISION", limit=limit)
|
|
95
|
+
|
|
96
|
+
def spatial(self, limit: int = 1) -> dict:
|
|
97
|
+
return self.perceive(modality="SPATIAL", limit=limit)
|
|
98
|
+
|
|
99
|
+
def acoustic(self, limit: int = 1) -> dict:
|
|
100
|
+
return self.perceive(modality="ACOUSTIC", limit=limit)
|
|
101
|
+
|
|
102
|
+
def environmental(self, limit: int = 1) -> dict:
|
|
103
|
+
return self.perceive(modality="ENVIRONMENTAL", limit=limit)
|
|
104
|
+
|
|
105
|
+
def molecular(self, limit: int = 1) -> dict:
|
|
106
|
+
return self.perceive(modality="MOLECULAR", limit=limit)
|
|
107
|
+
|
|
108
|
+
def interoception(self, limit: int = 1) -> dict:
|
|
109
|
+
return self.perceive(modality="INTEROCEPTION", limit=limit)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: afferens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Afferens Python SDK — Universal Sensory Layer for AI agents
|
|
5
|
+
Project-URL: Homepage, https://afferens.vercel.app
|
|
6
|
+
Project-URL: Documentation, https://afferens.vercel.app/docs
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Requires-Dist: requests>=2.28
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.28
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
afferens
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "afferens"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Afferens Python SDK — Universal Sensory Layer for AI agents"
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
dependencies = ["requests>=2.28"]
|
|
11
|
+
|
|
12
|
+
[project.urls]
|
|
13
|
+
Homepage = "https://afferens.vercel.app"
|
|
14
|
+
Documentation = "https://afferens.vercel.app/docs"
|
afferens-0.1.0/setup.cfg
ADDED