# 文件路径及文件名: laybot_ai/__init__.py
# 简要阐述该文件的作用: 统一导出 SDK 对外可用的核心类与工具函数，便于业务侧直接 import 使用。

from .chat import Chat
from .doc import Doc
from .embed import Embed
from .batch import Batch
from .fine_tune import FineTune
from .file import File
from .portal import Portal
from .cache import Caches
from .client import Client

from .jsonl import (
    parse_jsonl,
    iter_jsonl,
    iter_jsonl_safe,
    parse_jsonl_file,
    iter_jsonl_file,
    iter_jsonl_file_safe,
    dump_jsonl,
)

__all__ = [
    "Chat", "Doc", "Embed", "Batch",
    "FineTune", "File", "Portal",
    "Caches", "Client",
    "parse_jsonl", "iter_jsonl", "iter_jsonl_safe",
    "parse_jsonl_file", "iter_jsonl_file", "iter_jsonl_file_safe",
    "dump_jsonl",
    "via_gateway",
]

def via_gateway(base: str, *, token: str, header: str = "X-Jump-Auth", **kwargs):
    """
    语法糖：快速注入“跳板/网关鉴权头”并覆盖 base。
    - 不改变 SDK 的 vendor/协议语义，只是提供便利配置。
    - 对所有请求生效（包括 files / batches / cachedContents）。
    """
    headers = dict(kwargs.get("headers") or {})
    headers.setdefault(header, token)
    kwargs["headers"] = headers
    kwargs["base"] = base
    return kwargs

__version__ = "1.0.5"
