@simplexai/localmodels-linux-x64 0.1.0-dev.32.build.git0f60eee490864cf83e343f8db13a335676a19dd8 → 0.1.0-dev.35

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.
Files changed (140) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +138 -97
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +4 -0
  5. package/modules/localmodels/app.py +7 -2
  6. package/modules/localmodels/approval.py +4 -4
  7. package/modules/localmodels/bifrost_checks.py +121 -3
  8. package/modules/localmodels/bifrost_provider.py +53 -0
  9. package/modules/localmodels/bifrost_unit.py +32 -1
  10. package/modules/localmodels/budget.py +5 -1
  11. package/modules/localmodels/catalog.json +51 -10
  12. package/modules/localmodels/catalog.py +30 -29
  13. package/modules/localmodels/catalog_add.py +1 -0
  14. package/modules/localmodels/cli_parser.py +10 -2
  15. package/modules/localmodels/component.py +7 -1
  16. package/modules/localmodels/decode_calibration.json +6 -0
  17. package/modules/localmodels/decode_calibration.py +104 -0
  18. package/modules/localmodels/deploy.py +44 -7
  19. package/modules/localmodels/deploy_steps.py +10 -1
  20. package/modules/localmodels/engines-strata-0.1.49.2.json +31 -0
  21. package/modules/localmodels/engines.json +57 -1
  22. package/modules/localmodels/engines.py +6 -2
  23. package/modules/localmodels/estimator.py +21 -7
  24. package/modules/localmodels/frontend.py +4 -4
  25. package/modules/localmodels/gateway.py +14 -4
  26. package/modules/localmodels/gateway_app_bifrost.py +4 -3
  27. package/modules/localmodels/gateway_bifrost.py +70 -57
  28. package/modules/localmodels/gateway_probe.py +3 -4
  29. package/modules/localmodels/gguf.py +7 -0
  30. package/modules/localmodels/harness.py +24 -25
  31. package/modules/localmodels/harness_gateway.py +19 -10
  32. package/modules/localmodels/harness_probe.py +33 -6
  33. package/modules/localmodels/hosts.py +73 -9
  34. package/modules/localmodels/install.py +36 -6
  35. package/modules/localmodels/library_cli.py +179 -0
  36. package/modules/localmodels/library_convert.py +132 -0
  37. package/modules/localmodels/library_gateway.py +471 -0
  38. package/modules/localmodels/library_jobs.py +314 -0
  39. package/modules/localmodels/library_model.py +246 -0
  40. package/modules/localmodels/library_pricing.py +347 -0
  41. package/modules/localmodels/library_serve.py +348 -0
  42. package/modules/localmodels/library_state.py +373 -0
  43. package/modules/localmodels/library_status.py +349 -0
  44. package/modules/localmodels/llm_rank.py +16 -2
  45. package/modules/localmodels/memcalc.py +7 -30
  46. package/modules/localmodels/metal.py +26 -0
  47. package/modules/localmodels/plan_envelope.py +4 -1
  48. package/modules/localmodels/preparation.py +49 -0
  49. package/modules/localmodels/probe.py +8 -8
  50. package/modules/localmodels/process_identity.py +536 -9
  51. package/modules/localmodels/quant_formats.py +123 -0
  52. package/modules/localmodels/recommend_cli.py +8 -4
  53. package/modules/localmodels/records.py +1 -0
  54. package/modules/localmodels/remote_ops.py +104 -6
  55. package/modules/localmodels/remote_ops_download.py +17 -2
  56. package/modules/localmodels/remote_ops_prepare.py +406 -0
  57. package/modules/localmodels/remote_ops_remove.py +40 -7
  58. package/modules/localmodels/remote_ops_service.py +110 -8
  59. package/modules/localmodels/remote_ops_verify.py +15 -2
  60. package/modules/localmodels/runtime_auth.py +31 -1
  61. package/modules/localmodels/runtime_cli.py +3 -4
  62. package/modules/localmodels/runtime_io.py +50 -6
  63. package/modules/localmodels/service_autostart.py +45 -1
  64. package/modules/localmodels/service_control.py +13 -0
  65. package/modules/localmodels/service_deployment.py +12 -3
  66. package/modules/localmodels/service_jobs.py +33 -4
  67. package/modules/localmodels/service_probe.py +67 -13
  68. package/modules/localmodels/service_stop.py +152 -0
  69. package/modules/localmodels/service_worker.py +9 -1
  70. package/modules/localmodels/services_cli.py +50 -6
  71. package/modules/localmodels/setup_inspection.py +34 -25
  72. package/modules/localmodels/setup_text.py +118 -0
  73. package/modules/localmodels/sizecalc.py +625 -0
  74. package/modules/localmodels/sizecalc_cli.py +249 -0
  75. package/modules/localmodels/stack.py +69 -17
  76. package/modules/localmodels/stack_args.py +91 -19
  77. package/modules/localmodels/stack_auto.py +78 -0
  78. package/modules/localmodels/stack_binding.py +23 -35
  79. package/modules/localmodels/stack_card.py +195 -0
  80. package/modules/localmodels/stack_cleanup.py +379 -0
  81. package/modules/localmodels/stack_clients.py +4 -1
  82. package/modules/localmodels/stack_compose.py +150 -194
  83. package/modules/localmodels/stack_console.py +2 -0
  84. package/modules/localmodels/stack_decision.py +3 -2
  85. package/modules/localmodels/stack_down.py +189 -0
  86. package/modules/localmodels/stack_events.py +54 -0
  87. package/modules/localmodels/stack_hardware.py +22 -23
  88. package/modules/localmodels/stack_journal.py +29 -8
  89. package/modules/localmodels/stack_ledger.py +411 -0
  90. package/modules/localmodels/stack_lifecycle.py +162 -167
  91. package/modules/localmodels/stack_llm_ram.py +57 -5
  92. package/modules/localmodels/stack_memory.py +721 -0
  93. package/modules/localmodels/stack_picks.py +139 -0
  94. package/modules/localmodels/stack_plan.py +140 -22
  95. package/modules/localmodels/stack_ports.py +22 -0
  96. package/modules/localmodels/stack_preflight.py +699 -0
  97. package/modules/localmodels/stack_review.py +123 -5
  98. package/modules/localmodels/stack_rollback.py +2 -0
  99. package/modules/localmodels/stack_route.py +256 -0
  100. package/modules/localmodels/stack_run.py +11 -0
  101. package/modules/localmodels/stack_suite.py +102 -17
  102. package/modules/localmodels/stack_summary.py +65 -4
  103. package/modules/localmodels/stack_try.py +354 -0
  104. package/modules/localmodels/stack_try_client.py +194 -0
  105. package/modules/localmodels/stack_try_docs.py +139 -0
  106. package/modules/localmodels/stack_up.py +8 -1
  107. package/modules/localmodels/stack_update.py +29 -4
  108. package/modules/localmodels/stack_verify.py +3 -1
  109. package/modules/localmodels/stack_view.py +10 -11
  110. package/modules/localmodels/stack_view_apply.py +4 -2
  111. package/modules/localmodels/stack_view_events.py +2 -1
  112. package/modules/localmodels/stack_view_serve.py +3 -0
  113. package/modules/localmodels/stack_view_text.py +1 -1
  114. package/modules/localmodels/stack_view_words.py +4 -1
  115. package/modules/localmodels/stack_warm.py +574 -0
  116. package/modules/localmodels/stack_whatif.py +558 -0
  117. package/modules/localmodels/suite.py +48 -39
  118. package/modules/localmodels/tool_archive.py +40 -0
  119. package/modules/localmodels/tools.json +8 -0
  120. package/modules/localmodels/transport.py +1 -0
  121. package/modules/localmodels/vision.py +8 -1
  122. package/modules/localmodels/web/sizecalc/app.js +431 -0
  123. package/modules/localmodels/web/sizecalc/calc.js +269 -0
  124. package/modules/localmodels/web/sizecalc/page.html +362 -0
  125. package/modules/localmodels/web/view/ASSET-SOURCES.md +11 -0
  126. package/modules/localmodels/web/view/i18n.js +1 -1
  127. package/modules/localmodels/web/view/logo-claude.svg +3 -0
  128. package/modules/localmodels/web/view/logo-codex.png +0 -0
  129. package/modules/localmodels/web/view/logo-pi.svg +6 -0
  130. package/modules/localmodels/web/view/view.css +4 -0
  131. package/modules/localmodels/web/view/view.js +15 -6
  132. package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/METADATA +1 -1
  133. package/modules/simplex_localmodels-0.1.0.dev35.dist-info/RECORD +241 -0
  134. package/package.json +1 -1
  135. package/tool.json +1 -1
  136. package/modules/simplex_localmodels-0.1.0.dev32.dist-info/RECORD +0 -200
  137. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/WHEEL +0 -0
  138. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/entry_points.txt +0 -0
  139. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/licenses/NOTICE +0 -0
  140. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -0,0 +1,78 @@
