Class: WeeklyLlmModelSyncWorker
- Inherits:
-
Object
- Object
- WeeklyLlmModelSyncWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/weekly_llm_model_sync_worker.rb
Overview
Weekly sync of the live provider model registry into the llm_models table.
After syncing, validates every model referenced in AiModelConstants against
the refreshed registry and sends a report when issues are detected.
Runs weekly (Monday 3 AM CT) via sidekiq-cron. New flagship releases are rare
(roughly monthly), so a weekly cadence catches them with far less email noise
than a nightly run. For an on-demand sync after pinning a new model in
AiModelConstants, run mise exec -- bin/rails llm:sync. Idempotent — safe to re-run.
Instance Method Summary collapse
-
#perform ⇒ Object
Runs the job.
Instance Method Details
#perform ⇒ Object
Runs the job.
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 |
# File 'app/workers/weekly_llm_model_sync_worker.rb', line 20 def perform sync_started_at = Time.current before = LlmModel.count LlmModel.refresh! after = LlmModel.count new_models = LlmModel.where(created_at: sync_started_at..).order(:provider, :model_id).to_a # Check all registered constants against the freshly-synced model list. unavailable = AiModelConstants.validate_availability stale_anthropic = AiModelConstants.stale_anthropic_defaults Rails.logger.info "[WeeklyLlmModelSyncWorker] Synced #{after} models (#{after - before} new)" unavailable.each do |role, info| if info[:status] == :no_fallback Rails.logger.error "[WeeklyLlmModelSyncWorker] CRITICAL: #{role} primary #{info[:primary].inspect} " \ "not in provider APIs and NO fallback available" else Rails.logger.warn "[WeeklyLlmModelSyncWorker] #{role}: primary #{info[:primary].inspect} unavailable, " \ "fallback #{info[:active_fallback].inspect} will be used at runtime" end end stale_anthropic.each do |role, info| Rails.logger.warn "[WeeklyLlmModelSyncWorker] Stale Anthropic default: #{role} = #{info[:current].inspect}, " \ "latest = #{info[:recommended].inspect}" end return unless (after - before) > 0 || unavailable.any? || stale_anthropic.any? send_report( models_total: after, models_added: after - before, new_models: new_models, unavailable_models: unavailable, stale_defaults: stale_anthropic ) end |