mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-22 08:57:42 +08:00
feat: 新增 thinking 注入配置支持,扩展设置管理与前端交互
新增 promptcompat 和 OpenAI shared 层的 thinking 注入逻辑, 完善配置系统的编解码与校验,更新设置管理 API 与前端 UI。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,9 @@ const DEFAULT_FORM = {
|
||||
responses: { store_ttl_seconds: 900 },
|
||||
embeddings: { provider: '' },
|
||||
auto_delete: { mode: 'none' },
|
||||
history_split: { enabled: true, trigger_after_turns: 1 },
|
||||
history_split: { enabled: false, trigger_after_turns: 1 },
|
||||
current_input_file: { enabled: true, min_chars: 0 },
|
||||
thinking_injection: { enabled: true },
|
||||
model_aliases_text: '{}',
|
||||
}
|
||||
|
||||
@@ -50,6 +52,8 @@ function normalizeAutoDeleteMode(raw) {
|
||||
}
|
||||
|
||||
function fromServerForm(data) {
|
||||
const historySplitEnabled = Boolean(data.history_split?.enabled)
|
||||
const currentInputFileEnabled = historySplitEnabled ? false : (data.current_input_file?.enabled ?? true)
|
||||
return {
|
||||
admin: { jwt_expire_hours: Number(data.admin?.jwt_expire_hours || 24) },
|
||||
runtime: {
|
||||
@@ -71,14 +75,23 @@ function fromServerForm(data) {
|
||||
mode: normalizeAutoDeleteMode(data.auto_delete),
|
||||
},
|
||||
history_split: {
|
||||
enabled: true,
|
||||
enabled: historySplitEnabled,
|
||||
trigger_after_turns: Number(data.history_split?.trigger_after_turns || 1),
|
||||
},
|
||||
current_input_file: {
|
||||
enabled: currentInputFileEnabled,
|
||||
min_chars: Number(data.current_input_file?.min_chars ?? 0),
|
||||
},
|
||||
thinking_injection: {
|
||||
enabled: data.thinking_injection?.enabled ?? true,
|
||||
},
|
||||
model_aliases_text: JSON.stringify(data.model_aliases || {}, null, 2),
|
||||
}
|
||||
}
|
||||
|
||||
function toServerPayload(form) {
|
||||
const historySplitEnabled = Boolean(form.history_split?.enabled)
|
||||
const currentInputFileEnabled = historySplitEnabled ? false : Boolean(form.current_input_file?.enabled)
|
||||
return {
|
||||
admin: { jwt_expire_hours: Number(form.admin.jwt_expire_hours) },
|
||||
runtime: {
|
||||
@@ -94,9 +107,16 @@ function toServerPayload(form) {
|
||||
embeddings: { provider: String(form.embeddings.provider || '').trim() },
|
||||
auto_delete: { mode: normalizeAutoDeleteMode(form.auto_delete) },
|
||||
history_split: {
|
||||
enabled: true,
|
||||
enabled: historySplitEnabled,
|
||||
trigger_after_turns: Number(form.history_split?.trigger_after_turns || 1),
|
||||
},
|
||||
current_input_file: {
|
||||
enabled: currentInputFileEnabled,
|
||||
min_chars: Number(form.current_input_file?.min_chars ?? 0),
|
||||
},
|
||||
thinking_injection: {
|
||||
enabled: Boolean(form.thinking_injection?.enabled ?? true),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user