Skip to content

Commit

Permalink
base - add support for adding/removing allowed models
Browse files Browse the repository at this point in the history
  • Loading branch information
cobycloud committed Feb 7, 2025
1 parent 8064f7c commit ad02d41
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkgs/base/swarmauri_base/llms/LLMBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ def _validate_name_in_allowed_models(cls, values):
)
return values

def add_allowed_model(self, model: str) -> None:
"""
Add a new model to the list of allowed models.
Raises:
ValueError: If the model is already in the allowed models list.
"""
if model in self.allowed_models:
raise ValueError(f"Model '{model}' is already allowed.")
self.allowed_models.append(model)

def remove_allowed_model(self, model: str) -> None:
"""
Remove a model from the list of allowed models.
Raises:
ValueError: If the model is not in the allowed models list.
"""
if model not in self.allowed_models:
raise ValueError(f"Model '{model}' is not in the allowed models list.")
self.allowed_models.remove(model)

@abstractmethod
def predict(self, *args, **kwargs):
raise NotImplementedError("predict() not implemented in subclass yet.")
Expand Down

0 comments on commit ad02d41

Please sign in to comment.