"""
TOXO - Smart Layer for Context Augmented Language Models (CALM)
Public Python Package for .toxo file support.

Client-only (default): Use ToxoClient to talk to the TOXO API on GCP.
    pip install toxo

Local processing: Use ToxoLayer for full local runtime.
    pip install toxo[local]

Usage (client - recommended):
    from toxo import ToxoClient
    client = ToxoClient()
    response = client.query("your_model.toxo", "Your question", api_key="...")

Usage (local - requires toxo[local]):
    from toxo import ToxoLayer
    layer = ToxoLayer.load("your_model.toxo")
    layer.setup_api_key("your_api_key")
    response = layer.query_sync("Your question")
"""

__version__ = "2.0.4"
__author__ = "ToxoTune"
__email__ = "support@toxotune.com"
__license__ = "Proprietary"

from .client import ToxoClient
from .utils import get_version, check_dependencies

__all__ = [
    "ToxoClient",
    "get_version",
    "check_dependencies",
    "__version__",
]


def __getattr__(name: str):
    """Lazy import ToxoLayer only when toxo[local] is installed."""
    if name == "ToxoLayer":
        try:
            from .core import ToxoLayer
            return ToxoLayer
        except ImportError as e:
            raise ImportError(
                "ToxoLayer requires toxo[local]. Install with: pip install toxo[local]\n"
                "For cloud API usage, use: from toxo import ToxoClient"
            ) from e
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

# Version check and welcome message
def _check_environment():
    """Check if the environment is properly set up."""
    import sys
    if sys.version_info < (3, 9):
        raise RuntimeError("TOXO requires Python 3.9 or higher")

# Run environment check on import
_check_environment()

# Optional: Print welcome message (can be disabled with environment variable)
import os
if not os.environ.get("TOXO_QUIET", False):
    print(f"🧠 TOXO v{__version__} - Smart Layer for Context Augmented Language Models (CALM)")
    print("   Visit https://toxotune.com to create your AI experts")