更新
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use app\adminapi\logic\tcm\DiagnosisAiLogic;
|
||||
use app\adminapi\logic\tcm\PatientAiReportLogic;
|
||||
use app\common\service\TcmAncientBooksReference;
|
||||
|
||||
function provenanceExpect(bool $condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
fwrite(STDERR, "FAIL: {$message}\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$source = [
|
||||
'title' => '测试古籍', 'chapter' => '消渴篇', 'path' => '123-测试古籍.txt',
|
||||
'line' => 42, 'commit' => TcmAncientBooksReference::COMMIT,
|
||||
'url' => TcmAncientBooksReference::REPOSITORY_URL . '/blob/'
|
||||
. TcmAncientBooksReference::COMMIT . '/123-%E6%B5%8B%E8%AF%95%E5%8F%A4%E7%B1%8D.txt#L42',
|
||||
];
|
||||
$json = json_encode([$source], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$diagnosisFormat = new ReflectionMethod(DiagnosisAiLogic::class, 'formatReportRow');
|
||||
$diagnosis = $diagnosisFormat->invoke(null, [
|
||||
'report_content' => '{}',
|
||||
'prompt_version' => 'patient-context-case-explain-nihaixia-ancient-v4',
|
||||
'ancient_book_sources_json' => $json,
|
||||
], '');
|
||||
provenanceExpect($diagnosis['ancient_book_sources'] === [$source], 'diagnosis report retains saved book and line');
|
||||
$oldDiagnosis = $diagnosisFormat->invoke(null, ['report_content' => '{}', 'prompt_version' => 'legacy-v2'], '');
|
||||
provenanceExpect($oldDiagnosis['ancient_book_sources'] === [], 'old diagnosis report gets no ancient citation');
|
||||
|
||||
$patientFormat = new ReflectionMethod(PatientAiReportLogic::class, 'formatReportRow');
|
||||
$patient = $patientFormat->invoke(null, [
|
||||
'report_json' => '{}',
|
||||
'prompt_version' => 'patient-longitudinal-report-nihaixia-ancient-v4',
|
||||
'ancient_book_sources_json' => $json,
|
||||
]);
|
||||
provenanceExpect($patient['ancient_book_sources'] === [$source], 'patient report retains saved book and line');
|
||||
$oldPatient = $patientFormat->invoke(null, ['report_json' => '{}', 'prompt_version' => 'legacy-v2']);
|
||||
provenanceExpect($oldPatient['ancient_book_sources'] === [], 'old patient report gets no ancient citation');
|
||||
|
||||
echo "TCM ancient-books report provenance contract passed.\n";
|
||||
Reference in New Issue
Block a user