import os
import yaml

def load_config(config_file="config.yaml"):
    config = {
        "port": 8000,
        "nlu_provider": "rasa",
        "rasa_url": "http://localhost:5005",
        "log_level": "INFO"
    }

    try:
        with open(config_file, "r") as f:
            config.update(yaml.safe_load(f))
    except FileNotFoundError:
        print(f"Configuration file not found: {config_file}")

    config["port"] = int(os.environ.get("AIVA_PORT", config["port"]))
    config["nlu_provider"] = os.environ.get("AIVA_NLU_PROVIDER", config["nlu_provider"])
    config["rasa_url"] = os.environ.get("AIVA_RASA_URL", config["rasa_url"])
    config["log_level"] = os.environ.get("AIVA_LOG_LEVEL", config["log_level"])

    return config

config = load_config()
print(config)