mcp-core.php
10 hours ago
mcp-oauth.php
1 month ago
mcp-rest.php
3 weeks ago
mcp.conf
1 year ago
mcp.js
8 months ago
mcp.md
8 months ago
mcp.php
1 week ago
wpai-connectors.php
2 months ago
wpai-gateway-availability.php
2 months ago
wpai-gateway-directory.php
2 months ago
wpai-gateway-image-model.php
2 months ago
wpai-gateway-model.php
2 months ago
wpai-gateway-providers.php
2 months ago
wpai-gateway.php
2 months ago
wpai-gateway-availability.php
39 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Availability check. Scoped: configured iff AI Engine has an env of the |
| 4 | * given type with a key (or no key needed, like Ollama). Unscoped: any env. |
| 5 | */ |
| 6 | |
| 7 | use WordPress\AiClient\Providers\Contracts\ProviderAvailabilityInterface; |
| 8 | |
| 9 | class Meow_MWAI_Labs_WPAI_Gateway_Availability implements ProviderAvailabilityInterface { |
| 10 | |
| 11 | private ?string $engine_type; |
| 12 | |
| 13 | public function __construct( ?string $engine_type = null ) { |
| 14 | $this->engine_type = $engine_type; |
| 15 | } |
| 16 | |
| 17 | public function isConfigured(): bool { |
| 18 | $core = Meow_MWAI_Labs_WPAI_Gateway::$core; |
| 19 | if ( ! $core ) { |
| 20 | return false; |
| 21 | } |
| 22 | $options = $core->get_all_options(); |
| 23 | if ( empty( $options['ai_envs'] ) ) { |
| 24 | return false; |
| 25 | } |
| 26 | foreach ( $options['ai_envs'] as $env ) { |
| 27 | $type = $env['type'] ?? ''; |
| 28 | if ( $this->engine_type !== null && $type !== $this->engine_type ) { |
| 29 | continue; |
| 30 | } |
| 31 | $key = $env['apikey'] ?? ''; |
| 32 | if ( $type === 'ollama' || ! empty( $key ) ) { |
| 33 | return true; |
| 34 | } |
| 35 | } |
| 36 | return false; |
| 37 | } |
| 38 | } |
| 39 |