<?php

declare(strict_types=1);

return [
    /*
    |--------------------------------------------------------------------------
    | AI Biography – enabled flag
    |--------------------------------------------------------------------------
    | Set to false to skip generation globally (e.g. while deploying).
    */
    'enabled' => env('AI_BIOGRAPHY_ENABLED', true),

    /*
    |--------------------------------------------------------------------------
    | LLM provider
    |--------------------------------------------------------------------------
    | Supported providers:
    |   - together        (Together.ai — primary, google/gemma-3n-E4B-it)
    |   - vision_gateway  (Skinbase Vision gateway, uses VISION_GATEWAY_URL / API key)
    |   - gemini          (direct Google Gemini API)
    |   - home            (remote LM Studio / OpenAI-compatible endpoint)
    */
    'provider' => env('AI_BIOGRAPHY_LLM_PROVIDER', 'together'),

    /*
    |--------------------------------------------------------------------------
    | Together.ai provider (primary)
    |--------------------------------------------------------------------------
    | Used when AI_BIOGRAPHY_LLM_PROVIDER=together (the default).
    |
    | Example:
    |   TOGETHER_API_KEY=your_key_here
    |   AI_BIOGRAPHY_TOGETHER_MODEL=google/gemma-3n-E4B-it
    */
    'together' => [
        'base_url'                => env('AI_BIOGRAPHY_TOGETHER_BASE_URL', 'https://api.together.xyz'),
        'endpoint'                => env('AI_BIOGRAPHY_TOGETHER_ENDPOINT', '/v1/chat/completions'),
        'model'                   => env('AI_BIOGRAPHY_TOGETHER_MODEL', 'google/gemma-3n-E4B-it'),
        'api_key'                 => env('TOGETHER_API_KEY', env('AI_BIOGRAPHY_TOGETHER_API_KEY', '')),
        'timeout_seconds'         => (int) env('AI_BIOGRAPHY_TOGETHER_TIMEOUT', env('AI_BIOGRAPHY_LLM_TIMEOUT', 90)),
        'connect_timeout_seconds' => (int) env('AI_BIOGRAPHY_TOGETHER_CONNECT_TIMEOUT', 5),
    ],

    /*
    |--------------------------------------------------------------------------
    | Vision LLM gateway endpoint
    |--------------------------------------------------------------------------
    | Primary endpoint: /ai/chat  (preferred for the Skinbase Vision gateway)
    | Fallback:         /v1/chat/completions  (OpenAI-compatible)
    |
    | Base URL and API key are shared with the existing Vision gateway config:
    |   VISION_GATEWAY_URL / VISION_GATEWAY_API_KEY
    */
    'llm_endpoint'          => env('AI_BIOGRAPHY_LLM_ENDPOINT', '/ai/chat'),
    'llm_fallback_endpoint' => env('AI_BIOGRAPHY_LLM_FALLBACK_ENDPOINT', '/v1/chat/completions'),
    'llm_timeout_seconds'   => (int) env('AI_BIOGRAPHY_LLM_TIMEOUT', 90),
    'llm_model'             => env('AI_BIOGRAPHY_LLM_MODEL', 'vision-gateway'),

    /*
    |--------------------------------------------------------------------------
    | Gemini direct API (optional alternative provider)
    |--------------------------------------------------------------------------
    | Used when AI_BIOGRAPHY_LLM_PROVIDER=gemini.
    |
    | Example:
    |   GEMINI_API_KEY=...
    |   AI_BIOGRAPHY_GEMINI_MODEL=gemini-flash-latest
    */
    'gemini' => [
        'base_url' => env('AI_BIOGRAPHY_GEMINI_BASE_URL', 'https://generativelanguage.googleapis.com'),
        'model' => env('AI_BIOGRAPHY_GEMINI_MODEL', 'gemini-flash-latest'),
        'api_key' => env('GEMINI_API_KEY', env('AI_BIOGRAPHY_GEMINI_API_KEY', '')),
    ],

    /*
    |--------------------------------------------------------------------------
    | Home LM Studio API (optional alternative provider)
    |--------------------------------------------------------------------------
    | Used when AI_BIOGRAPHY_LLM_PROVIDER=home.
    | This targets a remote LM Studio / OpenAI-compatible endpoint.
    |
    | Example:
    |   AI_BIOGRAPHY_HOME_BASE_URL=http://home.klevze.si:8200
    |   AI_BIOGRAPHY_HOME_MODEL=qwen/qwen3.5-9b
    */
    'home' => [
        'base_url' => env('AI_BIOGRAPHY_HOME_BASE_URL', 'http://home.klevze.si:8200'),
        'endpoint' => env('AI_BIOGRAPHY_HOME_ENDPOINT', '/v1/chat/completions'),
        'model' => env('AI_BIOGRAPHY_HOME_MODEL', 'qwen/qwen3.5-9b'),
        'api_key' => env('AI_BIOGRAPHY_HOME_API_KEY', ''),
        'verify_ssl' => env('AI_BIOGRAPHY_HOME_VERIFY_SSL', true),
        'timeout_seconds' => (int) env('AI_BIOGRAPHY_HOME_TIMEOUT', env('AI_BIOGRAPHY_LLM_TIMEOUT', 90)),
        'connect_timeout_seconds' => (int) env('AI_BIOGRAPHY_HOME_CONNECT_TIMEOUT', 3),
    ],

    /*
    |--------------------------------------------------------------------------
    | Queue
    |--------------------------------------------------------------------------
    | Queue name for GenerateAiBiographyJob.
    */
    'queue' => env('AI_BIOGRAPHY_QUEUE', 'default'),

    /*
    |--------------------------------------------------------------------------
    | Stale threshold (days)
    |--------------------------------------------------------------------------
    | A biography is considered stale if older than this many days
    | AND the source hash has changed. The batch refresh command uses this.
    */
    'stale_threshold_days' => (int) env('AI_BIOGRAPHY_STALE_DAYS', 30),
];
