Skip to content

Add ModalityCombinationsUtil for building modality combination sets#225

Draft
sarthak-19 wants to merge 1 commit intoWordPress:trunkfrom
sarthak-19:feat/modality_combinations
Draft

Add ModalityCombinationsUtil for building modality combination sets#225
sarthak-19 wants to merge 1 commit intoWordPress:trunkfrom
sarthak-19:feat/modality_combinations

Conversation

@sarthak-19
Copy link
Copy Markdown

Summary

Adds a new static utility class ModalityCombinationsUtil under src/Messages/Util/ that generates all valid modality combinations from a set of required modalities and a set of optional modalities.

This reduces repetitive, error-prone manual array declarations that provider implementations currently need when registering which input/output modality combinations their models support.

How it works

Uses binary bitmask enumeration to produce all 2^n subsets of the optional modalities, each merged with the fixed required modalities. Because modality lists are unordered, subsets (not permutations) are the correct unit — each combination appears exactly once.

Usage

// All combinations that include text, plus any subset of image/audio/document
$combos = ModalityCombinationsUtil::buildCombinations(
    [ModalityEnum::text()],
    [ModalityEnum::image(), ModalityEnum::audio(), ModalityEnum::document()]
);
// → 8 combinations

// All subsets of text + audio (including the "neither" case)
$combos = ModalityCombinationsUtil::buildCombinations(
    [],
    [ModalityEnum::text(), ModalityEnum::audio()]
);
// → 4 combinations

Issue :

@github-actions
Copy link
Copy Markdown

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: sarthak-19 <sarthak8858@git.wordpress.org>

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

@sarthak-19 sarthak-19 marked this pull request as draft March 24, 2026 16:11
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.16%. Comparing base (6317042) to head (6805f5e).

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #225      +/-   ##
============================================
+ Coverage     88.12%   88.16%   +0.03%     
- Complexity     1213     1217       +4     
============================================
  Files            60       61       +1     
  Lines          3934     3945      +11     
============================================
+ Hits           3467     3478      +11     
  Misses          467      467              
Flag Coverage Δ
unit 88.16% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant