Spaces:
Sleeping
Sleeping
File size: 1,864 Bytes
116524e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | """ACE LLM providers — PydanticAI model resolution and configuration.
- ``resolve_model`` — resolve a model string to a PydanticAI model
- ``settings_from_config`` — build ModelSettings from ACEModelConfig
- ``ModelConfig`` / ``ACEModelConfig`` — configuration types
- ``validate_connection`` / ``search_models`` — model registry helpers
"""
from __future__ import annotations
from typing import TYPE_CHECKING
# Config is lightweight — always available eagerly.
from .config import ACEModelConfig, ModelConfig, load_config, save_config
if TYPE_CHECKING:
from .pydantic_ai import resolve_model, settings_from_config
from .registry import ValidationResult, search_models, validate_connection
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
# PydanticAI helpers
"resolve_model": ("ace.providers.pydantic_ai", "resolve_model"),
"settings_from_config": ("ace.providers.pydantic_ai", "settings_from_config"),
# Registry
"ValidationResult": ("ace.providers.registry", "ValidationResult"),
"validate_connection": ("ace.providers.registry", "validate_connection"),
"search_models": ("ace.providers.registry", "search_models"),
}
def __getattr__(name: str) -> object:
if name in _LAZY_IMPORTS:
module_path, attr = _LAZY_IMPORTS[name]
import importlib
module = importlib.import_module(module_path)
value = getattr(module, attr)
globals()[name] = value
return value
raise AttributeError(f"module 'ace.providers' has no attribute {name!r}")
__all__ = [
# Config
"ModelConfig",
"ACEModelConfig",
"load_config",
"save_config",
# PydanticAI helpers
"resolve_model",
"settings_from_config",
# Registry
"ValidationResult",
"validate_connection",
"search_models",
]
|