AI Providers - one provider's window: Add (no id) or Edit. Its kind * fills in its address and says where its key is made; the key is never put * back into the page, so left empty it stays. Test asks the provider for its * models, which shows they work and suggests the model to start with. Save * asks first (check_ai_provider, admin/post/ai_provider.php): what is wrong * shows beside each field and the window stays open - a provider that doesn't * answer can still be saved, once said. */ require_once '../../includes/modal_header.php'; $provider_id = intval($_GET['id'] ?? 0); $row = $provider_id ? aiProviderRow($provider_id) : null; if ($provider_id && !$row) { echo json_encode(['error' => 'That AI provider no longer exists.']); exit; } $kinds = aiProviderKinds(); $kind_key = $row ? (string) $row['ai_provider_kind'] : 'openai'; $kind_key = isset($kinds[$kind_key]) ? $kind_key : 'custom'; $kind = $kinds[$kind_key]; $has_key = $row && trim((string) $row['ai_provider_api_key']) !== ''; $redact = $row ? intval($row['ai_provider_redact']) === 1 : true; // Adding the first, the model to start with comes along - for everything $offer_first_model = !$row && !getAiModel('General'); // What the window's script needs of each kind $kinds_js = []; foreach ($kinds as $key => $info) { $kinds_js[$key] = ['name' => $info['name'], 'url' => $info['url'], 'key' => $info['key'], 'keysUrl' => $info['keys_url'], 'local' => $info['local'], 'example' => $info['example']]; } // Where what is wrong with a field shows $error_for = function ($field) { return '
'; }; ob_start(); ?>