From 8464b3048543e683a9a31d7593d1eac75f280a48 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 10 Jun 2024 22:10:53 -0700 Subject: [PATCH] refac --- backend/apps/webui/routers/tools.py | 4 ++- src/lib/components/workspace/Tools.svelte | 25 ++++++++++++++++--- .../workspace/Tools/ToolkitEditor.svelte | 1 - .../(app)/workspace/tools/create/+page.svelte | 16 ++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/backend/apps/webui/routers/tools.py b/backend/apps/webui/routers/tools.py index 92f9ab0a8..67e391ddd 100644 --- a/backend/apps/webui/routers/tools.py +++ b/backend/apps/webui/routers/tools.py @@ -80,6 +80,8 @@ async def create_new_toolkit(form_data: ToolForm, user=Depends(get_admin_user)): detail="Only alphanumeric characters and underscores are allowed in the id", ) + form_data.id = form_data.id.lower() + toolkit = Tools.get_tool_by_id(form_data.id) if toolkit == None: toolkit_path = os.path.join(TOOLS_DIR, f"{form_data.id}.py") @@ -151,7 +153,7 @@ async def update_toolkit_by_id( specs = get_tools_specs(TOOLS[id]) updated = { - **form_data.model_dump(), + **form_data.model_dump(exclude={"id"}), "specs": specs, } diff --git a/src/lib/components/workspace/Tools.svelte b/src/lib/components/workspace/Tools.svelte index d5650c68d..959dc17cb 100644 --- a/src/lib/components/workspace/Tools.svelte +++ b/src/lib/components/workspace/Tools.svelte @@ -8,7 +8,13 @@ import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts'; import { goto } from '$app/navigation'; - import { createNewTool, deleteToolById, exportTools, getTools } from '$lib/apis/tools'; + import { + createNewTool, + deleteToolById, + exportTools, + getToolById, + getTools + } from '$lib/apis/tools'; const i18n = getContext('i18n'); @@ -121,9 +127,20 @@