valueproof 0.4.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.
- mixed_model_cost/__init__.py +22 -0
- valueproof/__init__.py +22 -0
- valueproof/claude.py +81 -0
- valueproof/cli.py +95 -0
- valueproof/gemini.py +60 -0
- valueproof/lever_runner.py +161 -0
- valueproof/openai.py +57 -0
- valueproof/pipeline.py +70 -0
- valueproof/scout_rescue.py +69 -0
- valueproof/starter.py +82 -0
- valueproof-0.4.0.dist-info/METADATA +275 -0
- valueproof-0.4.0.dist-info/RECORD +16 -0
- valueproof-0.4.0.dist-info/WHEEL +5 -0
- valueproof-0.4.0.dist-info/entry_points.txt +3 -0
- valueproof-0.4.0.dist-info/licenses/LICENSE-CODE +21 -0
- valueproof-0.4.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Old name of `valueproof`. Kept so existing code keeps working; removed in version 1.0.
|
|
2
|
+
|
|
3
|
+
import mixed_model_cost -> import valueproof
|
|
4
|
+
from mixed_model_cost.claude import -> from valueproof.claude import
|
|
5
|
+
"""
|
|
6
|
+
import importlib
|
|
7
|
+
import sys
|
|
8
|
+
import warnings
|
|
9
|
+
|
|
10
|
+
warnings.warn(
|
|
11
|
+
"`mixed_model_cost` is now `valueproof` - use `import valueproof`. The old name will be removed in version 1.0.",
|
|
12
|
+
DeprecationWarning,
|
|
13
|
+
stacklevel=2,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from valueproof import * # noqa: E402,F401,F403
|
|
17
|
+
from valueproof import __all__, __version__ # noqa: E402,F401
|
|
18
|
+
|
|
19
|
+
# Old submodule paths: mixed_model_cost.claude, .openai, .gemini, ... point to valueproof's.
|
|
20
|
+
# Adapters import their provider SDK only when called, so this needs no extra packages.
|
|
21
|
+
for _name in ("scout_rescue", "pipeline", "lever_runner", "cli", "starter", "claude", "openai", "gemini"):
|
|
22
|
+
sys.modules[f"{__name__}.{_name}"] = importlib.import_module(f"valueproof.{_name}")
|
valueproof/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Valueproof: let cheap and strong models work together,
|
|
2
|
+
and measure what each change does to cost and quality before it ships.
|
|
3
|
+
|
|
4
|
+
from valueproof import scout_and_rescue, ModelResult
|
|
5
|
+
from valueproof.claude import claude # [claude] extra
|
|
6
|
+
from valueproof.openai import openai_model # [openai] extra
|
|
7
|
+
from valueproof.gemini import gemini_model # [gemini] extra
|
|
8
|
+
|
|
9
|
+
Any provider works: a model is just a function `prompt -> ModelResult`.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .lever_runner import Report, Run, Score, is_outcome, print_table, run_levers, save, summarize
|
|
13
|
+
from .pipeline import RunResult, Step, StepLog, run_pipeline
|
|
14
|
+
from .scout_rescue import Check, Model, ModelResult, Outcome, handoff_prompt, scout_and_rescue
|
|
15
|
+
|
|
16
|
+
__version__ = "0.4.0"
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Check", "Model", "ModelResult", "Outcome", "handoff_prompt", "scout_and_rescue",
|
|
20
|
+
"RunResult", "Step", "StepLog", "run_pipeline",
|
|
21
|
+
"Report", "Run", "Score", "is_outcome", "print_table", "run_levers", "save", "summarize",
|
|
22
|
+
]
|
valueproof/claude.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Claude adapter: turns a Claude model into a `Model` function for
|
|
2
|
+
scout_rescue and pipeline. Other providers need only a function with the
|
|
3
|
+
same shape (prompt in, ModelResult out).
|
|
4
|
+
|
|
5
|
+
Requires: pip install "valueproof[claude]" (or anthropic), and credentials (ANTHROPIC_API_KEY or `ant auth login`).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .scout_rescue import Model, ModelResult
|
|
11
|
+
|
|
12
|
+
# USD per million tokens: (input, output). Prices change - check the current
|
|
13
|
+
# price list before you trust any cost number. Haiku 5.5 price is for prompts
|
|
14
|
+
# up to 100K tokens. Cache discounts are ignored here for simplicity.
|
|
15
|
+
PRICES = {
|
|
16
|
+
"claude-haiku-5-5": (0.10, 0.50),
|
|
17
|
+
"claude-sonnet-5-5": (2.00, 10.00),
|
|
18
|
+
"claude-opus-5-5": (4.00, 20.00),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# These models support server-side refusal fallbacks; we turn them on so a
|
|
22
|
+
# rare policy decline is retried on a suitable model instead of returning nothing.
|
|
23
|
+
_FALLBACK_MODELS = {"claude-opus-5-5", "claude-sonnet-5-5"}
|
|
24
|
+
|
|
25
|
+
_client = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _get_client():
|
|
29
|
+
global _client
|
|
30
|
+
if _client is None:
|
|
31
|
+
import anthropic
|
|
32
|
+
|
|
33
|
+
_client = anthropic.Anthropic()
|
|
34
|
+
return _client
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def claude(
|
|
38
|
+
model: str,
|
|
39
|
+
effort: str = "low",
|
|
40
|
+
system: str | None = None,
|
|
41
|
+
max_tokens: int = 16000,
|
|
42
|
+
prices: tuple[float, float] | None = None,
|
|
43
|
+
client=None,
|
|
44
|
+
) -> Model:
|
|
45
|
+
"""Return a Model function for one Claude model at one effort level.
|
|
46
|
+
|
|
47
|
+
`prices` = (input, output) in USD per million tokens; needed for models not in PRICES.
|
|
48
|
+
"""
|
|
49
|
+
if prices is None and model not in PRICES:
|
|
50
|
+
raise ValueError(f"No price for {model!r}: pass prices=(input, output) in USD per million tokens.")
|
|
51
|
+
price_in, price_out = prices or PRICES[model]
|
|
52
|
+
|
|
53
|
+
def call(prompt: str) -> ModelResult:
|
|
54
|
+
kwargs = dict(
|
|
55
|
+
model=model,
|
|
56
|
+
max_tokens=max_tokens,
|
|
57
|
+
output_config={"effort": effort},
|
|
58
|
+
messages=[{"role": "user", "content": prompt}],
|
|
59
|
+
)
|
|
60
|
+
if system:
|
|
61
|
+
kwargs["system"] = system
|
|
62
|
+
|
|
63
|
+
api = client or _get_client()
|
|
64
|
+
if model in _FALLBACK_MODELS:
|
|
65
|
+
response = api.beta.messages.create(
|
|
66
|
+
betas=["server-side-fallback-2026-07-01"], fallbacks="default", **kwargs
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
response = api.messages.create(**kwargs)
|
|
70
|
+
|
|
71
|
+
# A refusal returns no usable text; the check will treat "" as a failure.
|
|
72
|
+
if response.stop_reason == "refusal":
|
|
73
|
+
text = ""
|
|
74
|
+
else:
|
|
75
|
+
text = "".join(block.text for block in response.content if block.type == "text")
|
|
76
|
+
|
|
77
|
+
usage = response.usage
|
|
78
|
+
cost = (usage.input_tokens * price_in + usage.output_tokens * price_out) / 1_000_000
|
|
79
|
+
return ModelResult(text=text, cost_usd=cost, model=model)
|
|
80
|
+
|
|
81
|
+
return call
|
valueproof/cli.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""The `valueproof` command.
|
|
2
|
+
|
|
3
|
+
valueproof init my_test.py # write a starter test that runs offline straight away
|
|
4
|
+
valueproof compare my_test.py # run every setup on every case, print the table
|
|
5
|
+
valueproof compare my_test.py --live # your file decides what "live" means (real API calls)
|
|
6
|
+
valueproof compare my_test.py --out dir # where results and the blind review sheet go
|
|
7
|
+
|
|
8
|
+
Your test file is plain Python and defines one function:
|
|
9
|
+
|
|
10
|
+
def build(live: bool, args: list[str]) -> dict:
|
|
11
|
+
return {
|
|
12
|
+
"cases": [...], # your test requests
|
|
13
|
+
"setups": {"baseline": run, ...}, # name -> run(case) -> Run; first is the baseline
|
|
14
|
+
"judge": judge, # optional: judge(case, text) -> Score
|
|
15
|
+
"describe": lambda case: str(case), # optional: how a case shows on the review sheet
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Checks stay in code, inside your setups - that is what makes them reliable.
|
|
19
|
+
Any extra arguments after the file are passed to build() as `args`.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import importlib.util
|
|
26
|
+
import sys
|
|
27
|
+
from datetime import datetime
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from . import __version__
|
|
31
|
+
from .lever_runner import print_table, run_levers, save
|
|
32
|
+
from .starter import STARTER
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _load(path: Path):
|
|
36
|
+
sys.path.insert(0, str(path.parent)) # let the test file import its neighbours
|
|
37
|
+
spec = importlib.util.spec_from_file_location(path.stem, path)
|
|
38
|
+
if spec is None or spec.loader is None:
|
|
39
|
+
raise SystemExit(f"Cannot load {path}")
|
|
40
|
+
module = importlib.util.module_from_spec(spec)
|
|
41
|
+
sys.modules[spec.name] = module # dataclasses in the test file need this
|
|
42
|
+
spec.loader.exec_module(module)
|
|
43
|
+
if not hasattr(module, "build"):
|
|
44
|
+
raise SystemExit(f"{path} must define build(live, args) -> dict. See: valueproof compare --help")
|
|
45
|
+
return module
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def compare(file: str, live: bool = False, out: str | None = None, extra: list[str] | None = None) -> None:
|
|
49
|
+
path = Path(file).resolve()
|
|
50
|
+
spec = _load(path).build(live, extra or [])
|
|
51
|
+
cases, setups = spec["cases"], spec["setups"]
|
|
52
|
+
print(f"{'LIVE' if live else 'OFFLINE'}: {len(cases)} cases x {len(setups)} setups")
|
|
53
|
+
report = run_levers(cases, setups, judge=spec.get("judge"))
|
|
54
|
+
print()
|
|
55
|
+
print_table(report, list(setups))
|
|
56
|
+
out_dir = Path(out) if out else path.parent / "results" / datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
57
|
+
save(report, cases, out_dir, describe=spec.get("describe", str))
|
|
58
|
+
print(f"\nSaved to {out_dir}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def init(file: str) -> None:
|
|
62
|
+
path = Path(file)
|
|
63
|
+
if path.exists():
|
|
64
|
+
raise SystemExit(f"{path} already exists - pick another name: valueproof init my_test.py")
|
|
65
|
+
path.write_text(STARTER.format(name=path.name))
|
|
66
|
+
print(f"Wrote {path}. Try it: valueproof compare {path}\nThen edit the four parts marked EDIT.")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main(argv: list[str] | None = None) -> None:
|
|
70
|
+
parser = argparse.ArgumentParser(prog="valueproof", description="Test cheaper AI setups against your current one.")
|
|
71
|
+
parser.add_argument("--version", action="version", version=f"valueproof {__version__}")
|
|
72
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
73
|
+
cmp_ = sub.add_parser("compare", help="run setups side by side and print a keep-or-drop table",
|
|
74
|
+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
75
|
+
cmp_.add_argument("file", help="your test file, defining build(live, args)")
|
|
76
|
+
cmp_.add_argument("--live", action="store_true", help="tell build() to use real models")
|
|
77
|
+
cmp_.add_argument("--out", help="folder for results (default: results/<time> next to the file)")
|
|
78
|
+
ini = sub.add_parser("init", help="write a starter test file that runs offline straight away")
|
|
79
|
+
ini.add_argument("file", nargs="?", default="valueproof_test.py", help="file to create (default: valueproof_test.py)")
|
|
80
|
+
args, extra = parser.parse_known_args(argv)
|
|
81
|
+
if args.command == "compare":
|
|
82
|
+
compare(args.file, args.live, args.out, extra)
|
|
83
|
+
elif args.command == "init":
|
|
84
|
+
init(args.file)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def main_mmco(argv: list[str] | None = None) -> None:
|
|
89
|
+
"""The old command name. Kept so existing scripts keep working; removed in version 1.0."""
|
|
90
|
+
print("Note: the `mmco` command is now `valueproof`. `mmco` will be removed in version 1.0.", file=sys.stderr)
|
|
91
|
+
main(argv)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
main()
|
valueproof/gemini.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Gemini adapter: turns a Google Gemini model into a `Model` function.
|
|
2
|
+
|
|
3
|
+
Requires: pip install "valueproof[gemini]", and GEMINI_API_KEY.
|
|
4
|
+
|
|
5
|
+
from valueproof.gemini import gemini_model
|
|
6
|
+
cheap = gemini_model("<model id>", price_in=..., price_out=..., thinking_level="low")
|
|
7
|
+
|
|
8
|
+
Prices are USD per million tokens and must be passed in: they change often, so
|
|
9
|
+
copy them from the provider's current price list. Thinking tokens are billed as
|
|
10
|
+
output and counted here. Cache discounts are ignored for simplicity.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
from .scout_rescue import Model, ModelResult
|
|
18
|
+
|
|
19
|
+
_client = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _get_client():
|
|
23
|
+
global _client
|
|
24
|
+
if _client is None:
|
|
25
|
+
from google import genai
|
|
26
|
+
|
|
27
|
+
_client = genai.Client()
|
|
28
|
+
return _client
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def gemini_model(
|
|
32
|
+
model: str,
|
|
33
|
+
price_in: float,
|
|
34
|
+
price_out: float,
|
|
35
|
+
thinking_level: Optional[str] = None,
|
|
36
|
+
system: Optional[str] = None,
|
|
37
|
+
max_output_tokens: int = 16000,
|
|
38
|
+
client=None,
|
|
39
|
+
) -> Model:
|
|
40
|
+
"""Return a Model function for one Gemini model. `thinking_level`: "minimal", "low", "medium" or "high"."""
|
|
41
|
+
|
|
42
|
+
def call(prompt: str) -> ModelResult:
|
|
43
|
+
from google.genai import types
|
|
44
|
+
|
|
45
|
+
config = types.GenerateContentConfig(
|
|
46
|
+
max_output_tokens=max_output_tokens,
|
|
47
|
+
system_instruction=system,
|
|
48
|
+
thinking_config=types.ThinkingConfig(thinking_level=thinking_level.upper()) if thinking_level else None,
|
|
49
|
+
)
|
|
50
|
+
response = (client or _get_client()).models.generate_content(model=model, contents=prompt, config=config)
|
|
51
|
+
|
|
52
|
+
# A blocked answer has no text; the check will treat "" as a failure.
|
|
53
|
+
text = response.text or ""
|
|
54
|
+
u = response.usage_metadata
|
|
55
|
+
tokens_in = (u.prompt_token_count or 0) if u else 0
|
|
56
|
+
tokens_out = ((u.candidates_token_count or 0) + (u.thoughts_token_count or 0)) if u else 0
|
|
57
|
+
cost = (tokens_in * price_in + tokens_out * price_out) / 1_000_000
|
|
58
|
+
return ModelResult(text=text, cost_usd=cost, model=model)
|
|
59
|
+
|
|
60
|
+
return call
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Lever runner: test one change (a "lever") against your current setup on the
|
|
2
|
+
same requests, at the same time, and print a keep-or-drop table.
|
|
3
|
+
|
|
4
|
+
You give it:
|
|
5
|
+
cases - a list of test requests (any objects)
|
|
6
|
+
setups - {name: run(case) -> Run}; the first one is the baseline
|
|
7
|
+
judge - optional: judge(case, text) -> Score, for a blind quality review
|
|
8
|
+
|
|
9
|
+
Every case runs through every setup before the next case starts (in a shuffled
|
|
10
|
+
order), so all setups see the same moment - same web, same API load.
|
|
11
|
+
The judge sees one reply at a time and never the setup's name.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import csv
|
|
17
|
+
import json
|
|
18
|
+
import random
|
|
19
|
+
import statistics
|
|
20
|
+
from dataclasses import asdict, dataclass, field
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any, Callable, Optional
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Run:
|
|
27
|
+
text: str
|
|
28
|
+
cost_usd: float
|
|
29
|
+
seconds: float
|
|
30
|
+
path: str = "single" # "scout", "rescue" or "single"
|
|
31
|
+
final_check: Optional[str] = None # None if the final text passes your check
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class Score:
|
|
36
|
+
points: int # on your fixed rubric
|
|
37
|
+
max_points: int
|
|
38
|
+
hard_failure: bool = False # wrong policy, invented promise, no answer ...
|
|
39
|
+
note: str = ""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class Row:
|
|
44
|
+
case: int
|
|
45
|
+
setup: str
|
|
46
|
+
run: Run
|
|
47
|
+
score: Optional[Score] = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class Report:
|
|
52
|
+
rows: list[Row] = field(default_factory=list)
|
|
53
|
+
|
|
54
|
+
def for_setup(self, name: str) -> list[Row]:
|
|
55
|
+
return [r for r in self.rows if r.setup == name]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def run_levers(
|
|
59
|
+
cases: list[Any],
|
|
60
|
+
setups: dict[str, Callable[[Any], Run]],
|
|
61
|
+
judge: Optional[Callable[[Any, str], Score]] = None,
|
|
62
|
+
seed: int = 1,
|
|
63
|
+
) -> Report:
|
|
64
|
+
rng = random.Random(seed)
|
|
65
|
+
report = Report()
|
|
66
|
+
for i, case in enumerate(cases):
|
|
67
|
+
names = list(setups)
|
|
68
|
+
rng.shuffle(names) # no setup always goes first
|
|
69
|
+
for name in names:
|
|
70
|
+
report.rows.append(Row(i, name, setups[name](case)))
|
|
71
|
+
print(f" case {i + 1}/{len(cases)} done", flush=True)
|
|
72
|
+
|
|
73
|
+
if judge:
|
|
74
|
+
# Score each distinct reply once, in random order, without the setup name.
|
|
75
|
+
unique = {(r.case, r.run.text) for r in report.rows}
|
|
76
|
+
order = sorted(unique)
|
|
77
|
+
rng.shuffle(order)
|
|
78
|
+
scores = {}
|
|
79
|
+
for n, (i, text) in enumerate(order, 1):
|
|
80
|
+
scores[(i, text)] = judge(cases[i], text)
|
|
81
|
+
print(f" reviewed {n}/{len(order)}", flush=True)
|
|
82
|
+
for r in report.rows:
|
|
83
|
+
r.score = scores[(r.case, r.run.text)]
|
|
84
|
+
return report
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def is_outcome(row: Row) -> bool:
|
|
88
|
+
"""A request counts as an outcome when the final result passes your check and,
|
|
89
|
+
if a judge ran, has no hard failure - the result a user could actually rely on."""
|
|
90
|
+
return row.run.final_check is None and not (row.score and row.score.hard_failure)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def summarize(report: Report, setups: list[str]) -> list[dict]:
|
|
94
|
+
"""The numbers behind the table, one dict per setup.
|
|
95
|
+
|
|
96
|
+
cost_per_outcome = everything the setup spent / requests that ended in an outcome.
|
|
97
|
+
Failed attempts and bad results still cost money, so they raise it.
|
|
98
|
+
"""
|
|
99
|
+
out = []
|
|
100
|
+
for name in setups:
|
|
101
|
+
rows = report.for_setup(name)
|
|
102
|
+
costs = [r.run.cost_usd for r in rows]
|
|
103
|
+
outcomes = sum(is_outcome(r) for r in rows)
|
|
104
|
+
scored = [r.score for r in rows if r.score]
|
|
105
|
+
out.append({
|
|
106
|
+
"setup": name,
|
|
107
|
+
"requests": len(rows),
|
|
108
|
+
"avg_cost": statistics.mean(costs),
|
|
109
|
+
"median_cost": statistics.median(costs),
|
|
110
|
+
"outcomes": outcomes,
|
|
111
|
+
"cost_per_outcome": sum(costs) / outcomes if outcomes else float("inf"),
|
|
112
|
+
"rescued": sum(r.run.path == "rescue" for r in rows),
|
|
113
|
+
"avg_seconds": statistics.mean(r.run.seconds for r in rows),
|
|
114
|
+
"check_fail": sum(r.run.final_check is not None for r in rows),
|
|
115
|
+
"quality": sum(s.points for s in scored) if scored else None,
|
|
116
|
+
"quality_max": sum(s.max_points for s in scored) if scored else None,
|
|
117
|
+
"hard_fail": sum(s.hard_failure for s in scored) if scored else None,
|
|
118
|
+
})
|
|
119
|
+
return out
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def print_table(report: Report, setups: list[str]) -> None:
|
|
123
|
+
rows = summarize(report, setups)
|
|
124
|
+
base = rows[0]["cost_per_outcome"]
|
|
125
|
+
has_scores = rows[0]["quality"] is not None
|
|
126
|
+
head = (f"{'setup':<26}{'cost/outcome':>13}{'vs base':>9}{'outcomes':>10}{'avg cost':>10}{'median':>9}"
|
|
127
|
+
f"{'rescued':>9}{'avg s':>7}{'check fail':>11}")
|
|
128
|
+
if has_scores:
|
|
129
|
+
head += f"{'quality':>12}{'hard fail':>10}"
|
|
130
|
+
print(head)
|
|
131
|
+
for s in rows:
|
|
132
|
+
cpo = s["cost_per_outcome"]
|
|
133
|
+
vs = f"{(cpo / base - 1) * 100:>+8.0f}%" if cpo != float("inf") and base not in (0, float("inf")) else f"{'-':>9}"
|
|
134
|
+
line = (
|
|
135
|
+
f"{s['setup']:<26}{(f'{cpo * 100:.3f}c' if cpo != float('inf') else 'none'):>13}{vs}"
|
|
136
|
+
f"{s['outcomes']:>6}/{s['requests']:<3}{s['avg_cost'] * 100:>9.3f}c{s['median_cost'] * 100:>8.3f}c"
|
|
137
|
+
f"{s['rescued']:>5}/{s['requests']:<3}{s['avg_seconds']:>7.1f}{s['check_fail']:>11}"
|
|
138
|
+
)
|
|
139
|
+
if has_scores:
|
|
140
|
+
line += f"{s['quality']:>7}/{s['quality_max']:<4}{s['hard_fail']:>10}"
|
|
141
|
+
print(line)
|
|
142
|
+
print("\ncost/outcome = everything spent / requests whose final result passed the check"
|
|
143
|
+
+ (" and had no hard failure" if has_scores else "") + ". It is the number to compare.")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def save(report: Report, cases: list[Any], out_dir: Path, describe: Callable[[Any], str]) -> None:
|
|
147
|
+
"""Write all results, plus a blind review sheet a person can score by hand."""
|
|
148
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
149
|
+
(out_dir / "results.json").write_text(
|
|
150
|
+
json.dumps([asdict(r) for r in report.rows], indent=2, ensure_ascii=False)
|
|
151
|
+
)
|
|
152
|
+
rng = random.Random(7)
|
|
153
|
+
rows = report.rows[:]
|
|
154
|
+
rng.shuffle(rows)
|
|
155
|
+
with open(out_dir / "blind_review.csv", "w", newline="") as f, open(out_dir / "blind_key.csv", "w", newline="") as k:
|
|
156
|
+
sheet, key = csv.writer(f), csv.writer(k)
|
|
157
|
+
sheet.writerow(["id", "request", "reply", "your score", "hard failure?"])
|
|
158
|
+
key.writerow(["id", "case", "setup"])
|
|
159
|
+
for n, r in enumerate(rows, 1):
|
|
160
|
+
sheet.writerow([n, describe(cases[r.case]), r.run.text, "", ""])
|
|
161
|
+
key.writerow([n, r.case, r.setup])
|
valueproof/openai.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""OpenAI adapter: turns an OpenAI model into a `Model` function (Responses API).
|
|
2
|
+
|
|
3
|
+
Requires: pip install "valueproof[openai]", and OPENAI_API_KEY.
|
|
4
|
+
|
|
5
|
+
from valueproof.openai import openai_model
|
|
6
|
+
cheap = openai_model("<model id>", price_in=..., price_out=..., effort="low")
|
|
7
|
+
|
|
8
|
+
Prices are USD per million tokens and must be passed in: they change often, so
|
|
9
|
+
copy them from the provider's current price list. Reasoning tokens are part of
|
|
10
|
+
`output_tokens` and billed as output. Cache discounts are ignored for simplicity.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
from .scout_rescue import Model, ModelResult
|
|
18
|
+
|
|
19
|
+
_client = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _get_client():
|
|
23
|
+
global _client
|
|
24
|
+
if _client is None:
|
|
25
|
+
import openai
|
|
26
|
+
|
|
27
|
+
_client = openai.OpenAI()
|
|
28
|
+
return _client
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def openai_model(
|
|
32
|
+
model: str,
|
|
33
|
+
price_in: float,
|
|
34
|
+
price_out: float,
|
|
35
|
+
effort: Optional[str] = None,
|
|
36
|
+
instructions: Optional[str] = None,
|
|
37
|
+
max_output_tokens: int = 16000,
|
|
38
|
+
client=None,
|
|
39
|
+
) -> Model:
|
|
40
|
+
"""Return a Model function for one OpenAI model. `effort` sets reasoning effort, if the model supports it."""
|
|
41
|
+
|
|
42
|
+
def call(prompt: str) -> ModelResult:
|
|
43
|
+
kwargs = dict(model=model, input=prompt, max_output_tokens=max_output_tokens)
|
|
44
|
+
if effort:
|
|
45
|
+
kwargs["reasoning"] = {"effort": effort}
|
|
46
|
+
if instructions:
|
|
47
|
+
kwargs["instructions"] = instructions
|
|
48
|
+
response = (client or _get_client()).responses.create(**kwargs)
|
|
49
|
+
|
|
50
|
+
# An incomplete or refused answer still returns whatever text there is;
|
|
51
|
+
# your check decides whether it is usable.
|
|
52
|
+
text = response.output_text or ""
|
|
53
|
+
usage = response.usage
|
|
54
|
+
cost = (usage.input_tokens * price_in + usage.output_tokens * price_out) / 1_000_000 if usage else 0.0
|
|
55
|
+
return ModelResult(text=text, cost_usd=cost, model=model)
|
|
56
|
+
|
|
57
|
+
return call
|
valueproof/pipeline.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Split one AI job into steps and give each step the cheapest model that
|
|
2
|
+
does it well. A step either uses one model, or Scout & Rescue.
|
|
3
|
+
|
|
4
|
+
Typical split:
|
|
5
|
+
read / extract -> small, cheap model
|
|
6
|
+
analyze / draft -> Scout & Rescue (cheap first, strong only when needed)
|
|
7
|
+
review -> code checks where possible, a model only where needed
|
|
8
|
+
aggregate -> mid-size model, once per batch instead of once per item
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from typing import Callable, Optional
|
|
15
|
+
|
|
16
|
+
from .scout_rescue import Model, Outcome, scout_and_rescue
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Step:
|
|
21
|
+
name: str
|
|
22
|
+
build_prompt: Callable[[dict], str] # turns the data so far into a prompt
|
|
23
|
+
model: Optional[Model] = None # single model, or ...
|
|
24
|
+
scout: Optional[Model] = None # ... Scout & Rescue
|
|
25
|
+
rescue: Optional[Model] = None
|
|
26
|
+
# check(text, data) -> None if usable, else a reason. Gets the data so far,
|
|
27
|
+
# so it can compare against earlier steps (e.g. "mentions the order id?").
|
|
28
|
+
check: Optional[Callable[[str, dict], Optional[str]]] = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class StepLog:
|
|
33
|
+
step: str
|
|
34
|
+
path: str
|
|
35
|
+
model: str
|
|
36
|
+
cost_usd: float
|
|
37
|
+
note: str = ""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class RunResult:
|
|
42
|
+
data: dict
|
|
43
|
+
log: list[StepLog] = field(default_factory=list)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def cost_usd(self) -> float:
|
|
47
|
+
return sum(entry.cost_usd for entry in self.log)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def run_step(step: Step, data: dict) -> Outcome:
|
|
51
|
+
prompt = step.build_prompt(data)
|
|
52
|
+
if step.model is not None:
|
|
53
|
+
result = step.model(prompt)
|
|
54
|
+
return Outcome(result.text, "single", result.cost_usd, result.model)
|
|
55
|
+
if step.scout and step.rescue and step.check:
|
|
56
|
+
return scout_and_rescue(prompt, step.scout, step.rescue, lambda text: step.check(text, data))
|
|
57
|
+
raise ValueError(f"Step {step.name!r} needs either `model` or `scout` + `rescue` + `check`.")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def run_pipeline(steps: list[Step], data: dict) -> RunResult:
|
|
61
|
+
"""Run the steps in order. Each step's output is stored under its name."""
|
|
62
|
+
run = RunResult(data=dict(data))
|
|
63
|
+
for step in steps:
|
|
64
|
+
outcome = run_step(step, run.data)
|
|
65
|
+
run.data[step.name] = outcome.text
|
|
66
|
+
run.log.append(
|
|
67
|
+
StepLog(step.name, outcome.path, outcome.model, outcome.cost_usd,
|
|
68
|
+
f"scout rejected: {outcome.rejected_because}" if outcome.rejected_because else "")
|
|
69
|
+
)
|
|
70
|
+
return run
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Scout & Rescue: a cheap model tries first; a strong model runs only when
|
|
2
|
+
a check in code says the cheap result is not usable.
|
|
3
|
+
|
|
4
|
+
This file has no provider code. A "model" is any function that takes a prompt
|
|
5
|
+
and returns a ModelResult, so you can plug in Claude, OpenAI, Gemini, a local
|
|
6
|
+
model, or a stub for tests.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from typing import Callable, Optional
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class ModelResult:
|
|
17
|
+
text: str
|
|
18
|
+
cost_usd: float
|
|
19
|
+
model: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# A model: prompt in, result out.
|
|
23
|
+
Model = Callable[[str], ModelResult]
|
|
24
|
+
|
|
25
|
+
# A check: returns None if the text is usable, or a short reason why it is not.
|
|
26
|
+
# Keep checks in plain code - free, instant, and predictable.
|
|
27
|
+
Check = Callable[[str], Optional[str]]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class Outcome:
|
|
32
|
+
text: str
|
|
33
|
+
path: str # "scout" or "rescue"
|
|
34
|
+
cost_usd: float
|
|
35
|
+
model: str
|
|
36
|
+
rejected_because: Optional[str] = None # why the scout's result failed the check
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def handoff_prompt(prompt: str, draft: str, problem: str) -> str:
|
|
40
|
+
"""The rescuer's prompt when it is told what the scout tried and why it failed."""
|
|
41
|
+
return (
|
|
42
|
+
f"{prompt}\n\n---\nA first draft of this answer was rejected by an automatic check.\n"
|
|
43
|
+
f"Reason: {problem}\nRejected draft:\n{draft}\n---\n"
|
|
44
|
+
"Write the answer again, fixing that problem. Do not copy mistakes from the draft."
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def scout_and_rescue(
|
|
49
|
+
prompt: str, scout: Model, rescue: Model, check: Check, handoff: bool = False
|
|
50
|
+
) -> Outcome:
|
|
51
|
+
"""Run the cheap scout first; call the strong rescuer only if the check fails.
|
|
52
|
+
|
|
53
|
+
handoff=True also gives the rescuer the scout's draft and the reason it was
|
|
54
|
+
rejected. It may help the rescuer, or make it copy the scout's mistakes and
|
|
55
|
+
read more tokens - treat it as a lever and test it before you turn it on.
|
|
56
|
+
"""
|
|
57
|
+
first = scout(prompt)
|
|
58
|
+
problem = check(first.text)
|
|
59
|
+
if problem is None:
|
|
60
|
+
return Outcome(first.text, "scout", first.cost_usd, first.model)
|
|
61
|
+
|
|
62
|
+
second = rescue(handoff_prompt(prompt, first.text, problem) if handoff else prompt)
|
|
63
|
+
return Outcome(
|
|
64
|
+
text=second.text,
|
|
65
|
+
path="rescue",
|
|
66
|
+
cost_usd=first.cost_usd + second.cost_usd, # you pay for both attempts
|
|
67
|
+
model=second.model,
|
|
68
|
+
rejected_because=problem,
|
|
69
|
+
)
|
valueproof/starter.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""The file `valueproof init` writes: a test that runs offline straight away, ready to edit."""
|
|
2
|
+
|
|
3
|
+
STARTER = '''"""My cost test: compare today's setup with a cheaper one on the same requests.
|
|
4
|
+
|
|
5
|
+
valueproof compare {name} # fake models: checks the wiring, no cost
|
|
6
|
+
valueproof compare {name} --live # real models: costs money
|
|
7
|
+
|
|
8
|
+
Edit the four parts marked EDIT, from top to bottom.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
from valueproof import ModelResult, Run, Score, scout_and_rescue
|
|
14
|
+
|
|
15
|
+
# EDIT 1 - your test requests: 20-100 real ones from your logs, including the hard ones.
|
|
16
|
+
CASES = [
|
|
17
|
+
{{"request": "Where is my order 48213?", "must_mention": "48213"}},
|
|
18
|
+
{{"request": "My order 77120 arrived broken. I want a refund.", "must_mention": "77120"}},
|
|
19
|
+
{{"request": "Charged twice for order 50911, and the invoice name is wrong.", "must_mention": "50911"}},
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def prompt_for(case: dict) -> str:
|
|
24
|
+
return "Answer this customer briefly and helpfully:\\n\\n" + case["request"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# EDIT 2 - your checks: plain code that says why a result is unusable (None = usable).
|
|
28
|
+
def check(text: str, case: dict):
|
|
29
|
+
if len(text.strip()) < 40:
|
|
30
|
+
return "too short"
|
|
31
|
+
if case["must_mention"] not in text:
|
|
32
|
+
return "does not mention the order number"
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# EDIT 3 - your models. Fake ones first, so the file runs without a key.
|
|
37
|
+
def fake(name, cost, good=True):
|
|
38
|
+
def call(prompt):
|
|
39
|
+
order = next((w for w in prompt.split() if w.strip(".,?").isdigit()), "")
|
|
40
|
+
hard = "invoice" in prompt # the fake cheap model fails the hard request, so you see a rescue
|
|
41
|
+
text = "Sorry!" if (hard and not good) else f"Thanks for your message about order {{order}}. We are on it and will email you today."
|
|
42
|
+
return ModelResult(text, cost, name)
|
|
43
|
+
return call
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def models(live: bool):
|
|
47
|
+
if not live:
|
|
48
|
+
return {{"cheap": fake("fake-cheap", 0.0004, good=False), "strong": fake("fake-strong", 0.0100)}}
|
|
49
|
+
# Pick one provider; pip install "valueproof[claude]" (or [openai], [gemini]).
|
|
50
|
+
from valueproof.claude import claude
|
|
51
|
+
return {{"cheap": claude("claude-haiku-5-5"), "strong": claude("claude-opus-5-5", effort="medium")}}
|
|
52
|
+
# from valueproof.openai import openai_model
|
|
53
|
+
# return {{"cheap": openai_model("<cheap model>", price_in=..., price_out=...),
|
|
54
|
+
# "strong": openai_model("<strong model>", price_in=..., price_out=...)}}
|
|
55
|
+
# from valueproof.gemini import gemini_model
|
|
56
|
+
# return {{"cheap": gemini_model("<cheap model>", price_in=..., price_out=...),
|
|
57
|
+
# "strong": gemini_model("<strong model>", price_in=..., price_out=...)}}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# EDIT 4 - the setups to compare. The first one is the baseline (what you run today).
|
|
61
|
+
def build(live: bool, args: list) -> dict:
|
|
62
|
+
m = models(live)
|
|
63
|
+
|
|
64
|
+
def today(case) -> Run:
|
|
65
|
+
t0 = time.time()
|
|
66
|
+
r = m["strong"](prompt_for(case))
|
|
67
|
+
return Run(r.text, r.cost_usd, time.time() - t0, "single", check(r.text, case))
|
|
68
|
+
|
|
69
|
+
def scout_rescue(case) -> Run:
|
|
70
|
+
t0 = time.time()
|
|
71
|
+
out = scout_and_rescue(prompt_for(case), m["cheap"], m["strong"], lambda t: check(t, case))
|
|
72
|
+
return Run(out.text, out.cost_usd, time.time() - t0, out.path, check(out.text, case))
|
|
73
|
+
|
|
74
|
+
return {{
|
|
75
|
+
"cases": CASES,
|
|
76
|
+
"setups": {{"today (strong model)": today, "Scout & Rescue": scout_rescue}},
|
|
77
|
+
# Optional blind review: judge(case, text) -> Score. Use a person, or a strong model
|
|
78
|
+
# with a fixed rubric. Leave it out and the table shows cost, speed and checks only.
|
|
79
|
+
"judge": None,
|
|
80
|
+
"describe": lambda case: case["request"],
|
|
81
|
+
}}
|
|
82
|
+
'''
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: valueproof
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Prove an AI cost cut on your own traffic before you ship it: cheap and strong models working together (Scout & Rescue), measured by cost per outcome with a blind quality review.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/AndyJakob78/valueproof
|
|
7
|
+
Project-URL: Old package name, https://pypi.org/project/ai-mixed-model-cost-optimization/
|
|
8
|
+
Keywords: llm,llm cost,cost per outcome,model cascade,evaluation,finops,llmops
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE-CODE
|
|
15
|
+
Provides-Extra: claude
|
|
16
|
+
Requires-Dist: anthropic>=2.14; extra == "claude"
|
|
17
|
+
Provides-Extra: openai
|
|
18
|
+
Requires-Dist: openai>=3.60; extra == "openai"
|
|
19
|
+
Provides-Extra: gemini
|
|
20
|
+
Requires-Dist: google-genai>=3.6; python_version >= "3.11" and extra == "gemini"
|
|
21
|
+
Provides-Extra: all
|
|
22
|
+
Requires-Dist: anthropic>=2.14; extra == "all"
|
|
23
|
+
Requires-Dist: openai>=3.60; extra == "all"
|
|
24
|
+
Requires-Dist: google-genai>=3.6; python_version >= "3.11" and extra == "all"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Valueproof
|
|
30
|
+
|
|
31
|
+
*AI mixed-model cost optimization, proven per outcome.*
|
|
32
|
+
|
|
33
|
+
**Prove an AI cost cut on your own traffic before you ship it. Let cheap and strong models work together, and measure cost per outcome — not cost per token.**
|
|
34
|
+
|
|
35
|
+
**In 30 seconds:**
|
|
36
|
+
- **What it is:** a method and a small Python tool. A cheap model does the work first; a strong model steps in only when a check in code rejects the result (*Scout & Rescue*). Every change is tested side by side against your current setup on your own requests, with a blind quality review.
|
|
37
|
+
- **What we measured:** on a live app's web-search step, cost per article fell from 9.7 ¢ to 4.6–7.7 ¢, and quality held in a blind review. On 40 support tickets, a usable, correct reply cost 0.12 ¢ instead of 1.05 ¢ with Claude Opus 5.5 alone — 89% less per outcome.
|
|
38
|
+
- **The trade-off:** on the support tickets, quality was 2–6% lower, and one wrong refund rule slipped past the checks. Your checks decide how much quality you keep.
|
|
39
|
+
|
|
40
|
+
## When it fits
|
|
41
|
+
|
|
42
|
+
It fits when your product sends a lot of requests to a frontier model — such as Claude Opus 5.5 or Fable 5.2, GPT-6.2 Astra, or Gemini 4 Carbon — to read, analyze, review or summarize data. For example:
|
|
43
|
+
- support chatbots
|
|
44
|
+
- code-review bots
|
|
45
|
+
- data extraction
|
|
46
|
+
- search and research assistants
|
|
47
|
+
- document summarizers
|
|
48
|
+
|
|
49
|
+
And most of those requests are routine, and a bad result can be detected in code: an empty result, a missing field, an outdated date, or an invalid format.
|
|
50
|
+
|
|
51
|
+
## What this measures
|
|
52
|
+
|
|
53
|
+
Most cost tools stop at the first row. This method measures the second before you ship, and tells you how to track the third after.
|
|
54
|
+
|
|
55
|
+
| Layer | The question | Who asks it | Where it is measured |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| Model output | What does a token cost? How fast is the model? | Engineers | Price lists, benchmarks |
|
|
58
|
+
| **Outcome** (before shipping) | Did the user get a usable, correct result — and what did that result cost, including failed attempts? | Product, engineering | **The eval: `valueproof compare` on your own requests** |
|
|
59
|
+
| **Value shipped** (after shipping) | How much margin did we bank per user, without more complaints, escalations or refunds? | CFO, VP Product | Ship behind a switch, keep measuring — [method, step 9](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md#step-9--ship-behind-a-switch-keep-measuring) |
|
|
60
|
+
|
|
61
|
+
**The eval proves you won't break the product. The switch and the ledger prove the margin you banked.**
|
|
62
|
+
|
|
63
|
+
## Target audience
|
|
64
|
+
|
|
65
|
+
| Role | What you get |
|
|
66
|
+
|---|---|
|
|
67
|
+
| **Product Manager** | A way to cut AI cost per user with evidence, and to defend every keep-or-drop decision |
|
|
68
|
+
| **System Designer** | A pattern for splitting one AI job into steps, each with the right model |
|
|
69
|
+
| **AI Engineer** | A small Python package: Scout & Rescue, multi-model pipelines, and a test runner (`valueproof compare`) |
|
|
70
|
+
| **Prompt & Context Engineer** | A test routine that shows whether a prompt change really saves tokens — or quietly costs more |
|
|
71
|
+
| **AI Builder** | A way to test cheaper setups for an AI app on a small budget, and keep only those that hold quality |
|
|
72
|
+
| **AI Evaluation** | A blind A/B review setup and a fixed scoring sheet |
|
|
73
|
+
| **LLMOps** | Code checks and logging that track how often the expensive model runs |
|
|
74
|
+
| **FinOps** | A clear before-and-after cost per request, and the yearly saving at your scale |
|
|
75
|
+
|
|
76
|
+
## The problem
|
|
77
|
+
|
|
78
|
+
Some AI features cannot afford a weak answer. **Compliance, regulation or safety** may demand it — a wrong fact in a financial, medical or legal answer is a real risk. Or the **user experience** depends on it — one confidently wrong answer and users stop trusting the product.
|
|
79
|
+
|
|
80
|
+
So teams do the safe thing: **one strong model does the whole job, end to end, for every request.** Quality is high. But:
|
|
81
|
+
- **You pay top price for easy work.** Most requests are routine and don't need the strongest model. They are still billed at its rate.
|
|
82
|
+
- **The cost grows with every user.** At scale, a request can cost more than it earns.
|
|
83
|
+
- **The usual fixes put quality at risk.** "Switch to a smaller model" or "shorten the prompt" may save money, or may quietly lower quality, or may even raise cost. Without a test, you can't tell.
|
|
84
|
+
|
|
85
|
+
**What this method can and cannot do:** it saves money on the requests where a cheap model's mistakes can be caught by a check in code — an empty result, a missing field, an old date, an invalid format. It does **not** catch an answer that looks right but is wrong, such as a plausible but false refund rule. Where such errors carry legal or safety risk, either build a check that really catches them, or keep that step on the strong model.
|
|
86
|
+
|
|
87
|
+
### Real-world signals (2026)
|
|
88
|
+
|
|
89
|
+
**AI cost is squeezing companies:**
|
|
90
|
+
- **Harvey** (legal AI): in March it updated its AI agents, and customers began using them far more — token use grew about 20× during the year. Harvey mostly charges customers a fixed price per seat but pays the model providers per token, so its gross margin reportedly fell from about **+50% to −50%** by June: serving customers cost about $1.50 for every $1 of revenue. In August it moved its flagship to its own model built on an open-weight model, and margins reportedly turned positive again. [Bloomberg](https://www.bloomberg.com/news/articles/2026-09-21/startups-like-harvey-embrace-open-models-to-cut-reliance-on-anthropic-openai) · [Artificial Lawyer](https://artificiallawyer.com/2026/07/08/harvey-increases-token-use-14x-in-just-6-months)
|
|
91
|
+
- **Industry survey** (Mavvrik, a cost-management vendor, with Benchmarkit; 396 companies, April–May 2026):
|
|
92
|
+
- **62%** say an unexpected AI cost changed a business decision in the past year. Of those, 40% had to escalate it to the board, 33% froze spending, and 25% delayed or cancelled an AI project.
|
|
93
|
+
- **49%** had to raise prices of their AI products because costs rose more than expected.
|
|
94
|
+
- Only **11%** can forecast their AI spend within ±10% (down from 15% in 2025).
|
|
95
|
+
- **43%** name token costs as a top source of surprise spend. Agents are a growing blind spot: almost all companies run them, but only about a third include them in cost reports.
|
|
96
|
+
- [Channel Insider](https://www.channelinsider.com/ai/mavvrik-state-of-ai-cost-governance/) · [CFO Dive](https://cfodive.com/news/1-in-4-companies-delay-cancel-ai-projects-over-cost/827524) · [Diginomica](https://diginomica.com/tokenomics-ai-bill-shock-goes-mainstream-key-cost-driver-becomes-task-complexity)
|
|
97
|
+
|
|
98
|
+
**And when an AI answer is wrong, courts hold the company liable:**
|
|
99
|
+
- **Hamm, Germany (May 2026):** a clinic's website chatbot invented specialist titles for its doctors. The Higher Regional Court held the clinic responsible — even though the bot had been trained on correct data and was run by an IT provider. Switching the bot off was not enough; the clinic also had to sign a cease-and-desist declaration. Not yet final: an appeal to the Federal Court of Justice is allowed. [Court press release (German)](https://www.justiz.nrw/presse/2026-05-12) · [DLA Piper](https://www.dlapiper.com/en/insights/publications/2026/06/german-court-addresses-liability)
|
|
100
|
+
- **Munich, Germany (May 2026):** Google's AI Overviews made false claims about two publishers that did not appear in the linked sources. The Regional Court of Munich treated the AI summary as Google's own statement and barred Google from repeating it, with fines of up to €250,000 per violation. Not yet final. [Court press release (German)](https://www.justiz.bayern.de/gerichte-und-behoerden/landgericht/muenchen-1/presse/2026/13.php) · [The Decoder](https://the-decoder.com/landmark-german-ruling-declares-googles-ai-overviews-are-googles-own-words-and-makes-it-liable-for-false-answers/)
|
|
101
|
+
|
|
102
|
+
The lesson: cut cost **and** prove quality, one change at a time — with tests on real requests, not just offline benchmarks.
|
|
103
|
+
|
|
104
|
+
### What this looked like for us
|
|
105
|
+
|
|
106
|
+
**The project:** a live language-learning app that turns current local news into reading lessons. Every lesson starts with an AI step that searches the web for one fresh, **true** story. A wrong or outdated fact would be taught to the learner as true, so we ran this step on a strong model for every lesson: **Claude Sonnet 5.5 with full web search**. It cost **9.7 cents per article**. A lesson uses AI twice: once to find the story and once to write the lesson. Finding the story was about half of the lesson's total AI cost, and every lesson a free user read was paid for out of pocket.
|
|
107
|
+
|
|
108
|
+
**Before and after, per article:**
|
|
109
|
+
|
|
110
|
+
| | Before | After | What it means |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| Setup | Claude Sonnet 5.5 + full web search, for every article | **Scout:** Claude Haiku 5.5 + simple web search. **Rescue:** Sonnet 5.5 + full web search | The rescuer runs only when a code check finds no usable story or only an old one — 2 to 5 of every 18 articles. |
|
|
113
|
+
| Cost per article (average) | 9.7 ¢ | **4.6 – 7.7 ¢ (−53% to −21%)** | Depends on how often the rescuer runs (2 to 5 of every 18 articles across our runs); rescued articles pay for both attempts. The final combined test against production gave 4.6 ¢. |
|
|
114
|
+
| Cost per article (typical) | 9.2 ¢ | **2.6 ¢ (−71%)** | Median from the final combined test: most articles finish on the scout. |
|
|
115
|
+
| Quality, blind review (18 articles, max 540) | 434 | **472** | Quality held or improved. This is one blind review of 18 articles, scored by an AI model on a fixed rubric; we did not measure how much this score varies between runs, and in another paired run Scout & Rescue scored level with its competitor (437 vs 429). Likely reasons for the gain: the freshness check sends old stories to the rescuer, and new fact rules keep contact details, guessed descriptions and facts that sources disagree on out of the lesson. We did not measure each reason separately. |
|
|
116
|
+
| Time per search (average) | 34 s | 34 s | Same average, wide spread: in a second comparison run, a typical article took about 14 s on the scout; a rescued article takes the scout's time plus the rescuer's, which pulls the average up. The same setup run twice varies by about ±10%. |
|
|
117
|
+
| Lessons without an article | 0 | 0 | Every one of the 18 test requests ended with a usable story — a test result, not a guarantee. Two cheaper ideas failed here: the scout alone left 1 of 18 learners without a story, and a "lazier" rescuer was 22% cheaper but let old stories through (quality 440 vs 470). |
|
|
118
|
+
|
|
119
|
+
**Over a year:** 1,000 users reading one article a day is 365,000 articles.
|
|
120
|
+
|
|
121
|
+
| | Best run (4.6 ¢) | Most rescues (7.7 ¢) |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| Before (9.7 ¢ per article) | $35,405 | $35,405 |
|
|
124
|
+
| After | $16,790 | $28,105 |
|
|
125
|
+
| **Saved** | **$18,615** | **$7,300** |
|
|
126
|
+
|
|
127
|
+
Costs cover the search step only, at the API prices of our test, extrapolated from 18 test requests. Your own rescue rate decides where you land.
|
|
128
|
+
|
|
129
|
+
### A second example: a service chatbot (estimate)
|
|
130
|
+
|
|
131
|
+
An online shop's chatbot sends every turn to Claude Opus 5.5: **2.6 cents per turn, about $156,000 a year** at 500,000 turns a month. Split into steps — Haiku 5.5 to understand the message, Scout & Rescue (Haiku first, Opus only when a check rejects the draft) to answer, and Sonnet 5.5 for one daily summary:
|
|
132
|
+
|
|
133
|
+
| How often Opus is still needed | Cost per year | Saved |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| 1 in 5 turns | $36,200 | **$119,800 (−77%)** |
|
|
136
|
+
| 2 in 5 turns | $67,400 | **$88,600 (−57%)** |
|
|
137
|
+
|
|
138
|
+
These numbers come from assumptions, not a measurement, and are an upper estimate: they leave out prompt caching, which would make the "before" setup cheaper and the saving smaller. → [Full chatbot example, with the checks and how to prove it](https://github.com/AndyJakob78/valueproof/blob/main/docs/example-service-chatbot.md)
|
|
139
|
+
|
|
140
|
+
### Measured: support replies
|
|
141
|
+
|
|
142
|
+
We then ran the support-reply step of this idea for real: 40 made-up tickets (20 of them hard), Claude Haiku 5.5 as the scout, Opus 5.5 as the rescuer, against Opus 5.5 alone, with a blind review.
|
|
143
|
+
|
|
144
|
+
| | Scout & Rescue | Opus 5.5 alone |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| Cost per reply | **81–88% less** | — |
|
|
147
|
+
| Quality (blind review, two runs) | **2–6% lower** | — |
|
|
148
|
+
| Hard failures (run 2, 40 tickets) | 3 | 2 |
|
|
149
|
+
| **Cost per outcome** (run 2) | **0.12 ¢** (36 of 40) | 1.05 ¢ (35 of 40) |
|
|
150
|
+
|
|
151
|
+
**Good for cost, with a quality trade-off.** Most cheap replies were good, but some were weaker in ways no check saw, and one stated a wrong refund rule. Use it where a few percent of quality is acceptable, or where your checks catch the mistakes that matter; keep refund, money and legal answers on the strong model until they do. → [Full results, caveats and how to rerun it](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md)
|
|
152
|
+
|
|
153
|
+
**And where a cheap model is already in use:** in a game that writes an AI newspaper article per match day, the cheap model passed every check, so the rescuer never ran. The strong model alone cost 18× more for 13% better text, and the blind review found fact errors in both that no check caught. The better lever there is a better check, not a bigger model. → [Game article test](https://github.com/AndyJakob78/valueproof/blob/main/docs/game-article-test.md)
|
|
154
|
+
|
|
155
|
+
## The solution
|
|
156
|
+
|
|
157
|
+
**1. Break the job into steps, and give each step the right model.** A recommended starting point — our case study tested this on one step (the search), not a full pipeline.
|
|
158
|
+
|
|
159
|
+
| Step | Recommended starting point |
|
|
160
|
+
|---|---|
|
|
161
|
+
| Read / extract | small, cheap model |
|
|
162
|
+
| Analyze / draft | **Scout & Rescue** (see below) |
|
|
163
|
+
| Review | a check in code where possible |
|
|
164
|
+
| Aggregate | mid-size model, once per batch |
|
|
165
|
+
|
|
166
|
+
**2. Scout & Rescue for the steps that are usually easy but sometimes hard.** A cheap model (the scout) tries first. A strong model (the rescuer) runs only when a check in code says the scout's result is unusable. When most requests pass the check, most finish at the cheap price; the rest get the same strong model you use today.
|
|
167
|
+
|
|
168
|
+
```mermaid
|
|
169
|
+
flowchart LR
|
|
170
|
+
R["Request"] --> SC["Scout<br/>cheap model"] --> C1{"Check in code:<br/>usable?"}
|
|
171
|
+
C1 -- yes --> A["Answer<br/>at the cheap price"]
|
|
172
|
+
C1 -- no --> RS["Rescuer<br/>strong model"] --> C2{"Check:<br/>usable?"}
|
|
173
|
+
C2 -- yes --> A2["Answer<br/>pays for both calls"]
|
|
174
|
+
C2 -- no --> F["Fallback<br/>template, human, or error"]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The checks decide the quality: a mistake no check catches goes straight to the user at the cheap price.
|
|
178
|
+
|
|
179
|
+
**Expect a small quality cost.** Requests that pass the check are only as good as the cheap model's answer. In our support test, Scout & Rescue cost 81–88% less than the strong model alone and scored 2–6% lower in a blind review — a much stronger cost lever than tuning the strong model, with a quality trade-off you should measure for your own task. How much quality you keep depends mostly on your checks.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from valueproof import scout_and_rescue
|
|
183
|
+
from valueproof.claude import claude
|
|
184
|
+
|
|
185
|
+
outcome = scout_and_rescue(
|
|
186
|
+
prompt, # your request
|
|
187
|
+
scout=claude("claude-haiku-5-5"),
|
|
188
|
+
rescue=claude("claude-opus-5-5"),
|
|
189
|
+
check=lambda text: None if order_id in text else "does not mention the order id", # order_id from your data
|
|
190
|
+
)
|
|
191
|
+
print(outcome.path, outcome.cost_usd) # "scout" or "rescue" - how often each runs depends on your checks
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Install** (version 0.3, early: the API may still change; Python 3.10+, Gemini adapter 3.11+):
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pip install "valueproof[claude]"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
One name for everything: `pip install valueproof`, `import valueproof`, `valueproof compare`. (Until version 0.3 the package was called `ai-mixed-model-cost-optimization`; the old name still installs and pulls in `valueproof`.)
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from valueproof import scout_and_rescue
|
|
204
|
+
from valueproof.claude import claude # or .openai / .gemini
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The core has no dependencies and works with any provider: a model is just a function `prompt -> ModelResult`. Adapters come as extras: `[claude]`, `[openai]`, `[gemini]` or `[all]`. For a local model, write a function with the same shape.
|
|
208
|
+
|
|
209
|
+
**Test a change on your own requests** with one command — it runs every setup on every request, side by side, and prints cost (average and median), rescue rate, time, check failures and blind-review quality:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
valueproof init my_test.py # a starter test that runs straight away, with fake models
|
|
213
|
+
valueproof compare my_test.py --live
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
→ How to write `my_test.py`, plus a support-ticket demo that works without an API key: [examples/](https://github.com/AndyJakob78/valueproof/blob/main/examples/). The live Claude mode was run in the [support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md).
|
|
217
|
+
|
|
218
|
+
**A second, smaller lever: lower effort on the strong model.** In the same test, running the rescuer at effort low instead of medium cost 24–25% less in two runs, with no measurable quality loss on the rescued tickets. Measured on short support replies only.
|
|
219
|
+
|
|
220
|
+
**3. Prove every change before you ship it.** Change one thing at a time. Run the old and new versions side by side on the same requests. Review quality blind, as A vs. B. Keep only what saves money *and* holds quality.
|
|
221
|
+
|
|
222
|
+
The test setup is an **eval**: a fixed set of real requests, checks in code and a blind review, built once and reused for every change. Without it you can't tell a saving from a quality loss.
|
|
223
|
+
|
|
224
|
+
```mermaid
|
|
225
|
+
flowchart LR
|
|
226
|
+
E["1. Build the eval<br/>real requests, checks in code,<br/>blind review"] --> L["2. Pick the next lever<br/>e.g. Scout & Rescue, lower effort"]
|
|
227
|
+
L --> T["3. Test it against today<br/>same requests, same moment<br/>valueproof compare"]
|
|
228
|
+
T --> D{"Cheaper AND<br/>quality holds?"}
|
|
229
|
+
D -- "yes: keep" --> L
|
|
230
|
+
D -- "no: drop" --> L
|
|
231
|
+
L -- "no levers left" --> S["4. Test all kept levers together,<br/>ship, keep measuring"]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The full flow, with the cost breakdown and the ledger: [method.md](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md#the-flow)
|
|
235
|
+
|
|
236
|
+
→ The step-by-step method: [docs/method.md](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md) · Templates: [templates/](https://github.com/AndyJakob78/valueproof/blob/main/templates/)
|
|
237
|
+
|
|
238
|
+
## How this differs from other tools
|
|
239
|
+
|
|
240
|
+
The technique is not new: a cheap model first and a strong one on failure is a well-known *LLM cascade* (see [FrugalGPT](https://github.com/stanford-futuredata/FrugalGPT)). What is less common is the workflow around it: prove the cut on your own traffic, one change at a time, and publish what failed.
|
|
241
|
+
|
|
242
|
+
| Tool | What it does | How it relates |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| [RouteLLM](https://github.com/lm-sys/RouteLLM) | Trained routers that pick a model per request | A routing technique. You can test it against your setup with `valueproof compare`. |
|
|
245
|
+
| [cascadeflow](https://github.com/lemony-ai/cascadeflow) | A cascading runtime for agents, with streaming and tool-call routing | A runtime for production. Test it here first. |
|
|
246
|
+
| [LiteLLM](https://github.com/BerriAI/litellm) | A gateway to 100+ model APIs | Infrastructure to call models. Works as the model behind a setup here. |
|
|
247
|
+
| [promptfoo](https://github.com/promptfoo/promptfoo) | Broad testing of prompts, agents and RAG, plus red teaming | A general eval suite. This repo is narrower: one cost change at a time, judged by cost per outcome. |
|
|
248
|
+
|
|
249
|
+
**Use this when** you want evidence on your own requests before you commit to a router or gateway — or to show that a cheaper setup really holds quality. **Use the others when** you need production routing at scale.
|
|
250
|
+
|
|
251
|
+
## The full story
|
|
252
|
+
|
|
253
|
+
We tested 12 cost-saving ideas one at a time, and **7 raised cost or lowered quality**. For example, a shorter prompt made the model search *more*.
|
|
254
|
+
|
|
255
|
+
→ [Case study](https://github.com/AndyJakob78/valueproof/blob/main/docs/case-study.md) · [Support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md) · [Game article test](https://github.com/AndyJakob78/valueproof/blob/main/docs/game-article-test.md) · [Scout & Rescue in detail](https://github.com/AndyJakob78/valueproof/blob/main/docs/scout-and-rescue.md) · [Lessons](https://github.com/AndyJakob78/valueproof/blob/main/docs/lessons.md)
|
|
256
|
+
|
|
257
|
+
## Terms used on this page
|
|
258
|
+
|
|
259
|
+
- **Token:** the unit AI providers bill by — roughly a short word of text the model reads or writes.
|
|
260
|
+
- **Lever:** one change that should lower cost, such as a smaller model or a shorter prompt. Each lever is tested on its own.
|
|
261
|
+
- **Scout:** the cheap, fast model that tries first.
|
|
262
|
+
- **Rescuer:** the strong model that runs only when a check in code rejects the scout's result.
|
|
263
|
+
- **Full web search:** a search tool that filters the results with code before the model reads them. Fewer pages to read, but more steps.
|
|
264
|
+
- **Simple web search:** a search tool that hands the raw results straight to the model. Fewer steps; the model reads everything it gets, which is cheap on a small model but expensive on a large one.
|
|
265
|
+
- **Blind review:** a reviewer scores two results labelled only A and B, without knowing which setup made which.
|
|
266
|
+
- **Eval:** the fixed test that decides whether a change is kept — real requests, checks in code and a blind review, run the same way every time.
|
|
267
|
+
- **Outcome:** a request whose final result passed your checks and, if reviewed, had no hard failure — a result a user could rely on.
|
|
268
|
+
- **Cost per outcome:** everything a setup spent, including failed and rescued attempts, divided by its outcomes. The number to compare.
|
|
269
|
+
- **Typical (median):** the middle value — half the requests cost less, half more. Unlike the average, a few expensive outliers don't move it.
|
|
270
|
+
|
|
271
|
+
## About
|
|
272
|
+
|
|
273
|
+
Built from a real cost-reduction project on a live language-learning app. Engineering, testing and blind reviews were done with an AI coding assistant (Claude); a product owner made every keep-or-drop decision from the results.
|
|
274
|
+
|
|
275
|
+
Text: [CC BY 4.0](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE). Code in [src/](https://github.com/AndyJakob78/valueproof/blob/main/src/) and [examples/](https://github.com/AndyJakob78/valueproof/blob/main/examples/): [MIT](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE-CODE). Use it, adapt it, credit it.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
mixed_model_cost/__init__.py,sha256=OS7tRQ6iiCArrVKTeGhoD9QgyCpg7EXe60X8dGJfDUg,945
|
|
2
|
+
valueproof/__init__.py,sha256=3wZeQO-utRAZD5nNE8_Igy9hUZV9XAAiVLNLyVaOVqs,1003
|
|
3
|
+
valueproof/claude.py,sha256=mPot1LPEtFPOKUonuubL1YoHiPbktNt0FlqMI5NTcZM,2754
|
|
4
|
+
valueproof/cli.py,sha256=z6T7kj42RrcXb1nphG5fDckXszr6yGjfwYMOv8b6MhM,4436
|
|
5
|
+
valueproof/gemini.py,sha256=ybIf_azgN8ZxKveU7K7i70u_8Bff9aTJxI7BMr7s51I,2042
|
|
6
|
+
valueproof/lever_runner.py,sha256=tbHi8_fCfMv1oDh-zE5OVCNg3RWUQV7hyGl6iDZ7BFw,6240
|
|
7
|
+
valueproof/openai.py,sha256=_YCmUAhwdPk0IeokwLVKykCcKw6TdTMxqlLzb2ACZVo,1868
|
|
8
|
+
valueproof/pipeline.py,sha256=Mf44dUvzb63UmV9ArQMGtw9l5kGtsnf-yjGN3fdd664,2417
|
|
9
|
+
valueproof/scout_rescue.py,sha256=HcW79D56hifRnAJ6CdGzzjLwF_BsmGfC1ZBJU6M8ewE,2297
|
|
10
|
+
valueproof/starter.py,sha256=f5OA9fITiE46yRY5tT_nXmK36PZ6cK7ex3OBDisw4P8,3582
|
|
11
|
+
valueproof-0.4.0.dist-info/licenses/LICENSE-CODE,sha256=XtgPdAxyOJ1ZcsGC7dYR5_xWErc-6AOgPe0JSuyZI0M,1080
|
|
12
|
+
valueproof-0.4.0.dist-info/METADATA,sha256=08RiKz95UQDMqSFJwqY2tgCd2Mc66B_1zht90YVonv4,23350
|
|
13
|
+
valueproof-0.4.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
14
|
+
valueproof-0.4.0.dist-info/entry_points.txt,sha256=yPSERGQxj6Kf05EV0OEzWYHcO9KKyorfo0Z65cZmfyQ,83
|
|
15
|
+
valueproof-0.4.0.dist-info/top_level.txt,sha256=RY-vh8jIUi7erPwrmcTqiP8zyUOzcIAhGz4DK1yKrR8,28
|
|
16
|
+
valueproof-0.4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Valueproof contributors
|
|
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.
|