diff --git a/src/agentscope/models/__init__.py b/src/agentscope/models/__init__.py index c4609482a..576d1d6aa 100644 --- a/src/agentscope/models/__init__.py +++ b/src/agentscope/models/__init__.py @@ -61,6 +61,13 @@ def _get_model_wrapper(model_type: str) -> Type[ModelWrapperBase]: return ModelWrapperBase.registry[ # type: ignore [return-value] model_type ] + elif model_type in ModelWrapperBase.deprecated_type_registry: + cls = ModelWrapperBase.deprecated_type_registry[model_type] + logger.warning( + f"Model type [{model_type}] will be deprecated in future releases," + f" please use [{cls.model_type}] instead.", + ) + return cls # type: ignore [return-value] else: logger.warning( f"Unsupported model_type [{model_type}]," diff --git a/src/agentscope/models/dashscope_model.py b/src/agentscope/models/dashscope_model.py index 62c139ff6..b246909c5 100644 --- a/src/agentscope/models/dashscope_model.py +++ b/src/agentscope/models/dashscope_model.py @@ -106,6 +106,8 @@ class DashScopeChatWrapper(DashScopeWrapper): model_type: str = "dashscope_chat" + deprecated_model_type: str = "tongyi_chat" + def _register_default_metrics(self) -> None: # Set monitor accordingly # TODO: set quota to the following metrics diff --git a/src/agentscope/models/model.py b/src/agentscope/models/model.py index 2496120aa..6de9ebf5f 100644 --- a/src/agentscope/models/model.py +++ b/src/agentscope/models/model.py @@ -200,10 +200,15 @@ def __init__(cls, name: Any, bases: Any, attrs: Any) -> None: if not hasattr(cls, "registry"): cls.registry = {} cls.type_registry = {} + cls.deprecated_type_registry = {} else: cls.registry[name] = cls if hasattr(cls, "model_type"): cls.type_registry[cls.model_type] = cls + if hasattr(cls, "deprecated_model_type"): + cls.deprecated_type_registry[ + cls.deprecated_model_type + ] = cls super().__init__(name, bases, attrs)