fix(import): discover all resources from CivitAI modelVersionIds

CivitAI image API returns modelVersionIds at the root level of the
response (not inside meta), containing ALL model version IDs across
all resources (checkpoint + LoRAs). Two bugs prevented LoRAs from
being discovered:

1. _download_remote_media only extracted the first modelVersionId for
   enrichment, dropping the rest.
2. CivitAI API meta parsing only ran as an EXIF fallback, but most
   images have embedded EXIF metadata (prompt, steps, etc.), so the
   fallback was never triggered.
3. When civitai_meta_raw itself has a nested 'meta' key, unwrapping
   it stripped the injected modelVersionIds.

Also fixed gen_params merge: API gen_params now overlays EXIF at the
field level instead of full replacement, preserving EXIF-only fields
like detailed generation parameters.
This commit is contained in:
Will Miao
2026-05-16 22:12:30 +08:00
parent 31c54ff068
commit 94edfaa190
2 changed files with 74 additions and 15 deletions

View File

@@ -785,10 +785,16 @@ async def test_import_remote_recipe_merges_metadata(
async def parse_metadata(self, raw, recipe_scanner=None):
return json.loads(raw[len("Recipe metadata: ") :])
class MockApiParser:
async def parse_metadata(self, raw, recipe_scanner=None):
return {"gen_params": raw, "loras": []}
class MockFactory:
def create_parser(self, raw):
if raw.startswith("Recipe metadata: "):
if isinstance(raw, str) and raw.startswith("Recipe metadata: "):
return MockParser()
if isinstance(raw, dict):
return MockApiParser()
return None
# 4. Setup Harness and run test