mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat(models): add extra_body config field in model add/edit UI (#1969)
* Add extraBody field to model configuration forms
This adds a new field allowing users to specify additional JSON fields
to inject into the request body when configuring models.
* 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:
@@ -204,8 +204,13 @@ func (h *Handler) handleUpdateModel(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
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 {
|
||||
mc.ExtraBody = cfg.ModelList[idx].ExtraBody
|
||||
} else if len(mc.ExtraBody) == 0 {
|
||||
mc.ExtraBody = nil
|
||||
}
|
||||
|
||||
cfg.ModelList[idx] = &mc.ModelConfig
|
||||
|
||||
Reference in New Issue
Block a user