feat: clone support

This commit is contained in:
Timothy J. Baek 2024-05-24 23:42:27 -07:00
parent 0715cd2811
commit 96c0b8a6a6
1 changed files with 24 additions and 7 deletions

View File

@ -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);
}
});
</script>