feat(backend/frontend): remove AI hallucinated reportCode and use UUID programmatic assignment for absolute context integrity
This commit is contained in:
parent
b8a541dcea
commit
43a6018e6a
@ -762,13 +762,12 @@ class DeepviewSSEServer:
|
|||||||
|
|
||||||
# ── Stage 2 格式引擎: qwen3-plus via LiteLLM (JSON Schema 硬约束) ──
|
# ── Stage 2 格式引擎: qwen3-plus via LiteLLM (JSON Schema 硬约束) ──
|
||||||
# 纯转换任务,不做内容创造,只做结构对齐
|
# 纯转换任务,不做内容创造,只做结构对齐
|
||||||
jsonSchema = {
|
jsonSchema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"reportCode": {"type": "string"},
|
"patientName": {"type": "string"},
|
||||||
"patientName": {"type": "string"},
|
"coreDemand": {"type": "string"},
|
||||||
"coreDemand": {"type": "string"},
|
"acceptance": {"type": "string"},
|
||||||
"acceptance": {"type": "string"},
|
|
||||||
"duration": {"type": "number"},
|
"duration": {"type": "number"},
|
||||||
"xray": {
|
"xray": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -866,7 +865,7 @@ class DeepviewSSEServer:
|
|||||||
"required": ["module1", "module2", "module3", "module4", "module5"]
|
"required": ["module1", "module2", "module3", "module4", "module5"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["reportCode", "patientName", "coreDemand", "acceptance", "duration", "xray"]
|
"required": ["patientName", "coreDemand", "acceptance", "duration", "xray"]
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -922,6 +921,12 @@ xray.module5: track1(数组,每项含node/action/strategy/purpose), track2(数
|
|||||||
import uuid
|
import uuid
|
||||||
reportId = presetReportId if presetReportId else "rep_" + uuid.uuid4().hex[:8]
|
reportId = presetReportId if presetReportId else "rep_" + uuid.uuid4().hex[:8]
|
||||||
|
|
||||||
|
# Programmatically inject the real report identifier instead of hallucinated one
|
||||||
|
parsedData['reportCode'] = f"DW-AMXG-{reportId[4:].upper()}"
|
||||||
|
parsedData['id'] = reportId
|
||||||
|
parsedData['context_id'] = contextId
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from hermes_state import SessionDB
|
from hermes_state import SessionDB
|
||||||
reportDb = SessionDB()
|
reportDb = SessionDB()
|
||||||
|
|||||||
@ -457,9 +457,10 @@ export class App implements OnDestroy, OnInit {
|
|||||||
} else {
|
} else {
|
||||||
// No history, push initial greeting
|
// No history, push initial greeting
|
||||||
const title = this.chatCtx.contextTitle();
|
const title = this.chatCtx.contextTitle();
|
||||||
|
const code = this.chatCtx.contextCode();
|
||||||
const greeting = this.chatCtx.contextType() === 'client'
|
const greeting = this.chatCtx.contextType() === 'client'
|
||||||
? `医生您好,上下文已锁定为:${title}(全景档案)。您可以向我追问历史拒因分析或索要跨品类破冰话术。`
|
? `医生您好,上下文已锁定:${title}(全景档案)。您可以向我追问历史拒因分析或索要跨品类破冰话术。`
|
||||||
: `医生您好,我是本场面诊的深维特勤 AI。上下文已锁定。您可以随时向我追问改进方案。`;
|
: `医生您好,我是本场面诊的深维特勤 AI。上下文 (标识:${code}) 已锁定。您可以随时向我追问改进方案。`;
|
||||||
this.chatMessages.push({ role: 'agent', content: greeting, isStreaming: false });
|
this.chatMessages.push({ role: 'agent', content: greeting, isStreaming: false });
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@ -13,6 +13,9 @@ export class ChatContextService {
|
|||||||
/** 上下文类型:recording | client | '' */
|
/** 上下文类型:recording | client | '' */
|
||||||
contextType = signal<'recording' | 'client' | ''>('');
|
contextType = signal<'recording' | 'client' | ''>('');
|
||||||
|
|
||||||
|
/** 当前上下文的附加编码 (如 DW-AMXG-1234) */
|
||||||
|
contextCode = signal<string>('');
|
||||||
|
|
||||||
/** 基于 contextId 派生 chatId */
|
/** 基于 contextId 派生 chatId */
|
||||||
chatId = computed(() => {
|
chatId = computed(() => {
|
||||||
const ctx = this.contextId();
|
const ctx = this.contextId();
|
||||||
|
|||||||
@ -55,6 +55,7 @@ export class ReportDetail implements OnInit {
|
|||||||
this.chatCtx.contextId.set(data.context_id || `recording:${reportId}`);
|
this.chatCtx.contextId.set(data.context_id || `recording:${reportId}`);
|
||||||
this.chatCtx.contextTitle.set(data.clientName || '未归档录音');
|
this.chatCtx.contextTitle.set(data.clientName || '未归档录音');
|
||||||
this.chatCtx.contextType.set('recording');
|
this.chatCtx.contextType.set('recording');
|
||||||
|
this.chatCtx.contextCode.set(data.reportCode || reportId);
|
||||||
|
|
||||||
// 同步写 localStorage 作为离线缓存
|
// 同步写 localStorage 作为离线缓存
|
||||||
localStorage.setItem(`deepview_report_${reportId}`, JSON.stringify(data));
|
localStorage.setItem(`deepview_report_${reportId}`, JSON.stringify(data));
|
||||||
@ -79,6 +80,7 @@ export class ReportDetail implements OnInit {
|
|||||||
this.chatCtx.contextId.set(this.report.context_id || `recording:${reportId}`);
|
this.chatCtx.contextId.set(this.report.context_id || `recording:${reportId}`);
|
||||||
this.chatCtx.contextTitle.set(this.report.clientName || '未归档录音');
|
this.chatCtx.contextTitle.set(this.report.clientName || '未归档录音');
|
||||||
this.chatCtx.contextType.set('recording');
|
this.chatCtx.contextType.set('recording');
|
||||||
|
this.chatCtx.contextCode.set(this.report.reportCode || reportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterClients() {
|
filterClients() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user