Spaces:
Paused
Paused
File size: 1,022 Bytes
8125804 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from __future__ import annotations
from typing import Any
def get_text_config(config: Any) -> Any:
text_config = getattr(config, "text_config", None)
return text_config if text_config is not None else config
def get_config_attr(
config: Any,
name: str,
default: Any | None = None,
) -> Any:
text_config = get_text_config(config)
if hasattr(text_config, name):
return getattr(text_config, name)
if hasattr(config, name):
return getattr(config, name)
if default is not None:
return default
raise AttributeError(f"config does not define `{name}`")
def is_conditional_generation_config(config: Any) -> bool:
model_type = str(getattr(config, "model_type", ""))
architectures = [str(item) for item in (getattr(config, "architectures", None) or [])]
if "ConditionalGeneration" in "".join(architectures):
return True
if model_type == "qwen3_5" and getattr(config, "text_config", None) is not None:
return True
return False
|