Retrieves to image and text model reference and stores in it a var
(self)
| 27 | ImageBaselineRecord, |
| 28 | ModelReferenceManager, |
| 29 | PendingModelProvider, |
| 30 | PrefetchStrategy, |
| 31 | SourceSelector, |
| 32 | horde_model_reference_settings, |
| 33 | ) |
| 34 | from horde_model_reference.meta_consts import KNOWN_IMAGE_GENERATION_BASELINE |
| 35 | from horde_model_reference.model_reference_records import ImageGenerationModelRecord |
| 36 | |
| 37 | from horde import metrics |
| 38 | from horde.logger import logger # type: ignore[attr-defined] |
| 39 | from horde.model_reference_snapshot import ( |
| 40 | DEFAULT_PUBLISH_LOCK_SECONDS, |
| 41 | ImageReferenceSnapshot, |
| 42 | build_snapshot, |
| 43 | redis_image_reference_snapshots, |
| 44 | ) |
| 45 | from horde.vars import horde_instance_id |
| 46 | |
| 47 | BETA_CATEGORIES_ENV_VAR: Final[str] = "HORDE_BETA_MODEL_CATEGORIES" |
| 48 | """Comma-separated categories to merge pending (beta) models into. Empty disables beta.""" |
| 49 | |
| 50 | BETA_API_KEY_ENV_VAR: Final[str] = "HORDE_BETA_MODELS_API_KEY" |
| 51 | """A reader-level AI-Horde API key authenticating the pending-model reads.""" |
| 52 | |
| 53 | DEFAULT_BETA_CATEGORIES: Final[str] = MODEL_REFERENCE_CATEGORY.image_generation.value |
| 54 | """Image generation is the only category this API reads from the reference.""" |
| 55 | |
| 56 | ANONYMOUS_API_KEY: Final[str] = "0000000000" |
| 57 | """The PRIMARY accepts the anonymous key for pending reads, so beta needs no dedicated credential.""" |
| 58 | |
| 59 | MODEL_REQUIREMENT_VALUE = int | float | str | list[int] | list[float] | list[str] | bool |
| 60 | """One value a model record may publish as a request requirement.""" |
| 61 | |
| 62 | MODEL_NAME_BASELINE_SUFFIXES: Final[tuple[tuple[str, KNOWN_IMAGE_GENERATION_BASELINE], ...]] = ( |
| 63 | ("[SDXL]", KNOWN_IMAGE_GENERATION_BASELINE.stable_diffusion_xl), |
| 64 | ("[Flux]", KNOWN_IMAGE_GENERATION_BASELINE.flux_1), |
| 65 | ("[Qwen]", KNOWN_IMAGE_GENERATION_BASELINE.qwen_image), |
| 66 | ("[ZModel]", KNOWN_IMAGE_GENERATION_BASELINE.z_image_turbo), |
| 67 | ("[ZImage]", KNOWN_IMAGE_GENERATION_BASELINE.z_image_turbo), |
| 68 | ) |
| 69 | """Baselines inferred from a customizer model name the reference has never heard of.""" |
| 70 | |
| 71 | FLEET_PUBLISH_INTERVAL_SECONDS: Final[int] = 3600 |
| 72 | """How old a healthy fleet snapshot may be before the elected publisher refreshes it.""" |
| 73 | |
| 74 | STALE_SNAPSHOT_SECONDS: Final[int] = 3 * FLEET_PUBLISH_INTERVAL_SECONDS |
| 75 | """Snapshot age past which a process warns: three missed publisher cycles.""" |
| 76 | |
| 77 | STALE_WARNING_INTERVAL_SECONDS: Final[int] = 3600 |
| 78 | """Minimum spacing between repeated stale-snapshot warnings from one process.""" |
| 79 | |
| 80 | |
| 81 | def _packaged_baseline_catalog() -> ImageBaselineCatalog: |
| 82 | """Return the baseline catalog shipped inside horde_model_reference.""" |
| 83 | return ImageBaselineCatalog.model_validate_json( |
| 84 | files("horde_model_reference").joinpath("data", "baselines", "catalog.json").read_text(encoding="utf-8"), |
| 85 | ) |
| 86 |
no test coverage detected