feat: add agent response depth control

This commit is contained in:
2026-07-20 11:36:18 +08:00
parent 537978082a
commit c2655361b5
12 changed files with 192 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import { computed, nextTick, onMounted, reactive, ref, watch } from "vue";
import { api, streamDebugAgent } from "../services/api";
import type { AgentRuntimeConfig, KnowledgeItem, ModelItem, PromptDetail, PromptHistoryItem } from "../types/api";
import AgentGenerationParameters from "./AgentGenerationParameters.vue";
import AgentResponseDepthControl from "./AgentResponseDepthControl.vue";
import AdminPagination from "./AdminPagination.vue";
import StreamingMarkdownMessage from "./StreamingMarkdownMessage.vue";
@@ -51,6 +52,7 @@ const agentForm = reactive({
maxToken: 8192 as number | null,
streamEnabled: 1,
reasoningVisible: 0,
responseDepth: 35,
question: "",
});
const runtimeConfig = ref<AgentRuntimeConfig | null>(null);
@@ -63,6 +65,7 @@ const runtimeForm = reactive({
maxToken: 8192 as number | null,
streamEnabled: 1,
reasoningVisible: 0,
responseDepth: 35,
});
const promptDirty = computed(() => promptContent.value !== savedPromptContent.value);
@@ -119,6 +122,7 @@ function applyRuntimeConfig(value: AgentRuntimeConfig) {
maxToken: value.maxToken,
streamEnabled: value.streamEnabled,
reasoningVisible: value.reasoningVisible,
responseDepth: value.responseDepth ?? 35,
});
}
@@ -134,6 +138,7 @@ function applyDebugModelDefaults(modelId?: number) {
maxToken: model.maxToken ?? (model.enabled === 1 ? runtimeConfig.value?.maxToken : null) ?? 8192,
streamEnabled: model.streamEnabled ?? 1,
reasoningVisible: runtimeConfig.value?.reasoningVisible ?? 0,
responseDepth: runtimeConfig.value?.responseDepth ?? 35,
});
}
@@ -151,6 +156,7 @@ async function saveRuntimeConfig() {
maxToken: runtimeForm.maxToken,
streamEnabled: runtimeForm.streamEnabled,
reasoningVisible: runtimeForm.reasoningVisible,
responseDepth: runtimeForm.responseDepth,
});
applyRuntimeConfig(saved);
const model = models.value.find((item) => item.id === saved.modelId);
@@ -304,6 +310,7 @@ async function debugAgent() {
maxToken: agentForm.maxToken,
streamEnabled: agentForm.streamEnabled,
reasoningVisible: agentForm.reasoningVisible,
responseDepth: agentForm.responseDepth,
},
(chunk) => {
currentAssistant().content += chunk;
@@ -423,6 +430,7 @@ function errorMessage(error: unknown, fallback: string) {
v-model:max-token="runtimeForm.maxToken"
:disabled="!runtimeConfig?.modelId"
/>
<AgentResponseDepthControl v-model="runtimeForm.responseDepth" :disabled="!runtimeConfig?.modelId" />
<el-form-item class="agent-stream-setting">
<div class="agent-stream-setting-copy">
<strong>用户端流式输出</strong>
@@ -480,6 +488,7 @@ function errorMessage(error: unknown, fallback: string) {
v-model:frequency-penalty="agentForm.frequencyPenalty"
v-model:max-token="agentForm.maxToken"
/>
<AgentResponseDepthControl v-model="agentForm.responseDepth" />
<el-form-item class="agent-stream-setting">
<div class="agent-stream-setting-copy">
<strong>流式输出</strong>