from odoo import api, fields, models


class EncoachAISettings(models.TransientModel):
    _inherit = "res.config.settings"

    # ── OpenAI ──
    ai_openai_api_key = fields.Char(
        string="OpenAI API Key",
        config_parameter="encoach_ai.openai_api_key",
    )
    ai_openai_model = fields.Selection(
        [("gpt-4o", "GPT-4o"), ("gpt-4o-mini", "GPT-4o Mini"), ("gpt-3.5-turbo", "GPT-3.5 Turbo")],
        string="OpenAI Model",
        default="gpt-4o",
        config_parameter="encoach_ai.openai_model",
    )
    ai_openai_fast_model = fields.Selection(
        [("gpt-4o-mini", "GPT-4o Mini"), ("gpt-3.5-turbo", "GPT-3.5 Turbo")],
        string="OpenAI Fast Model",
        default="gpt-3.5-turbo",
        config_parameter="encoach_ai.openai_fast_model",
    )

    # ── AWS Polly ──
    ai_aws_access_key = fields.Char(
        string="AWS Access Key ID",
        config_parameter="encoach_ai.aws_access_key",
    )
    ai_aws_secret_key = fields.Char(
        string="AWS Secret Access Key",
        config_parameter="encoach_ai.aws_secret_key",
    )
    ai_aws_region = fields.Char(
        string="AWS Region",
        default="eu-west-1",
        config_parameter="encoach_ai.aws_region",
    )

    # ── ElevenLabs ──
    ai_elevenlabs_api_key = fields.Char(
        string="ElevenLabs API Key",
        config_parameter="encoach_ai.elevenlabs_api_key",
    )
    ai_elevenlabs_model = fields.Char(
        string="ElevenLabs Model",
        default="eleven_multilingual_v2",
        config_parameter="encoach_ai.elevenlabs_model",
    )
    ai_tts_provider = fields.Selection(
        [("polly", "AWS Polly"), ("elevenlabs", "ElevenLabs")],
        string="TTS Provider",
        default="polly",
        config_parameter="encoach_ai.tts_provider",
    )

    # ── GPTZero ──
    ai_gptzero_api_key = fields.Char(
        string="GPTZero API Key",
        config_parameter="encoach_ai.gptzero_api_key",
    )

    # ── ELAI ──
    ai_elai_token = fields.Char(
        string="ELAI Token",
        config_parameter="encoach_ai.elai_token",
    )

    # ── Operational ──
    ai_max_retries = fields.Integer(
        string="Max Generation Retries",
        default=3,
        config_parameter="encoach_ai.max_retries",
    )
    ai_enabled = fields.Boolean(
        string="AI Services Enabled",
        default=True,
        config_parameter="encoach_ai.enabled",
    )