1
+ """The existing auto planner's Strata comparison, shared by planning and upgrade advice.
2
+
3
+ The caller supplies the resident llama.cpp score and id. The validated recipe order, tie band,
4
+ RAM fit and generated-pack refusals are the same policy formerly in stack_compose; local reads
5
+ are supplied through the planner's readers and suite.build_plan. No state is saved or applied.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from collections.abc import Callable
11
+
12
+ from localmodels import llm_rank, preparation, stack_suite
13
+ from localmodels.plan_envelope import PlanError
14
+ from localmodels.probe import HostFacts
15
+ from localmodels.records import Plan
16
+ from localmodels.stack_plan import Parts, StackError, StackOptions
17
+
18
+
19
+ def strata_parts(
20
+ facts: HostFacts,
21
+ options: StackOptions,
22
+ llama: tuple[int, str],
23
+ listening: Callable[[int], bool],
24
+ previous: Callable[[str, int], Plan | None],
25
+ owned_ram: Callable[[], int],
26
+ passed_over: list[str],
27
+ check: Callable[[Parts, StackOptions], None] | None = None,
28
+ ) -> Parts | None:
29
+ """The best validated Strata recipe whose installed SimplexAI score beats the llama.cpp
30
+ pick by at least llm_rank.TIE_BAND and that fits this host, priced as if ``--llm`` named
31
+ it (roadmap decisions 26 and 33: Strata keeps the experts in RAM, so a 24 GB card with 64 GB runs
32
+ Flash-Next). None leaves the choice to llama.cpp; why each better recipe was passed over is
33
+ added to ``passed_over`` for the llama.cpp plan's warnings."""
34
+ bar, llama_id = llama
35
+ skipped: list[str] = []
36
+ for recipe in stack_suite.auto_strata_candidates(facts, llm_rank.strata_bar(bar, options)):
37
+ score = recipe["quality"]["score"]
38
+ why = (
39
+ f"LLM: auto picks Strata {recipe['id']} (installed SimplexAI score {score}"
40
+ + (
41
+ f", best llama.cpp {llama_id} scores {bar}"
42
+ if llama_id
43
+ else ", no llama.cpp model fits"
44
+ )
45
+ + f", --prefer {options.get('prefer') or 'smartest'})"
46
+ )
47
+ try:
48
+ candidate_options = options.copy()
49
+ parts = stack_suite.strata_parts(
50
+ facts,
51
+ candidate_options,
52
+ recipe,
53
+ [why, *skipped],
54
+ listening=listening,
55
+ previous=previous,
56
+ owned_ram=owned_ram,
57
+ )
58
+ missing = [
59
+ f for f in parts["llm"]["files"] if f.get("generated") and not preparation.ready(f)
60
+ ]
61
+ if missing:
62
+ raise StackError(
63
+ f"{recipe['id']} needs {len(missing)} files that Strata setup generates; "
64
+ "complete prebuilt Strata runtime files are unavailable. Point --reuse-from "
65
+ "at an existing Strata model directory, or name --llm explicitly to prepare it"
66
+ )
67
+ if check is not None:
68
+ check(parts, candidate_options)
69
+ except (StackError, PlanError) as exc: # PlanError: its Strata pack is not on this host
70
+ skipped.append(
71
+ f"LLM: auto passed over the smarter Strata {recipe['id']} "
72
+ f"(installed SimplexAI score {score}): {exc}"
73
+ )
74
+ continue
75
+ options.update(candidate_options)
76
+ return parts
77
+ passed_over.extend(skipped)
78
+ return None
@@ -9,6 +9,7 @@ from typing import TypedDict, cast
9
9
 
