From 96c0b8a6a60204606918ba85b5a4f89d60fc9814 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 24 May 2024 23:42:27 -0700 Subject: [PATCH] feat: clone support --- .../workspace/models/create/+page.svelte | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/routes/(app)/workspace/models/create/+page.svelte b/src/routes/(app)/workspace/models/create/+page.svelte index a3bbca921..47671028e 100644 --- a/src/routes/(app)/workspace/models/create/+page.svelte +++ b/src/routes/(app)/workspace/models/create/+page.svelte @@ -29,6 +29,11 @@ let id = ''; let name = ''; + let params = {}; + let capabilities = { + vision: true + }; + let info = { id: '', base_model_id: null, @@ -47,12 +52,6 @@ } }; - let params = {}; - - let capabilities = { - vision: false - }; - $: if (name) { id = name.replace(/\s+/g, '-').toLowerCase(); } @@ -96,6 +95,19 @@ success = false; }; + const initModel = (model) => { + id = model.id; + name = model.name; + + params = { ...params, ...model?.info?.params }; + capabilities = { ...capabilities, ...(model?.info?.meta?.capabilities ?? {}) }; + + info = { + ...info, + ...model.info + }; + }; + onMount(async () => { window.addEventListener('message', async (event) => { if ( @@ -108,8 +120,11 @@ ].includes(event.origin) ) return; + const model = JSON.parse(event.data); console.log(model); + + initModel(model); }); if (window.opener ?? false) { @@ -118,8 +133,10 @@ if (sessionStorage.model) { const model = JSON.parse(sessionStorage.model); - console.log(model); sessionStorage.removeItem('model'); + + console.log(model); + initModel(model); } });