Handle ExtraBody clearing when frontend sends empty object
The backend now interprets an empty object sent from the frontend as a
signal to clear the ExtraBody field, while nil/undefined preserves the
existing value. Frontend changed to send {} instead of undefined when
the field is empty.
This commit is contained in:
parent
47a796b08f
commit
f9e4b6cc36
2 changed files with 6 additions and 1 deletions
|
|
@ -202,8 +202,13 @@ func (h *Handler) handleUpdateModel(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
mc.ModelConfig.SetAPIKey(mc.APIKey)
|
mc.ModelConfig.SetAPIKey(mc.APIKey)
|
||||||
}
|
}
|
||||||
|
// Preserve existing ExtraBody when omitted (nil), but clear it when
|
||||||
|
// the frontend sends an empty object {} to indicate the field should
|
||||||
|
// be removed.
|
||||||
if mc.ExtraBody == nil {
|
if mc.ExtraBody == nil {
|
||||||
mc.ExtraBody = cfg.ModelList[idx].ExtraBody
|
mc.ExtraBody = cfg.ModelList[idx].ExtraBody
|
||||||
|
} else if len(mc.ExtraBody) == 0 {
|
||||||
|
mc.ExtraBody = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.ModelList[idx] = &mc.ModelConfig
|
cfg.ModelList[idx] = &mc.ModelConfig
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ export function EditModelSheet({
|
||||||
thinking_level: form.thinkingLevel || undefined,
|
thinking_level: form.thinkingLevel || undefined,
|
||||||
extra_body: form.extraBody.trim()
|
extra_body: form.extraBody.trim()
|
||||||
? JSON.parse(form.extraBody.trim())
|
? JSON.parse(form.extraBody.trim())
|
||||||
: undefined,
|
: {},
|
||||||
})
|
})
|
||||||
if (setAsDefault && !model.is_default) {
|
if (setAsDefault && !model.is_default) {
|
||||||
await setDefaultModel(model.model_name)
|
await setDefaultModel(model.model_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue