Skip to content

Commit

Permalink
add warning for deprecated model type
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Mar 14, 2024
1 parent 46a8df1 commit 55fdaa2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/agentscope/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}],"
Expand Down
2 changes: 2 additions & 0 deletions src/agentscope/models/dashscope_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/agentscope/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 55fdaa2

Please sign in to comment.