WordPress/ai

Connector validity check assumes text generation, so speech-only and image-only connectors report as invalid

开放

#933 创建于 2026年8月13日

 (0 条评论) (0 个反应) (1 位负责人)PHP (136 个派生)auto 404
Help Wanted

仓库指标

星标
 (246 个星标)
PR 合并指标
 (平均合并 5天 4小时) (30 天内合并 72 个 PR)

描述

Description

has_valid_ai_credentials() decides whether any configured connector is valid by asking a single question: can it generate text? A site whose only connector is a speech or image provider is therefore told its connectors may be invalid, when they are correctly configured and working.

The notice shown is:

The AI plugin requires a valid AI Connector to function properly. Please review the AI Connectors you have configured to ensure they are valid.

That reads as "your connector is broken." The connector is fine; it simply does not do text.

Expected: the plugin explains that its features need a text-generation connector, and that the configured connector does not provide one.

Actual: a red error notice asking the user to review their connectors "to ensure they are valid."

Note the UI already distinguishes two cases — "no connectors configured" versus "configured but not valid" — and a non-text connector lands in the second. So the connector is detected correctly; it is the verdict and the wording that mismatch.

Step-by-step reproduction instructions

  1. Install WordPress 7.0.4 and the AI plugin 1.2.0, with no AI connector configured.
  2. Activate a connector plugin that registers a non-text capability only, and give it a working API key. I used an ElevenLabs provider registering TEXT_TO_SPEECH_CONVERSION and SPEECH_GENERATION.
  3. Confirm in Settings → Connectors that the connector shows as Connected.
  4. Visit the AI plugin settings screen.

The red "ensure they are valid" notice appears.

Screenshots, screen recording, code snippet

Run against the environment above, with the connector configured and authenticated:

$p = wp_ai_client_prompt( 'Test' );
var_dump( $p->is_supported_for_text_generation() );            // false
var_dump( $p->is_supported_for_text_to_speech_conversion() );  // true
var_dump( WordPress\AI\has_valid_ai_credentials() );           // false

The connector is registered, authenticated, and usable for the capability it advertises. Only the text-generation question fails.

The verdict comes from includes/helpers.php, in has_valid_ai_credentials() (line 617 on develop at the time of writing):

// See if we have credentials that give us access to generate text.
try {
    return wp_ai_client_prompt( 'Test' )->is_supported_for_text_generation();
} catch ( Throwable $t ) {
    return false;
}

That result reaches the settings screen as PAGE_DATA.hasValidCredentials.

Why this may be worth separating

Most current features — alt text, summarisation, classification, comment moderation — genuinely do need text generation, so gating them is right. The issue is that a capability-specific requirement is reported as a global validity judgement.

This will affect more sites over time. The AI Client SDK defines capabilities for text-to-speech, speech generation, image generation, video generation, and embeddings, and connectors implementing the non-text ones are starting to appear. Any such connector, alone on a site, produces this notice.

There is precedent in this repository for a finer-grained approach: PR #679 ("Gate image generation UI on provider support detection") gates the image generation UI on whether a provider actually supports it, and PR #748 refined that detection. The global credentials check has not yet picked up the same capability awareness.

Possible directions, not prescriptive:

  1. Keep has_valid_ai_credentials() as the "can this plugin do its text-based work" gate, but reword the notice to name the missing capability, e.g. "These features need a connector that generates text. Your configured connectors provide speech only."
  2. Split the check: a connector is valid if it authenticates and registers any capability; sufficient for a feature is then decided per feature, the way image generation already is.
  3. Report per-capability status on the settings screen, so a site can see that speech is available even while text is not.

Happy to work on a PR if there is a preferred direction.

Environment info

  • WordPress 7.0.4
  • AI plugin 1.2.0. The same code is present on develop, so this is not specific to the released version.
  • PHP AI Client 1.3.1 (bundled in core)
  • Connector under test: a third-party ElevenLabs provider, v0.3.0
  • Environment: wp-env, block theme (Twenty Twenty-Five), Chrome on macOS

Confirmations

  • Searched existing issues: yes. I looked for valid connector, has_valid_ai_credentials, and capability/connector wording. The closest existing work is about whether credentials are present (#197, #534, #731, #799) rather than about a valid connector of a non-text modality, and PRs #603, #679, #748 on capability detection. I did not find an existing report of this behaviour, but I may have missed one.
  • Tested with all plugins deactivated except the AI plugin: not applicable, and I want to be straightforward about why rather than tick the box. This behaviour requires a second plugin — a connector — to be active. With every other plugin deactivated there is no connector at all, which produces the other branch of this notice ("Verify you have one or more AI Connectors configured"). The minimal reproduction is the AI plugin plus exactly one non-text connector.
  • Theme type: Block.

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5). Used for: reproducing the behaviour in a local wp-env environment, tracing it to has_valid_ai_credentials(), searching for duplicates, and drafting this report. The reproduction commands above were executed and their output is quoted verbatim.

贡献者指南