Skip to content

v0.4.0

@hudhaifas hudhaifas tagged this 25 Apr 01:04
Split monolithic service.py (828 lines) into focused modules:
- providers.py: extensible provider registry (register_provider,
  create_chat_model, create_transcription_client)
- chat.py: agent chat/resume, HITL, conversation history
- service.py: slim AIService facade (invoke, chat, resume, transcribe)

New capabilities:
- ai_service.transcribe(): Whisper with chunking, duration-based cost,
  credit deduction, and usage logging
- register_provider(): add Google, Bedrock, or any provider at startup
- register_transcription_provider(): add Deepgram or any transcription
  provider
- explicit_cost_usd on _record_usage(): non-token models (Whisper) get
  accurate cost tracking

Fixes:
- AIUsageLog.save(): cost_usd=Decimal('0') no longer overwritten
  (was falsy check, now None check)
- subprocess timeouts on ffprobe (30s) and ffmpeg (300s)
- AIModel.provider: removed hardcoded choices, now free-form with
  admin help text showing registered providers

Tests: 93 unit tests across 7 files (was 40 across 4 files)
- test_providers.py: registry, resolution, custom providers, API keys
- test_chat.py: usage extraction, interrupt counting, history keys
- test_record_usage.py: token cost, explicit cost, credit deduction
- Regression test for Decimal('0') falsy bug

Breaking: None. All existing imports still work. service.py re-exports
everything consumers need.
Assets 2
Loading