spawnllm 0.17.6__tar.gz → 0.17.7__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.
- {spawnllm-0.17.6 → spawnllm-0.17.7}/PKG-INFO +2 -2
- {spawnllm-0.17.6 → spawnllm-0.17.7}/README.md +1 -1
- {spawnllm-0.17.6 → spawnllm-0.17.7}/pyproject.toml +1 -1
- {spawnllm-0.17.6 → spawnllm-0.17.7}/pyproject.toml.orig +1 -1
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/cli.py +74 -1
- {spawnllm-0.17.6 → spawnllm-0.17.7}/LICENSE +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/__init__.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/__main__.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/_core/__init__.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/_core/spawnllm_core.wasm +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/__init__.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/apple.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/base.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/claude.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/claude_sdk.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/codex.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/gemini.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/mlx.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/openai_endpoint.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/backends/registry.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/call.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/decide.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/extract.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/mlx/__init__.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/mlx/codec.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/mlx/engine.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/mlx/fuse.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/mlx/patches.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/proc.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/py.typed +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/response.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/run.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/spec.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/structured.py +0 -0
- {spawnllm-0.17.6 → spawnllm-0.17.7}/spawnllm/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spawnllm
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.7
|
|
4
4
|
Summary: Delete your subprocess wrappers around claude, codex, and gemini.
|
|
5
5
|
Keywords:
|
|
6
6
|
Author: Yasyf Mohamedali
|
|
@@ -194,7 +194,7 @@ Both expose `Call`/`call` and typed `Extract`/`extract` against your existing CL
|
|
|
194
194
|
- **Decisions** — every question and answer type, the provider pins, and the retry and key-lookup rules — [Deciding reference](https://yasyf.github.io/spawnllm/reference/#deciding)
|
|
195
195
|
- **Backend selection** — the priority chain, plus `specialty=` routing (`debugging` and `review` go to Codex, `general` to the Claude Agent SDK backend) — [Backends reference](https://yasyf.github.io/spawnllm/reference/#backends)
|
|
196
196
|
- **Transport helpers** — `run_cli`, `collect_process`, and `map_concurrent`, the subprocess plumbing shared by every CLI backend — [Transport reference](https://yasyf.github.io/spawnllm/reference/#transport)
|
|
197
|
-
- **The CLI** — `spawnllm call`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
|
|
197
|
+
- **The CLI** — `spawnllm call`, `decide`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
|
|
198
198
|
- **MLX internals** — the adapter codec, fuser, and runtime patches behind the local engine — [MLX reference](https://yasyf.github.io/spawnllm/reference/#mlx)
|
|
199
199
|
|
|
200
200
|
Read the [docs](https://yasyf.github.io/spawnllm/) for the full guide and API reference. Licensed under [MIT](https://github.com/yasyf/spawnllm/blob/main/LICENSE).
|
|
@@ -142,7 +142,7 @@ Both expose `Call`/`call` and typed `Extract`/`extract` against your existing CL
|
|
|
142
142
|
- **Decisions** — every question and answer type, the provider pins, and the retry and key-lookup rules — [Deciding reference](https://yasyf.github.io/spawnllm/reference/#deciding)
|
|
143
143
|
- **Backend selection** — the priority chain, plus `specialty=` routing (`debugging` and `review` go to Codex, `general` to the Claude Agent SDK backend) — [Backends reference](https://yasyf.github.io/spawnllm/reference/#backends)
|
|
144
144
|
- **Transport helpers** — `run_cli`, `collect_process`, and `map_concurrent`, the subprocess plumbing shared by every CLI backend — [Transport reference](https://yasyf.github.io/spawnllm/reference/#transport)
|
|
145
|
-
- **The CLI** — `spawnllm call`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
|
|
145
|
+
- **The CLI** — `spawnllm call`, `decide`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
|
|
146
146
|
- **MLX internals** — the adapter codec, fuser, and runtime patches behind the local engine — [MLX reference](https://yasyf.github.io/spawnllm/reference/#mlx)
|
|
147
147
|
|
|
148
148
|
Read the [docs](https://yasyf.github.io/spawnllm/) for the full guide and API reference. Licensed under [MIT](https://github.com/yasyf/spawnllm/blob/main/LICENSE).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "spawnllm"
|
|
3
3
|
# Inert sentinel: the real version is set from the release tag (uv version --frozen).
|
|
4
|
-
version = "0.17.
|
|
4
|
+
version = "0.17.7"
|
|
5
5
|
description = "Delete your subprocess wrappers around claude, codex, and gemini."
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = "MIT"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import dataclasses
|
|
4
|
+
import json
|
|
3
5
|
import subprocess
|
|
4
6
|
import sys
|
|
7
|
+
from typing import Any
|
|
5
8
|
|
|
6
9
|
import click
|
|
7
10
|
from loguru import logger
|
|
@@ -15,10 +18,35 @@ from spawnllm.backends import (
|
|
|
15
18
|
)
|
|
16
19
|
from spawnllm.backends.registry import BACKENDS_BY_NAME, PRIORITY, select_backend
|
|
17
20
|
from spawnllm.call import DEFAULT_MODEL, call_sync
|
|
18
|
-
from spawnllm.decide import
|
|
21
|
+
from spawnllm.decide import (
|
|
22
|
+
DEFAULT_TIMEOUT,
|
|
23
|
+
JEV,
|
|
24
|
+
OPENAI,
|
|
25
|
+
Answer,
|
|
26
|
+
Binary,
|
|
27
|
+
BinaryAnswer,
|
|
28
|
+
DecideError,
|
|
29
|
+
DecideKeyMissing,
|
|
30
|
+
Label,
|
|
31
|
+
LabelAnswer,
|
|
32
|
+
Provider,
|
|
33
|
+
Question,
|
|
34
|
+
Refused,
|
|
35
|
+
Score,
|
|
36
|
+
ScoreAnswer,
|
|
37
|
+
decide_sync,
|
|
38
|
+
store_key,
|
|
39
|
+
)
|
|
19
40
|
|
|
20
41
|
BACKEND_NAMES = tuple(BACKENDS_BY_NAME)
|
|
21
42
|
DECIDE_PROVIDERS: dict[str, Provider] = {provider.name: provider for provider in (JEV, OPENAI)}
|
|
43
|
+
QUESTION_TYPES: dict[str, type[Binary | Label | Score]] = {"binary": Binary, "label": Label, "score": Score}
|
|
44
|
+
ANSWER_TYPES: dict[type[Answer], str] = {
|
|
45
|
+
BinaryAnswer: "binary",
|
|
46
|
+
LabelAnswer: "label",
|
|
47
|
+
ScoreAnswer: "score",
|
|
48
|
+
Refused: "refused",
|
|
49
|
+
}
|
|
22
50
|
|
|
23
51
|
|
|
24
52
|
@click.group()
|
|
@@ -73,6 +101,51 @@ def status() -> None:
|
|
|
73
101
|
click.echo(f"core: {(v := _core.version())['core_version']}@{v['source_hash'][:12]}")
|
|
74
102
|
|
|
75
103
|
|
|
104
|
+
@main.command("decide")
|
|
105
|
+
@click.option("--provider", type=click.Choice(list(DECIDE_PROVIDERS)), default=JEV.name, show_default=True)
|
|
106
|
+
@click.option(
|
|
107
|
+
"--timeout",
|
|
108
|
+
type=float,
|
|
109
|
+
default=DEFAULT_TIMEOUT,
|
|
110
|
+
show_default=True,
|
|
111
|
+
help="Seconds for the whole call, retries included.",
|
|
112
|
+
)
|
|
113
|
+
def decide_questions(provider: str, timeout: float) -> None:
|
|
114
|
+
"""Ask the questions a JSON object on stdin holds about its state, and print the answers as JSON.
|
|
115
|
+
|
|
116
|
+
The object holds `state`, the text or JSON to judge, and `questions`, each id mapped to
|
|
117
|
+
`{"binary": {...}}`, `{"label": {...}}` or `{"score": {...}}` holding that question's fields,
|
|
118
|
+
such as `{"label": {"instructions": "...", "options": {"none": "...", "a1": null}}}`. It prints
|
|
119
|
+
`{"model": ..., "answers": {<id>: {"type": "label", "choice": ..., "probabilities": {...}, "confidence": ...}}}`.
|
|
120
|
+
"""
|
|
121
|
+
try:
|
|
122
|
+
request = json.loads(sys.stdin.read())
|
|
123
|
+
questions = {id: question(spec) for id, spec in request["questions"].items()}
|
|
124
|
+
decision = decide_sync(request["state"], questions, provider=DECIDE_PROVIDERS[provider], timeout=timeout)
|
|
125
|
+
except (
|
|
126
|
+
json.JSONDecodeError,
|
|
127
|
+
KeyError,
|
|
128
|
+
TypeError,
|
|
129
|
+
ValueError,
|
|
130
|
+
TimeoutError,
|
|
131
|
+
DecideError,
|
|
132
|
+
DecideKeyMissing,
|
|
133
|
+
) as error:
|
|
134
|
+
raise click.ClickException(str(error)) from error
|
|
135
|
+
answers = {
|
|
136
|
+
id: {"type": ANSWER_TYPES[type(answer)], **dataclasses.asdict(answer)}
|
|
137
|
+
for id, answer in decision.answers.items()
|
|
138
|
+
}
|
|
139
|
+
click.echo(json.dumps({"model": decision.model, "answers": answers}))
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def question(spec: dict[str, Any]) -> Question:
|
|
143
|
+
[(kind, fields)] = spec.items()
|
|
144
|
+
if kind not in QUESTION_TYPES:
|
|
145
|
+
raise ValueError(f"unknown question type {kind!r}: use {', '.join(QUESTION_TYPES)}")
|
|
146
|
+
return QUESTION_TYPES[kind](**fields)
|
|
147
|
+
|
|
148
|
+
|
|
76
149
|
@main.group()
|
|
77
150
|
def key() -> None:
|
|
78
151
|
"""Manage the decision providers' API keys in the macOS Keychain."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|