214 lines
9.1 KiB
HTML
214 lines
9.1 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}知识库管理 - DEMO-AGENT V2{% endblock %}
|
|
{% block body_class %}app-body{% endblock %}
|
|
|
|
{% block content %}
|
|
<main class="app-shell">
|
|
<header class="topbar">
|
|
<div class="topbar-left">
|
|
<div class="tabbar" role="tablist" aria-label="页面切换">
|
|
<a class="tab" href="/" role="tab" aria-selected="false">首页</a>
|
|
<a class="tab" href="/" role="tab" aria-selected="false">审核智能体</a>
|
|
<a class="tab active" href="{% url 'knowledge_base_manager' %}" role="tab" aria-selected="true">知识库管理</a>
|
|
<a class="tab" href="{% url 'attachment_manager' %}" role="tab" aria-selected="false">附件管理</a>
|
|
</div>
|
|
</div>
|
|
<div class="topbar-right">
|
|
<div class="user-menu">
|
|
<button class="user-menu-trigger" type="button">
|
|
<span class="avatar large">{{ request.user.username|slice:":1"|upper }}</span>
|
|
<div class="user-copy">
|
|
<strong>{{ request.user.username }}</strong>
|
|
<span>当前登录用户</span>
|
|
</div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<section
|
|
class="knowledge-page"
|
|
data-document-url="{% url 'knowledge_base_document_list' %}"
|
|
data-search-url="{% url 'knowledge_base_search' %}"
|
|
>
|
|
<header class="attachment-manager-hero attachment-manager-toolbar">
|
|
<div>
|
|
<p class="eyebrow">知识库管理</p>
|
|
<h1>知识库管理</h1>
|
|
<p>管理当前账号所有对话可调用的法规、制度、模板和审查依据。</p>
|
|
</div>
|
|
<div class="knowledge-hero-actions">
|
|
<span class="knowledge-status status-{{ knowledge_base.status.code }}">{{ knowledge_base.status.label }}</span>
|
|
<a class="return-chat-link" href="{% url 'home' %}">返回对话</a>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="attachment-manager-content attachment-manager-split knowledge-workbench">
|
|
<aside class="knowledge-left-rail">
|
|
<section class="attachment-manager-panel knowledge-panel knowledge-upload-panel">
|
|
<div class="summary-subheading">
|
|
<h3>上传知识</h3>
|
|
<span>所有对话可调用</span>
|
|
</div>
|
|
<form class="knowledge-document-form" id="knowledgeDocumentForm">
|
|
{% csrf_token %}
|
|
<div
|
|
class="upload-dropzone manager-upload-dropzone knowledge-upload-dropzone"
|
|
id="knowledgeUploadDropzone"
|
|
tabindex="0"
|
|
role="button"
|
|
aria-controls="knowledgeDocumentFile"
|
|
>
|
|
<input id="knowledgeDocumentFile" name="file" type="file" required hidden>
|
|
<strong>点击选择文件,或拖拽到这里</strong>
|
|
<span>支持 doc、docx、xls、xlsx、ppt、pptx、pdf、txt、md</span>
|
|
</div>
|
|
<div class="knowledge-inline-actions">
|
|
<label class="knowledge-checkbox">
|
|
<input name="is_active" type="checkbox" checked>
|
|
<span>上传后启用</span>
|
|
</label>
|
|
<button type="submit">上传并解析</button>
|
|
</div>
|
|
<p class="upload-status" id="knowledgeDocumentStatus">上传后会进入当前账号的全局知识库。</p>
|
|
</form>
|
|
</section>
|
|
|
|
<section class="attachment-manager-panel knowledge-panel knowledge-parse-panel">
|
|
<div class="summary-subheading">
|
|
<h3>解析与索引</h3>
|
|
<span class="knowledge-status status-{{ knowledge_base.status.code }}">{{ knowledge_base.status.label }}</span>
|
|
</div>
|
|
<dl class="knowledge-compact-stats">
|
|
<div>
|
|
<dt>向量片段</dt>
|
|
<dd>{{ knowledge_base.collection.count }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt>用户材料</dt>
|
|
<dd>{{ knowledge_base.managed_document_count|default:0 }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt>内置法规</dt>
|
|
<dd>{{ knowledge_base.source_count }}</dd>
|
|
</div>
|
|
</dl>
|
|
<p class="knowledge-panel-note">{{ knowledge_base.status.message }}</p>
|
|
<div class="knowledge-form-actions">
|
|
<button type="button" onclick="window.location.reload()">刷新状态</button>
|
|
<button type="button" disabled>重建索引</button>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="attachment-manager-panel knowledge-panel knowledge-search-panel">
|
|
<div class="summary-subheading">
|
|
<h3>RAG 检索测试</h3>
|
|
<span>Top 3</span>
|
|
</div>
|
|
<form class="knowledge-search-form" id="knowledgeSearchForm">
|
|
{% csrf_token %}
|
|
<label class="sr-only" for="knowledgeSearchQuery">检索问题</label>
|
|
<input id="knowledgeSearchQuery" name="query" type="search" placeholder="输入审查问题或关键词">
|
|
<button type="submit">测试检索</button>
|
|
</form>
|
|
<div class="knowledge-search-results" id="knowledgeSearchResults">
|
|
<p class="panel-empty">输入问题后查看命中材料、依据片段和相似度。</p>
|
|
</div>
|
|
</section>
|
|
</aside>
|
|
|
|
<section class="knowledge-right-display">
|
|
<section class="attachment-manager-panel knowledge-panel knowledge-document-list-panel">
|
|
<div class="summary-subheading">
|
|
<h3>知识库材料列表</h3>
|
|
<input class="attachment-search" id="knowledgeDocumentSearch" type="search" placeholder="搜索文件名">
|
|
</div>
|
|
<div class="attachment-table-wrap">
|
|
<table class="attachment-table knowledge-document-table" id="knowledgeDocumentTable">
|
|
<thead>
|
|
<tr>
|
|
<th>状态</th>
|
|
<th>材料名称</th>
|
|
<th>文件名</th>
|
|
<th>大小</th>
|
|
<th>入库状态</th>
|
|
<th>更新时间</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for document in knowledge_base.managed_documents %}
|
|
<tr
|
|
data-document-id="{{ document.id }}"
|
|
data-detail-url="/api/review-agent/knowledge-base/documents/{{ document.id }}/"
|
|
data-index-url="/api/review-agent/knowledge-base/documents/{{ document.id }}/index/"
|
|
>
|
|
<td>{% if document.is_active %}启用{% else %}停用{% endif %}</td>
|
|
<td class="attachment-name">{{ document.display_name }}</td>
|
|
<td>{{ document.original_name }}</td>
|
|
<td>{{ document.file_size }} bytes</td>
|
|
<td>{{ document.indexed_label }}</td>
|
|
<td>{{ document.updated_at|slice:":19" }}</td>
|
|
<td class="attachment-actions">
|
|
<button type="button" data-kb-action="index">解析入库</button>
|
|
<button type="button" data-kb-action="edit">编辑</button>
|
|
<button type="button" data-kb-action="toggle">{% if document.is_active %}停用{% else %}启用{% endif %}</button>
|
|
<button type="button" data-kb-action="delete">删除</button>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="table-empty">当前知识库暂无材料</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="attachment-manager-panel knowledge-panel knowledge-source-panel">
|
|
<div class="summary-subheading">
|
|
<h3>内置法规材料</h3>
|
|
<input class="attachment-search" id="knowledgeSourceSearch" type="search" placeholder="搜索内置材料">
|
|
</div>
|
|
<div class="attachment-table-wrap">
|
|
<table class="attachment-table knowledge-source-table" id="knowledgeSourceTable">
|
|
<thead>
|
|
<tr>
|
|
<th>状态</th>
|
|
<th>文件</th>
|
|
<th>类型</th>
|
|
<th>大小</th>
|
|
<th>索引</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for source in knowledge_base.sources %}
|
|
<tr data-source-name="{{ source.name }}">
|
|
<td>{% if source.supported %}可解析{% else %}暂不支持{% endif %}</td>
|
|
<td class="attachment-name">{{ source.relative_path }}</td>
|
|
<td>{{ source.suffix }}</td>
|
|
<td>{{ source.size }} bytes</td>
|
|
<td>{{ source.indexed_label }}</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="5" class="table-empty">暂无法规材料</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</section>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script src="{% static 'js/knowledge_base.js' %}?v=20260608-kb5"></script>
|
|
{% endblock %}
|