first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use app\adminapi\logic\tcm\DiagnosisAiLogic;
|
||||
|
||||
function analysisRoutingExpect($expected, $actual, string $message): void
|
||||
{
|
||||
if ($expected !== $actual) {
|
||||
fwrite(STDERR, sprintf(
|
||||
"FAIL: %s; expected=%s, actual=%s\n",
|
||||
$message,
|
||||
var_export($expected, true),
|
||||
var_export($actual, true)
|
||||
));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$reflection = new ReflectionClass(DiagnosisAiLogic::class);
|
||||
$select = $reflection->getMethod('selectAnalysisProfile');
|
||||
|
||||
analysisRoutingExpect('qwen', $select->invoke(null), 'missing model defaults to qwen');
|
||||
analysisRoutingExpect('qwen', $select->invoke(null, 'qwen'), 'qwen is selected exactly');
|
||||
analysisRoutingExpect('openai', $select->invoke(null, 'openai'), 'openai is selected exactly');
|
||||
|
||||
foreach (['', 'QWEN', 'OpenAI', ' qwen', 'openai ', 'gpt-5.6-sol', 'provider=openai'] as $invalid) {
|
||||
analysisRoutingExpect(null, $select->invoke(null, $invalid), "rejects invalid model {$invalid}");
|
||||
}
|
||||
|
||||
$analysis = $reflection->getMethod('analysis');
|
||||
$parameters = $analysis->getParameters();
|
||||
analysisRoutingExpect('qwen', $parameters[3]->getDefaultValue(), 'legacy internal call defaults to qwen');
|
||||
|
||||
analysisRoutingExpect(
|
||||
null,
|
||||
DiagnosisAiLogic::analysis(7, 0, [], 'gpt-5.6-sol'),
|
||||
'public business logic rejects model names before loading a diagnosis'
|
||||
);
|
||||
analysisRoutingExpect(
|
||||
'AI模型仅支持qwen或openai',
|
||||
DiagnosisAiLogic::getError(),
|
||||
'business logic returns a fixed non-secret invalid-model error'
|
||||
);
|
||||
|
||||
echo "Diagnosis AI analysis model selection: OK\n";
|
||||
Reference in New Issue
Block a user