refac
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user