refactor(frontend): simplify report build page, drop LLM checkboxes

Made-with: Cursor
This commit is contained in:
hub-gif 2026-04-14 13:25:51 +08:00
parent f3fe8cd5fd
commit 48ed337310
2 changed files with 33 additions and 34 deletions

View File

@ -11,6 +11,18 @@ function splitTriggers(text) {
.filter(Boolean)
}
/**
* 表单未展示的大模型/细类归纳等布尔项从任务读入后在保存时原样写回避免误清空
* backend ``validate_report_config_body`` 允许的键一致
*/
const REPORT_CONFIG_PASSTHROUGH_BOOL_KEYS = [
'llm_comment_sentiment',
'llm_section_bridges',
'llm_matrix_group_summaries',
'llm_price_group_summaries',
'llm_comment_group_summaries',
]
/**
* 报告调参表单与后端 report_config 字段对应面向非技术用户
*/
@ -20,15 +32,14 @@ export function useReportConfigForm() {
const marketRows = ref([
{ indicator: '', value_and_scope: '', source: '', year: '' },
])
const useLlmCommentSentiment = ref(false)
const useLlmSectionBridges = ref(false)
/** 表单未编辑的布尔项,从任务配置读入后随保存写回 */
const passthroughBools = ref({})
function resetToEmpty() {
focusWordRows.value = [{ text: '' }]
scenarioGroups.value = [{ label: '', triggersText: '' }]
marketRows.value = [{ indicator: '', value_and_scope: '', source: '', year: '' }]
useLlmCommentSentiment.value = false
useLlmSectionBridges.value = false
passthroughBools.value = {}
}
/**
@ -99,8 +110,11 @@ export function useReportConfigForm() {
marketRows.value = [{ indicator: '', value_and_scope: '', source: '', year: '' }]
}
useLlmCommentSentiment.value = Boolean(cfg.llm_comment_sentiment)
useLlmSectionBridges.value = Boolean(cfg.llm_section_bridges)
const pass = {}
for (const k of REPORT_CONFIG_PASSTHROUGH_BOOL_KEYS) {
if (Object.prototype.hasOwnProperty.call(cfg, k)) pass[k] = Boolean(cfg[k])
}
passthroughBools.value = pass
}
/** @returns {Record<string, unknown>} 可 PATCH 到后端的 report_config全空则为 {} */
@ -140,9 +154,7 @@ export function useReportConfigForm() {
}))
}
out.llm_comment_sentiment = useLlmCommentSentiment.value
out.llm_section_bridges = useLlmSectionBridges.value
Object.assign(out, passthroughBools.value)
return out
}
@ -188,8 +200,7 @@ export function useReportConfigForm() {
focusWordRows,
scenarioGroups,
marketRows,
useLlmCommentSentiment,
useLlmSectionBridges,
passthroughBools,
resetToEmpty,
applyFromApiConfig,
buildPayload,

View File

@ -11,7 +11,6 @@ import { useReportConfigForm } from '../../composables/useReportConfigForm'
const { jobs } = useJobs()
const selectedId = ref('')
const useLlm = ref(false)
const regenErr = ref('')
const genInFlight = generationInFlightKey()
const REGEN_PREFIX = 'regenerate-report:'
@ -31,8 +30,6 @@ const {
focusWordRows,
scenarioGroups,
marketRows,
useLlmCommentSentiment,
useLlmSectionBridges,
applyFromApiConfig,
buildPayload,
addFocusRow,
@ -159,7 +156,7 @@ async function regenerateReport() {
try {
const r = await api(`/api/jobs/${id}/regenerate-report/`, {
method: 'POST',
body: JSON.stringify({ generator: useLlm.value ? 'llm' : 'rules' }),
body: JSON.stringify({ generator: 'rules' }),
})
const text = await r.text()
if (!r.ok) {
@ -213,17 +210,12 @@ watch(
<section class="ma-card">
<h2>分析报告生成</h2>
<p class="hint-top">
选择<strong>已成功</strong>的任务调整报告统计规则后保存<strong>未勾选</strong>下方选项时按固定统计规则生成报告<strong>勾选使用大模型生成</strong>由大模型根据本批次摘要撰写全文通常更慢且可能计费均不重新爬取
选择<strong>已成功</strong>的任务调整下方统计规则后点保存以上设置再点重新生成报告本页<strong>始终按规则引擎</strong>更新
<code>competitor_analysis.md</code>统计图与表格不重新爬取若需大模型整篇稿或 §8.2 等开关请用高级 JSON写入对应字段后保存或通过 API 调用
阅读与下载请至
<RouterLink to="/jd/analysis-view">报告查看</RouterLink>
</p>
<div class="toolbar">
<label class="chk-inline">
<input v-model="useLlm" type="checkbox" />
使用大模型生成服务端需已配置并可用
</label>
</div>
<div class="toolbar">
<label class="sel-label">任务</label>
<select v-model="selectedId" class="job-select">
@ -249,18 +241,9 @@ watch(
<div v-if="selectedId" class="report-config-block">
<h3 class="report-config-title">报告里的评价统计怎么算</h3>
<p class="hint-top report-config-hint">
下面几项都<strong>可以不改</strong>留空并保存表示沿用系统内置规则请先点保存以上设置再点重新生成报告需要大模型时勾选下方评价归纳各章衔接页顶使用大模型生成仍用于整份报告另一种生成模式
关注词场景词组外部市场表等<strong>可以不改</strong>留空并保存即沿用内置规则大模型相关布尔项
<code>llm_comment_sentiment</code><code>llm_section_bridges</code>不再单独占勾选框若任务里已有会在保存时保留要改请展开高级 JSON
</p>
<div class="toolbar toolbar-llm-flags">
<label class="chk-inline">
<input v-model="useLlmCommentSentiment" type="checkbox" />
评价章大模型归纳§8.2 主题解读 API 密钥
</label>
<label class="chk-inline">
<input v-model="useLlmSectionBridges" type="checkbox" />
各章大模型衔接分析第一九章标题后各一段一次调用多章需密钥
</label>
</div>
<div class="report-config-actions">
<button
type="button"
@ -294,7 +277,12 @@ watch(
<details class="rc-advanced" @toggle="onAdvancedJsonToggle">
<summary>高级 JSON 编辑一般不需要</summary>
<p class="rc-help">打开时会根据上面表单生成内容改完后点写回表单再保存</p>
<p class="rc-help">
打开时会根据上面表单生成内容改完后点写回表单再保存可在此加入
<code>llm_comment_sentiment</code><code>llm_section_bridges</code><code>llm_matrix_group_summaries</code>
等布尔字段须为 <code>true</code>/<code>false</code>重新生成整篇大模型稿需调接口
<code>POST /regenerate-report/</code> body <code>"generator":"llm"</code>
</p>
<textarea v-model="advancedJsonText" class="report-config-editor" rows="10" spellcheck="false" />
<button type="button" class="ma-btn ma-btn-secondary rc-add" @click="applyAdvancedJsonToForm"> JSON 写回表单</button>
</details>