From 4601a0246f60caf32f30ab2864f8b441e8da5274 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 10 Jun 2024 21:53:51 -0700 Subject: [PATCH] fix: tool edit --- backend/apps/webui/routers/tools.py | 15 ++++++++++----- src/lib/components/common/CodeEditor.svelte | 5 ++++- .../(app)/workspace/tools/edit/+page.svelte | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/apps/webui/routers/tools.py b/backend/apps/webui/routers/tools.py index 048813c72..59f193858 100644 --- a/backend/apps/webui/routers/tools.py +++ b/backend/apps/webui/routers/tools.py @@ -111,7 +111,7 @@ async def create_new_toolkit(form_data: ToolForm, user=Depends(get_admin_user)): ############################ -@router.get("/id/{id}", response_model=Optional[ToolResponse]) +@router.get("/id/{id}", response_model=Optional[ToolModel]) async def get_toolkit_by_id(id: str, user=Depends(get_admin_user)): toolkit = Tools.get_tool_by_id(id) @@ -129,7 +129,7 @@ async def get_toolkit_by_id(id: str, user=Depends(get_admin_user)): ############################ -@router.post("/id/{id}/update", response_model=Optional[ToolResponse]) +@router.post("/id/{id}/update", response_model=Optional[ToolModel]) async def update_toolkit_by_id( id: str, form_data: ToolForm, user=Depends(get_admin_user) ): @@ -143,9 +143,14 @@ async def update_toolkit_by_id( TOOLS[id] = toolkit_module specs = get_tools_specs(TOOLS[id]) - toolkit = Tools.update_tool_by_id( - id, {**form_data.model_dump(), "specs": specs} - ) + + updated = { + **form_data.model_dump(), + "specs": specs, + } + + print(updated) + toolkit = Tools.update_tool_by_id(id, updated) if toolkit: return toolkit diff --git a/src/lib/components/common/CodeEditor.svelte b/src/lib/components/common/CodeEditor.svelte index 4f3e2baef..ef923b09f 100644 --- a/src/lib/components/common/CodeEditor.svelte +++ b/src/lib/components/common/CodeEditor.svelte @@ -60,7 +60,10 @@ ]; onMount(() => { - value = boilerplate; + console.log(value); + if (value === '') { + value = boilerplate; + } // Check if html class has dark mode isDarkMode = document.documentElement.classList.contains('dark'); diff --git a/src/routes/(app)/workspace/tools/edit/+page.svelte b/src/routes/(app)/workspace/tools/edit/+page.svelte index 7b7378b0d..c60ab5e0a 100644 --- a/src/routes/(app)/workspace/tools/edit/+page.svelte +++ b/src/routes/(app)/workspace/tools/edit/+page.svelte @@ -40,6 +40,8 @@ goto('/workspace/tools'); return null; }); + + console.log(tool); } });