-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow custom provider to be passed into infer_model #3341
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
base: main
Are you sure you want to change the base?
Conversation
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.
@slkoo-cc Thanks, I like that this diff is a lot smaller :) Can you add a test please?
| def infer_model(model: Model | KnownModelName | str) -> Model: # noqa: C901 | ||
| """Infer the model from the name.""" | ||
| def infer_model( # noqa: C901 | ||
| model: Model | KnownModelName | str, provider_generator: Callable[[str], Provider[Any]] | None = None |
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.
"generator" has a different specific meaning in Python, so let's use "factory", and we can make the existing function the default argument value:
| model: Model | KnownModelName | str, provider_generator: Callable[[str], Provider[Any]] | None = None | |
| model: Model | KnownModelName | str, provider_factory: Callable[[str], Provider[Any]] = infer_provider |
| if provider_generator is None: | ||
| provider_generator = infer_provider | ||
| provider = provider_generator(provider_name) |
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.
| if provider_generator is None: | |
| provider_generator = infer_provider | |
| provider = provider_generator(provider_name) | |
| provider = provider_factory(provider_name) |
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.
@slkoo-cc Thanks, I like that this diff is a lot smaller :) Can you add a test please?
Fix #3163 based on feedback in #3185