tokid 0.1.0a3__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.
- tokid-0.1.0a3/PKG-INFO +175 -0
- tokid-0.1.0a3/README.md +154 -0
- tokid-0.1.0a3/pyproject.toml +40 -0
- tokid-0.1.0a3/setup.cfg +4 -0
- tokid-0.1.0a3/src/tokid/__init__.py +483 -0
- tokid-0.1.0a3/src/tokid/generated/profiles/openai-cross-underscore-v1.json +1855 -0
- tokid-0.1.0a3/src/tokid/generated/profiles/openai-cross-v1.json +1532 -0
- tokid-0.1.0a3/src/tokid/generated/registry.json +20 -0
- tokid-0.1.0a3/src/tokid.egg-info/PKG-INFO +175 -0
- tokid-0.1.0a3/src/tokid.egg-info/SOURCES.txt +10 -0
- tokid-0.1.0a3/src/tokid.egg-info/dependency_links.txt +1 -0
- tokid-0.1.0a3/src/tokid.egg-info/top_level.txt +1 -0
tokid-0.1.0a3/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokid
|
|
3
|
+
Version: 0.1.0a3
|
|
4
|
+
Summary: Token-native IDs for LLM-facing systems
|
|
5
|
+
Author: Tyler O'Briant
|
|
6
|
+
License-Expression: ISC
|
|
7
|
+
Project-URL: Homepage, https://github.com/Tetra-Research/tokid/tree/main/packages/python#readme
|
|
8
|
+
Project-URL: Repository, https://github.com/Tetra-Research/tokid
|
|
9
|
+
Project-URL: Issues, https://github.com/Tetra-Research/tokid/issues
|
|
10
|
+
Keywords: tokenizer,identifiers,llm,tokid
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# tokid Python SDK
|
|
23
|
+
|
|
24
|
+
Python SDK for the `tokid` portable profile format.
|
|
25
|
+
|
|
26
|
+
`tokid` is for the narrow case where identifiers regularly pass through prompts, tool calls, JSON payloads, logs, or URLs and token cost matters.
|
|
27
|
+
|
|
28
|
+
It is not a shorter UUID.
|
|
29
|
+
It is not a universal replacement for `uuid`, `ulid`, `nanoid`, or `sqids`.
|
|
30
|
+
|
|
31
|
+
Status: early alpha.
|
|
32
|
+
Capability tier: `core`.
|
|
33
|
+
Runtime target: Python `3.11+`.
|
|
34
|
+
Registry readiness: `publish-now`.
|
|
35
|
+
Registry status: Wave 2 target, not yet published.
|
|
36
|
+
Package name: `tokid` on PyPI.
|
|
37
|
+
|
|
38
|
+
## What You Get
|
|
39
|
+
|
|
40
|
+
This SDK supports the stable day-to-day surface:
|
|
41
|
+
|
|
42
|
+
- generate tokids in prompt, transport, or envelope format
|
|
43
|
+
- parse and validate existing tokids
|
|
44
|
+
- convert between prompt, transport, and envelope renderings
|
|
45
|
+
- pin a profile once with a factory
|
|
46
|
+
|
|
47
|
+
The current alpha ships two built-in profiles:
|
|
48
|
+
|
|
49
|
+
- `openai-cross-v1`
|
|
50
|
+
- `openai-cross-underscore-v1`
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
Until the first PyPI release is published, install from a local checkout:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install ./packages/python
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
After publish, the install command will be:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install tokid
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from tokid import generate, is_tokid, to_prompt, to_transport
|
|
70
|
+
|
|
71
|
+
tokid = generate()
|
|
72
|
+
|
|
73
|
+
if not is_tokid(tokid):
|
|
74
|
+
raise ValueError("invalid tokid")
|
|
75
|
+
|
|
76
|
+
prompt = to_prompt(tokid)
|
|
77
|
+
transport = to_transport(tokid)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`generate()` returns the durable envelope form by default. That is the form you should store, exchange, and pass across boundaries unless you have a strong reason not to.
|
|
81
|
+
|
|
82
|
+
## Factory API
|
|
83
|
+
|
|
84
|
+
Bind profile choice and default length once:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from tokid import create_tokid_factory
|
|
88
|
+
|
|
89
|
+
tokid = create_tokid_factory(
|
|
90
|
+
profile="openai-cross-v1",
|
|
91
|
+
length=8,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
identifier = tokid.generate()
|
|
95
|
+
logical = tokid.parse(identifier)
|
|
96
|
+
prompt = tokid.prompt(identifier)
|
|
97
|
+
transport = tokid.transport(identifier)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You can also inspect the active profile:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
profile = tokid.profile()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Prompt, Transport, Envelope
|
|
107
|
+
|
|
108
|
+
Every tokid has one logical identity and three useful renderings:
|
|
109
|
+
|
|
110
|
+
- `prompt`: best when a human or LLM reads the ID in natural text
|
|
111
|
+
- `transport`: best when the ID must survive URLs, JSON, logs, or APIs
|
|
112
|
+
- `envelope`: best when the ID must be stored, exchanged, validated, and parsed later
|
|
113
|
+
|
|
114
|
+
If you only remember one rule, use this one:
|
|
115
|
+
|
|
116
|
+
- use `envelope` at persistence and network boundaries
|
|
117
|
+
|
|
118
|
+
## Profile Choice
|
|
119
|
+
|
|
120
|
+
### `openai-cross-v1`
|
|
121
|
+
|
|
122
|
+
Default profile.
|
|
123
|
+
|
|
124
|
+
- prompt uses spaces
|
|
125
|
+
- transport uses raw concatenation
|
|
126
|
+
- best when token cost is the main concern
|
|
127
|
+
|
|
128
|
+
### `openai-cross-underscore-v1`
|
|
129
|
+
|
|
130
|
+
Opt-in profile.
|
|
131
|
+
|
|
132
|
+
- prompt still uses spaces
|
|
133
|
+
- transport uses `_`
|
|
134
|
+
- best when visual segmentation matters more than the last bit of transport efficiency
|
|
135
|
+
|
|
136
|
+
Example:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from tokid import create_tokid_factory
|
|
140
|
+
|
|
141
|
+
tokid = create_tokid_factory(profile="openai-cross-underscore-v1")
|
|
142
|
+
identifier = tokid.generate()
|
|
143
|
+
transport = tokid.transport(identifier)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## When To Use It
|
|
147
|
+
|
|
148
|
+
Use `tokid` when most of these are true:
|
|
149
|
+
|
|
150
|
+
- your application regularly sends IDs through prompts or tool calls
|
|
151
|
+
- you care about token cost inside JSON, logs, URLs, or text-heavy transports
|
|
152
|
+
- you want a stable external envelope plus alternate prompt and transport renderings
|
|
153
|
+
- you are comfortable pinning an explicit profile in your application
|
|
154
|
+
|
|
155
|
+
Choose something else when minimal byte length, ecosystem standardization, sortable IDs, or authentication-grade secrets matter more than token behavior.
|
|
156
|
+
|
|
157
|
+
## Runtime Notes
|
|
158
|
+
|
|
159
|
+
- Python `3.11+`
|
|
160
|
+
- the current built-in profiles are OpenAI-derived
|
|
161
|
+
- this SDK intentionally documents the `core` surface first even though lower-level runtime types exist
|
|
162
|
+
|
|
163
|
+
## Maintainer Release
|
|
164
|
+
|
|
165
|
+
Dry-run:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm run release:pypi:dry-run
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Official upload:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm run release:pypi
|
|
175
|
+
```
|
tokid-0.1.0a3/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# tokid Python SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for the `tokid` portable profile format.
|
|
4
|
+
|
|
5
|
+
`tokid` is for the narrow case where identifiers regularly pass through prompts, tool calls, JSON payloads, logs, or URLs and token cost matters.
|
|
6
|
+
|
|
7
|
+
It is not a shorter UUID.
|
|
8
|
+
It is not a universal replacement for `uuid`, `ulid`, `nanoid`, or `sqids`.
|
|
9
|
+
|
|
10
|
+
Status: early alpha.
|
|
11
|
+
Capability tier: `core`.
|
|
12
|
+
Runtime target: Python `3.11+`.
|
|
13
|
+
Registry readiness: `publish-now`.
|
|
14
|
+
Registry status: Wave 2 target, not yet published.
|
|
15
|
+
Package name: `tokid` on PyPI.
|
|
16
|
+
|
|
17
|
+
## What You Get
|
|
18
|
+
|
|
19
|
+
This SDK supports the stable day-to-day surface:
|
|
20
|
+
|
|
21
|
+
- generate tokids in prompt, transport, or envelope format
|
|
22
|
+
- parse and validate existing tokids
|
|
23
|
+
- convert between prompt, transport, and envelope renderings
|
|
24
|
+
- pin a profile once with a factory
|
|
25
|
+
|
|
26
|
+
The current alpha ships two built-in profiles:
|
|
27
|
+
|
|
28
|
+
- `openai-cross-v1`
|
|
29
|
+
- `openai-cross-underscore-v1`
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Until the first PyPI release is published, install from a local checkout:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install ./packages/python
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
After publish, the install command will be:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install tokid
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from tokid import generate, is_tokid, to_prompt, to_transport
|
|
49
|
+
|
|
50
|
+
tokid = generate()
|
|
51
|
+
|
|
52
|
+
if not is_tokid(tokid):
|
|
53
|
+
raise ValueError("invalid tokid")
|
|
54
|
+
|
|
55
|
+
prompt = to_prompt(tokid)
|
|
56
|
+
transport = to_transport(tokid)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`generate()` returns the durable envelope form by default. That is the form you should store, exchange, and pass across boundaries unless you have a strong reason not to.
|
|
60
|
+
|
|
61
|
+
## Factory API
|
|
62
|
+
|
|
63
|
+
Bind profile choice and default length once:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from tokid import create_tokid_factory
|
|
67
|
+
|
|
68
|
+
tokid = create_tokid_factory(
|
|
69
|
+
profile="openai-cross-v1",
|
|
70
|
+
length=8,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
identifier = tokid.generate()
|
|
74
|
+
logical = tokid.parse(identifier)
|
|
75
|
+
prompt = tokid.prompt(identifier)
|
|
76
|
+
transport = tokid.transport(identifier)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can also inspect the active profile:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
profile = tokid.profile()
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Prompt, Transport, Envelope
|
|
86
|
+
|
|
87
|
+
Every tokid has one logical identity and three useful renderings:
|
|
88
|
+
|
|
89
|
+
- `prompt`: best when a human or LLM reads the ID in natural text
|
|
90
|
+
- `transport`: best when the ID must survive URLs, JSON, logs, or APIs
|
|
91
|
+
- `envelope`: best when the ID must be stored, exchanged, validated, and parsed later
|
|
92
|
+
|
|
93
|
+
If you only remember one rule, use this one:
|
|
94
|
+
|
|
95
|
+
- use `envelope` at persistence and network boundaries
|
|
96
|
+
|
|
97
|
+
## Profile Choice
|
|
98
|
+
|
|
99
|
+
### `openai-cross-v1`
|
|
100
|
+
|
|
101
|
+
Default profile.
|
|
102
|
+
|
|
103
|
+
- prompt uses spaces
|
|
104
|
+
- transport uses raw concatenation
|
|
105
|
+
- best when token cost is the main concern
|
|
106
|
+
|
|
107
|
+
### `openai-cross-underscore-v1`
|
|
108
|
+
|
|
109
|
+
Opt-in profile.
|
|
110
|
+
|
|
111
|
+
- prompt still uses spaces
|
|
112
|
+
- transport uses `_`
|
|
113
|
+
- best when visual segmentation matters more than the last bit of transport efficiency
|
|
114
|
+
|
|
115
|
+
Example:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from tokid import create_tokid_factory
|
|
119
|
+
|
|
120
|
+
tokid = create_tokid_factory(profile="openai-cross-underscore-v1")
|
|
121
|
+
identifier = tokid.generate()
|
|
122
|
+
transport = tokid.transport(identifier)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## When To Use It
|
|
126
|
+
|
|
127
|
+
Use `tokid` when most of these are true:
|
|
128
|
+
|
|
129
|
+
- your application regularly sends IDs through prompts or tool calls
|
|
130
|
+
- you care about token cost inside JSON, logs, URLs, or text-heavy transports
|
|
131
|
+
- you want a stable external envelope plus alternate prompt and transport renderings
|
|
132
|
+
- you are comfortable pinning an explicit profile in your application
|
|
133
|
+
|
|
134
|
+
Choose something else when minimal byte length, ecosystem standardization, sortable IDs, or authentication-grade secrets matter more than token behavior.
|
|
135
|
+
|
|
136
|
+
## Runtime Notes
|
|
137
|
+
|
|
138
|
+
- Python `3.11+`
|
|
139
|
+
- the current built-in profiles are OpenAI-derived
|
|
140
|
+
- this SDK intentionally documents the `core` surface first even though lower-level runtime types exist
|
|
141
|
+
|
|
142
|
+
## Maintainer Release
|
|
143
|
+
|
|
144
|
+
Dry-run:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm run release:pypi:dry-run
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Official upload:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm run release:pypi
|
|
154
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tokid"
|
|
7
|
+
version = "0.1.0a3"
|
|
8
|
+
description = "Token-native IDs for LLM-facing systems"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "ISC"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Tyler O'Briant" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["tokenizer", "identifiers", "llm", "tokid"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/Tetra-Research/tokid/tree/main/packages/python#readme"
|
|
29
|
+
Repository = "https://github.com/Tetra-Research/tokid"
|
|
30
|
+
Issues = "https://github.com/Tetra-Research/tokid/issues"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools]
|
|
33
|
+
package-dir = {"" = "src"}
|
|
34
|
+
include-package-data = true
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["src"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
tokid = ["generated/*.json", "generated/profiles/*.json"]
|
tokid-0.1.0a3/setup.cfg
ADDED