接入 DSH 专用运行时和对话界面,保留模型原始回答,支持会话分页、连续追问与显式报告。 补齐组合筛选、各维度 Top100、分组查询到排名图的转换,图表故障静默省略并基于保存数据自动恢复。 优化报告风格、图表顺序和表格换行,更新接入说明及构建输入。 验证:独立目录前后端构建通过;118 项 Java、102 项前端、102 项图表、14 项 DSH 应用和 13 项组合筛选检查通过。 仅提交相关源码、锁定依赖与测试;不包含凭据、会话、业务数据或本地产物。
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""Bounded replacement frames for DSH's provisional assistant text."""
|
|
import hashlib
|
|
import re
|
|
import time
|
|
|
|
_PRIVATE_OUTPUT = re.compile(
|
|
r"(?i)https?://|bearer\s|api[_-]?key\b|authorization\b|clientKey\b|accessToken\b|\bsk-[a-z0-9_-]{10,}|"
|
|
r"quality-turn:|(?:scope|execution|attempt|release|actor|session)[_-]?id\b|"
|
|
r"(?:^|\n)\s*(?:\{|```)|<\s*/?\s*[a-z][a-z0-9:-]*(?:\s|/?>)|"
|
|
r"系统提示词|内部请求归属标记|本轮已确认任务、身份和上下文|本运行时使用DSH|"
|
|
r"【平台能力与职责】|【默认业务口径】|【内容组织】"
|
|
)
|
|
_UUID = re.compile(r"(?i)\b[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\b")
|
|
_NONPRINTING = re.compile(r"[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]")
|
|
|
|
|
|
def display_text(value):
|
|
if not isinstance(value, str) or _PRIVATE_OUTPUT.search(value):
|
|
return ""
|
|
return _NONPRINTING.sub("", _UUID.sub("[标识已隐藏]", value)).strip()[:4000]
|
|
|
|
|
|
class DraftPublisher:
|
|
def __init__(self, emit, *, clock=time.monotonic):
|
|
self.emit = emit
|
|
self.clock = clock
|
|
self.last_time = float("-inf")
|
|
self.current = ""
|
|
|
|
def update(self, attempt, text):
|
|
candidate = display_text(text)
|
|
if len(candidate) < 16:
|
|
self.clear()
|
|
return
|
|
now = self.clock()
|
|
if candidate == self.current or now - self.last_time < 0.25:
|
|
return
|
|
self.current = candidate
|
|
self.last_time = now
|
|
key = hashlib.sha256(attempt.encode("utf-8")).hexdigest()[:24]
|
|
self.emit({"type": "progress", "dshDraft": candidate, "dshAttemptId": key})
|
|
|
|
def clear(self):
|
|
if not self.current:
|
|
return
|
|
self.current = ""
|
|
self.emit({"type": "progress", "dshDraft": ""})
|