mirror of
https://github.com/open-webui/open-webui.git
synced 2026-04-29 04:00:01 -05:00
refac
This commit is contained in:
@@ -512,6 +512,7 @@ async def update_model_by_id(
|
||||
|
||||
class ModelAccessGrantsForm(BaseModel):
|
||||
id: str
|
||||
name: Optional[str] = None
|
||||
access_grants: list[dict]
|
||||
|
||||
|
||||
@@ -535,7 +536,7 @@ async def update_model_access_by_id(
|
||||
model = Models.insert_new_model(
|
||||
ModelForm(
|
||||
id=form_data.id,
|
||||
name=form_data.id,
|
||||
name=form_data.name or form_data.id,
|
||||
meta=ModelMeta(),
|
||||
params=ModelParams(),
|
||||
),
|
||||
|
||||
@@ -281,7 +281,7 @@ export const updateModelById = async (token: string, id: string, model: object)
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateModelAccessGrants = async (token: string, id: string, accessGrants: any[]) => {
|
||||
export const updateModelAccessGrants = async (token: string, id: string, name: string, accessGrants: any[]) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/access/update`, {
|
||||
@@ -291,7 +291,7 @@ export const updateModelAccessGrants = async (token: string, id: string, accessG
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ id, access_grants: accessGrants })
|
||||
body: JSON.stringify({ id, name, access_grants: accessGrants })
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
|
||||
@@ -346,7 +346,7 @@
|
||||
onChange={async () => {
|
||||
if (edit && model?.id) {
|
||||
try {
|
||||
await updateModelAccessGrants(localStorage.token, model.id, accessGrants);
|
||||
await updateModelAccessGrants(localStorage.token, model.id, model.name ?? name, accessGrants);
|
||||
toast.success($i18n.t('Saved'));
|
||||
} catch (error) {
|
||||
toast.error(error?.detail ?? `${error}`);
|
||||
|
||||
Reference in New Issue
Block a user