from __future__ import annotations

import logging

def configure_example_logging(
    *,
    log_level: str = "WARNING",
    quiet_third_party: bool = True,
) -> None:
    """Reduce noisy third-party logs for interactive examples."""

    level = getattr(logging, log_level.upper(), logging.WARNING)

    root = logging.getLogger()
    if not root.handlers:
        logging.basicConfig(level=level)
    else:
        root.setLevel(level)

    if quiet_third_party:
        for logger_name in (
            "llama_index",
            "llama_index.core",
            "chromadb",
            "httpx",
            "openai",
        ):
            logging.getLogger(logger_name).setLevel(logging.ERROR)
