diff --git a/backend/apps/web/models/modelfiles.py b/backend/apps/web/models/modelfiles.py index a0f9f1aa3..4d8202db9 100644 --- a/backend/apps/web/models/modelfiles.py +++ b/backend/apps/web/models/modelfiles.py @@ -74,11 +74,16 @@ class ModelfilesTable: "timestamp": int(time.time()), } ) - result = Modelfile.create(**modelfile.model_dump()) - if result: - return modelfile - else: + + try: + result = Modelfile.create(**modelfile.model_dump()) + if result: + return modelfile + else: + return None + except: return None + else: return None diff --git a/backend/apps/web/routers/modelfiles.py b/backend/apps/web/routers/modelfiles.py index 4563c4df2..dd1f6cc59 100644 --- a/backend/apps/web/routers/modelfiles.py +++ b/backend/apps/web/routers/modelfiles.py @@ -56,12 +56,19 @@ async def create_new_modelfile(form_data: ModelfileForm, cred=Depends(bearer_sch # Admin Only if user.role == "admin": modelfile = Modelfiles.insert_new_modelfile(user.id, form_data) - return ModelfileResponse( - **{ - **modelfile.model_dump(), - "modelfile": json.loads(modelfile.modelfile), - } - ) + + if modelfile: + return ModelfileResponse( + **{ + **modelfile.model_dump(), + "modelfile": json.loads(modelfile.modelfile), + } + ) + else: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=ERROR_MESSAGES.DEFAULT(), + ) else: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, diff --git a/src/lib/apis/modelfiles/index.ts b/src/lib/apis/modelfiles/index.ts index ad72eec90..91af5e381 100644 --- a/src/lib/apis/modelfiles/index.ts +++ b/src/lib/apis/modelfiles/index.ts @@ -19,7 +19,7 @@ export const createNewModelfile = async (token: string, modelfile: object) => { return res.json(); }) .catch((err) => { - error = err; + error = err.detail; console.log(err); return null; }); diff --git a/src/routes/(app)/modelfiles/+page.svelte b/src/routes/(app)/modelfiles/+page.svelte index 2a8f12ab4..416915241 100644 --- a/src/routes/(app)/modelfiles/+page.svelte +++ b/src/routes/(app)/modelfiles/+page.svelte @@ -1,11 +1,20 @@