first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
function analysisConfigExpect(bool $condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
fwrite(STDERR, "FAIL: {$message}\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$configPath = dirname(__DIR__) . '/config/prescription_ai.php';
|
||||
$configSource = file_get_contents($configPath);
|
||||
analysisConfigExpect(is_string($configSource), 'prescription_ai config is readable');
|
||||
analysisConfigExpect(str_contains($configSource, "'qwen' => ["), 'qwen profile exists');
|
||||
analysisConfigExpect(str_contains($configSource, "'openai' => ["), 'openai profile exists');
|
||||
analysisConfigExpect(
|
||||
str_contains($configSource, "'prescription_ai.QWEN_API_KEY'")
|
||||
&& str_contains($configSource, "'prescription_ai.OPENAI_API_KEY'"),
|
||||
'both credentials come from server environment'
|
||||
);
|
||||
analysisConfigExpect(
|
||||
!preg_match('/(?:sk-|app-)[A-Za-z0-9_-]{16,}/', $configSource),
|
||||
'config source does not hard-code an API credential'
|
||||
);
|
||||
|
||||
$example = file_get_contents(dirname(__DIR__) . '/.env.prescription-ai.example');
|
||||
analysisConfigExpect(is_string($example), 'safe environment example is readable');
|
||||
analysisConfigExpect(str_contains($example, 'QWEN_API_KEY = "replace-on-server"'), 'qwen example is a placeholder');
|
||||
analysisConfigExpect(str_contains($example, 'OPENAI_API_KEY = "replace-on-server"'), 'openai example is a placeholder');
|
||||
analysisConfigExpect(!str_contains($example, 'chat2.zhenyangtang.com.cn'), 'example does not expose a real upstream host');
|
||||
|
||||
echo "Diagnosis AI analysis config: OK\n";
|
||||
Reference in New Issue
Block a user