refactor: extract hardcoded sats limit in grok L402 proxy
Some checks failed
Tests / lint (pull_request) Failing after 12s
Tests / test (pull_request) Has been skipped

Replace hardcoded sats values with config.settings references:
- grok.py: use settings.grok_sats_hard_cap instead of literal 100
- cli.py: default --price to settings.grok_sats_hard_cap from config

Fixes #937

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-22 21:40:11 -04:00
parent 45bde4df58
commit 91af33d71c
2 changed files with 7 additions and 2 deletions

View File

@@ -125,7 +125,7 @@ def _run_grok_query(message: str) -> dict:
from lightning.factory import get_backend as get_ln_backend
ln = get_ln_backend()
sats = min(settings.grok_max_sats_per_query, 100)
sats = min(settings.grok_max_sats_per_query, settings.grok_sats_hard_cap)
ln.create_invoice(sats, f"Grok: {message[:50]}")
invoice_note = f" | {sats} sats"
except Exception as exc:

View File

@@ -14,10 +14,15 @@ app = typer.Typer(help="Timmy Serve — sovereign AI agent API")
def start(
port: int = typer.Option(8402, "--port", "-p", help="Port for the serve API"),
host: str = typer.Option("0.0.0.0", "--host", "-h", help="Host to bind to"),
price: int = typer.Option(100, "--price", help="Price per request in sats"),
price: int = typer.Option(None, "--price", help="Price per request in sats (default: from config)"),
dry_run: bool = typer.Option(False, "--dry-run", help="Print config and exit (for testing)"),
):
"""Start Timmy in serve mode."""
from config import settings
if price is None:
price = settings.grok_sats_hard_cap
typer.echo(f"Starting Timmy Serve on {host}:{port}")
typer.echo(f"L402 payment proxy active — {price} sats per request")
typer.echo("Press Ctrl-C to stop")