from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    app_name: str = "Intelligent Cabin Agent"
    app_env: str = "dev"
    app_host: str = "0.0.0.0"
    app_port: int = 8000
    intent_config_path: str = "app/data/intents.json"
    domain_config_path: str = "config/domain.yml"
    action_config_path: str = "config/actions.yml"
    response_config_path: str = "config/responses.yml"
    form_config_path: str = "config/forms.yml"
    rule_config_path: str = "config/rules.yml"
    dialog_act_config_path: str = "config/dialog_acts.yml"
    workflow_config_path: str = "config/workflows.yml"
    # 本地上下文改写引擎配置（不同设备可切换不同 yml 文件）
    context_rewrite_config_path: str = "config/context_rewrite.yml"
    session_backend: str = "memory"
    redis_url: str = "redis://127.0.0.1:6379/0"
    redis_key_prefix: str = "agent:session"
    session_ttl_seconds: int = 86400
    matcher_pipeline: str = "classifier"
    slot_extractor_backend: str = "joint_bert"
    classifier_backend: str = "joint_bert"
    classifier_threshold: float = 1.2
    classifier_bert_threshold: float = 0.0
    classifier_top_k: int = 3
    classifier_model_path: str = ""
    classifier_label_map_path: str = ""
    classifier_warmup_enabled: bool = True
    classifier_warmup_text: str = "打开车窗"
    classifier_remote_url: str = ""
    classifier_remote_timeout_seconds: float = 3.0
    joint_nlu_model_path: str = "models/local_joint_bert_nlu"
    joint_nlu_intent_threshold: float = 0.0
    joint_nlu_top_k: int = 3
    local_route_to_cloud_threshold: float = 0.75
    local_clarify_margin_threshold: float = 0.12
    local_classifier_execute_score_threshold: float = 0.55
    local_classifier_execute_margin_threshold: float = 0.18
    planner_backend: str = "heuristic"
    planner_base_url: str = ""
    planner_api_key: str = ""
    planner_model_name: str = ""
    planner_timeout_seconds: float = 6.0
    planner_clause_classifier_enabled: bool = True
    planner_clause_classifier_weight: float = 1.6
    planner_clause_model_only_threshold: float = 0.62
    planner_multi_intent_detector_enabled: bool = True
    planner_multi_intent_detector_model_path: str = ""
    planner_multi_intent_detector_threshold: float = 0.0
    planner_multi_intent_detector_top_k: int = 8
    planner_multi_intent_detector_max_labels: int = 4
    # 本地知识库目录（存放 .md 格式知识文档）
    knowledge_dir: str = "config/knowledge"

    model_config = SettingsConfigDict(env_file=".env", env_prefix="AGENT_")


settings = Settings()
