diff --git a/backend/apps/web/models/modelfiles.py b/backend/apps/web/models/modelfiles.py index a0f9f1aa..4d8202db 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 4563c4df..dd1f6cc5 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 ad72eec9..91af5e38 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 2a8f12ab..41691524 100644 --- a/src/routes/(app)/modelfiles/+page.svelte +++ b/src/routes/(app)/modelfiles/+page.svelte @@ -1,11 +1,20 @@