Skip to content

Conversation

@slkoo-cc
Copy link
Contributor

@slkoo-cc slkoo-cc commented Nov 5, 2025

Fix #3163 based on feedback in #3185

Copy link
Collaborator

@DouweM DouweM left a 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
Copy link
Collaborator

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:

Suggested change
model: Model | KnownModelName | str, provider_generator: Callable[[str], Provider[Any]] | None = None
model: Model | KnownModelName | str, provider_factory: Callable[[str], Provider[Any]] = infer_provider

Comment on lines +718 to +720
if provider_generator is None:
provider_generator = infer_provider
provider = provider_generator(provider_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if provider_generator is None:
provider_generator = infer_provider
provider = provider_generator(provider_name)
provider = provider_factory(provider_name)

Copy link
Collaborator

@DouweM DouweM left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamically change provider api_key in infer_model

2 participants