mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-16 14:15:20 +08:00
refactor: replace history_split with current_input_file configuration
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,51 +1,9 @@
|
||||
export default function HistorySplitSection({ t, form, setForm }) {
|
||||
export default function CurrentInputFileSection({ t, form, setForm }) {
|
||||
return (
|
||||
<div className="bg-card border border-border rounded-xl p-5 space-y-4">
|
||||
<div className="space-y-1">
|
||||
<h3 className="font-semibold">{t('settings.historySplitTitle')}</h3>
|
||||
<p className="text-sm text-muted-foreground">{t('settings.historySplitDesc')}</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label className="flex items-start gap-3 rounded-lg border border-border bg-background/60 p-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(form.history_split?.enabled)}
|
||||
onChange={(e) => setForm((prev) => ({
|
||||
...prev,
|
||||
history_split: {
|
||||
...prev.history_split,
|
||||
enabled: e.target.checked,
|
||||
},
|
||||
current_input_file: {
|
||||
...prev.current_input_file,
|
||||
enabled: e.target.checked ? false : Boolean(prev.current_input_file?.enabled),
|
||||
},
|
||||
}))}
|
||||
className="mt-1 h-4 w-4 rounded border-border"
|
||||
/>
|
||||
<div className="space-y-1">
|
||||
<span className="text-sm font-medium block">{t('settings.historySplitEnabled')}</span>
|
||||
<span className="text-xs text-muted-foreground block">{t('settings.historySplitEnabledDesc')}</span>
|
||||
</div>
|
||||
</label>
|
||||
<label className="text-sm space-y-2">
|
||||
<span className="text-muted-foreground">{t('settings.historySplitTriggerAfterTurns')}</span>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={1000}
|
||||
value={form.history_split?.trigger_after_turns || 1}
|
||||
onChange={(e) => setForm((prev) => ({
|
||||
...prev,
|
||||
history_split: {
|
||||
...prev.history_split,
|
||||
trigger_after_turns: Number(e.target.value || 1),
|
||||
},
|
||||
}))}
|
||||
className="w-full bg-background border border-border rounded-lg px-3 py-2"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.historySplitTriggerHelp')}</p>
|
||||
</label>
|
||||
<h3 className="font-semibold">{t('settings.currentInputFileTitle')}</h3>
|
||||
<p className="text-sm text-muted-foreground">{t('settings.currentInputFileDesc')}</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label className="flex items-start gap-3 rounded-lg border border-border bg-background/60 p-4">
|
||||
@@ -54,10 +12,6 @@ export default function HistorySplitSection({ t, form, setForm }) {
|
||||
checked={Boolean(form.current_input_file?.enabled)}
|
||||
onChange={(e) => setForm((prev) => ({
|
||||
...prev,
|
||||
history_split: {
|
||||
...prev.history_split,
|
||||
enabled: e.target.checked ? false : Boolean(prev.history_split?.enabled),
|
||||
},
|
||||
current_input_file: {
|
||||
...prev.current_input_file,
|
||||
enabled: e.target.checked,
|
||||
@@ -89,7 +43,6 @@ export default function HistorySplitSection({ t, form, setForm }) {
|
||||
<p className="text-xs text-muted-foreground">{t('settings.currentInputFileHelp')}</p>
|
||||
</label>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.splitPassThroughHelp')}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useSettingsForm } from './useSettingsForm'
|
||||
import SecuritySection from './SecuritySection'
|
||||
import RuntimeSection from './RuntimeSection'
|
||||
import BehaviorSection from './BehaviorSection'
|
||||
import HistorySplitSection from './HistorySplitSection'
|
||||
import CurrentInputFileSection from './HistorySplitSection'
|
||||
import CompatibilitySection from './CompatibilitySection'
|
||||
import AutoDeleteSection from './AutoDeleteSection'
|
||||
import ModelSection from './ModelSection'
|
||||
@@ -96,7 +96,7 @@ export default function SettingsContainer({ onRefresh, onMessage, authFetch, onF
|
||||
|
||||
<BehaviorSection t={t} form={form} setForm={setForm} />
|
||||
|
||||
<HistorySplitSection t={t} form={form} setForm={setForm} />
|
||||
<CurrentInputFileSection t={t} form={form} setForm={setForm} />
|
||||
|
||||
<CompatibilitySection t={t} form={form} setForm={setForm} />
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ const DEFAULT_FORM = {
|
||||
responses: { store_ttl_seconds: 900 },
|
||||
embeddings: { provider: '' },
|
||||
auto_delete: { mode: 'none' },
|
||||
history_split: { enabled: false, trigger_after_turns: 1 },
|
||||
current_input_file: { enabled: true, min_chars: 0 },
|
||||
thinking_injection: { enabled: true, prompt: '', default_prompt: '' },
|
||||
model_aliases_text: '{}',
|
||||
@@ -52,8 +51,7 @@ function normalizeAutoDeleteMode(raw) {
|
||||
}
|
||||
|
||||
function fromServerForm(data) {
|
||||
const historySplitEnabled = Boolean(data.history_split?.enabled)
|
||||
const currentInputFileEnabled = historySplitEnabled ? false : (data.current_input_file?.enabled ?? true)
|
||||
const currentInputFileEnabled = data.current_input_file?.enabled ?? true
|
||||
return {
|
||||
admin: { jwt_expire_hours: Number(data.admin?.jwt_expire_hours || 24) },
|
||||
runtime: {
|
||||
@@ -74,10 +72,6 @@ function fromServerForm(data) {
|
||||
auto_delete: {
|
||||
mode: normalizeAutoDeleteMode(data.auto_delete),
|
||||
},
|
||||
history_split: {
|
||||
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),
|
||||
@@ -92,8 +86,7 @@ function fromServerForm(data) {
|
||||
}
|
||||
|
||||
function toServerPayload(form) {
|
||||
const historySplitEnabled = Boolean(form.history_split?.enabled)
|
||||
const currentInputFileEnabled = historySplitEnabled ? false : Boolean(form.current_input_file?.enabled)
|
||||
const currentInputFileEnabled = Boolean(form.current_input_file?.enabled)
|
||||
return {
|
||||
admin: { jwt_expire_hours: Number(form.admin.jwt_expire_hours) },
|
||||
runtime: {
|
||||
@@ -108,10 +101,6 @@ function toServerPayload(form) {
|
||||
responses: { store_ttl_seconds: Number(form.responses.store_ttl_seconds) },
|
||||
embeddings: { provider: String(form.embeddings.provider || '').trim() },
|
||||
auto_delete: { mode: normalizeAutoDeleteMode(form.auto_delete) },
|
||||
history_split: {
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user