更新
This commit is contained in:
@@ -15,7 +15,6 @@ final class NihaixiaClinicalSkill
|
||||
{
|
||||
public const VERSION = 'nihaixia-270e94e-clinical-v1';
|
||||
|
||||
public const REPOSITORY_URL = 'https://github.com/coinweth/nihaixia-skill';
|
||||
public const COMMIT = '270e94e637c4249dc411e54ac6715f21247de3cb';
|
||||
public const SECTIONS = ['六经速查表', '六经辨证诊断公式', '七步走辨证思维模式'];
|
||||
|
||||
@@ -24,12 +23,26 @@ final class NihaixiaClinicalSkill
|
||||
{
|
||||
return [
|
||||
'title' => '倪海厦临床参考 Skill',
|
||||
'url' => self::REPOSITORY_URL . '/blob/' . self::COMMIT . '/SKILL.md',
|
||||
'url' => '',
|
||||
'path' => 'SKILL.md',
|
||||
'commit' => self::COMMIT,
|
||||
'sections' => self::SECTIONS,
|
||||
];
|
||||
}
|
||||
|
||||
/** Remove external links from saved prescription results without changing their attribution. */
|
||||
public static function localizeKnowledgeSource(mixed $source): ?array
|
||||
{
|
||||
if (!is_array($source)) {
|
||||
return null;
|
||||
}
|
||||
$source['url'] = '';
|
||||
if (($source['commit'] ?? null) === self::COMMIT && empty($source['path'])) {
|
||||
$source['path'] = 'SKILL.md';
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
|
||||
/** Historical reports only claim the reference when their saved version identifies it. */
|
||||
public static function knowledgeSourceForPromptVersion(string $promptVersion): ?array
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ final class TcmAncientBooksReference
|
||||
{
|
||||
public const COMMIT = 'db0155dc7c42b9c6b3736896661f317c7110038f';
|
||||
public const INDEX_VERSION = 3;
|
||||
public const REPOSITORY_URL = 'https://github.com/xiaopangxia/TCM-Ancient-Books';
|
||||
private const MARKER = '[TCM_ANCIENT_BOOKS:' . self::COMMIT . ']';
|
||||
|
||||
/** Modern terms are mapped to searchable historical headings/phrases. */
|
||||
@@ -136,7 +135,7 @@ final class TcmAncientBooksReference
|
||||
'path' => $path,
|
||||
'line' => $line,
|
||||
'commit' => self::COMMIT,
|
||||
'url' => self::REPOSITORY_URL . '/blob/' . self::COMMIT . '/' . rawurlencode($path) . '#L' . $line,
|
||||
'url' => '',
|
||||
];
|
||||
if (count($sources) >= $limit) {
|
||||
break;
|
||||
@@ -145,6 +144,20 @@ final class TcmAncientBooksReference
|
||||
return $sources;
|
||||
}
|
||||
|
||||
/** Keep saved citations and excerpts, but never expose an external source URL. */
|
||||
public static function localizeSources(array $sources): array
|
||||
{
|
||||
$localized = [];
|
||||
foreach ($sources as $source) {
|
||||
if (!is_array($source)) {
|
||||
continue;
|
||||
}
|
||||
$source['url'] = '';
|
||||
$localized[] = $source;
|
||||
}
|
||||
return $localized;
|
||||
}
|
||||
|
||||
public static function augmentQuery(string $query): string
|
||||
{
|
||||
if (str_contains($query, self::MARKER)) {
|
||||
@@ -189,7 +202,7 @@ final class TcmAncientBooksReference
|
||||
$lines[] = '《' . $source['title'] . '》' . ($source['chapter'] !== '' ? '「' . $source['chapter'] . '」' : '')
|
||||
. ' 第' . $source['line'] . '行:' . mb_substr($source['excerpt'], 0, 80, 'UTF-8');
|
||||
}
|
||||
$lines[] = '只可引用上述原文;书名、篇章、行号及固定提交链接由系统保存并展示。保持原任务的 JSON 结构与来源编号。';
|
||||
$lines[] = '只可引用上述原文;书名、篇章、文件名、行号及资料版本由系统保存并展示。保持原任务的 JSON 结构与来源编号。';
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\common\service\prescriptionai;
|
||||
|
||||
use app\common\service\NihaixiaClinicalSkill;
|
||||
use app\common\service\TcmAncientBooksReference;
|
||||
use DomainException;
|
||||
use think\facade\Db;
|
||||
|
||||
@@ -345,8 +347,9 @@ final class PrescriptionAiStore
|
||||
$coverageStatus = in_array($coverageStatus, ['complete', 'full'], true) ? 'complete' : 'partial';
|
||||
$body = ['report' => $output['report'] ?? [], 'candidate' => $output['candidate'] ?? null,
|
||||
'comparison' => $comparison, 'coverage' => $coverage, 'usage' => $output['usage'] ?? [],
|
||||
'knowledge_source' => $output['knowledge_source'] ?? null,
|
||||
'ancient_book_sources' => $output['ancient_book_sources'] ?? []];
|
||||
'knowledge_source' => NihaixiaClinicalSkill::localizeKnowledgeSource($output['knowledge_source'] ?? null),
|
||||
'ancient_book_sources' => TcmAncientBooksReference::localizeSources(
|
||||
is_array($output['ancient_book_sources'] ?? null) ? $output['ancient_book_sources'] : [])];
|
||||
$now = time();
|
||||
$resultId = (int) Db::name('prescription_ai_result')->insertGetId([
|
||||
'batch_id' => $task['batch_id'], 'model_key' => $task['model_key'],
|
||||
|
||||
Reference in New Issue
Block a user