Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

55 lines
1.8 KiB
Python

"""Instructor v2 public exports with lazy loading."""
from __future__ import annotations
from importlib import import_module
from typing import Any
from instructor.v2.core.provider_specs import PUBLIC_FACTORY_ATTRS
__all__ = [
"Mode",
"Provider",
"ModeHandler",
"ModeHandlers",
"ModeRegistry",
"mode_registry",
"normalize_mode",
"patch_v2",
"register_mode_handler",
"ReaskHandler",
"RequestHandler",
"ResponseParser",
"providers",
*PUBLIC_FACTORY_ATTRS.keys(),
]
_LAZY_ATTRS: dict[str, tuple[str, str | None]] = {
"Mode": ("instructor.v2.core.mode", "Mode"),
"Provider": ("instructor.v2.core.providers", "Provider"),
"ModeHandler": ("instructor.v2.core.handler", "ModeHandler"),
"ModeHandlers": ("instructor.v2.core.registry", "ModeHandlers"),
"ModeRegistry": ("instructor.v2.core.registry", "ModeRegistry"),
"mode_registry": ("instructor.v2.core.registry", "mode_registry"),
"normalize_mode": ("instructor.v2.core.registry", "normalize_mode"),
"patch_v2": ("instructor.v2.core.patch", "patch_v2"),
"register_mode_handler": (
"instructor.v2.core.decorators",
"register_mode_handler",
),
"ReaskHandler": ("instructor.v2.core.protocols", "ReaskHandler"),
"RequestHandler": ("instructor.v2.core.protocols", "RequestHandler"),
"ResponseParser": ("instructor.v2.core.protocols", "ResponseParser"),
"providers": ("instructor.v2.providers", None),
**PUBLIC_FACTORY_ATTRS,
}
def __getattr__(name: str) -> Any:
if name not in __all__:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
module_path, attr_name = _LAZY_ATTRS[name]
module = import_module(module_path)
value = module if attr_name is None else getattr(module, attr_name)
globals()[name] = value
return value