mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-07-06 17:31:16 -03:00
fix(agent): preserve preview URLs for collection repo models with flat heading structure
Three-part fix for enrich_hf_metadata failing to extract correct preview_url from HuggingFace collection repos where models share flat heading levels: 1. _strip_standalone_images() now converts <img> tags to markdown image syntax  instead of stripping the URL entirely, so the LLM can still extract preview URLs. 2. _extract_section() uses a line-count-based forward window (stopping at <a id> anchors) for non-heading matches, instead of stopping at the very next heading. This prevents same-level sub-headings (# Download, # Trigger, # Sample prompt within a single model section) from truncating the window before sample images are included. 3. Post-processor preview fallback now filters gallery images to the model-specific README section before falling back to the repo-wide first image.
This commit is contained in:
@@ -803,10 +803,12 @@ pixel art sprite, game asset, transparent background
|
||||
assert "## Gallery" in result
|
||||
assert "Some text." in result
|
||||
|
||||
def test_html_img_tag_stripped(self):
|
||||
def test_html_img_tag_converted_to_markdown_image(self):
|
||||
"""``<img>`` converted to ````, preserving URL for LLM."""
|
||||
md = '## Preview\n<img src="https://cdn.hf.co/img.webp"></img>\n\nDescription.'
|
||||
result = self._clean(md)
|
||||
assert "cdn.hf.co" not in result
|
||||
assert "" in result
|
||||
assert "cdn.hf.co" in result # URL preserved for LLM extraction
|
||||
assert "Description." in result
|
||||
|
||||
def test_inline_image_within_paragraph_preserved(self):
|
||||
|
||||
@@ -242,11 +242,12 @@ After"""
|
||||
cleaned = R.clean_readme_for_llm(text)
|
||||
assert "./preview.png" in cleaned
|
||||
|
||||
def test_strips_html_img_tag(self, R):
|
||||
"""``<img src="...">`` → stripped."""
|
||||
def test_converts_html_img_tag_to_markdown_image(self, R):
|
||||
"""``<img src="...">`` → ```` preserving URL for LLM."""
|
||||
text = 'before\n<img src="logo.png">\nafter'
|
||||
cleaned = R.clean_readme_for_llm(text)
|
||||
assert "logo.png" not in cleaned
|
||||
assert "" in cleaned
|
||||
assert "logo.png" in cleaned # URL preserved for LLM extraction
|
||||
|
||||
def test_widget_stripped_frontmatter_preserved(self, R):
|
||||
"""Widget YAML stripped but ``base_model:`` kept."""
|
||||
|
||||
Reference in New Issue
Block a user