refac
This commit is contained in:
1 parent
ad9fbfc1af
commit
3c54863414
3 files changed
+5
-4
No files matched your search
@@ -512,6 +512,7 @@ async def update_model_by_id(
|
|||||||
|
|
||||||
class ModelAccessGrantsForm(BaseModel):
|
class ModelAccessGrantsForm(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
|
name: Optional[str] = None
|
||||||
access_grants: list[dict]
|
access_grants: list[dict]
|
||||||
|
|
||||||
|
|
||||||
@@ -535,7 +536,7 @@ async def update_model_access_by_id(
|
|||||||
model = Models.insert_new_model(
|
model = Models.insert_new_model(
|
||||||
ModelForm(
|
ModelForm(
|
||||||
id=form_data.id,
|
id=form_data.id,
|
||||||
name=form_data.id,
|
name=form_data.name or form_data.id,
|
||||||
meta=ModelMeta(),
|
meta=ModelMeta(),
|
||||||
params=ModelParams(),
|
params=ModelParams(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ export const updateModelById = async (token: string, id: string, model: object)
|
|||||||
return res;
|
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;
|
let error = null;
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/access/update`, {
|
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',
|
'Content-Type': 'application/json',
|
||||||
authorization: `Bearer ${token}`
|
authorization: `Bearer ${token}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ id, access_grants: accessGrants })
|
body: JSON.stringify({ id, name, access_grants: accessGrants })
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (!res.ok) throw await res.json();
|
if (!res.ok) throw await res.json();
|
||||||
|
|||||||
@@ -346,7 +346,7 @@
|
|||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
if (edit && model?.id) {
|
if (edit && model?.id) {
|
||||||
try {
|
try {
|
||||||
await updateModelAccessGrants(localStorage.token, model.id, accessGrants);
|
await updateModelAccessGrants(localStorage.token, model.id, model.name ?? name, accessGrants);
|
||||||
toast.success($i18n.t('Saved'));
|
toast.success($i18n.t('Saved'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error?.detail ?? `${error}`);
|
toast.error(error?.detail ?? `${error}`);
|
||||||
|
|||||||
Reference in new issue
Block a user