MCPcopy Create free account
hub / github.com/Haidra-Org/AI-Horde / call_function

Method call_function

horde/model_reference.py:29–94  ·  view source on GitHub ↗

Retrieves to image and text model reference and stores in it a var

(self)

Source from the content-addressed store, hash-verified

27 ImageBaselineRecord,
28 ModelReferenceManager,
29 PendingModelProvider,
30 PrefetchStrategy,
31 SourceSelector,
32 horde_model_reference_settings,
33)
34from horde_model_reference.meta_consts import KNOWN_IMAGE_GENERATION_BASELINE
35from horde_model_reference.model_reference_records import ImageGenerationModelRecord
36
37from horde import metrics
38from horde.logger import logger # type: ignore[attr-defined]
39from horde.model_reference_snapshot import (
40 DEFAULT_PUBLISH_LOCK_SECONDS,
41 ImageReferenceSnapshot,
42 build_snapshot,
43 redis_image_reference_snapshots,
44)
45from horde.vars import horde_instance_id
46
47BETA_CATEGORIES_ENV_VAR: Final[str] = "HORDE_BETA_MODEL_CATEGORIES"
48"""Comma-separated categories to merge pending (beta) models into. Empty disables beta."""
49
50BETA_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
53DEFAULT_BETA_CATEGORIES: Final[str] = MODEL_REFERENCE_CATEGORY.image_generation.value
54"""Image generation is the only category this API reads from the reference."""
55
56ANONYMOUS_API_KEY: Final[str] = "0000000000"
57"""The PRIMARY accepts the anonymous key for pending reads, so beta needs no dedicated credential."""
58
59MODEL_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
62MODEL_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
71FLEET_PUBLISH_INTERVAL_SECONDS: Final[int] = 3600
72"""How old a healthy fleet snapshot may be before the elected publisher refreshes it."""
73
74STALE_SNAPSHOT_SECONDS: Final[int] = 3 * FLEET_PUBLISH_INTERVAL_SECONDS
75"""Snapshot age past which a process warns: three missed publisher cycles."""
76
77STALE_WARNING_INTERVAL_SECONDS: Final[int] = 3600
78"""Minimum spacing between repeated stale-snapshot warnings from one process."""
79
80
81def _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

Callers 1

model_reference.pyFile · 0.45

Calls 2

getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected