plm-electrical 0.1.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.
- plm_electrical/__init__.py +1 -0
- plm_electrical/claims.py +28 -0
- plm_electrical/controller.py +35 -0
- plm_electrical/levels.py +26 -0
- plm_electrical/manifest.py +23 -0
- plm_electrical-0.1.0.dist-info/METADATA +20 -0
- plm_electrical-0.1.0.dist-info/RECORD +10 -0
- plm_electrical-0.1.0.dist-info/WHEEL +4 -0
- plm_electrical-0.1.0.dist-info/entry_points.txt +2 -0
- plm_electrical-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Electrical engineering pack: level rules and tiers; the rest is plm.numeric."""
|
plm_electrical/claims.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Which tasks the electrical pack claims, and how strongly."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
from plm.numeric.checks import requested_unit
|
|
6
|
+
from plm.pack import evidence
|
|
7
|
+
|
|
8
|
+
# An electrical calculation names something electrical (a term, or a unit symbol
|
|
9
|
+
# after a number) and gives numbers or asks for a unit. Conceptual questions
|
|
10
|
+
# ("Explain Ohm's law") have neither and go to the general pack.
|
|
11
|
+
ELECTRICAL_TERM = re.compile(
|
|
12
|
+
# "air resistance" (and wind, rolling) is mechanics, not a resistor
|
|
13
|
+
r"\b(?:volts?|voltage|amps?|amperes?|amperage|current|ohms?|(?<!air )(?<!wind )(?<!rolling )resist(?:or|ors|ance)"
|
|
14
|
+
r"|capacit(?:or|ors|ance)"
|
|
15
|
+
r"|inductors?|inductance|watts?|kilowatts?|kWh|transformers?|circuits?|hertz|batter(?:y|ies)|LEDs?"
|
|
16
|
+
r"|op-amps?|amplifiers?|impedance|reactance|three-phase|RMS|farads?|henr(?:y|ies)|siemens|coulombs?"
|
|
17
|
+
r"|power factor|electricity|diodes?)\b",
|
|
18
|
+
re.IGNORECASE)
|
|
19
|
+
UNIT_SYMBOL = re.compile(r"\d\s*(?:k|m|M|u|µ|μ|n)?(?:V|A|W|Ω|Hz|F|H|VA|var|Ah|Wh)\b") # case-sensitive on purpose
|
|
20
|
+
NUMBER = re.compile(r"\d")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def claims(text):
|
|
24
|
+
"""Distinct electrical terms and unit symbols, when there are numbers or a unit is asked for."""
|
|
25
|
+
if ((ELECTRICAL_TERM.search(text) or UNIT_SYMBOL.search(text))
|
|
26
|
+
and (NUMBER.search(text) or requested_unit(text) is not None)):
|
|
27
|
+
return evidence(ELECTRICAL_TERM, text, UNIT_SYMBOL)
|
|
28
|
+
return 0
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Electrical pack: tiers and level rules on top of the shared numeric controller.
|
|
2
|
+
|
|
3
|
+
The defaults are the best policy from evals/simulate_routing.py: calm and alert
|
|
4
|
+
problems go to the small model with the calculator, intensive ones to the large
|
|
5
|
+
model, and any answer that fails plm.numeric.checks moves to the next step.
|
|
6
|
+
Agreement checks (a second model's opinion) are not used: in the simulation they
|
|
7
|
+
cost more compute than they saved.
|
|
8
|
+
|
|
9
|
+
Model names can be overridden with PLM_SMALL_MODEL and PLM_LARGE_MODEL.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
from plm.numeric import controller as numeric
|
|
15
|
+
|
|
16
|
+
from plm_electrical.levels import classify
|
|
17
|
+
|
|
18
|
+
MODELS = {
|
|
19
|
+
"small": os.environ.get("PLM_SMALL_MODEL", "hf.co/bartowski/Qwen_Qwen3-4B-GGUF:Q4_K_M"),
|
|
20
|
+
"large": os.environ.get("PLM_LARGE_MODEL", "qwen3:8b"),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Per level: token budget and the escalation chain of (model, strategy) steps.
|
|
24
|
+
# Budgets are >2.5x the longest calculator answer seen in the eval runs.
|
|
25
|
+
LEVELS = {
|
|
26
|
+
"calm": {"num_predict": 384, "chain": [("small", "tool"), ("large", "tool")]},
|
|
27
|
+
"alert": {"num_predict": 512, "chain": [("small", "tool"), ("large", "tool")]},
|
|
28
|
+
"intensive": {"num_predict": 1024, "chain": [("large", "tool"), ("large", "bare")]},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def solve(task, level=None, timeout=300):
|
|
33
|
+
"""Answer one electrical task. Returns the answer plus a record of every model call."""
|
|
34
|
+
return numeric.solve(task, pack="electrical", classify=classify, levels=LEVELS, models=MODELS,
|
|
35
|
+
level=level, timeout=timeout)
|
plm_electrical/levels.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Electrical pack: chain cues for the shared numeric level rules (plm/numeric/levels.py).
|
|
2
|
+
|
|
3
|
+
The cues are written from the level definitions there, not fitted per question.
|
|
4
|
+
Evaluate them with: .venv/bin/python evals/eval_levels.py --pack electrical
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from plm.numeric import levels as numeric_levels
|
|
8
|
+
|
|
9
|
+
# Each family is a sign that the answer needs a chain: compute X, then use X.
|
|
10
|
+
CHAIN_CUES = {
|
|
11
|
+
"losses": r"efficien|internal resistance|\blost\b|\bloss|voltage drop|voltage at the",
|
|
12
|
+
"sizing": r"\bmaximum\b|\bminimum\b|needed to|required to|\braise\b|must run",
|
|
13
|
+
"topology": r"\bbridge\b|\bnode\b|\bdelta\b|\bwye\b|in series with a parallel|connected in parallel\b.*\bto the\b|"
|
|
14
|
+
r"through the \d|same circuit|\bthen\b|stage",
|
|
15
|
+
"ac-chain": r"power factor.*(capacit|reactive)|series RLC|series RC.*across|three-phase.*(real|total) power|line current",
|
|
16
|
+
"accumulate": r"\bcost\b|per day|a day|all day|surplus|deficit|\bfalls to\b",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def features(text):
|
|
21
|
+
return numeric_levels.features(text, CHAIN_CUES)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def classify(text):
|
|
25
|
+
"""Return (level, reason)."""
|
|
26
|
+
return numeric_levels.classify(text, CHAIN_CUES)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""The electrical pack's manifest: what the router needs to know about it."""
|
|
2
|
+
|
|
3
|
+
from plm.pack import Pack
|
|
4
|
+
|
|
5
|
+
from plm_electrical import controller
|
|
6
|
+
from plm_electrical.claims import claims
|
|
7
|
+
|
|
8
|
+
UNIT_WORDS = {
|
|
9
|
+
"volts": "V", "millivolts": "mV", "kilovolts": "kV",
|
|
10
|
+
"amperes": "A", "amps": "A", "milliamperes": "mA",
|
|
11
|
+
"milliwatts": "mW", "var": "V*A", "volt-amperes": "V*A",
|
|
12
|
+
"ohms": "ohm", "kilohms": "kohm", "ohm-meters": "ohm*m",
|
|
13
|
+
"hertz": "Hz", "kilohertz": "kHz",
|
|
14
|
+
"watt-hours": "Wh", "kilowatt-hours": "kWh", "coulombs": "C",
|
|
15
|
+
"farads": "F", "microfarads": "uF", "nanofarads": "nF", "farads per meter": "F/m",
|
|
16
|
+
"henries": "H", "millihenries": "mH",
|
|
17
|
+
"siemens": "S", "millisiemens": "mS",
|
|
18
|
+
"decibels": "dB",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
PACK = Pack(name="electrical", version="0.1.0", claims=claims, priority=60, solve=controller.solve,
|
|
22
|
+
levels=controller.LEVELS, models=controller.MODELS, unit_words=UNIT_WORDS,
|
|
23
|
+
eval_set="evals/electrical/problems.jsonl")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: plm-electrical
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: plm pack: Electrical engineering calculations, checked by units and sanity rules
|
|
5
|
+
Project-URL: Homepage, https://github.com/ro-rbl/plm-orchestrator
|
|
6
|
+
Project-URL: Source, https://github.com/ro-rbl/plm-orchestrator
|
|
7
|
+
Project-URL: Issues, https://github.com/ro-rbl/plm-orchestrator/issues
|
|
8
|
+
Author: ro-rbl
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Python: >=3.13
|
|
12
|
+
Requires-Dist: plm-core<0.2,>=0.1
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# plm-electrical
|
|
16
|
+
|
|
17
|
+
Plm pack: Electrical engineering calculations, checked by units and sanity rules.
|
|
18
|
+
|
|
19
|
+
A domain pack for [plm-core](https://github.com/ro-rbl/plm-orchestrator): install it with `plm packs install electrical`, which also pulls the
|
|
20
|
+
models it needs into Ollama. Documentation, benchmark results and caveats: https://github.com/ro-rbl/plm-orchestrator
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
plm_electrical/__init__.py,sha256=7I1SgizGAHMoQfi9HyPMWj005NPQIWHkP68HlevUyu8,83
|
|
2
|
+
plm_electrical/claims.py,sha256=4rCXbYChpwqXqp_B9AhnnfR4nXbqW_wE9bh2UAjf1Oo,1383
|
|
3
|
+
plm_electrical/controller.py,sha256=kB2NaAJv-_H9acxagUCI4Eu_HAg3soWmNt9MAgcDP-E,1494
|
|
4
|
+
plm_electrical/levels.py,sha256=eZSWRCBy5OonHPLijiBwQcqNwIM9AhEFr5FMoWFRKUA,1149
|
|
5
|
+
plm_electrical/manifest.py,sha256=e8c5w2gkIJFCnYtK4HiCM_oFTkh-dWBhKy4IKqYBRRU,979
|
|
6
|
+
plm_electrical-0.1.0.dist-info/METADATA,sha256=jHbp4cjg3dM8fE6C9kPUwQM1Dufppb7GpZZrb8YsWBE,871
|
|
7
|
+
plm_electrical-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
plm_electrical-0.1.0.dist-info/entry_points.txt,sha256=JGkpE6RN8fY0zYp8KrMbTLx5JGtmBrel2WTxxnAWD_A,54
|
|
9
|
+
plm_electrical-0.1.0.dist-info/licenses/LICENSE,sha256=KcrxZgcJO8eG0MOaibWc_3Pxvh6U_KruTKPaGwV6-vA,1063
|
|
10
|
+
plm_electrical-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ro-rbl
|
|
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.
|