优化上下文
This commit is contained in:
@@ -113,6 +113,8 @@
|
||||
"model": "Model",
|
||||
"timeout": "Timeout (seconds)",
|
||||
"max_tokens": "Max Tokens",
|
||||
"context_window_tokens": "Context Window Tokens",
|
||||
"context_window_tokens_hint": "0 means unlimited. When exceeded, the system prompt and latest messages are kept while oldest Q/A turns are removed.",
|
||||
"system_prompt": "System Prompt",
|
||||
"tool_router": "Tool Router",
|
||||
"router_profile": "Router Profile",
|
||||
@@ -132,6 +134,7 @@
|
||||
"error_api_key_required": "When AI is enabled, the default profile must have an API key",
|
||||
"error_timeout": "Timeout must be a positive integer",
|
||||
"error_max_tokens": "Max tokens must be a positive integer",
|
||||
"error_context_window_tokens": "Context window tokens must be a non-negative integer",
|
||||
"error_router_profile": "Tool router profile must exist in profile list",
|
||||
"error_tool_name_required": "Tool name is required",
|
||||
"error_tool_name_duplicate": "Tool names must be unique"
|
||||
|
||||
@@ -113,6 +113,8 @@
|
||||
"model": "模型",
|
||||
"timeout": "超时(秒)",
|
||||
"max_tokens": "最大 Token",
|
||||
"context_window_tokens": "上下文窗口 Token",
|
||||
"context_window_tokens_hint": "0 表示不限制;超过后会保留系统提示词和最新消息,删除最早的问答记录。",
|
||||
"system_prompt": "系统提示词",
|
||||
"tool_router": "工具路由",
|
||||
"router_profile": "路由接口",
|
||||
@@ -132,6 +134,7 @@
|
||||
"error_api_key_required": "启用 AI 时默认接口必须配置 API Key",
|
||||
"error_timeout": "超时必须是正整数",
|
||||
"error_max_tokens": "最大 Token 必须是正整数",
|
||||
"error_context_window_tokens": "上下文窗口 Token 必须是非负整数",
|
||||
"error_router_profile": "工具路由接口必须来自现有接口列表",
|
||||
"error_tool_name_required": "工具名称不能为空",
|
||||
"error_tool_name_duplicate": "工具名称不能重复"
|
||||
|
||||
@@ -42,6 +42,7 @@ function normalizeProfile(profile = {}) {
|
||||
model: profile.model || '',
|
||||
timeout: Number(profile.timeout || 120),
|
||||
maxTokens: Number(profile.maxTokens || 4096),
|
||||
contextWindowTokens: Number(profile.contextWindowTokens || 0),
|
||||
systemPrompt: profile.systemPrompt || '',
|
||||
}
|
||||
}
|
||||
@@ -117,6 +118,7 @@ function addProfile() {
|
||||
model: '',
|
||||
timeout: 120,
|
||||
maxTokens: 4096,
|
||||
contextWindowTokens: 0,
|
||||
systemPrompt: '',
|
||||
})
|
||||
}
|
||||
@@ -178,6 +180,7 @@ function validate() {
|
||||
|
||||
profile.timeout = Number(profile.timeout)
|
||||
profile.maxTokens = Number(profile.maxTokens)
|
||||
profile.contextWindowTokens = Number(profile.contextWindowTokens)
|
||||
if (!Number.isInteger(profile.timeout) || profile.timeout <= 0) {
|
||||
toast.error(t('aiconfig.error_timeout'))
|
||||
return false
|
||||
@@ -186,6 +189,10 @@ function validate() {
|
||||
toast.error(t('aiconfig.error_max_tokens'))
|
||||
return false
|
||||
}
|
||||
if (!Number.isInteger(profile.contextWindowTokens) || profile.contextWindowTokens < 0) {
|
||||
toast.error(t('aiconfig.error_context_window_tokens'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasActive) {
|
||||
@@ -248,6 +255,7 @@ function buildPayload() {
|
||||
model: profile.model.trim(),
|
||||
timeout: Number(profile.timeout),
|
||||
maxTokens: Number(profile.maxTokens),
|
||||
contextWindowTokens: Number(profile.contextWindowTokens),
|
||||
systemPrompt: profile.systemPrompt || '',
|
||||
})),
|
||||
toolRouter: {
|
||||
@@ -360,6 +368,11 @@ async function saveConfig() {
|
||||
<span>{{ t('aiconfig.max_tokens') }}</span>
|
||||
<input v-model.number="profile.maxTokens" class="input" type="number" min="1" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>{{ t('aiconfig.context_window_tokens') }}</span>
|
||||
<input v-model.number="profile.contextWindowTokens" class="input" type="number" min="0" />
|
||||
<span class="text-xs font-normal text-gray-500 dark:text-dk-subtle">{{ t('aiconfig.context_window_tokens_hint') }}</span>
|
||||
</label>
|
||||
<label class="field md:col-span-2">
|
||||
<span>{{ t('aiconfig.system_prompt') }}</span>
|
||||
<textarea v-model="profile.systemPrompt" class="input min-h-24 resize-y" />
|
||||
|
||||
Reference in New Issue
Block a user