handle empty valves

This commit is contained in:
Chris Kanich 2025-03-15 17:58:40 -05:00
parent 3bc97cf3fb
commit 078f025830
2 changed files with 16 additions and 3 deletions

View File

@ -9,7 +9,7 @@
export let filters = []; export let filters = [];
export let selectedFilterIds = []; export let selectedFilterIds = [];
export let valvesSpecs = {}; export let valvesSpecs = {};
export let valves = {}; export let valves = {};
@ -69,7 +69,6 @@
> >
<div slot="content"> <div slot="content">
<Valves valvesSpec={valvesSpecs[filter]} bind:valves={valves[filter]} /> <Valves valvesSpec={valvesSpecs[filter]} bind:valves={valves[filter]} />
</div> </div>
</Collapsible> </Collapsible>
{/if} {/if}

View File

@ -67,7 +67,11 @@
profile_image_url: '/static/favicon.png', profile_image_url: '/static/favicon.png',
description: '', description: '',
suggestion_prompts: null, suggestion_prompts: null,
tags: [] tags: [],
valves: {
functions: {},
tools: {}
}
}, },
params: { params: {
system: '' system: ''
@ -174,6 +178,16 @@
delete info.params[key]; delete info.params[key];
} }
}); });
// iterate through all valve settings for both functions and tools, and remove empty settings (aka things that got set back to default)
Object.keys(info.meta.valves).forEach((valveType) => {
Object.keys(info.meta.valves[valveType]).forEach((functionId) => {
Object.keys(info.meta.valves[valveType][functionId]).forEach((key) => {
if (info.meta.valves[valveType][functionId][key] === null) {
delete info.meta.valves.functions[functionId][key];
}
});
});
});
await onSubmit(info); await onSubmit(info);