Skip to content

has_ai_credentials returns false if key is configured via constant #536

Description

@LukasFritzeDev

Description

Instead of setting the API_KEY for the provider using the GUI and a database option, one can also set the env value or a constant in wp-config.php:

// wp-config.php
define( 'MITTWALD_API_KEY', 'sk-5S...' );

This works well, the connectors screen shows this information and displays the provider as connected, all AI requests succeed, the models can fetched, and so on.

In Settings › AI, where you can activate the experiments, the experiments can be activated and with the new Developer mode model controls form 0.9.0 the models can be selected.

The problem is, that the following error is still displayed on the top of the page:

The AI plugin requires a valid AI Connector to function properly. Verify you have one or more AI Connectors configured.

Image

Step-by-step reproduction instructions

  1. set provider API Key using content or env:
    // wp-config.php
    define( 'PROVIDER_API_KEY', 'sk-5S...' );
    
  2. Validate that the key is configured correctly by checking Settings › Connectors
  3. Go to Settings › AI
  4. Error shown despite key is configured correctly

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 7.0-RC3
  • AI-Plugin Version 0.9.0
  • DDEV and mittwald hosting project

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except the AI plugin.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Labels

[Type] BugSomething isn't working

Type

No fields configured for Bug.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions