feat: 按模型上下文自动配置智能体压缩阈值
- 从 llm.json 解析上下文与输出上限,并增强短模型 ID 匹配 - 切换模型、保存和试运行时按预算公式重算,目录缺失时回退 30K - 修复模型列表接口未返回能力元数据
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
/* eslint-disable vue/no-mutating-props */
|
||||
import type { AgentInfo, AgentOption } from '../types';
|
||||
import type { AgentInfo, AgentOption, AgentToolBinding } from '../types';
|
||||
|
||||
import { InfoFilled } from '@element-plus/icons-vue';
|
||||
import {
|
||||
@@ -15,13 +15,33 @@ import {
|
||||
ElTooltip,
|
||||
} from 'element-plus';
|
||||
|
||||
defineProps<{
|
||||
import { resolveAgentCompressionTokenThreshold } from '../compression-threshold';
|
||||
|
||||
const props = defineProps<{
|
||||
agent: AgentInfo;
|
||||
categories: AgentOption[];
|
||||
models: AgentOption[];
|
||||
toolBindings: AgentToolBinding[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ change: [] }>();
|
||||
|
||||
function handleModelChange(modelId: AgentInfo['modelId']) {
|
||||
const selectedModel = props.models.find(
|
||||
(model) => model.value === String(modelId ?? ''),
|
||||
);
|
||||
const memoryConfig = (props.agent.memoryConfigJson ||= {});
|
||||
const compressionParameter = (memoryConfig.compressionParameter ||= {});
|
||||
compressionParameter.minCompressionTokenThreshold =
|
||||
resolveAgentCompressionTokenThreshold({
|
||||
contextWindowTokens: selectedModel?.raw?.contextWindowTokens,
|
||||
generationConfig: props.agent.generationConfigJson,
|
||||
maxOutputTokens: selectedModel?.raw?.maxOutputTokens,
|
||||
systemPrompt: props.agent.promptConfigJson?.systemPrompt,
|
||||
toolBindings: props.toolBindings,
|
||||
});
|
||||
emit('change');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -67,7 +87,7 @@ const emit = defineEmits<{ change: [] }>();
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="模型" required>
|
||||
<ElSelect v-model="agent.modelId" filterable @change="emit('change')">
|
||||
<ElSelect v-model="agent.modelId" filterable @change="handleModelChange">
|
||||
<ElOption
|
||||
v-for="item in models"
|
||||
:key="item.value"
|
||||
@@ -172,7 +192,7 @@ const emit = defineEmits<{ change: [] }>();
|
||||
<span class="agent-form__label">
|
||||
最小压缩 Token 阈值
|
||||
<ElTooltip
|
||||
content="工作记忆的 Token 数达到该值时,会触发上下文压缩。"
|
||||
content="选择模型时按上下文 85% 与扣除输出、系统提示词、工具和安全余量后的可用值取较小值;模型目录未提供上下文时使用 30K。"
|
||||
effect="light"
|
||||
placement="top"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user