22c3b54746
The eval (#1130) proved the frozen-embedding + trained-head spine; this lands its production form (the first of three slices that make heads the suggestion source, replacing Camie + centroid). - tag_head: one logistic-regression head per general/character concept with enough labelled positives. Weights (pgvector), honest CV-derived suggest threshold + earned-auto-apply point, and per-concept quality metrics. - head_training_run: persisted batch lifecycle (mirrors tag_eval_run) so the admin card shows live + historical status across navigation. - services/ml/heads.py: TRAIN (sync, ml worker, reuses tag_eval's proven data loaders + metric math so production heads match measured eval numbers) and SCORE (async, API worker — numpy via pgvector, no scikit-learn): score one image's embedding against all heads → the rail's suggestions, cached on (count, max trained_at) so a retrain invalidates without per-request loads. - tasks.ml.train_heads (ml queue, commits per head so a kill leaves progress) + recover_stalled_head_training_runs sweep + retention(20) + 5-min beat (rule 89). - api/heads.py: POST /api/heads/train (one run at a time, 409 guard) + GET /api/heads (count, graduated, last-trained, running, per-concept table, recent runs). - ml_settings: head_min_positives + head_auto_apply_precision, tunable via /api/ml/settings. Scoring isn't wired into the rail yet (slice C) and the admin UI is slice B — this slice makes training + scoring exist and CI-verifiable. 'precision' column stored as precision_cv (SQL reserved word). Migration 0058. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
"""API blueprint registration.
|
|
|
|
This module is imported by the Quart app factory; it just exposes the
|
|
top-level `api_bp` for backward compatibility with FC-1's health route,
|
|
and ALL_BLUEPRINTS for the factory to register sibling blueprints.
|
|
"""
|
|
|
|
from quart import Blueprint
|
|
|
|
from . import health
|
|
|
|
api_bp = Blueprint("api", __name__, url_prefix="/api")
|
|
api_bp.add_url_rule("/health", view_func=health.get_health, methods=["GET"])
|
|
|
|
|
|
def all_blueprints() -> list[Blueprint]:
|
|
from .admin import admin_bp
|
|
from .aliases import aliases_bp
|
|
from .allowlist import allowlist_bp
|
|
from .artist import artist_bp
|
|
from .artists import artists_bp
|
|
from .attachments import attachments_bp
|
|
from .cleanup import cleanup_bp
|
|
from .credentials import credentials_bp
|
|
from .downloads import downloads_bp
|
|
from .extension import extension_bp
|
|
from .gallery import gallery_bp
|
|
from .heads import heads_bp
|
|
from .import_admin import import_admin_bp
|
|
from .ml_admin import ml_admin_bp
|
|
from .platforms import platforms_bp
|
|
from .posts import posts_bp
|
|
from .provenance import provenance_bp
|
|
from .settings import settings_bp
|
|
from .showcase import showcase_bp
|
|
from .sources import sources_bp
|
|
from .suggestions import suggestions_bp
|
|
from .system_activity import system_activity_bp
|
|
from .system_backup import system_backup_bp
|
|
from .tag_eval import tag_eval_bp
|
|
from .tags import tags_bp
|
|
from .thumbnails import thumbnails_bp
|
|
return [
|
|
api_bp,
|
|
attachments_bp,
|
|
gallery_bp,
|
|
provenance_bp,
|
|
tags_bp,
|
|
artist_bp,
|
|
artists_bp,
|
|
showcase_bp,
|
|
settings_bp,
|
|
system_activity_bp,
|
|
system_backup_bp,
|
|
admin_bp,
|
|
cleanup_bp,
|
|
import_admin_bp,
|
|
suggestions_bp,
|
|
allowlist_bp,
|
|
aliases_bp,
|
|
tag_eval_bp,
|
|
heads_bp,
|
|
ml_admin_bp,
|
|
thumbnails_bp,
|
|
sources_bp,
|
|
platforms_bp,
|
|
posts_bp,
|
|
credentials_bp,
|
|
extension_bp,
|
|
downloads_bp,
|
|
]
|