diff --git a/src/lib/apis/models/index.ts b/src/lib/apis/models/index.ts index 73b9d619a..9faa358d3 100644 --- a/src/lib/apis/models/index.ts +++ b/src/lib/apis/models/index.ts @@ -32,7 +32,7 @@ export const addNewModel = async (token: string, model: object) => { export const getModelInfos = async (token: string = '') => { let error = null; - const res = await fetch(`${WEBUI_API_BASE_URL}/models/`, { + const res = await fetch(`${WEBUI_API_BASE_URL}/models`, { method: 'GET', headers: { Accept: 'application/json', @@ -63,10 +63,10 @@ export const getModelInfos = async (token: string = '') => { export const getModelById = async (token: string, id: string) => { let error = null; - const url = new URL(`${WEBUI_API_BASE_URL}/models`); - url.searchParams.append('id', id); + const searchParams = new URLSearchParams(); + searchParams.append('id', id); - const res = await fetch(url.toString(), { + const res = await fetch(`${WEBUI_API_BASE_URL}/models?${searchParams.toString()}`, { method: 'GET', headers: { Accept: 'application/json', @@ -98,10 +98,10 @@ export const getModelById = async (token: string, id: string) => { export const updateModelById = async (token: string, id: string, model: object) => { let error = null; - const url = new URL(`${WEBUI_API_BASE_URL}/models/update`); - url.searchParams.append('id', id); + const searchParams = new URLSearchParams(); + searchParams.append('id', id); - const res = await fetch(url.toString(), { + const res = await fetch(`${WEBUI_API_BASE_URL}/models/update?${searchParams.toString()}`, { method: 'POST', headers: { Accept: 'application/json', @@ -134,10 +134,10 @@ export const updateModelById = async (token: string, id: string, model: object) export const deleteModelById = async (token: string, id: string) => { let error = null; - const url = new URL(`${WEBUI_API_BASE_URL}/models/delete`); - url.searchParams.append('id', id); + const searchParams = new URLSearchParams(); + searchParams.append('id', id); - const res = await fetch(url.toString(), { + const res = await fetch(`${WEBUI_API_BASE_URL}/models/delete?${searchParams.toString()}`, { method: 'DELETE', headers: { Accept: 'application/json',