Merge pull request #927 from zanllp/feat/parse-extra-json-meta-info

feat(metadata): parse and mixin extraJsonMetaInfo field
docs/update-changelog-inline-video
zanllp 2026-02-22 23:26:51 +08:00 committed by GitHub
commit f8015e6631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -680,6 +680,20 @@ def parse_generation_parameters(x: str):
if not x: if not x:
return {"meta": {}, "pos_prompt": [], "lora": [], "lyco": []} return {"meta": {}, "pos_prompt": [], "lora": [], "lyco": []}
# 提取并混入 extraJsonMetaInfo 字段
extra_json_match = re.search(r'\nextraJsonMetaInfo:\s*(\{[\s\S]*\})\s*$', x.strip())
if extra_json_match:
try:
extra_json_meta_info = json.loads(extra_json_match.group(1))
# 混入到 res 中,确保所有值都是字符串
for k, v in extra_json_meta_info.items():
res[k] = json.dumps(v) if not isinstance(v, str) else v
# 从原始参数中移除 extraJsonMetaInfo 部分
x = re.sub(r'\nextraJsonMetaInfo:\s*\{[\s\S]*\}\s*$', '', x.strip())
except json.JSONDecodeError:
# 解析失败,保留原始字符串
pass
*lines, lastline = x.strip().split("\n") *lines, lastline = x.strip().split("\n")
if len(re_param.findall(lastline)) < 3: if len(re_param.findall(lastline)) < 3:
lines.append(lastline) lines.append(lastline)