feat(chat): allow knowledge chat before upload

This commit is contained in:
2026-06-04 22:16:54 +08:00
parent 1d8a526770
commit efb06519d8
6 changed files with 158 additions and 27 deletions

View File

@@ -53,7 +53,7 @@
<li class="detail-item">
<strong><a href="{% url 'chat:detail' item.conversation_id %}">{{ item.title }}</a></strong>
<div class="muted">产品:{{ item.product_name|default:"未识别" }}</div>
<div class="muted">批次:{{ item.batch_id }}</div>
<div class="muted">批次:{{ item.batch_id|default:"未绑定" }}</div>
<div class="muted">风险:{{ item.risk_level }}</div>
<div class="muted">最近更新:{{ item.updated_at|date:"Y-m-d H:i" }}</div>
<div class="badge-row" style="margin-top: 8px;">
@@ -61,7 +61,10 @@
</div>
</li>
{% empty %}
<li class="detail-item">暂无会话,请先从资料包页面导入资料。</li>
<li class="detail-item">
<strong>暂无历史会话</strong>
<div class="muted">可以直接在中间区域提问Agent 会优先检索知识库。</div>
</li>
{% endfor %}
</ul>
</article>
@@ -75,13 +78,14 @@
<p class="section-copy">中间区域承接用户问题、Agent 回答和节点式结果摘要。</p>
</div>
</div>
{% if conversation %}
{% if node_results %}
<div class="badge-row" style="margin-bottom: 14px;">
{% for node in node_results %}
<span class="pill {% if node.status == '已完成' %}pill-success{% else %}pill-signal{% endif %}">{{ node.label }} / {{ node.status }}</span>
{% endfor %}
</div>
<form method="post" class="stack">
{% endif %}
<form method="post" class="stack" action="{% if conversation %}{% url 'chat:detail' conversation.conversation_id %}{% else %}{% url 'chat:index' %}{% endif %}">
{% csrf_token %}
<div>
{{ form.message.label_tag }}
@@ -99,12 +103,12 @@
<span>{{ checkbox.choice_label }}</span>
</label>
{% empty %}
<div class="notice">当前资料包还没有可选文档</div>
<div class="notice">未选择文档时Agent 会按问题检索当前知识库</div>
{% endfor %}
</div>
</div>
<div class="button-row">
<button type="submit">提交审核任务</button>
<button type="submit">发送问题</button>
</div>
</form>
{% if result %}
@@ -112,10 +116,9 @@
<strong>Agent 回答</strong>
<div>{{ result.answer|linebreaksbr }}</div>
</div>
{% elif not conversation %}
<div class="notice" style="margin-top: 16px;">可以先不上传资料,直接询问注册法规、资料清单、模板字段或历史知识库内容。</div>
{% endif %}
{% else %}
<div class="notice">暂无会话,请先导入资料包。</div>
{% endif %}
</article>
<article class="panel">
@@ -423,7 +426,20 @@
</div>
</form>
{% else %}
<div class="notice">暂无绑定资料包。</div>
<div class="notice">暂无绑定资料包,仍可先通过中间对话区查询知识库</div>
<form method="post" action="{% url 'documents:upload' %}" enctype="multipart/form-data" class="stack" style="margin-top: 16px;">
{% csrf_token %}
<input type="hidden" name="scenario_id" value="document_review">
<div>
{{ upload_form.files.label_tag }}
{{ upload_form.files }}
<p class="help-text">支持 PDF、DOCX、MD、TXT、ZIP、7Z 与 RAR。上传后会自动形成资料包并绑定新的审核会话。</p>
</div>
<div class="button-row">
<button type="submit">导入资料包</button>
<a class="button" href="{% url 'documents:upload' %}">打开导入向导</a>
</div>
</form>
{% endif %}
</article>
@@ -456,7 +472,7 @@
{% endif %}
</div>
</li>
<li class="detail-item">当前会话围绕 `conversation_id / batch_id / product_name` 串联。</li>
<li class="detail-item">当前会话围绕 conversation_id / batch_id / product_name 串联;未绑定资料包时以知识库问答方式执行</li>
{% if audit_log %}
<li class="detail-item"><a href="{% url 'audit:detail' audit_log.id %}">查看本次处理历史</a></li>
{% endif %}