mirror of
https://github.com/open-webui/open-webui
synced 2024-11-21 23:57:51 +00:00
refac: models api
This commit is contained in:
parent
7c5b845d16
commit
7966367107
@ -83,7 +83,8 @@ async def create_new_model(
|
||||
###########################
|
||||
|
||||
|
||||
@router.get("/id/{id}", response_model=Optional[ModelResponse])
|
||||
# Note: We're not using the typical url path param here, but instead using a query parameter to allow '/' in the id
|
||||
@router.get("/model", response_model=Optional[ModelResponse])
|
||||
async def get_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
model = Models.get_model_by_id(id)
|
||||
if model:
|
||||
@ -105,7 +106,7 @@ async def get_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
############################
|
||||
|
||||
|
||||
@router.post("/id/{id}/toggle", response_model=Optional[ModelResponse])
|
||||
@router.post("/model/toggle", response_model=Optional[ModelResponse])
|
||||
async def toggle_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
model = Models.get_model_by_id(id)
|
||||
if model:
|
||||
@ -140,7 +141,7 @@ async def toggle_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
############################
|
||||
|
||||
|
||||
@router.post("/id/{id}/update", response_model=Optional[ModelModel])
|
||||
@router.post("/model/update", response_model=Optional[ModelModel])
|
||||
async def update_model_by_id(
|
||||
id: str,
|
||||
form_data: ModelForm,
|
||||
@ -163,7 +164,7 @@ async def update_model_by_id(
|
||||
############################
|
||||
|
||||
|
||||
@router.delete("/id/{id}/delete", response_model=bool)
|
||||
@router.delete("/model/delete", response_model=bool)
|
||||
async def delete_model_by_id(id: str, user=Depends(get_verified_user)):
|
||||
model = Models.get_model_by_id(id)
|
||||
if not model:
|
||||
|
@ -97,7 +97,7 @@ export const getModelById = async (token: string, id: string) => {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('id', id);
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/id/${id}`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model?${searchParams.toString()}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -132,7 +132,7 @@ export const toggleModelById = async (token: string, id: string) => {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('id', id);
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/id/${id}/toggle`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/toggle?${searchParams.toString()}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -167,7 +167,7 @@ export const updateModelById = async (token: string, id: string, model: object)
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('id', id);
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/id/${id}/update`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/update?${searchParams.toString()}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -203,7 +203,7 @@ export const deleteModelById = async (token: string, id: string) => {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('id', id);
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/id/${id}/delete`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/models/model/delete?${searchParams.toString()}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
|
Loading…
Reference in New Issue
Block a user