feat: add agent response depth control
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
modelValue: number;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
defineEmits<{
|
||||
"update:modelValue": [value: number];
|
||||
}>();
|
||||
|
||||
function depthLabel(value: number) {
|
||||
if (value <= 33) return "精简";
|
||||
if (value <= 66) return "平衡";
|
||||
return "深入";
|
||||
}
|
||||
|
||||
function depthCopy(value: number) {
|
||||
if (value <= 33) return "少分析、短建议,优先回到当下和身体感受。";
|
||||
if (value <= 66) return "保留必要解释,给出清楚但不过度展开的建议。";
|
||||
return "允许更完整拆解,但仍保持回归自身、觉察和释放的方向。";
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-form-item class="agent-response-depth">
|
||||
<div class="agent-response-depth-head">
|
||||
<div class="agent-stream-setting-copy">
|
||||
<strong>回答深度</strong>
|
||||
<span>{{ depthCopy(props.modelValue) }}</span>
|
||||
</div>
|
||||
<el-tag effect="plain">{{ depthLabel(props.modelValue) }} {{ props.modelValue }}</el-tag>
|
||||
</div>
|
||||
<el-slider
|
||||
:model-value="props.modelValue"
|
||||
:disabled="disabled"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="5"
|
||||
:marks="{ 0: '精简', 50: '平衡', 100: '深入' }"
|
||||
@update:model-value="$emit('update:modelValue', Number($event))"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
Reference in New Issue
Block a user