/**
 * Model capability detection for native audio input support.
 *
 * Models that support native audio will receive raw audio data directly.
 * Models that don't will receive a Whisper transcript as text instead.
 */

export type ModelProvider = 'anthropic' | 'openai' | 'gemini' | 'bedrock' | 'github' | 'ollama' | 'llamacpp' | 'openrouter' | 'zhipuai' | 'xai';

/**
 * Models known to support native audio input via their API.
 * We use an allowlist (not a provider-level blanket) to avoid silently
 * dropping audio for models that don't actually handle audio content parts.
 */
const AUDIO_CAPABLE_MODELS = new Set<string>([
  // Gemini — all current models support audio
  'gemini-2.0-flash',
  'gemini-2.0-pro',
  'gemini-1.5-flash',
  'gemini-1.5-pro',
  // OpenAI — only multimodal audio models
  'gpt-4o',
  'gpt-4o-mini',
  'gpt-4o-audio-preview',
]);

/** Providers where all models support audio (e.g. Gemini). */
const AUDIO_CAPABLE_PROVIDERS = new Set<string>([
  'gemini',
]);

/**
 * Check whether a provider+model combination supports native audio input.
 *
 * Returns true if the model can receive raw audio data directly via its API,
 * false if audio must be transcribed to text before sending.
 */
export function supportsAudioInput(provider: string, model: string, override?: boolean): boolean {
  if (override !== undefined) {return override;}

  // Provider-level blanket (all models support audio)
  if (AUDIO_CAPABLE_PROVIDERS.has(provider)) {
    return true;
  }

  // Model-level allowlist
  if (AUDIO_CAPABLE_MODELS.has(model)) {
    return true;
  }

  return false;
}
