Files
clicktrack/lib/analysis/providers.ts
AJ Avezzano 5e686fc9c4 feat: MusicBrainz BPM enrichment + improved AI prompts
- lookupRecordingWithTags, extractBpmFromTags, extractTimeSigFromTags, getMusicBrainzRecording added to MB client
- upsertSong preserves existing BPM via COALESCE on conflict
- updateSongBpm helper for async enrichment writes
- AnalysisInput gains confirmedBpm / confirmedTimeSigNum fields
- POST /api/analyze fetches confirmed BPM from DB then MB tags before generation
- All three AI providers use confirmedBpm as authoritative and build enriched userMessage
- POST /api/tracks auto-registration now fetches tags via getMusicBrainzRecording
- Updated User-Agent and MB client fallback URL to Gitea

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:25:04 -04:00

32 lines
1.0 KiB
TypeScript

import type { CTPDocument } from '@/lib/ctp/schema';
export interface AnalysisInput {
bpm: number;
duration: number; // seconds
title?: string;
artist?: string;
mbid?: string | null;
contributed_by: string;
ollamaModel?: string; // required when provider id is "ollama"
confirmedBpm?: number | null; // from MusicBrainz tags or other reliable source
confirmedTimeSigNum?: number | null; // time signature numerator if confirmed
}
export interface ProviderInfo {
id: string;
label: string;
type: 'cloud-ai' | 'local-ai' | 'algorithmic';
available: boolean;
unavailableReason?: string; // present only when available === false
ollamaBaseUrl?: string; // present only for the ollama provider
}
export interface AnalysisProvider {
id: string;
label: string;
type: 'cloud-ai' | 'local-ai' | 'algorithmic';
/** Returns true if this provider is configured and reachable. Must not throw. */
isAvailable(): Promise<{ available: boolean; reason?: string }>;
generateCTP(input: AnalysisInput): Promise<CTPDocument>;
}