feat: refine topic insights and learner experience
This commit is contained in:
@@ -37,6 +37,7 @@ const selectedHistory = ref<PromptDetail | null>(null);
|
||||
const historyDetailLoading = ref(false);
|
||||
const agentDebugTrace = ref<Record<string, any>[]>([]);
|
||||
const lastDebugRoute = ref<{ modelName?: string; routeReason?: string } | null>(null);
|
||||
const DEFAULT_AGENT_PREVIEW_MESSAGE = "选择模型和知识库后,可以在这里调试 Agent 的真实问答效果。";
|
||||
const agentPreviewMessages = ref<{
|
||||
role: "user" | "assistant" | "system";
|
||||
content: string;
|
||||
@@ -44,7 +45,7 @@ const agentPreviewMessages = ref<{
|
||||
showReasoning?: boolean;
|
||||
streaming?: boolean;
|
||||
}[]>([
|
||||
{ role: "assistant", content: "选择模型和知识库后,可以在这里调试 Agent 的真实问答效果。" },
|
||||
{ role: "assistant", content: DEFAULT_AGENT_PREVIEW_MESSAGE },
|
||||
]);
|
||||
|
||||
const agentForm = reactive({
|
||||
@@ -132,9 +133,9 @@ async function load() {
|
||||
?? modelRows[0]?.id;
|
||||
applyRuntimeConfig(formalConfig);
|
||||
applyDebugModelDefaults(agentForm.modelId);
|
||||
agentForm.knowledgeIds = knowledgeRows
|
||||
.filter((item) => item.status === 1 && item.lifecycleStatus === "active")
|
||||
.map((item) => item.id);
|
||||
// 空选择由后端使用和用户端一致的“正式开放知识库”规则。
|
||||
// 只有管理员显式勾选时,才进入指定知识库的预览模式。
|
||||
agentForm.knowledgeIds = [];
|
||||
if (props.previewKnowledgeId) applyPreviewKnowledge(props.previewKnowledgeId);
|
||||
void searchDebugUsers("");
|
||||
await loadHistory();
|
||||
@@ -457,10 +458,15 @@ function scrollAgentPreview() {
|
||||
});
|
||||
}
|
||||
|
||||
function clearAgentPreview(message = "预览已清空,可以继续发起新的 Agent 调试。") {
|
||||
agentPreviewMessages.value = [{ role: "assistant", content: message }];
|
||||
function clearAgentPreview(message?: string) {
|
||||
const notice = typeof message === "string" && message.trim()
|
||||
? message
|
||||
: "预览已清空,可以继续发起新的 Agent 调试。";
|
||||
agentPreviewMessages.value = [{ role: "assistant", content: notice }];
|
||||
agentDebugTrace.value = [];
|
||||
lastDebugRoute.value = null;
|
||||
agentForm.question = "";
|
||||
scrollAgentPreview();
|
||||
}
|
||||
|
||||
function changeTypeLabel(value?: string) {
|
||||
@@ -621,9 +627,18 @@ function errorMessage(error: unknown, fallback: string) {
|
||||
<el-select v-model="agentForm.knowledgeIds" class="debug-knowledge-select" multiple filterable collapse-tags collapse-tags-tooltip :max-collapse-tags="2" popper-class="debug-knowledge-popper" placeholder="默认使用全部已开放知识库">
|
||||
<el-option v-for="item in knowledge" :key="item.id" :label="`${item.name}${item.status === 0 ? ' · 已关闭(仅本次预览)' : ''}`" :value="item.id" />
|
||||
</el-select>
|
||||
<div class="agent-form-help">不选时与用户端一致,只使用已开放、已确认且来源正常的正式版本;显式选择则是本次预览范围。</div>
|
||||
</el-form-item>
|
||||
<section class="agent-advanced-settings">
|
||||
<div class="agent-subsection-title"><h4>高级生成参数</h4><span>仅影响本次后台调试</span></div>
|
||||
<el-alert
|
||||
v-if="agentForm.temperature == null"
|
||||
class="agent-debug-randomness-alert"
|
||||
title="当前未指定回答随机性,将使用模型供应商默认值;做同题稳定性对比时建议设为 0。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<AgentGenerationParameters
|
||||
v-model:temperature="agentForm.temperature"
|
||||
v-model:top-p="agentForm.topP"
|
||||
@@ -699,7 +714,7 @@ function errorMessage(error: unknown, fallback: string) {
|
||||
<aside class="agent-preview-panel">
|
||||
<div class="agent-preview-head">
|
||||
<div><h3>调试预览</h3><small>{{ selectedKnowledgeSummary }} · {{ selectedDebugUserLabel }} · {{ selectedDebugTopicLabel }}</small></div>
|
||||
<div class="agent-preview-head-actions"><span :title="lastDebugRoute?.routeReason || ''">{{ lastDebugRoute?.modelName || selectedModelName }}</span><el-button link :disabled="agentDebugging" @click="clearAgentPreview">清空</el-button></div>
|
||||
<div class="agent-preview-head-actions"><span :title="lastDebugRoute?.routeReason || ''">{{ lastDebugRoute?.modelName || selectedModelName }}</span><el-button link :disabled="agentDebugging" @click="clearAgentPreview()">清空</el-button></div>
|
||||
</div>
|
||||
<div ref="agentPreviewChat" class="agent-preview-chat">
|
||||
<article v-for="(message, index) in agentPreviewMessages" :key="`${message.role}-${index}`" class="agent-preview-message-row" :class="message.role">
|
||||
@@ -719,7 +734,10 @@ function errorMessage(error: unknown, fallback: string) {
|
||||
</article>
|
||||
</div>
|
||||
<div class="agent-preview-composer">
|
||||
<el-input v-model="agentForm.question" type="textarea" :rows="2" resize="none" :disabled="agentDebugging" placeholder="向 Agent 发送测试问题;Enter 发送,Shift+Enter 换行" @keydown.enter.exact.prevent="debugAgent" />
|
||||
<div class="agent-preview-input">
|
||||
<el-input v-model="agentForm.question" type="textarea" :rows="2" resize="none" :disabled="agentDebugging" placeholder="向 Agent 发送测试问题;Enter 发送,Shift+Enter 换行" @keydown.enter.exact.prevent="debugAgent" />
|
||||
<small>连续发送会携带上方历史;同题对比请先清空,并将“回答随机性”设为 0。</small>
|
||||
</div>
|
||||
<el-button :type="agentDebugging ? 'danger' : 'primary'" @click="agentDebugging ? stopDebugAgent() : debugAgent()">{{ agentDebugging ? '停止' : '发送' }}</el-button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user