10
10
  from localmodels import harness, hosts, stack, stack_run
11
11
  from localmodels import stack_lifecycle as lifecycle
12
+ from localmodels.setup_text import Lang, text
12
13
  from localmodels.stack_plan import StackPlan, deployments
13
14
 
14
15
 
@@ -17,6 +18,10 @@ class Reason(TypedDict):
17
18
  message: str
18
19
 
19
20
 
21
+ def _reason(code: str, lang: Lang, key: str | None = None) -> Reason:
22
+ return {"code": code, "message": text(key or code, lang)}
23
+
24
+
20
25
  class PiBinding(TypedDict):
21
26
  executable: str
22
27
  environment: dict[str, str]
@@ -102,7 +107,7 @@ def _deployments_ready(plan: StackPlan, owned: hosts.Owned) -> bool:
102
107
  return True
103
108
 
104
109
 
105
- def _bifrost_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
110
+ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") -> PiBinding | Reason:
106
111
  from localmodels import bifrost_pi, gateway_bifrost
107
112
 
108
113
  gateway = plan["harness"]["gateway"]
@@ -116,12 +121,12 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
116
121
  or not owned["pi"]
117
122
  or owned["pi"]["model"] != gateway["pi_model"]
118
123
  ):
119
- return {"code": "gateway-ownership", "message": "网关或 Pi 的归属与批准计划不一致。"}
124
+ return _reason("gateway-ownership", lang)
120
125
  try:
