system-one-adapter 0.0.1a0__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.
- system_one_adapter-0.0.1a0/LICENSE +21 -0
- system_one_adapter-0.0.1a0/PKG-INFO +103 -0
- system_one_adapter-0.0.1a0/README.md +81 -0
- system_one_adapter-0.0.1a0/pyproject.toml +53 -0
- system_one_adapter-0.0.1a0/pyproject.toml.orig +55 -0
- system_one_adapter-0.0.1a0/src/system_one_adapter/__init__.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TypeSafe AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: system-one-adapter
|
|
3
|
+
Version: 0.0.1a0
|
|
4
|
+
Summary: Drop-in TypeSafeClient replacement backed by LLM APIs
|
|
5
|
+
Author: TypeSafe AI
|
|
6
|
+
Author-email: TypeSafe AI <support@typesafe.ai>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: msgspec>=0.19.0
|
|
10
|
+
Requires-Dist: tenacity>=8.0.0
|
|
11
|
+
Requires-Dist: typesafe-sdk>=0.6.0
|
|
12
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
13
|
+
Requires-Dist: anthropic>=0.121.0 ; extra == 'anthropic'
|
|
14
|
+
Requires-Dist: openai>=2.53.0 ; extra == 'openai'
|
|
15
|
+
Maintainer: Erik Gafni, Daniel Gafni
|
|
16
|
+
Maintainer-email: Erik Gafni <erik@typesafe.ai>, Daniel Gafni <daniel@typesafe.ai>
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Project-URL: Repository, https://github.com/typesafe-ai/system-one-adapter-python
|
|
19
|
+
Provides-Extra: anthropic
|
|
20
|
+
Provides-Extra: openai
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# System One Adapter
|
|
24
|
+
|
|
25
|
+
A drop-in replacement for `typesafe_sdk`'s `system_one` evaluation API, backed by LLM
|
|
26
|
+
APIs instead of TypeSafe.
|
|
27
|
+
|
|
28
|
+
Useful for comparing TypeSafe against an LLM on
|
|
29
|
+
cost/speed/intelligence.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
The provider SDKs are optional extras — install the one(s) you use:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install 'system-one-adapter[openai]' # OpenAI-compatible providers
|
|
37
|
+
pip install 'system-one-adapter[anthropic]' # native Anthropic
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Unlike `TypeSafeClient`, the client is configured with how the LLM should answer, and
|
|
43
|
+
each call names a `provider` alongside the `model`:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from system_one_adapter import SystemOneAdapterClient, Noul, Score, Choice
|
|
47
|
+
|
|
48
|
+
client = SystemOneAdapterClient(
|
|
49
|
+
structured_outputs=True, # use the provider's native structured-output mode
|
|
50
|
+
llm_answer_mode="probabilities", # or "discrete"
|
|
51
|
+
normalize_probabilities=True,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
response = client.system_one(
|
|
55
|
+
state="This book was a delight to read.",
|
|
56
|
+
questions={"positive": Noul(instructions="The book review is positive.")},
|
|
57
|
+
provider="openai", # "openai" or "anthropic"
|
|
58
|
+
model="gpt-4o-mini",
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`provider` and `model` may also be set on the constructor as defaults. `provider`
|
|
63
|
+
is required unless `model` is a `Provider` instance (e.g. a custom OpenAI-compatible
|
|
64
|
+
endpoint):
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from system_one_adapter.providers import OpenAIProvider
|
|
68
|
+
|
|
69
|
+
client.system_one(state, questions, model=OpenAIProvider("grok-4", base_url="https://api.x.ai/v1"))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Response
|
|
73
|
+
|
|
74
|
+
The response is a `typesafe_sdk.SystemOneResponse` subclass — same `answers` and typed
|
|
75
|
+
views — with two additions:
|
|
76
|
+
|
|
77
|
+
- `response.usage` adds `input_tokens_total` / `output_tokens_total` (across retries),
|
|
78
|
+
`n_retries`, `n_retries_malformed_structure`, and `latency`.
|
|
79
|
+
- `response.debug` holds `retry_reasons` and probability-normalization diagnostics.
|
|
80
|
+
|
|
81
|
+
It is a `msgspec.Struct` like every SDK response, so serialize it the same way (there is
|
|
82
|
+
no `model_dump`):
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import msgspec
|
|
86
|
+
|
|
87
|
+
print(msgspec.json.encode(response).decode())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Async
|
|
91
|
+
|
|
92
|
+
`AsyncSystemOneAdapterClient` mirrors the sync client with `await client.system_one(...)`
|
|
93
|
+
and `async with`.
|
|
94
|
+
|
|
95
|
+
## Options
|
|
96
|
+
|
|
97
|
+
| Option | Meaning |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `structured_outputs` | Use the provider's native structured output, else prompt for JSON and validate client-side (works with any chat model). |
|
|
100
|
+
| `llm_answer_mode` | `"probabilities"` (per-label distribution) or `"discrete"` (one value per question). |
|
|
101
|
+
| `normalize_probabilities` | Rescale invalid LLM probability distributions to sum to 1. |
|
|
102
|
+
| `n_retry_malformed_structure` | Corrective retries when the model's output fails schema validation. |
|
|
103
|
+
| `retry` | `typesafe_sdk.RetryPolicy` for transient provider failures. |
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# System One Adapter
|
|
2
|
+
|
|
3
|
+
A drop-in replacement for `typesafe_sdk`'s `system_one` evaluation API, backed by LLM
|
|
4
|
+
APIs instead of TypeSafe.
|
|
5
|
+
|
|
6
|
+
Useful for comparing TypeSafe against an LLM on
|
|
7
|
+
cost/speed/intelligence.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
The provider SDKs are optional extras — install the one(s) you use:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install 'system-one-adapter[openai]' # OpenAI-compatible providers
|
|
15
|
+
pip install 'system-one-adapter[anthropic]' # native Anthropic
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Unlike `TypeSafeClient`, the client is configured with how the LLM should answer, and
|
|
21
|
+
each call names a `provider` alongside the `model`:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from system_one_adapter import SystemOneAdapterClient, Noul, Score, Choice
|
|
25
|
+
|
|
26
|
+
client = SystemOneAdapterClient(
|
|
27
|
+
structured_outputs=True, # use the provider's native structured-output mode
|
|
28
|
+
llm_answer_mode="probabilities", # or "discrete"
|
|
29
|
+
normalize_probabilities=True,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
response = client.system_one(
|
|
33
|
+
state="This book was a delight to read.",
|
|
34
|
+
questions={"positive": Noul(instructions="The book review is positive.")},
|
|
35
|
+
provider="openai", # "openai" or "anthropic"
|
|
36
|
+
model="gpt-4o-mini",
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`provider` and `model` may also be set on the constructor as defaults. `provider`
|
|
41
|
+
is required unless `model` is a `Provider` instance (e.g. a custom OpenAI-compatible
|
|
42
|
+
endpoint):
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from system_one_adapter.providers import OpenAIProvider
|
|
46
|
+
|
|
47
|
+
client.system_one(state, questions, model=OpenAIProvider("grok-4", base_url="https://api.x.ai/v1"))
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Response
|
|
51
|
+
|
|
52
|
+
The response is a `typesafe_sdk.SystemOneResponse` subclass — same `answers` and typed
|
|
53
|
+
views — with two additions:
|
|
54
|
+
|
|
55
|
+
- `response.usage` adds `input_tokens_total` / `output_tokens_total` (across retries),
|
|
56
|
+
`n_retries`, `n_retries_malformed_structure`, and `latency`.
|
|
57
|
+
- `response.debug` holds `retry_reasons` and probability-normalization diagnostics.
|
|
58
|
+
|
|
59
|
+
It is a `msgspec.Struct` like every SDK response, so serialize it the same way (there is
|
|
60
|
+
no `model_dump`):
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import msgspec
|
|
64
|
+
|
|
65
|
+
print(msgspec.json.encode(response).decode())
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Async
|
|
69
|
+
|
|
70
|
+
`AsyncSystemOneAdapterClient` mirrors the sync client with `await client.system_one(...)`
|
|
71
|
+
and `async with`.
|
|
72
|
+
|
|
73
|
+
## Options
|
|
74
|
+
|
|
75
|
+
| Option | Meaning |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `structured_outputs` | Use the provider's native structured output, else prompt for JSON and validate client-side (works with any chat model). |
|
|
78
|
+
| `llm_answer_mode` | `"probabilities"` (per-label distribution) or `"discrete"` (one value per question). |
|
|
79
|
+
| `normalize_probabilities` | Rescale invalid LLM probability distributions to sum to 1. |
|
|
80
|
+
| `n_retry_malformed_structure` | Corrective retries when the model's output fails schema validation. |
|
|
81
|
+
| `retry` | `typesafe_sdk.RetryPolicy` for transient provider failures. |
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "system-one-adapter"
|
|
3
|
+
version = "0.0.1a0"
|
|
4
|
+
description = "Drop-in TypeSafeClient replacement backed by LLM APIs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"msgspec>=0.19.0",
|
|
11
|
+
"tenacity>=8.0.0",
|
|
12
|
+
"typesafe-sdk>=0.6.0",
|
|
13
|
+
"typing-extensions>=4.0.0",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[[project.authors]]
|
|
17
|
+
name = "TypeSafe AI"
|
|
18
|
+
email = "support@typesafe.ai"
|
|
19
|
+
|
|
20
|
+
[[project.maintainers]]
|
|
21
|
+
name = "Erik Gafni"
|
|
22
|
+
email = "erik@typesafe.ai"
|
|
23
|
+
|
|
24
|
+
[[project.maintainers]]
|
|
25
|
+
name = "Daniel Gafni"
|
|
26
|
+
email = "daniel@typesafe.ai"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Repository = "https://github.com/typesafe-ai/system-one-adapter-python"
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
openai = ["openai>=2.53.0"]
|
|
33
|
+
anthropic = ["anthropic>=0.121.0"]
|
|
34
|
+
|
|
35
|
+
[dependency-groups]
|
|
36
|
+
dev = [
|
|
37
|
+
"pyrefly>=1.2.0",
|
|
38
|
+
"pytest>=9.0.2",
|
|
39
|
+
"pytest-recording>=0.13.4",
|
|
40
|
+
"ruff>=0.16.6",
|
|
41
|
+
"tach>=0.35.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[tool.uv.build-backend]
|
|
45
|
+
module-name = "system_one_adapter"
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|
|
49
|
+
addopts = "--block-network -p no:tach"
|
|
50
|
+
|
|
51
|
+
[build-system]
|
|
52
|
+
requires = ["uv_build>=0.11.7,<0.12.0"]
|
|
53
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "system-one-adapter"
|
|
3
|
+
version = "0.0.1a0"
|
|
4
|
+
description = "Drop-in TypeSafeClient replacement backed by LLM APIs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "TypeSafe AI", email = "support@typesafe.ai" }
|
|
10
|
+
]
|
|
11
|
+
maintainers = [
|
|
12
|
+
{ name = "Erik Gafni", email = "erik@typesafe.ai" },
|
|
13
|
+
{ name = "Daniel Gafni", email = "daniel@typesafe.ai" }
|
|
14
|
+
]
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"msgspec>=0.19.0",
|
|
18
|
+
"tenacity>=8.0.0",
|
|
19
|
+
"typesafe-sdk>=0.6.0",
|
|
20
|
+
"typing-extensions>=4.0.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Repository = "https://github.com/typesafe-ai/system-one-adapter-python"
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
openai = [
|
|
28
|
+
"openai>=2.53.0",
|
|
29
|
+
]
|
|
30
|
+
anthropic = [
|
|
31
|
+
"anthropic>=0.121.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"pyrefly>=1.2.0",
|
|
37
|
+
"pytest>=9.0.2",
|
|
38
|
+
"pytest-recording>=0.13.4",
|
|
39
|
+
"ruff>=0.16.6",
|
|
40
|
+
"tach>=0.35.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.uv.build-backend]
|
|
44
|
+
module-name = "system_one_adapter"
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|
|
48
|
+
# Fail rather than silently making a live call when a cassette is missing. Passing
|
|
49
|
+
# --record-mode (anything but "none") lifts this for cassette-backed tests. The tach
|
|
50
|
+
# pytest plugin is disabled; boundaries are checked by `tach check`, not at test time.
|
|
51
|
+
addopts = "--block-network -p no:tach"
|
|
52
|
+
|
|
53
|
+
[build-system]
|
|
54
|
+
requires = ["uv_build>=0.11.7,<0.12.0"]
|
|
55
|
+
build-backend = "uv_build"
|
|
File without changes
|