修复:DSH 自主查询、图片直显与报告稳定性
允许 Agent 在循环中查目录、修正查询和提问,保留实时权限检查及模型原始回答。 统一相同查询证据与图表资源;排名补齐阶段指标,修正 OR 重量筛选,并限制模型明细输入。 增加运行恢复、图表自适应坐标轴与两位小数,修复报告主图选择、重复图及边缘标签。 验证:独立副本通过 162 项 Python、73 项前端及 21 项后端测试,前端构建通过。 线上已用原 8 题复测,并追加两轮双期对比;TOP100 与组合筛选分别核对 100 行和 20 行。
This commit is contained in:
@@ -14,6 +14,32 @@ const Markdown = new Function('React', 'tableTextAlignment', 'sanitizeAnalysisDi
|
||||
ts.transpileModule(`${source}\nreturn AiMarkdown;`, { compilerOptions: { target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.React } }).outputText
|
||||
)(React, tableTextAlignment, sanitizeAnalysisDisplayText, analysisEvidenceParts);
|
||||
|
||||
test('image syntax renders as a chart reference or caption without rewriting source or fetching URLs', () => {
|
||||
const answer = '前文。 后文。\n\n\n\n``';
|
||||
const html = renderToStaticMarkup(React.createElement(Markdown, { content: answer, preserveSource: true, imageTargets: { 'chart:actual-chart': 'actual-chart' } }));
|
||||
assert.match(html, /href="#actual-chart">趋势标题<\/a>/);
|
||||
assert.match(html, /前文。/); assert.match(html, /后文。/);
|
||||
assert.match(html, /ai-markdown-image-caption[^>]*>未绑定标题<\/span>/);
|
||||
assert.match(html, /<code>!\[代码示例\]\(chart:example\)<\/code>/);
|
||||
assert.doesNotMatch(html, /<img|tracker\.png|chart:actual-chart/);
|
||||
assert.ok(answer.includes(''));
|
||||
});
|
||||
|
||||
test('a bound chart image renders in place while surrounding prose and code examples remain intact', () => {
|
||||
const answer = '分析前文。\n\n\n\n分析后文。\n\n```markdown\n\n```';
|
||||
const source = 'data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%2F%3E';
|
||||
const html = renderToStaticMarkup(React.createElement(Markdown, {
|
||||
content: answer, preserveSource: true,
|
||||
renderImage: (alt, target, key) => target === 'chart:verified' ? React.createElement('img', { key, src: source, alt }) : undefined,
|
||||
}));
|
||||
assert.match(html, /<img[^>]+alt="产品趋势"/);
|
||||
assert.equal((html.match(/<img /g) || []).length, 1);
|
||||
assert.ok(html.indexOf('分析前文') < html.indexOf('<img'));
|
||||
assert.ok(html.indexOf('<img') < html.indexOf('分析后文'));
|
||||
assert.match(html, /<pre><code>!\[代码示例\]\(chart:verified\)/);
|
||||
assert.ok(answer.includes(''));
|
||||
});
|
||||
|
||||
test('original answers preserve wording, table headers, headings and escaped markup', () => {
|
||||
const answer = '## 模型原始回答\n\n数学说明保留。\n\n| 月份 | 原始值 |\n| --- | --- |\n| 8月 | 98.35% |\n\n<script>alert(1)</script>';
|
||||
const html = renderToStaticMarkup(React.createElement(Markdown, { content: answer, preserveSource: true }));
|
||||
|
||||
Reference in New Issue
Block a user