121
126
  if gateway_bifrost.require_target(plan["harness"]) != record:
122
127
  raise harness.HarnessError("Bifrost record changed")
123
128
  except harness.HarnessError:
124
- return {"code": "gateway-ownership", "message": "网关归属与批准计划不一致。"}
129
+ return _reason("gateway-ownership", lang, "gateway-record")
125
130
  executable = Path(harness.tool_path(plan["harness"], "pi"))
126
131
  profile = bifrost_pi.pi_profile(harness.gateway_environment(plan["harness"]))
127
132
  if not executable.is_absolute() or not profile.is_absolute():
@@ -132,7 +137,7 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
132
137
  or not gateway_bifrost.healthy(gateway["addr"])
133
138
  or bifrost_pi.pi_model(profile) != (gateway["pi_model"])
134
139
  ):
135
- return {"code": "gateway-unavailable", "message": "计划中的网关或 Pi 默认模型当前不可用。"}
140
+ return _reason("gateway-unavailable", lang)
136
141
  env = {**harness.gateway_environment(plan["harness"]), "PI_CODING_AGENT_DIR": str(profile)}
137
142
  listed = harness.run_tool([str(executable), "--list-models"], timeout=30, env=env)
138
143
  expected = gateway["pi_model"].split("/", 1)
@@ -140,9 +145,9 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
140
145
  len(fields) >= 2 and fields[:2] == expected
141
146
  for fields in (line.split() for line in listed.stdout.splitlines())
142
147
  ):
143
- return {"code": "pi-model-unavailable", "message": "Pi 当前没有列出计划中的网关模型。"}
148
+ return _reason("pi-model-unavailable", lang)
144
149
  if _profile_fingerprint(executable, profile) != fingerprint:
145
- return {"code": "pi-config-changed", "message": "检查期间 Pi 配置发生变化,请重新检查。"}
150
+ return _reason("pi-config-changed", lang)
146
151
  return {
147
152
  "executable": str(executable),
148
153
  "environment": {"PI_CODING_AGENT_DIR": str(profile)},
@@ -150,16 +155,16 @@ def _bifrost_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
150
155
  }
151
156
 
152
157
 
153
- def _pi_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
158
+ def _pi_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") -> PiBinding | Reason:
154
159
  gateway = plan["harness"]["gateway"]
155
160
  if harness.gateway_kind(gateway) == "bifrost":
156
- return _bifrost_binding(plan, owned)
161
+ return _bifrost_binding(plan, owned, lang)
157
162
  if (
158
163
  owned["gateway"]["group"] != gateway["group"]
159
164
  or not owned["pi"]
160
165
  or owned["pi"]["model"] != gateway["pi_model"]
161
166
  ):
162
- return {"code": "gateway-ownership", "message": "网关或 Pi 的归属与批准计划不一致。"}
167
+ return _reason("gateway-ownership", lang)
163
168
  executable = Path(harness.tool_path(plan["harness"], "pi"))
