Skip to content

Conversation

@Ref34t
Copy link
Contributor

@Ref34t Ref34t commented Aug 29, 2025

Summary

Implements Issue #66 by centralizing model requirements logic into the ModelRequirements class, improving separation of concerns between core API components and model discovery functionality.

Changes Made

  • Move methods to a centralized location:

  • ModelConfig::toRequiredOptions()ModelRequirements::fromPromptData()

  • ModelMetadata::meetsRequirements()ModelRequirements::areMetBy()

  • Remove PromptBuilder::getModelRequirements() method per issue requirements

  • Update call sites:

  • PromptBuilder now calls ModelRequirements::fromPromptData() directly

  • ProviderRegistry now calls ModelRequirements::areMetBy()

  • Clean up data holder classes:

  • ModelConfig and ModelMetadata are now pure data holders

  • Removed unused optimization maps from ModelMetadata

  • Add comprehensive tests:

  • 4 new tests for areMetBy() method (matching, missing capability, unsupported values, empty requirements)

  • 4 new tests for fromPromptData() method (text generation, chat history, multimodal input, config options)

Architecture Impact

Improved separation of concerns: Core API components no longer depend on model discovery
Single Responsibility: ModelRequirements handles all requirements analysis

Fixes #66

@Ref34t Ref34t marked this pull request as ready for review August 29, 2025 19:51
@Ref34t
Copy link
Contributor Author

Ref34t commented Aug 29, 2025

@felixarntz The refractor is ready for review, in your hands

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

@Ref34t Just spotting this has merge conflicts - would you be able to resolve these please?

@Ref34t
Copy link
Contributor Author

Ref34t commented Sep 2, 2025

@felixarntz will tackle it today sure

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @mohamed.khaled@9hdigital.com.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: mohamed.khaled@9hdigital.com.

Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: Ref34t <mokhaled@git.wordpress.org>

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

@Ref34t
Copy link
Contributor Author

Ref34t commented Sep 2, 2025

@felixarntz The merge conflicts have been resolved. kindly review now 🥇

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.

@Ref34t This looks like a solid start!

There are a few areas where maintaining the original logic would be preferable from a performance and architecture perspective. Likely because that's not the case, there are currently a few problems that need to be addressed either way.

Mohamed Khaled added 6 commits September 5, 2025 21:13
- Move ModelConfig::toRequiredOptions() → ModelRequirements::fromPromptData()
- Move ModelMetadata::meetsRequirements() → ModelRequirements::areMetBy()
- Remove PromptBuilder::getModelRequirements() method
- Update all call sites to use centralized requirements logic
- Add comprehensive test coverage for new methods
- Remove unused optimization maps from ModelMetadata

Fixes separation of concerns between core API components and model discovery.
ModelConfig and ModelMetadata are now pure data holders while ModelRequirements
handles all requirement analysis and validation logic.
These test methods were testing the toRequiredOptions() method that was removed
as part of Issue WordPress#66 refactoring. The functionality has been moved to
ModelRequirements::fromPromptData() method.
- Remove unused OptionEnum import
- Fix class closing brace formatting
Update areMetBy() and fromPromptData() method @SInCE annotations
from n.e.x.t to 0.2.0 to match the milestone.
@Ref34t Ref34t force-pushed the feature/issue-66-model-requirements-refactor-v2 branch from 196eb71 to 29c06c8 Compare September 5, 2025 18:22
@Ref34t Ref34t requested a review from felixarntz September 5, 2025 18:26
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.

@Ref34t This looks excellent - thank you for the iterations!

@felixarntz felixarntz merged commit a4a82c4 into WordPress:trunk Sep 10, 2025
14 checks passed
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.

Move responsibility for checking model requirements into ModelRequirements class

2 participants