Spaces:
Running
Running
File size: 24,601 Bytes
22def41 628ab0d 22def41 628ab0d 684a9cc 22def41 628ab0d afb6251 ce65d97 8fd5d73 ce65d97 8fd5d73 ce65d97 8fd5d73 ce65d97 684a9cc 628ab0d d7dbd19 d9fb20e 628ab0d d7dbd19 628ab0d d7dbd19 628ab0d afb6251 628ab0d d7dbd19 628ab0d d7dbd19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | ---
title: Electrocheap
emoji: ⚡
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
suggested_hardware: cpu-basic
short_description: XenoWAttz × Bhor Bohr — on-demand customer and NGO analysis
---
# Electrocheap · XenoWAttz × Bhor Bohr
**Electrocheap** is the electricity benchmark and Hugging Face Space.
**XenoWAttz** is the plugin identity, with **Bhor Bohr** visibly associated.
The interface is React; the calculations, REST APIs and MCP tools are Python.
## Portable LLM challenge · v0.5.0
Open **LLM challenge** in the workspace. Choose PT, DE or AU, download the test
and fine-tuning kit, run our chosen model/plugin externally, upload its prediction
JSON and select **Compare predictions**. **Try seasonal baseline** checks this
workflow immediately with a transparent seasonal-naive demo.
The six comparators are archived seasonal naive, Grokked SARIMA + frozen bias,
TimesFM 2.5, Chronos-2 and delegated Astra/Sol diagnostics. No live Astra call,
automatic model replacement, paid inference, fine-tuning job or scheduler starts.
The exact original unavailable KMLAIOps TSF remains unavailable; Grokked is the
recorded Forecast Lab implementation, not a substitute relabeled as that source.
Each of four prompts contains history only through its origin and six target IDs.
Scores use the same 24 targets as the archived comparison, with MAE/RMSE/WAPE/MASE,
per-origin and per-horizon slices, complete prediction coverage and evidence hashes.
Missing/duplicate IDs, wrong panel hashes and nonfinite values are rejected.
Explicit timeouts/refusals/errors stay in the denominator. Incomplete predictions
receive conditional metrics and completion rate, but no comparative MAE gain.
Model/adapter identities are declared by the caller; output hashes do not prove
which model produced them. Four serially dependent origin blocks cannot support a
statistical-superiority claim. This public, reused historical test is retrospective;
use new private or prospective data for a confirmatory benchmark.
The ZIP contains chat-format `train.jsonl` with targets before October 2022,
`validation.jsonl` for October 2022–September 2024 and answer-free
`test-prompts.jsonl` for October 2024–September 2026. Keep evaluation prompts out of
training. This is a small grid-demand exercise, not a bill-savings training corpus.
The kit includes packet, response template, baseline demo and SHA-256 manifest.
| Interface | Operation |
|---|---|
| REST | POST `/api/challenge_packet` with `{"country":"PT"}` |
| REST | POST `/api/challenge_score` with the completed submission template |
| Download | GET `/api/challenge/PT/export` (DE/AU also supported) |
| MCP | `challenge_packet({"payload":{"country":"PT"}})` then `challenge_score({"payload":submission})` |
| Connections | GET `/api/connections` (configuration only; not upstream probes) |
Canonical MCP URL: `https://kugguk-electrocheap.hf.space/mcp-server/mcp`.
A connector bound to a separate older Worker will not inherit these tools; point
that connector at this Space to use the benchmark. News is shown as unconnected
and is unselected/disabled until a server-side SerpApi key is configured. No key
is copied to a client. Numerical analysis and benchmarking remain independent.
From a clone with Git LFS resources available, local export/scoring uses Python
standard-library code only:
```bash
python challenge_cli.py export --country PT --output kit.zip
python challenge_cli.py score --input predictions.json --output report.json
python challenge_cli.py run --country PT --adapter challenge_adapter_example:predict \
--model-id seasonal-naive-demo --revision electrocheap-challenge-v1 \
--output predictions.json
```
Replace the trusted `module:function` adapter with our own inference implementation.
It receives `(task, system_prompt)` and returns `[{"id":...,"forecast":...}, ...]`.
Record exact model, adapter and prompt revisions. Credentials stay in the adapter's
local environment; none are accepted by the public scoring API. Runner exceptions
produce explicit failed targets without exposing exception text. Run metadata
records per-origin latency; provider usage/cost is unmeasured unless our adapter
records it separately. The demo is infrastructure verification, not real LLM inference.
The German Official feeds view now reads all SMARD publication blocks covering
the local calendar month. Both demand and prices must contain every expected hour,
including daylight-saving transitions; negative wholesale prices remain valid.
The same reader supplies monthly demand refreshes. No inner join drops missing hours.
## Right to Energy · animated introduction
The live workspace opens with a **Right to Energy** introduction for households,
NGOs and small businesses: a responsive title panel, animated SVG electrical paths and atomic
orbits, and the user-supplied ten-second Bhor Bohr film. This is an audience and
product theme, not a claim of nonprofit registration or external endorsement.
The message is **Fair bills. Fair returns.** Its wider mission covers electricity,
gas and rooftop solar returns, with supplier prices, network costs, policy charges
and taxes open to evidence-based scrutiny. The current calculation tools cover
electricity; the intro does not present gas analysis or solar payback calculations
as available features, or assert a universal solar payback period.
The film preserves the original 16:9 composition and audio, with optimized
720p and mobile 360p versions. It starts muted and plays only when requested;
the poster loads before the video. Play, pause, replay and sound controls are
available. **Pause motion** stops the SVG animation and playing video, while
reduced-motion preferences start with the animation paused. Hidden/offscreen
video pauses automatically. The sidebar uses its existing static character
poster to avoid a second simultaneous animation.
**Analyse electricity** collapses the introduction and moves focus to the
workspace. Hiding or reopening the intro does not clear inputs or results.
The original source is unchanged; `assets/right-to-energy-media.json` inside
the verified resource bundle records source/output hashes and encoding steps.
## On-demand customer and NGO workspace · v0.4.0
The default **Analyze now** workspace runs a new private job when requested.
It does not load an archived leaderboard or a prefilled customer bill as its
starting state. Archived benchmarks remain available in their existing views.
- **Customer:** upload an anonymous monthly CSV (`month,kwh`, or
`timestamp,value,unit,coverage`), confirm that the months are complete measured
observations, choose a horizon and run a forecast. Twelve consecutive months
support the seasonal baseline; SARIMA, Grokked SARIMA and calendar SARIMAX–GARCH
require 36. A quarter of bills can still support the separate reviewed billing
and quote workflow; it is not enough to fit these seasonal models.
- **NGO:** request official grid-history inference or upload up to ten named
usage/price series. Official history combines the recorded archive prefix with
a newly verified final archive month and up to twelve missing complete months.
PT uses REN mainland `CONSUMPTION`; DE checks every hourly SMARD record across
publication blocks and local daylight-saving boundaries; AU preserves the
five-region NEM scope rather than splicing one regional series into it.
- **Offers:** annual/monthly customer profiles and complete dated supplied
quotes use the existing eligibility and cost calculator. The live API also
accepts up to 100 NGO profiles. Grid forecasts and news do not become retail
tariff quotes. Automatic whole-market retail collection remains incomplete.
- **News:** server-side SerpApi Google News requests add dated public market
context for PT, DE and AU. Customer data never enters the query. News is not
silently used as a fitted exogenous regressor; that requires a separately
recorded historical feature dataset and prospective evaluation.
The latest complete month is computed at request time. For example, on
2026-10-23 it is September 2026; October is still incomplete. Current monthly
inference rejects older observation cutoffs unless API clients explicitly set
`allow_historical_origin=true`, in which case the historical origin is disclosed.
PDF daily allocations cannot be relabeled as measured monthly observations.
Completed, partially successful and failed model runs have distinct statuses.
Source or news failures are explicit; no fabricated data is substituted.
### SerpApi configuration
Add **`SERPAPI_API_KEY` as a Hugging Face Space Secret** in the existing Docker
Space. Do not place the key in a React variable, source file, query supplied by a
customer, or browser request. No key is included in this repository.
Optional server configuration:
| Variable | Default | Purpose |
|---|---|---|
| `ELECTROCHEAP_NEWS_DAILY_LIMIT` | `6` | Conservative upstream attempts per UTC day |
| `ELECTROCHEAP_NEWS_MONTHLY_LIMIT` | `180` | Attempts per UTC calendar month |
| `ELECTROCHEAP_NEWS_DB_PATH` | Writable `/data`, otherwise `/tmp` | SQLite cache and local budget |
Public news is shared in a one-hour cache. No API retry or uncached public
override is exposed. Local quotas cover processes sharing the SQLite file;
ephemeral storage can reset on a Space restart, and independent replicas need
a shared budget service. Use the provider's own account cap for an account-wide
spending limit. The default build uses one CPU Basic replica and does not
purchase hardware or a SerpApi plan. Without a key, news returns
`not_configured` while numerical analysis remains available.
Official monthly refreshes have a ten-minute public cache. Earlier archived
months retain their original vintage; they are not represented as all being
re-fetched. Private customer inputs/results are never placed in these caches.
### Live endpoints and MCP tools
| Endpoint | Purpose |
|---|---|
| GET `/api/runtime` | Lightweight readiness, limits and latest complete month; no source or inference call |
| POST `/api/live_analysis` | Queue a composed customer/NGO request; returns private `job_id` |
| POST `/api/market_news` | Dated public news, cache and source status |
| POST `/api/analysis_result` | Poll the existing job; completed response includes `inference_status` |
The corresponding new MCP tools are **`live_analysis`** and **`market_news`**.
All existing tools remain available at `/mcp-server/mcp`.
Example NGO request, using the existing CPU queue and fresh source verification:
```json
{
"role": "ngo",
"country": "PT",
"use_official_history": true,
"horizon_months": 12,
"models": ["seasonal_naive", "grokked_sarima"],
"include_market": true,
"include_news": true
}
```
Uploaded series additionally require `observations_are_measured: true`. A
request without numerical data is explicitly a market brief. News is presented
with publisher date, ingestion date, cache status and article links. The private
audit ZIP includes exact refreshed model inputs, normalized requested inputs,
results, source provenance and implementation hashes. It expires with the job
after one hour or restart. Navigating among workspace tabs preserves the active
job in that browser tab; this is not a persistent authenticated customer account.
### Validation for this change
The resource bundle includes tests for input freshness, measured/allocated data,
private job separation, official publication coverage, model failures, API/MCP
compatibility, news normalization, quota concurrency, cache expiry and secret
redaction. News tests use mocked provider responses; connecting a real SerpApi
account still requires the server secret above. Test and live-source evidence
are recorded separately so a mocked test is never represented as a live search.
Space: `kugguk/electrocheap`. CPU Basic; no hardware upgrades, paid inference
calls, paid Jobs or new storage subscription are required by this build.
The public React runtime, REST APIs, MCP tools and a hosted Portugal
CPU benchmark were verified on 2026-10-10. Publication evidence is tracked in
`deployment_status.json` and `validation/build_status.json`.
## Run and maintain
Python 3.12 and Node 22.12+ are sufficient locally. Docker is used by Hugging
Face hosting; no Docker CLI or uv is required for local development.
```bash
bash start.sh
```
For frontend development, run the Python server and `npm run dev` in separate
terminals. Vite proxies API, download and branding requests to port 7860.
`npm run build` creates `dist/`; the same build runs in the Dockerfile's Node
stage. React, React DOM, Vite and the CSV parser are pinned with package-lock.json.
- `App.jsx`, `main.jsx`, `styles.css`: frontend; calculations stay in Python.
- `app.py`: FastAPI REST endpoints, static assets and stateless MCP server.
- `core.py`, `billing.py`: quote arithmetic, eligibility and monthly-bill validation.
- `benchmark.py`: chronological CPU benchmark protocol v2.
- `models.py`: full archived model evidence and version metadata.
- `sources.py`: allowlisted official data readers, no arbitrary user URL fetching.
Browser deployment keeps root source files plus `resources.zip` and its SHA-256
manifest. `bundle.py` validates archive membership, hashes and contained paths
before unpacking data, model evidence, tests, scripts, validation and the supplied XenoWAttz branding video.
The archive contains no customer bills, credentials or model weights.
## Markets and scope
| Market | Demand snapshot | Currency | Scope |
|---|---|---|---|
| Portugal | REN monthly energy | EUR | Mainland only |
| Germany | SMARD grid load | EUR | Grid load, not all final energy consumption |
| Australia | AEMO NEM energy | AUD | NSW1, QLD1, SA1, TAS1, VIC1; excludes WA/NT |
All three bundled demand snapshots contain 141 complete monthly aggregates,
January 2015–September 2026. They are current revised history, not independent
historical publication vintages. Wholesale prices are not retail tariffs;
national grid demand is not retailer customer demand. Provider benchmarks
require supplied data with an explicit provider column.
Complete historical wholesale-price series are **not bundled**: acquisition
was blocked by this build environment. Price benchmarking accepts an uploaded
series of at least 72 complete months; live price readers are available.
## REST and MCP
Swagger documentation: `/docs`. REST calls use JSON objects directly.
| Endpoint | Purpose |
|---|---|
| POST `/api/consumer_compare` | One household/site's eligible supplied quotes |
| POST `/api/ngo_compare` | Up to 100 anonymous profiles; currencies separate |
| POST `/api/model_evidence` | Archived grid scores and exact model versions |
| POST `/api/billing_import` | Multipart ZIP/PDF/CSV/JSON import; temporary private job |
| POST `/api/provider_history` | Dated supplied provider tariffs, separated by VAT and contract |
| POST `/api/analysis_submit` | Bulk CPU forecasts, benchmarks or constrained swap scenarios |
| POST `/api/analysis_result` | Poll/page private results and get an audit export link |
| POST `/api/dataset_inspect` | Public benchmark dataset manifest or paged records |
| GET `/api/analysis/{job_id}/export` | Private normalized audit ZIP, one-hour expiry |
| GET `/api/datasets/audit.zip` | Public source snapshots, truth, predictions and protocol |
| POST `/api/benchmark` | CPU demand or wholesale-price benchmark |
| POST `/api/live_market` | Official data for a complete selected month |
| POST `/api/aer_plans` | Australian retailer plan list |
| POST `/api/aer_detail` | Full selected plan detail |
| GET `/api/health` | Build identity and readiness |
MCP tools are `consumer_compare`, `ngo_compare`, `model_evidence`, `billing_import`,
`provider_history`, `analysis_submit`, `analysis_result` and `dataset_inspect`,
through Streamable HTTP at `/mcp-server/mcp`. They perform calculations/read evidence; no contracting,
supplier switching, paid inference, or account/payment mutation is exposed.
### Latest-year bills
Supply `billing_months` instead of `annual_kwh` and `current_annual_bill`:
exactly twelve complete monthly records immediately before `as_of` (default today).
Each record has `month` (YYYY-MM), `kwh`, `billed_total`, `currency`, and optional
`peak_kwh` for every month. Use actual tax-inclusive electricity charges, not
bank-payment instalments. Remove names, addresses and account numbers.
Contradictory annual overrides, duplicate/missing months and currency mismatches
are rejected. The UI parses CSV locally and sends normalized records on request.
The fictional Oct 2025–Sep 2026 sample totals 3,820 kWh and EUR 1,019. A year of
monthly bills supplies one seasonal cycle; it is a historical usage scenario,
not proof of a household forecasting winner.
### Supplied offers
Use `data/quote_template.csv`. All fields are required:
`offer_id,provider,country,region,currency,customer_type,tariff_type,rate_per_kwh,
offpeak_rate_per_kwh,daily_charge,annual_fees,guaranteed_credit,switching_cost,
tax_included,valid_from,valid_to,checked_at,source_url,evidence,conditions,
meter_type,price_guaranteed_months`.
First-year cost is `kWh × rate + 365 × daily_charge + annual_fees + switching_cost
− guaranteed_credit`. TOU uses supplied peak/off-peak shares. Quotes must be
tax-inclusive, open for enrolment, eligible for region/customer/meter and checked
within 14 days. Conditions require acknowledgement by offer ID. Country-wide
eligibility must explicitly use `ALL`. Currency is PT/DE EUR, AU AUD.
`evidence` is `submitted_quote` or `illustrative`; illustrative data is disabled
by default. Uploaded quotes are not independently verified. Complex demand,
capacity, indexed, tiered, controlled-load and export tariffs need a complete
scoped quote before comparison. No whole-market or realized-savings claim.
## Model families and versions
`model_evidence({"country":"PT"})` returns the full archived 2026-10-09 results:
TSF/Forecast Lab, Grokked SARIMA, TimesFM 2.5, Chronos-2 and Astra/Sol diagnostics.
The test contains 24 targets over four six-month forecast origins. Checkpoint
revisions and library versions are preserved in `foundation_config.json`.
Astra/Sol were delegated test-only diagnostics, not separately authenticated
provider API benchmarks. No live transformer/LLM inference is active here.
The unavailable original KMLAIOps TSF SARIMAX-GARCHX and a distinct Super Grokked
source are explicitly identified as unavailable. New adapters are never relabeled
as those exact implementations. Historical grid scores do not select a household
forecaster or demonstrate bill savings. No statistical superiority is claimed.
Live CPU protocol v2 includes seasonal naive/drift, SARIMA, frozen bias,
Grokked SARIMA (explicit 80/20 SARIMA/seasonal blend), calendar SARIMAX and
SARIMAX with GARCH(1,1) residual volatility. Known month length and weekday count
are the only calendar covariates. Scaling uses training observations only.
GARCH uses training residuals after a 12-month burn-in; it keeps the mean
forecast unchanged and does not supply calibrated multi-step intervals.
All fits must converge. Bias is capped and frozen in calibration. Validation
selects the model with a 5% improvement gate before test scoring.
Minimum input: 72 consecutive complete local month-start observations with
`timestamp,value,unit,coverage`. Maximum 600 records. `coverage=1` throughout;
no interpolation. Demand uses nonnegative GWh. Prices use EUR/MWh or AUD/MWh
and can be negative. Three final 12-month blocks serve calibration, validation
and test. Scores are descriptive retrospective evidence; reused tests are exploratory.
New v2 outputs are `validation/*_benchmark_v2.json`.
## Verification and limits
```bash
python -c "from bundle import ensure_resources; ensure_resources()"
python -m pytest -q tests test_challenge.py
npm run build
python scripts/smoke_app.py
```
The smoke check serves the production React build, calls REST quote/bill/model
endpoints and performs actual MCP initialization, tool discovery and a quote
calculation. The financial tests cover arithmetic, exclusion rules, dates,
currency, monthly-bill validation and portfolio aggregation. Chronological
tests ensure test actuals cannot change selection, calibration or predictions.
This is a public research service without customer billing, tenant isolation,
or automatic switching. EDP Portugal text PDFs can now be extracted; other templates
and scans require normalized data. Raw documents are discarded after processing;
anonymous results are held in a bounded in-memory store for one hour or until restart.
An opaque job ID is a bearer capability, not an authenticated customer account.
There is no customer-data database. JSON/CSV analysis limit is 2 MB; compressed
imports accept up to 25 MiB combined, 250 members / 100 MiB expanded, no nested ZIPs.
One bulk CPU queue and the existing single benchmark worker
runs at a time. Network readers use a 15-second timeout and reject failed or
incomplete feeds; previous results are never labeled fresh. AER complex plans
are shown as source records and never silently flattened into savings.
## Compressed billing and bulk scenario workflow (v0.3)
Open **Bulk & swaps** in React, upload one or more billing archives and wait for
the import to complete. Inspect each meter, its billing period, totals and source
hashes, then explicitly accept any allocated/annualized profile before using it.
Electricity, services, water and payment adjustments are not combined. PDF month
values are uniform daily allocations inside invoice periods, not measured monthly
consumption. The archive parser supports EDP Portugal text PDFs and anonymous monthly
CSV/JSON for PT/DE/AU. Normalized German EUR rows must include `country=DE`.
ChatGPT file inputs use the official top-level `files` array and
`_meta["openai/fileParams"]`: the host supplies `download_url`, `file_id`, and
optional `file_name`/`mime_type`. Only direct signed OpenAI attachment URLs are
downloaded, without credentials and with size limits; arbitrary URLs and redirects
are rejected. Space upload is a fallback if file delivery is unsupported by the host.
`analysis_submit` returns immediately with a private `job_id`; poll `analysis_result`.
Use `kind=forecast` for up to ten series and 1–36-month live CPU inference. Available
models are `seasonal_naive`, `sarima`, `grokked_sarima`, `sarimax_garch`. Statistical
models require 36 consecutive complete months; seasonal naive needs twelve.
Grokked is the explicit 80% SARIMA + 20% last-year template implementation, not an
unavailable distinct Super Grokked source. Transformer and hosted LLM results remain
archived; no API keys or GPU expenditure are enabled. `kind=benchmark` accepts up to
three complete grid/wholesale histories with at least 72 months each.
For `kind=switching`, supply reviewed anonymous profiles or `import_job_id`, complete
tax-inclusive offers, horizons such as `[3,12,36]`, and named `price_scenarios` with
provider-to-annual-change maps. Optional `rate_curve` maps YYYY-MM to a flat tariff's
tax-inclusive energy rate. Supply matching `contracted_power_kva` where known.
`minimum_term_months`, `exit_fee`, `credit_vesting_months` and `price_guaranteed_months`
are enforced. Signup credit is granted once per provider, with early-exit clawback;
unvested terminal credit is provisioned. Unpriced commitments beyond the horizon
are excluded. Future enrolment is not presumed unless `assume_future_enrolment=true`
is explicitly requested; otherwise later entries need dated `entry_months` within
the supplied enrolment window. Default unknown term/exit fees are zero assumptions,
not verified contract terms. Monthly switching has no activation-delay model.
The dynamic program returns a constrained minimum **within the supplied assumptions**.
It does not predict an unknowable future tariff winner, negotiate a contract or switch
suppliers. Short/middle/long scenarios can share supplied forecasts, but grid forecast
accuracy is not evidence of household savings or of collusion/market power.
Download the private result ZIP before expiry. It contains normalized inputs/results,
source hashes, implementation and version metadata, excluding raw bills and account
identifiers. Public audit downloads contain official grid snapshots and recorded model
evidence only. Customer records are never added to public datasets or committed here.
The plugin remains a private preview; this update does not submit it publicly.
|