164
169
  profile = Path(harness.gateway_environment(plan["harness"])["PI_CODING_AGENT_DIR"]).expanduser()
165
170
  if not executable.is_absolute() or not profile.is_absolute():
@@ -189,16 +194,16 @@ def _pi_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
189
194
  or os.path.realpath(state["pi"]) != os.path.realpath(executable)
190
195
  or state["pi_model"] != gateway["pi_model"]
191
196
  ):
192
- return {"code": "gateway-unavailable", "message": "计划中的网关或 Pi 默认模型当前不可用。"}
197
+ return _reason("gateway-unavailable", lang)
193
198
  listed = harness.run_tool([str(executable), "--list-models"], timeout=30, env=env)
194
199
  expected = gateway["pi_model"].split("/", 1)
195
200
  if listed.returncode != 0 or not any(
196
201
  len(fields) >= 2 and fields[:2] == expected
197
202
  for fields in (line.split() for line in listed.stdout.splitlines())
198
203
  ):
199
- return {"code": "pi-model-unavailable", "message": "Pi 当前没有列出计划中的网关模型。"}
204
+ return _reason("pi-model-unavailable", lang)
200
205
  if _profile_fingerprint(executable, profile) != fingerprint:
201
- return {"code": "pi-config-changed", "message": "检查期间 Pi 配置发生变化,请重新检查。"}
206
+ return _reason("pi-config-changed", lang)
202
207
  return {
203
208
  "executable": str(executable),
204
209
  "environment": {"PI_CODING_AGENT_DIR": str(profile)},
@@ -206,7 +211,7 @@ def _pi_binding(plan: StackPlan, owned: hosts.Owned) -> PiBinding | Reason:
206
211
  }
207
212
 
208
213
 
