mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
5ab0e88abc
A model file could only ever be linked to huggingface.co: `set_hf_url` validated the URL with a huggingface-only regex, the agent fetched the card from a hardcoded HF URL, and the readme processor built every relative image path off `https://huggingface.co/{repo}/resolve/main`. ModelScope publishes the same model-card convention (README.md + YAML frontmatter, often carrying `base_model:` and `trigger_words:`) behind a public, key-less API, so the enrichment pipeline could already serve it - it was the plumbing that was HF-shaped, not the idea. Make the external source a first-class, provider-driven concept: - New `py/services/model_sources/` registry. A `ModelSource` owns URL recognition (lenient for stored values, strict for user input), the canonical page URL, model-card fetching, the asset base URL and the capability flags. `HuggingFaceSource` is the previous logic relocated; `ModelScopeSource` reads `/models/{o}/{n}/resolve/{master|main}/README.md` and falls back to `/api/v1/models/{o}/{n}/repo`. `TensorArtSource` is link-only on purpose: tensor.art answers plain HTTP clients with a Cloudflare challenge and its internal API (ap-east-1.tensorart.cloud / cn.tensorart.net) rejects every /v1/model/* route with "invalid authorization header", so it declares supports_enrichment=False rather than failing silently later. - Metadata gains `source_platform` + `source_url`; `hf_url` stays as a read/write alias, written only for Hugging Face, so existing sidecars, cached rows and third-party consumers keep working. Normalisation runs at the scanner, the persistent cache (both directions, plus two new columns behind an ALTER migration) and the linking handler - which is what stops a user who switches sources from leaving a stale `hf_url` on a ModelScope model. - The agent pipeline keys off the provider instead of `hf_url`: the fast-fail gate now explains *why* a model is skipped (no source / unknown source / source without a reachable card), the prompt context exposes source_url/source_id/source_label/asset_base_url while still filling the legacy hf_url/repo aliases, and the four README image extractors take a base_url (defaulting to HF) so relative paths resolve against the right site. Version grouping generalises to hf: / ms: / ta: keys. - `POST /api/lm/set-hf-url` keeps its path and its legacy payload keys but accepts `source_url`, validates against every provider and returns the platform. `GET /api/lm/model-sources` lets the UI render the supported-site list from the server. - Frontend: a `modelSourceHelpers` mirror of the registry drives the link dialog, the card/modal globe (branded "View on ModelScope/TensorArt"), the version-group key and the enrichment gate; the versions tab no longer sends ms:/ta: keys to the CivitAI API. TensorArt stays in the list because provenance is worth keeping even when the card is unreadable - the dialog says so plainly ("Sites that don't expose one (currently TensorArt) can only be linked") and the context menu disables enrichment with a matching tooltip, instead of the user getting "Unsupported URL". Verified against the real ModelScope API: jj3550945163/Krea-2-LORA returns a 1882-byte card whose frontmatter carries base_model/tags/trigger_words, and relative images resolve to .../resolve/master/.... Tests: backend 2815 passed; frontend 1130 JS + 91 Vue passed; pytest tests/i18n and a Jinja compile pass over templates/. The nine locales carry [TODO: Translate] for the new strings, completed in the next commit.
76 lines
4.1 KiB
HTML
76 lines
4.1 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}{{ t('embeddings.title') }}{% endblock %}
|
|
{% block page_id %}embeddings{% endblock %}
|
|
|
|
{% block init_title %}{{ t('initialization.embeddings.title') }}{% endblock %}
|
|
{% block init_message %}{{ t('initialization.embeddings.message') }}{% endblock %}
|
|
{% block init_check_url %}/api/embeddings/list?page=1&page_size=1{% endblock %}
|
|
|
|
{% block additional_components %}
|
|
|
|
<div id="embeddingContextMenu" class="context-menu" style="display: none;">
|
|
<!-- Metadata -->
|
|
<div class="context-menu-item" data-action="refresh-metadata"><i class="fas fa-sync"></i> {{ t('loras.contextMenu.refreshMetadata') }}</div>
|
|
<div class="context-menu-item has-submenu" data-has-submenu="link-model">
|
|
<i class="fas fa-link"></i>
|
|
<span>{{ t('loras.contextMenu.linkModel') }}</span>
|
|
<i class="fas fa-chevron-right submenu-arrow"></i>
|
|
<div class="context-submenu">
|
|
<div class="context-menu-item" data-action="relink-civitai">
|
|
<i class="fas fa-external-link-alt"></i> <span>{{ t('loras.contextMenu.linkCivitai') }}</span>
|
|
</div>
|
|
<div class="context-menu-item" data-action="link-hf">
|
|
<i class="fas fa-robot"></i> <span>{{ t('loras.contextMenu.linkModelSource') }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="context-menu-separator menu-section-break"></div>
|
|
<!-- Workflow -->
|
|
<div class="context-menu-item" data-action="copyname"><i class="fas fa-copy"></i> {{ t('loras.contextMenu.copyFilename') }}</div>
|
|
<div class="context-menu-item" data-action="sendtoworkflow"><i class="fas fa-paper-plane"></i> {{ t('checkpoints.contextMenu.sendToWorkflow') }}</div>
|
|
<div class="context-menu-separator menu-section-break"></div>
|
|
<!-- Media / Preview -->
|
|
<div class="context-menu-item" data-action="preview"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.openExamples') }}</div>
|
|
<div class="context-menu-item has-submenu" data-has-submenu="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadExamples') }} <i class="fas fa-chevron-right submenu-arrow"></i>
|
|
<div class="context-submenu">
|
|
<div class="context-menu-item" data-action="download-examples"><i class="fas fa-download"></i> {{ t('loras.contextMenu.downloadMissingExamples') }}</div>
|
|
<div class="context-menu-item" data-action="download-examples-force"><i class="fas fa-redo-alt"></i> {{ t('loras.contextMenu.reprocessExamples') }}</div>
|
|
</div>
|
|
</div>
|
|
<div class="context-menu-item" data-action="replace-preview"><i class="fas fa-image"></i> {{ t('loras.contextMenu.replacePreview') }}</div>
|
|
<div class="context-menu-separator menu-section-break"></div>
|
|
<!-- Attributes -->
|
|
<div class="context-menu-item" data-action="set-nsfw"><i class="fas fa-exclamation-triangle"></i> {{ t('loras.contextMenu.setContentRating') }}</div>
|
|
<div class="context-menu-separator menu-section-break"></div>
|
|
<!-- Organization -->
|
|
<div class="context-menu-item" data-action="move"><i class="fas fa-folder-open"></i> {{ t('loras.contextMenu.moveToFolder') }}</div>
|
|
<div class="context-menu-separator"></div>
|
|
<!-- Destructive -->
|
|
<div class="context-menu-item" data-action="exclude"><i class="fas fa-eye-slash"></i> {{ t('loras.contextMenu.excludeModel') }}</div>
|
|
<div class="context-menu-item delete-item" data-action="delete"><i class="fas fa-trash"></i> {{ t('loras.contextMenu.deleteModel') }}</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="sticky-topbar">
|
|
{% include 'components/controls.html' %}
|
|
{% include 'components/breadcrumb.html' %}
|
|
</div>
|
|
{% include 'components/duplicates_banner.html' %}
|
|
{% include 'components/folder_sidebar.html' %}
|
|
|
|
<!-- Embedding cards container -->
|
|
<div class="card-grid" id="modelGrid">
|
|
<!-- Cards will be dynamically inserted here -->
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block overlay %}
|
|
<div class="bulk-mode-overlay"></div>
|
|
{% endblock %}
|
|
|
|
{% block main_script %}
|
|
<script type="module" src="/loras_static/js/embeddings.js?v={{ version }}"></script>
|
|
{% endblock %}
|