package com.optix.android.ai.providers

import com.optix.android.ai.MockBrain
import com.optix.android.domain.model.AiProviderConfig
import com.optix.android.domain.model.AiProviderType
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class AiProviderFactory @Inject constructor(
    private val mockBrain: MockBrain,
) {
    fun create(config: AiProviderConfig): LlmProvider = when (config.provider) {
        AiProviderType.OFFLINE    -> OfflineProvider(mockBrain)
        AiProviderType.GEMINI     -> GeminiProvider(config.apiKey, config.model.ifEmpty { "gemini-2.0-flash" })
        AiProviderType.OPENAI     -> OpenAiProvider(config.apiKey, config.model.ifEmpty { "gpt-4o" })
        AiProviderType.GROQ       -> OpenAiProvider(config.apiKey, config.model.ifEmpty { "llama-3.3-70b-versatile" }, "https://api.groq.com/openai/v1")
        AiProviderType.MISTRAL    -> OpenAiProvider(config.apiKey, config.model.ifEmpty { "mistral-large-latest" }, "https://api.mistral.ai/v1")
        AiProviderType.OPENROUTER -> OpenAiProvider(config.apiKey, config.model.ifEmpty { "openai/gpt-4o" }, "https://openrouter.ai/api/v1")
        AiProviderType.ANTHROPIC  -> AnthropicProvider(config.apiKey, config.model.ifEmpty { "claude-3-7-sonnet-20250219" })
    }
}
