Skip to content

Fix missing input and output modality combinations, fixing usage of Nano Banana (among other problems)#11

Merged
felixarntz merged 1 commit intotrunkfrom
fix/missing-input-and-output-modality-combinations
Feb 27, 2026
Merged

Fix missing input and output modality combinations, fixing usage of Nano Banana (among other problems)#11
felixarntz merged 1 commit intotrunkfrom
fix/missing-input-and-output-modality-combinations

Conversation

@felixarntz
Copy link
Member

Fixes #10

Great catch @dkotter! This pointed me to other similar omissions (which were probably less critical, but still could cause expected features to not work).

@felixarntz felixarntz added this to the 1.0.2 milestone Feb 27, 2026
@felixarntz felixarntz added the bug Something isn't working label Feb 27, 2026
@github-actions
Copy link

github-actions bot commented Feb 27, 2026

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: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

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

@gziolo
Copy link
Member

gziolo commented Feb 27, 2026

Overall, this looks good. I noticed a nearly identical fix in WordPress/ai-provider-for-openai#11.

I assume it's something every provider might need, so having a utility that simplifies configuration could help. I was thinking about using binary representation for optional modalities (not tested, but it should illustrate the idea):

/**
 * Build all modality combinations that always include the required modalities
 * with every possible subset of the optional modalities.
 *
 * @param array $required Required modalities included in every combination.
 * @param array $optional Optional modalities to generate subsets from.
 * @return array List of modality combinations.
 */
function build_modality_combinations( $required, $optional ) {
    $combinations = array();
    $count         = count( $optional );

    for ( $i = 0; $i < ( 1 << $count ); $i++ ) {
        $combo = $required;

        for ( $j = 0; $j < $count; $j++ ) {
            if ( $i & ( 1 << $j ) ) {
                $combo[] = $optional[ $j ];
            }
        }

        $combinations[] = $combo;
    }

    return $combinations;
}

Example usage:

$allModalityCombinationsWithText = build_modality_combinations(
    array( ModalityEnum::text() ),
    array( ModalityEnum::image(), ModalityEnum::audio(), ModalityEnum::document() )
);
$allModalityCombinationsTextAudio = build_modality_combinations(
    array(),
    array( ModalityEnum::text(), ModalityEnum::audio() )
);

@felixarntz
Copy link
Member Author

@gziolo Thank you! I opened WordPress/php-ai-client#215 to introduce such a helper, great idea. For now I'm going to proceed as is, and we can revise this once the helper has been released.

@felixarntz felixarntz merged commit 24c9654 into trunk Feb 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Nano Banana models don't seem to ever pass our current model checks

2 participants