209
- def inspect_binding(path: Path) -> BindingReport:
214
+ def inspect_binding(path: Path, lang: Lang = "zh") -> BindingReport:
210
215
  report: BindingReport = {
211
216
  "schema": "localmodels.stack-binding/v1",
212
217
  "ready": False,
@@ -222,39 +227,22 @@ def inspect_binding(path: Path) -> BindingReport:
222
227
  if stack.digest(plan) != plan["plan_id"]:
223
228
  raise ValueError("Plan digest mismatch")
224
229
  except (OSError, ValueError, KeyError):
225
- report["reasons"] = [
226
- {"code": "plan-invalid", "message": "批准计划不存在、无效或摘要不一致。"}
227
- ]
230
+ report["reasons"] = [_reason("plan-invalid", lang)]
228
231
  return report
229
232
  try:
230
233
  if not _acceptance_ready(plan):
231
- report["reasons"] = [
232
- {
233
- "code": "acceptance-unavailable",
234
- "message": "批准计划缺少完整成功的套件验收记录,请完成已有安装的验收后重试。",
235
- }
236
- ]
234
+ report["reasons"] = [_reason("acceptance-unavailable", lang)]
237
235
  return report
238
236
  owned = hosts.load_owned(plan["harness"]["tools_dir"])
239
237
  if not _deployments_ready(plan, owned):
240
- report["reasons"] = [
241
- {
242
- "code": "deployment-unavailable",
243
- "message": "计划中的部署尚未全部就绪,或当前记录与归属不一致。",
244
- }
245
- ]
238
+ report["reasons"] = [_reason("deployment-unavailable", lang)]
246
239
  return report
247
- binding = _pi_binding(plan, owned)
240
+ binding = _pi_binding(plan, owned, lang)
248
241
  if "code" in binding:
249
242
  report["reasons"] = [cast(Reason, binding)]
250
243
  else:
251
244
  report["ready"] = True
252
245
  report["pi"] = binding
253
246
  except (OSError, ValueError, KeyError, StopIteration, AttributeError, harness.HarnessError):
254
- report["reasons"] = [
255
- {
256
- "code": "binding-unavailable",
257
- "message": "Pi 配置或本机状态无法安全读取,请恢复已有安装后重试。",
258
- }
259
- ]
247
+ report["reasons"] = [_reason("binding-unavailable", lang)]
260
248
  return report
@@ -0,0 +1,195 @@
1
+ """A local SVG score card built from the accepted installation and an optional saved warm report.
2
+
3
+ Hardware and context are the plan's snapshots, not fresh measurements. A card never probes
4
+ hardware, starts inference, visits a URL, or claims full product acceptance. Save the latest
5
+ ``stack warm --json`` output to the deployment's ``warm.json`` or pass ``--warm-report``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import json
12
+ import math
13
+ from html import escape
14
+ from pathlib import Path
15
+
16
+ from localmodels import cli_help, stack_up, stack_view_llm, stack_warm, suite
17
+ from localmodels.budget import gib
18
+ from localmodels.stack_plan import StackError, StackPlan
19
+
20
+
21
+ def warm_speed(path: Path, plan: StackPlan) -> float | None:
22
+ """Require the same deployment, hostname, platform and total RAM as the installation."""
23
+ try:
24
+ raw = json.loads(path.read_text(encoding="utf-8"))
25
+ except (OSError, ValueError):
26
+ return None
27
+ if not isinstance(raw, dict) or raw.get("schema") != stack_warm.SCHEMA:
28
+ return None
29
+ hardware = plan.get("hardware")
30
+ memory = raw.get("memory_before")
31
+ if (
32
+ hardware is None
33
+ or raw.get("hostname") != plan["hostname"]
34
+ or not hardware.get("platform")
35
+ or raw.get("platform") != hardware["platform"]
36
+ or not isinstance(memory, dict)
37
+ or memory.get("total_bytes") != hardware["ram_total_bytes"]
38
+ ):
39
+ return None
40
+ llm = raw.get("llm")
41
+ if (
42
+ not isinstance(llm, dict)
43
+ or llm.get("name") != plan["llm"]["name"]
44
+ or llm.get("ok") is not True
45
+ ):
46
+ return None
47
+ speed = llm.get("decode_tok_s")
48
+ return (
49
+ float(speed)
50
+ if isinstance(speed, int | float)
51
+ and not isinstance(speed, bool)
52
+ and math.isfinite(speed)
53
+ and speed > 0
54
+ else None
55
+ )
56
+
57
+
58
+ def score(plan: StackPlan) -> int | None:
59
+ model_id = plan["llm"]["model"]["id"]
60
+ entry = stack_view_llm.catalog_entry(model_id)
61
+ if entry is not None:
62
+ return (
63
+ entry.quality
64
+ if any(s["type"] == "intelligence_score" for s in entry.quality_sources)
65
+ else None
66
+ )
67
+ recipe = next((r for r in suite.recipes("llm") if r["id"] == model_id), None)
68
+ if recipe is None or "quality" not in recipe:
69
+ return None
70
+ quality = recipe["quality"]
71
+ return (
72
+ quality["score"]
73
+ if any(s["type"] == "intelligence_score" for s in quality["sources"])
74
+ else None
75
+ )
76
+
77
+
78
+ def render(plan: StackPlan, decode: float | None = None) -> str:
79
+ """Self-contained SVG without external images, scripts, fonts or links."""
80
+ part = plan["llm"]
81
+ hardware = plan.get("hardware")
82
+ selected = part["placement"].get("gpus") or []
83
+ capacities = {c["index"]: c["total_bytes"] for c in hardware["cards"]} if hardware else {}
84
+ names = (
85
+ [
86
+ str(g.get("name", "unknown GPU"))
87
+ + (f" ({gib(capacities[g['index']])})" if g.get("index") in capacities else "")
88
+ for g in selected
89
+ if isinstance(g, dict)
90
+ ]
91
+ if isinstance(selected, list)
92
+ else []
93
+ )
94
+ installed_score = score(plan)
95
+ window = part["launch"].get("window")
96
+ slots = part["launch"].get("slots")
97
+ context = f"{window:,} tokens" if isinstance(window, int) and window > 0 else "unavailable"
98
+ if isinstance(slots, int) and slots > 0:
99
+ context += f" / {slots} slots"
100
+ rows = [
101
+ ("GPU", ", ".join(names) or "none recorded (CPU placement)"),
102
+ ("RAM", gib(hardware["ram_total_bytes"]) if hardware else "unavailable"),
103
+ ("Installed LLM", part["model"]["display_name"]),
104
+ ("Quantization", part["model"]["quant"]),
105
+ (
106
+ "SimplexAI score (estimate)",
107
+ str(installed_score) if installed_score is not None else "unavailable",
108
+ ),
109
+ (
110
+ "Context (shared window)",
111
+ context,
112
+ ),
113
+ (
114
+ "Last recorded warm decode",
115
+ f"{decode:.1f} tok/s (measured)" if decode is not None else "none",
116
+ ),
117
+ ]
118
+ badges = ["LOCAL", "GPU" if names else "CPU"]
119
+ if part["launch"].get("vision") not in (None, "off", False):
120
+ badges.append("VISION CONFIGURED")
121
+ if decode is not None:
122
+ badges.append("WARM MEASURED")
123
+ if isinstance(window, int) and window >= 65536:
124
+ badges.append("64K+ SHARED CONTEXT")
125
+ body = [
126
+ '<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="680" viewBox="0 0 1000 680" '
127
+ 'role="img" aria-labelledby="title description">',
128
+ '<title id="title">Local model stack score card</title>',
129
+ '<desc id="description">Recorded installation facts and optional measured warm speed. '
130
+ "Hardware and context are installation snapshots. Full product acceptance is not implied.</desc>",
131
+ '<rect width="1000" height="680" rx="24" fill="#111827"/>',
132
+ '<g font-family="sans-serif" fill="#f3f4f6">',
133
+ '<text x="48" y="62" font-size="30" font-weight="bold">LOCAL MODEL STACK</text>',
134
+ ]
135
+ for index, (label, value) in enumerate(rows):
136
+ y = 124 + index * 58
137
+ body.extend(
138
+ [
139
+ f'<text x="48" y="{y}" font-size="16" fill="#9ca3af">{escape(label)}</text>',
140
+ f'<text x="360" y="{y}" font-size="19">{escape(value)}</text>',
141
+ ]
142
+ )
143
+ body.append(
144
+ f'<text x="48" y="554" font-size="17" fill="#86efac">{escape(" / ".join(badges))}</text>'
145
+ )
146
+ body.extend(
147
+ [
148
+ '<text x="48" y="608" font-size="14" fill="#9ca3af">Hardware and context: installation snapshot. '
149
+ "Speed: saved stack warm report, if provided.</text>",
150
+ '<text x="48" y="638" font-size="14" fill="#9ca3af">Local file only. No telemetry. '
151
+ "Catalog score is not a new evaluation or full product acceptance.</text>",
152
+ "</g></svg>\n",
153
+ ]
154
+ )
155
+ return "\n".join(body)
156
+
157
+
158
+ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
159
+ parser = actions.add_parser(
160
+ "card", help="write a local SVG with installed hardware, score and speed"
161
+ )
162
+ parser.add_argument(
163
+ "--out", type=Path, help="SVG path (default: LLM deployment directory/score-card.svg)"
164
+ )
165
+ parser.add_argument(
166
+ "--warm-report",
167
+ type=Path,
168
+ help="saved stack warm --json (default: LLM deployment directory/warm.json)",
169
+ )
170
+ cli_help.document(
171
+ parser,
172
+ "Write a self-contained SVG from the unchanged accepted local stack. Uses recorded "
173
+ "hardware, catalog score, context and a saved warm report from the same host. Missing speed "
174
+ "is shown as none. Never runs warm, probes hardware or uploads anything. Prints the path.",
175
+ examples=[
176
+ ("%(prog)s", "write score-card.svg in this stack's LLM directory"),
177
+ ("%(prog)s --out ./stack.svg --warm-report ./warm.json", "use a saved warm report"),
178
+ ],
179
+ )
180
+
181
+
182
+ def cli(args: argparse.Namespace) -> int:
183
+ plan = stack_up._accepted()
184
+ if plan is None or stack_up.drift(plan):
185
+ raise StackError("no unchanged accepted local stack; run stack install or stack up")
186
+ directory = Path(plan["llm"]["service"]["deploy_dir"]).expanduser()
187
+ report = (args.warm_report or directory / "warm.json").expanduser()
188
+ path = (args.out or directory / "score-card.svg").expanduser().absolute()
189
+ try:
190
+ path.parent.mkdir(parents=True, exist_ok=True)
191
+ path.write_text(render(plan, warm_speed(report, plan)), encoding="utf-8")
192
+ except OSError:
193
+ raise StackError("cannot write the SVG output path") from None
194
+ print(path)
195
+ return 0