diff --git a/backend/open_webui/models/models.py b/backend/open_webui/models/models.py index 9bd3f888c..71296b295 100755 --- a/backend/open_webui/models/models.py +++ b/backend/open_webui/models/models.py @@ -143,6 +143,8 @@ class ModelAccessListResponse(BaseModel): class ModelForm(BaseModel): + model_config = ConfigDict(extra='ignore') + id: str base_model_id: Optional[str] = None name: str diff --git a/src/lib/apis/models/index.ts b/src/lib/apis/models/index.ts index 05f273c30..e7abaa309 100644 --- a/src/lib/apis/models/index.ts +++ b/src/lib/apis/models/index.ts @@ -152,6 +152,9 @@ export const getBaseModels = async (token: string = '') => { export const createNewModel = async (token: string, model: object) => { let error = null; + const { id, base_model_id, name, meta, params, access_grants, is_active } = model as any; + const payload = { id, base_model_id, name, meta, params, access_grants, is_active }; + const res = await fetch(`${WEBUI_API_BASE_URL}/models/create`, { method: 'POST', headers: { @@ -159,7 +162,7 @@ export const createNewModel = async (token: string, model: object) => { 'Content-Type': 'application/json', authorization: `Bearer ${token}` }, - body: JSON.stringify(model) + body: JSON.stringify(payload) }) .then(async (res) => { if (!res.ok) throw await res.json(); @@ -251,6 +254,9 @@ export const toggleModelById = async (token: string, id: string) => { export const updateModelById = async (token: string, id: string, model: object) => { let error = null; + const { base_model_id, name, meta, params, access_grants, is_active } = model as any; + const payload = { id, base_model_id, name, meta, params, access_grants, is_active }; + const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/update`, { method: 'POST', headers: { @@ -258,7 +264,7 @@ export const updateModelById = async (token: string, id: string, model: object) 'Content-Type': 'application/json', authorization: `Bearer ${token}` }, - body: JSON.stringify({ ...model, id }) + body: JSON.stringify(payload) }) .then(async (res) => { if (!res.ok) throw await res.json();