-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: check model use model_params #1911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,13 @@ def get_model_credential(self, model_type, model_name): | |
model_info = self.get_model_info_manage().get_model_info(model_type, model_name) | ||
return model_info.model_credential | ||
|
||
def is_valid_credential(self, model_type, model_name, model_credential: Dict[str, object], raise_exception=False): | ||
def get_model_params(self, model_type, model_name): | ||
model_info = self.get_model_info_manage().get_model_info(model_type, model_name) | ||
return model_info.model_credential.is_valid(model_type, model_name, model_credential, self, | ||
return model_info.model_credential | ||
|
||
def is_valid_credential(self, model_type, model_name, model_credential: Dict[str, object], model_params: Dict[str, object], raise_exception=False): | ||
model_info = self.get_model_info_manage().get_model_info(model_type, model_name) | ||
return model_info.model_credential.is_valid(model_type, model_name, model_credential, model_params, self, | ||
raise_exception=raise_exception) | ||
|
||
def get_model(self, model_type, model_name, model_credential: Dict[str, object], **model_kwargs) -> BaseModel: | ||
|
@@ -105,7 +109,7 @@ def filter_optional_params(model_kwargs): | |
class BaseModelCredential(ABC): | ||
|
||
@abstractmethod | ||
def is_valid(self, model_type: str, model_name, model: Dict[str, object], provider, raise_exception=True): | ||
def is_valid(self, model_type: str, model_name, model: Dict[str, object], model_params, provider, raise_exception=True): | ||
pass | ||
|
||
@abstractmethod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are some points to consider for your code:
Overall, your code is mostly clean with minor improvements possible related to naming conventions and readability. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is one significant change needed:
Explanation:
In the provided function
is_valid_credential
, there's an unexpected comma in the type hint of the parametermodel_params
. Without a leading colon after the variable list[provider, model_type, model_name, model_credential]
, Python will interpret this as a trailing comma for the previous argument.The suggested correction is to replace it with the correct syntax
: Dict[str, object],
which properly separates parameters from their types. This prevents errors like unbalanced parentheses due to the extra comma before the type hint.