Commit Graph
636 Commits
Author SHA1 Message Date
Shroominic 384a149600 fix tests 2025-10-04 20:52:15 +08:00
Shroominic 719c091145 ruff fmt 2025-10-04 20:19:04 +08:00
Shroominic c90abe9e79 update version 2025-10-04 20:12:28 +08:00
Shroominic 36d55216fe fix tests 2025-10-04 17:38:05 +08:00
Shroominic f657859249 refactor upstream functions into UpstreamProvider class 2025-10-04 17:38:00 +08:00
Shroominic f8090f5c35 dontations endpoint 2025-10-02 14:55:02 +08:00
shroominicandGitHub b2e5da4b46 Merge pull request #180 from Routstr/sh1ftred-patch-1
Fixed the bug where refund amount is below 1 sat for a sat mint
2025-09-23 12:40:43 +01:00
redshiftandGitHub 729f00caa2 Fixed the bug where refund amount is below 1 sat for a sat mint 2025-09-22 16:55:16 +00:00
Shroominic 54d7a5a247 fix periodic payouts 2025-09-22 17:54:28 +01:00
redshiftandGitHub ecbe3158c0 Merge pull request #179 from Routstr/503-mint-service-bug
Fixed the 503 mint service unavailable bug
2025-09-22 16:27:36 +00:00
redshiftandGitHub bac50f2150 Fixed the 503 mint service unavailable bug
This flag fetch all keysets from the db into the wallet, which is wrong given that we're initiating it for a mint. And load_mint sets the first keyset from all the keysets from the db, irrespective of the unit and the mint. 

Fixes #175
2025-09-22 16:25:02 +00:00
Shroominic 150f3084c1 remove need for ADMIN_PASSWORD, added in initial setup 2025-09-22 16:40:48 +01:00
Shroominic d4e1715613 improved upstream error message handling 2025-09-22 16:36:52 +01:00
Shroominic c2a26a3c00 v1/providers redirect to v1/providers/ 2025-09-22 16:36:35 +01:00
Shroominic 8e0ae6cbc8 filter out openrouter spam models 2025-09-22 13:46:07 +01:00
Shroominic 18a055ee2c add models.json batch paste 2025-09-22 12:58:53 +01:00
Shroominic c5289364e4 models admin dashboard 2025-09-22 12:47:39 +01:00
Shroominic 5fb583be55 v0.1.4-dev 2025-09-22 11:11:36 +01:00
shroominicandGitHub 4bf02226dc Merge pull request #172 from Routstr/fix-max-tokens-string-int
fix max-tokens coming in as string
2025-09-16 13:05:39 +01:00
Shroominic c8f4e7d3e5 fix max-tokens coming in as string 2025-09-16 13:00:38 +01:00
shroominicandGitHub 3d4a8e0e14 Merge pull request #169 from Routstr/dev
## Routstr v0.1.3 — 2025-09-15

### Highlights

- **DB-backed settings with live updates**: Env vars seed on first run; DB is the source of truth (except `DATABASE_URL`). Manage via Admin UI or `PATCH /admin/api/settings`.
- **Models moved to database** with background sats-pricing computation and optional periodic refresh.
- **Smarter max-cost reservation**: Discount based on prompt tokens and `max_tokens` using `TOLERANCE_PERCENTAGE`, with a `MIN_REQUEST_MSAT` floor.
- **Faster startup and provider discovery**; `.onion` endpoints use Tor proxy by default.

### Breaking changes

- **Configuration is DB-first** after bootstrap. Env changes won’t auto-apply (besides `DATABASE_URL`).
- **Models endpoint**: Use `/v1/models` for canonical model info; `/v1/info` keeps an empty `models` field for back-compat.
- **Legacy pricing envs** are auto-mapped but deprecated:
  - `MODEL_BASED_PRICING` → `!FIXED_PRICING`
  - `COST_PER_REQUEST` → `FIXED_COST_PER_REQUEST`
  - `COST_PER_1K_*` → `FIXED_PER_1K_*`

### Added

- **SettingsService** with env→computed→DB merge; runtime edits; app metadata (name/description) applied to OpenAPI.
- **Automatic migrations** on startup; new tables: `settings`, `models`.
- **Per-model sats pricing** and per-request maximums computed in the background.
- **Pricing controls**: `FIXED_PRICING`, `FIXED_COST_PER_REQUEST`, optional per-1k token overrides, `MIN_REQUEST_MSAT`.
- **Azure chat support**: Optional `CHAT_COMPLETIONS_API_VERSION` adds `api-version` to `/chat/completions`.
- **Derive `NPUB` from `NSEC`** during bootstrap if not provided.

### Changed / Improvements

- **Proxy header hardening**: Strip sensitive headers; replace Authorization with upstream key when configured.
- **Discovery**: Read `RELAYS` from settings; Tor proxy defaults for `.onion` via `TOR_PROXY_URL`; faster announcement fetching.
- **Admin**: Improved auth/log UX; fixed log search; show mint balances in dashboard.
- **Performance**: Optimized startup; lazy DB info loading.

### Fixed

