__init__.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Managed llama.cpp runtime.
  2. ``binaries`` answers which backend this machine uses and which PM-pinned
  3. engine is installed (the engine bytes live in pm's machine-wide store);
  4. ``bootstrap`` boots the managed server from what is installed — never a
  5. download; ``supervisor`` spawns and supervises one llama-server in router
  6. mode (readiness is a touch generation, never health-200 alone); ``detect``
  7. finds an already-running llama-server (external or ours).
  8. The package-level names resolve on first access. Shipped updaters import
  9. ``hermes_cli.local_runtime.processes`` from the NEW checkout after the pull,
  10. while their process still holds the OLD ``hermes_platform`` and other
  11. first-party modules. An eager re-export here would run every submodule
  12. against those stale modules and crash the update on any name added since.
  13. """
  14. from importlib import import_module
  15. _EXPORTS = {
  16. "binaries": ("BACKEND_PACKAGES", "BinaryResolutionError", "Engine", "ensure_engine",
  17. "installed_engine", "pinned_tag", "resolve_backend", "select_backend"),
  18. "bootstrap": ("ensure_local_runtime", "shutdown_local_runtime"),
  19. "context_policy": ("FLOOR", "growth_decision", "initial_window", "ladder", "launch_args"),
  20. "growth": ("clear_window_override", "load_window_overrides", "maybe_grow_window",
  21. "save_window_override"),
  22. "detect": ("detect_server",),
  23. "endpoint": ("resolve_llamacpp_endpoint",),
  24. "estimator": ("HardwareBudget", "ctx_bytes", "physics_check", "profile_from_gguf"),
  25. "gguf": ("read_gguf_header",),
  26. "hardware": ("probe_budget",),
  27. "presets": ("generate_presets",),
  28. "supervisor": ("LlamaServerSupervisor",),
  29. }
  30. _SOURCE = {name: module for module, names in _EXPORTS.items() for name in names}
  31. def __getattr__(name: str):
  32. module = _SOURCE.get(name)
  33. if module is None:
  34. raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
  35. value = getattr(import_module(f"{__name__}.{module}"), name)
  36. globals()[name] = value
  37. return value