Short God messages, escpos cost printing, Anthropic provider fixes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+20
-2
@@ -2070,9 +2070,27 @@ def _anthropic_call(model: str, system: str, user: str, config: dict,
|
||||
# Track cost (Haiku pricing)
|
||||
cost = (input_tokens / 1_000_000) * 0.80 + (output_tokens / 1_000_000) * 4.00
|
||||
with _anthropic_cost_lock:
|
||||
prev_dollar = int(_anthropic_total_cost)
|
||||
_anthropic_total_cost += cost
|
||||
if int(_anthropic_total_cost * 100) % 50 == 0 or _anthropic_total_cost >= budget * 0.9:
|
||||
log.info(f"Anthropic cost: ${_anthropic_total_cost:.4f} / ${budget:.2f}")
|
||||
curr_dollar = int(_anthropic_total_cost)
|
||||
if curr_dollar > prev_dollar:
|
||||
log.info(f"Anthropic cost milestone: ${_anthropic_total_cost:.4f} / ${budget:.2f}")
|
||||
# Print to POS printer
|
||||
try:
|
||||
import socket as _sock
|
||||
from escpos.printer import Dummy as _Dummy
|
||||
_p = _Dummy(profile="default")
|
||||
_p.set(font='b', align='center', bold=True)
|
||||
_p.text("MC AI TRAINING COST\n")
|
||||
_p.set(font='b', align='center', bold=False)
|
||||
_p.text(f"${_anthropic_total_cost:.4f} / ${budget:.2f}\n")
|
||||
_p.text(f"{time.strftime('%Y-%m-%d %H:%M')}\n")
|
||||
_p.text("=" * 57 + "\n")
|
||||
_p.cut()
|
||||
with _sock.create_connection(("192.168.0.137", 9100), timeout=5) as _s:
|
||||
_s.sendall(_p.output)
|
||||
except Exception as _pe:
|
||||
log.warning(f"POS print failed: {_pe}")
|
||||
|
||||
return text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user