- **Refunds**: Correct msat→sat conversion; configurable refund cache TTL via `REFUND_CACHE_TTL_SECONDS`; better error mapping for mint outages.
- **Balances**: Reserved balance reporting and negative-reserved edge cases.
- **Tests**: Updated to patch settings and use fixed-pricing flags.

### Upgrade notes (from v0.1.2)

1. Ensure `DATABASE_URL`, `UPSTREAM_BASE_URL`, and `ADMIN_PASSWORD` are set. Optionally set `UPSTREAM_API_KEY`, `RELAYS`, `CASHU_MINTS`, `TOR_PROXY_URL`.
2. Start the service; automatic Alembic migrations will run (`settings`, `models` tables).
3. Configure settings via Admin UI (`/admin`) or `PATCH /admin/api/settings`. Env changes after first run won’t apply automatically.
4. Prefer new pricing envs or a `models.json` at `MODELS_PATH`. Legacy envs are mapped but will be removed in a future release.
5. Optional tuning: `TOLERANCE_PERCENTAGE`, `MIN_REQUEST_MSAT`, `PRICING_REFRESH_INTERVAL_SECONDS`, `MODELS_REFRESH_INTERVAL_SECONDS`, `ENABLE_*_REFRESH`.
6. For Azure, set `CHAT_COMPLETIONS_API_VERSION`.

### References

- Configuration: `docs/getting-started/configuration.md`
- API: `docs/api/endpoints.md`
- Custom pricing: `docs/advanced/custom-pricing.md`

### Stats and credits

- 42 files changed, +1819/−832 lines.
- Merges: #170 token-discount-max-cost, #171 move-models-to-db.
- Contributors: Shroominic.
v0.1.3
2025-09-16 12:43:54 +01:00
Shroominic 8b9d53be3c fix deps issue 2025-09-15 18:04:35 +01:00
Shroominic 11a01dae89 fix pytests 2025-09-15 18:01:01 +01:00
Shroominic 9ab269dd8f ⬆️ v0.1.3 2025-09-15 17:55:20 +01:00
Shroominic c263d38732 add reserved balance info 2025-09-15 17:38:51 +01:00
Shroominic c4f84cd1e6 Merge remote-tracking branch 'refs/remotes/origin/dev' into dev 2025-09-11 13:40:36 +01:00
shroominicandGitHub 0478b1c360 Merge pull request #171 from Routstr/move-models-to-db
Move models to db
2025-09-11 13:40:04 +01:00
Shroominic 633ae39622 optimize startup time and announcement fetching 2025-09-11 13:39:29 +01:00
Shroominic 84ff9f5dc3 update default relays 2025-09-11 13:38:04 +01:00
Shroominic 88ec3395c7 fix: missing mints balances in admin dashboard 2025-09-11 12:51:03 +01:00
Shroominic 49485435ad fix admin log search 2025-09-11 12:46:06 +01:00
Shroominic d80df28b23 rm not needed setting 2025-09-11 12:42:23 +01:00
Shroominic 4cdbf23ec0 fixes 2025-09-10 13:28:48 +01:00
Shroominic 73d3613301 move MODELS to DB 2025-09-10 13:28:43 +01:00
shroominicandGitHub 6993e6b156 Merge pull request #170 from Routstr/token-discount-max-cost
max cost discount
2025-09-09 18:30:14 +01:00
Shroominic 6d1525748d fix tests 2025-09-09 18:27:48 +01:00
Shroominic 57ac38e6dc fix test patches 2025-09-09 14:27:25 +01:00
Shroominic 2e42af61bb rm tolerance percentage args 2025-09-09 14:00:39 +01:00
Shroominic 7dfc2f4056 max cost discount 2025-09-09 13:58:52 +01:00
Shroominic 2b045c95c7 dev version indicator 2025-09-08 14:52:52 +01:00
Shroominic 665b3f9a16 lazy load db information 2025-09-08 13:43:17 +01:00
Shroominic dcbaf7413a edit settings over admin dashboard 2025-09-08 12:57:29 +01:00
Shroominic 918a083a12 cleanup admin auth 2025-09-08 12:48:27 +01:00
Shroominic 7c9265b40d feat(settings): derive NPUB from NSEC during bootstrap (similar to ONION discovery) 2025-09-08 12:29:41 +01:00
Shroominic 44030ddbe5 docs: simplify discovery config (RELAYS only); drop OpenRouter BASE_URL mentions 2025-09-08 12:26:22 +01:00
Shroominic be372c48ea refactor(settings): remove NIP-91 fields; keep relays under discovery; drop openrouter_base_url 2025-09-08 12:24:32 +01:00
Shroominic 939a991d6b chore: update version/readme; minor auth logging and settings usage 2025-09-08 10:53:41 +01:00
Shroominic bb9991e7a5 docs: update configuration/pricing docs and compose with FIXED_* vars 2025-09-08 10:53:32 +01:00
Shroominic 496900baa6 test: update tests to patch settings and use fixed pricing flags 2025-09-08 10:53:23 +01:00
Shroominic 8f22826d63 fix(balance): correct sat refund conversion from msats and use settings for TTL 2025-09-08 10:53:11 +01:00