Files
zyt/server/tests/PrescriptionAiConfigTest.php
2026-08-14 14:37:30 +08:00

32 lines
953 B
PHP

<?php
declare(strict_types=1);
require dirname(__DIR__) . '/vendor/autoload.php';
$app = new think\App(dirname(__DIR__));
$app->initialize();
$config = config('prescription_ai') ?: [];
$checks = [
'ENABLE' => array_key_exists('enable', $config),
'BASE_URL' => trim((string) ($config['base_url'] ?? '')) !== '',
'TIMEOUT' => (int) ($config['timeout'] ?? 0) >= 1
&& (int) ($config['timeout'] ?? 0) <= 300,
'QWEN_API_KEY' => trim((string) ($config['models']['qwen']['api_key'] ?? '')) !== '',
'OPENAI_API_KEY' => trim((string) ($config['models']['openai']['api_key'] ?? '')) !== '',
];
$failed = false;
foreach ($checks as $name => $configured) {
echo $name . '=' . ($configured ? 'configured' : 'not-configured') . PHP_EOL;
$failed = $failed || !$configured;
}
if ($failed) {
fwrite(STDERR, "Prescription AI server configuration is incomplete.\n");
exit(1);
}
echo "Prescription AI configuration: OK\n";