upp-python 0.1.0__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.
- upp/__init__.py +183 -0
- upp/backends/.gitkeep +0 -0
- upp/backends/__init__.py +23 -0
- upp/backends/ingest.py +122 -0
- upp/backends/ontology.py +41 -0
- upp/backends/retriever.py +79 -0
- upp/client.py +148 -0
- upp/models/.gitkeep +0 -0
- upp/models/__init__.py +38 -0
- upp/models/client.py +113 -0
- upp/models/enums.py +124 -0
- upp/models/events.py +124 -0
- upp/models/labels.py +71 -0
- upp/ontologies/__init__.py +0 -0
- upp/ontologies/user_v1.py +112 -0
- upp/py.typed +0 -0
- upp/rpc/.gitkeep +0 -0
- upp/rpc/__init__.py +137 -0
- upp/rpc/codec.py +112 -0
- upp/rpc/errors.py +127 -0
- upp/rpc/messages.py +354 -0
- upp/rpc/methods.py +73 -0
- upp_python-0.1.0.dist-info/METADATA +137 -0
- upp_python-0.1.0.dist-info/RECORD +25 -0
- upp_python-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: upp-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python reference implementation of the Universal Personalization Protocol (UPP) data models
|
|
5
|
+
Project-URL: Homepage, https://github.com/Contextually-AI/upp
|
|
6
|
+
Project-URL: Documentation, https://github.com/Contextually-AI/upp/tree/main/spec
|
|
7
|
+
Project-URL: Repository, https://github.com/Contextually-AI/upp
|
|
8
|
+
Project-URL: Issues, https://github.com/Contextually-AI/upp/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Contextually-AI/upp/blob/main/CHANGELOG.md
|
|
10
|
+
Author: UPP Protocol Authors
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
Keywords: json-rpc,personalization,protocol,pydantic,user-profile
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# UPP Python — Reference Implementation
|
|
33
|
+
|
|
34
|
+
Python reference implementation of the [Universal Personalization Protocol (UPP)](../../spec/01-overview.md) data models, backends, and client.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install upp-python
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Development
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install -e ".[dev]"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from upp import Event, StoredEvent, SourceType, EventStatus
|
|
52
|
+
from upp import LabelDefinition, OntologyUserV1, UPPClient
|
|
53
|
+
|
|
54
|
+
# Create an event (pre-storage)
|
|
55
|
+
event = Event(
|
|
56
|
+
value="I work as a senior software engineer at Anthropic",
|
|
57
|
+
labels=["what_occupation"],
|
|
58
|
+
confidence=0.95,
|
|
59
|
+
source_type=SourceType.USER_STATED,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Use with a client (requires backend implementations)
|
|
63
|
+
import asyncio
|
|
64
|
+
|
|
65
|
+
async def demo():
|
|
66
|
+
client = UPPClient(
|
|
67
|
+
ingest=my_ingest_backend,
|
|
68
|
+
retriever=my_retriever_backend,
|
|
69
|
+
ontology=OntologyUserV1(),
|
|
70
|
+
)
|
|
71
|
+
stored = await client.ingest("user-123", [event])
|
|
72
|
+
print(f"Stored: {stored[0].value} (id={stored[0].id})")
|
|
73
|
+
|
|
74
|
+
# Retrieve events
|
|
75
|
+
events = await client.get_events("user-123")
|
|
76
|
+
print(f"Total events: {len(events)}")
|
|
77
|
+
|
|
78
|
+
asyncio.run(demo())
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Package Structure
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
src/upp/
|
|
85
|
+
├── __init__.py # Top-level exports
|
|
86
|
+
├── client.py # UPPClient — high-level protocol client
|
|
87
|
+
├── models/
|
|
88
|
+
│ ├── __init__.py # Model re-exports
|
|
89
|
+
│ ├── client.py # UPPClientProtocol
|
|
90
|
+
│ ├── enums.py # EventStatus, SourceType, SensitivityTier, Cardinality, Durability
|
|
91
|
+
│ ├── events.py # Event, StoredEvent
|
|
92
|
+
│ └── labels.py # LabelDefinition
|
|
93
|
+
├── backends/
|
|
94
|
+
│ ├── __init__.py # Backend re-exports
|
|
95
|
+
│ ├── ingest.py # IngestBackend protocol
|
|
96
|
+
│ ├── retriever.py # RetrieverBackend protocol
|
|
97
|
+
│ └── ontology.py # OntologyBackend protocol
|
|
98
|
+
├── ontologies/
|
|
99
|
+
│ ├── __init__.py
|
|
100
|
+
│ └── user_v1.py # OntologyUserV1 — loads ontologies/user/v1.json
|
|
101
|
+
└── rpc/
|
|
102
|
+
├── __init__.py # RPC re-exports
|
|
103
|
+
├── methods.py # UPP_INGEST, UPP_RETRIEVE, etc.
|
|
104
|
+
├── errors.py # Error codes and UppError
|
|
105
|
+
├── messages.py # JSON-RPC types + operation request/response models
|
|
106
|
+
└── codec.py # JSON-RPC encode/decode
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Protocol Operations
|
|
110
|
+
|
|
111
|
+
The UPP protocol defines 8 operations:
|
|
112
|
+
|
|
113
|
+
| Operation | Type | Description |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `upp/ingest` | Core (write) | Extract and ingest events from text |
|
|
116
|
+
| `upp/retrieve` | Core (read) | Intelligent retrieval of relevant events |
|
|
117
|
+
| `upp/events` | Core (read) | List all stored events |
|
|
118
|
+
| `upp/delete` | Core (write) | Delete events (GDPR compliance) |
|
|
119
|
+
| `upp/info` | Discovery | Server metadata |
|
|
120
|
+
| `upp/labels` | Discovery | Label definitions from an ontology |
|
|
121
|
+
| `upp/export` | Portability | Export events for migration |
|
|
122
|
+
| `upp/import` | Portability | Import events from another server |
|
|
123
|
+
|
|
124
|
+
## Requirements
|
|
125
|
+
|
|
126
|
+
- Python >= 3.11
|
|
127
|
+
- Pydantic >= 2.0.0
|
|
128
|
+
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pytest tests/ -v
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT — See [LICENSE](../../LICENSE) for details.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
upp/__init__.py,sha256=GH_qofYAA4EcWIuweG_0DEZnOPCmyxktwApMX9gFOtw,3818
|
|
2
|
+
upp/client.py,sha256=NwLzPzcHk2aazyXNCPrToVbssLwfmkB03dyg8MmOZPo,5590
|
|
3
|
+
upp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
upp/backends/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
upp/backends/__init__.py,sha256=Yq-B_MD44wdPKD_zvuqYWsrO01ZYF36rqLGPlz4HxD4,699
|
|
6
|
+
upp/backends/ingest.py,sha256=u7PEtjgB7H1JmukKFFY6SB_GKVej55a-BbR6aOCbZ5k,3472
|
|
7
|
+
upp/backends/ontology.py,sha256=oAqMjFEULLXNXaM1hVz4jlOqvF3crpqmGbUNKIDmoXA,1011
|
|
8
|
+
upp/backends/retriever.py,sha256=oUqT_JxSoD6PYfAMz4yHTAKo8RSvun74szH4B1ABpEU,2011
|
|
9
|
+
upp/models/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
upp/models/__init__.py,sha256=Y9ZKFP7kt1KzLSwH_6yKh8JYYfSvr7Vq0ePv4hCo6y8,831
|
|
11
|
+
upp/models/client.py,sha256=HlPuh1ubc7NR8fZoK86Ufg_Npd81yrMQueeYv5txEkI,3998
|
|
12
|
+
upp/models/enums.py,sha256=XQMoLo58BA0Crm85Tb1lK_66VdzG40Zj9wx5R0MmzHs,3294
|
|
13
|
+
upp/models/events.py,sha256=RiyLh9STmi-tjRYwxYnnihUyJhhBGJbmnojcHUGolmM,4098
|
|
14
|
+
upp/models/labels.py,sha256=4jV6nMyTvINe65XAvFimdiKmaIytN7106kiQw_TY_wI,2592
|
|
15
|
+
upp/ontologies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
upp/ontologies/user_v1.py,sha256=kIrGU8LPmjO6nRAlYvimIOrBezTSD-zzPxBHEMx1x6A,3666
|
|
17
|
+
upp/rpc/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
upp/rpc/__init__.py,sha256=U_k8RmSwXLdfbyx0B0O_6S1Mhv0NE0yON0KHH2y2nUs,3088
|
|
19
|
+
upp/rpc/codec.py,sha256=k22IZphOEOvGCuCvjlpQL_YN3ckdx9GElvEJh9gvpbo,3012
|
|
20
|
+
upp/rpc/errors.py,sha256=Gi3L_mXPyna7AWPtD7yDd7xQCH4UmjU5GXLmazsKxiE,3625
|
|
21
|
+
upp/rpc/messages.py,sha256=Kg6_REn2_S2FjWs94edI_m7sAwpuMBWR9Mby_O5Ak1E,10447
|
|
22
|
+
upp/rpc/methods.py,sha256=50M1arxkqNicqqBUTlHwZPtG3VeEo2A1G9tWLU_VJy4,1643
|
|
23
|
+
upp_python-0.1.0.dist-info/METADATA,sha256=ob27uRTMimS5nB4M8jIXEoReq_8_TXYc9QoBkGyEhrs,4580
|
|
24
|
+
upp_python-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
25
|
+
upp_python-0.1.0.dist-info/RECORD,,
|