@@ -241,6 +241,13 @@ def _can_use_transformers_legacy(model, model_spec):
241241 abilities = set (model .get ("model_ability" , []))
242242 return "chat" in abilities or "generate" in abilities
243243
244+ def _extract_primary_model_src (model ):
245+ if model .get ("model_specs" ):
246+ for spec in model ["model_specs" ]:
247+ if isinstance (spec , dict ) and "model_src" in spec :
248+ return spec ["model_src" ]
249+ return model .get ("model_src" )
250+
244251def main ():
245252 template_dir = '../templates'
246253 env = Environment (loader = FileSystemLoader (template_dir ))
@@ -456,9 +463,10 @@ def main():
456463
457464 for model in sorted_models :
458465 # Process model_src for template compatibility
459- if 'model_src' in model :
460- if 'huggingface' in model ['model_src' ]:
461- hf_src = model ['model_src' ]['huggingface' ]
466+ model_src = _extract_primary_model_src (model )
467+ if model_src :
468+ if 'huggingface' in model_src :
469+ hf_src = model_src ['huggingface' ]
462470 model ['model_id' ] = hf_src ['model_id' ]
463471 # Handle GGUF related fields
464472 if 'gguf_model_id' in hf_src :
@@ -470,8 +478,8 @@ def main():
470478 model ['lightning_model_id' ] = hf_src ['lightning_model_id' ]
471479 if 'lightning_versions' in hf_src :
472480 model ['lightning_versions' ] = ", " .join (hf_src ['lightning_versions' ])
473- elif 'modelscope' in model [ ' model_src' ] :
474- model ['model_id' ] = model [ ' model_src' ] ['modelscope' ]['model_id' ]
481+ elif 'modelscope' in model_src :
482+ model ['model_id' ] = model_src ['modelscope' ]['model_id' ]
475483
476484 available_controlnet = [cn ["model_name" ] for cn in model .get ("controlnet" , [])]
477485 if not available_controlnet :
@@ -502,11 +510,12 @@ def main():
502510
503511 for model in sorted_models :
504512 # Process model_src for template compatibility
505- if 'model_src' in model :
506- if 'huggingface' in model ['model_src' ]:
507- model ['model_id' ] = model ['model_src' ]['huggingface' ]['model_id' ]
508- elif 'modelscope' in model ['model_src' ]:
509- model ['model_id' ] = model ['model_src' ]['modelscope' ]['model_id' ]
513+ model_src = _extract_primary_model_src (model )
514+ if model_src :
515+ if 'huggingface' in model_src :
516+ model ['model_id' ] = model_src ['huggingface' ]['model_id' ]
517+ elif 'modelscope' in model_src :
518+ model ['model_id' ] = model_src ['modelscope' ]['model_id' ]
510519
511520 rendered = env .get_template ('audio.rst.jinja' ).render (model )
512521 output_file_path = os .path .join (output_dir , f"{ model ['model_name' ].lower ()} .rst" )
@@ -527,11 +536,12 @@ def main():
527536
528537 for model in sorted_models :
529538 # Process model_src for template compatibility
530- if 'model_src' in model :
531- if 'huggingface' in model ['model_src' ]:
532- model ['model_id' ] = model ['model_src' ]['huggingface' ]['model_id' ]
533- elif 'modelscope' in model ['model_src' ]:
534- model ['model_id' ] = model ['model_src' ]['modelscope' ]['model_id' ]
539+ model_src = _extract_primary_model_src (model )
540+ if model_src :
541+ if 'huggingface' in model_src :
542+ model ['model_id' ] = model_src ['huggingface' ]['model_id' ]
543+ elif 'modelscope' in model_src :
544+ model ['model_id' ] = model_src ['modelscope' ]['model_id' ]
535545
536546 model ["model_ability" ] = ', ' .join (model .get ("model_ability" ))
537547 rendered = env .get_template ('video.rst.jinja' ).render (model )
0 commit comments