Skip to content

Conversation

@JasonTheAdams
Copy link
Member

Resolved #103

This adds the PromptBuilder::usingModelPreference() method which allows the user to provide a list of models it would like to use. If no model is present, then it falls back on the discovery system.

@JasonTheAdams JasonTheAdams self-assigned this Oct 15, 2025
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: JasonTheAdams <[email protected]>
Co-authored-by: felixarntz <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@felixarntz felixarntz added the [Type] Enhancement A suggestion for improvement. label Oct 15, 2025
@felixarntz felixarntz added this to the 0.2.0 milestone Oct 15, 2025
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@JasonTheAdams I think there's a bit of a misunderstanding on what a model preference should mean here. See my below feedback.

Probably something that can be quickly addressed though once clarified.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

I think there's a fundamental flaw in the current logic, it's doing the reverse lookup of what needs to happen for the model preference list to work properly.

);
$candidateModels = [];
foreach ($modelsMetadata as $modelMetadata) {
$candidateModels[] = [$this->providerIdOrClassName, $modelMetadata];
Copy link
Member

Choose a reason for hiding this comment

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

Since this can be an ID or a class name, we need to normalize this to always be the ID, in order for the lookup to work.

We already ProviderRegistry::getProviderClassName($id). Maybe we should also have ProviderRegistry::getProviderId($className), and that we could then use here if the value is a class name. That should be fairly straightforward to add.

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored in 79a7a56

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you actually addressed the concern I mentioned above?

@JasonTheAdams
Copy link
Member Author

Ok, @felixarntz I significantly changed how the mapping works. I'm a bit cross-eyed, but I think this is better. Hahah! Here's how it works now:

  1. Instead of storing the model preferences as they were, it's now normalized to a list of the map keys, as that's really all we need for later
  2. The candidate models are mapped, so iteration is no longer necessary
  3. I used array intersection instead of iteration to find the first preferred model

I'm not really sure how else we'd boost performance, now. I think we're iterating as little as possible. 😄

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@JasonTheAdams High-level logic looks solid now, there are just a few minor notes. I think the only blocker to merging is the point on properly normalizing the provider class name or ID, so that it's always an ID when using it in a key.

);
$candidateModels = [];
foreach ($modelsMetadata as $modelMetadata) {
$candidateModels[] = [$this->providerIdOrClassName, $modelMetadata];
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you actually addressed the concern I mentioned above?

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@JasonTheAdams Awesome, looks great! 🚀

@felixarntz felixarntz merged commit 50ea672 into trunk Oct 17, 2025
6 checks passed
@felixarntz felixarntz deleted the preferred-model-support branch October 17, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow specifying preferred / suggested models for a specific prompt / task

3 participants