fix(agent): handle plain YAML scalar text in extract_gallery_images

Widget entries with unquoted multi-line YAML scalars (e.g. "text: two samurais...\n  continuation") were not parsed, leaving gallery image prompts empty. Add a third branch for plain scalar format alongside the existing quoted and >- folded block handlers.
This commit is contained in:
Will Miao
2026-07-03 07:34:24 +08:00
parent ee8250c26c
commit f06c60bd47
2 changed files with 29 additions and 8 deletions

View File

@@ -566,3 +566,20 @@ base_model: flux
) == "prithivMLmods/Flux-Long-Toon-LoRA"
assert extract_repo_from_hf_url("") == ""
assert extract_repo_from_hf_url("not a url") == ""
def test_plain_yaml_scalar_text(self):
"""Unquoted multi-line YAML scalar (plain format) should extract prompt."""
from py.services.agent.skills.enrich_hf_metadata.md_to_html import \
extract_gallery_images
md = """---
widget:
- text: two samurais doing a muay thai fight
while the other leans back. Textured abstract style
output:
url: images/00.png
---"""
images = extract_gallery_images(md, "user/repo")
assert len(images) == 1
assert "two samurais doing a muay thai fight" in images[0]["meta"]["prompt"]
assert "Textured abstract style" in images[0]["meta"]["prompt"]