Skip to content

Commit

Permalink
Revert "Don't call api inference if output exists"
Browse files Browse the repository at this point in the history
This reverts commit 7cfc6cd.
  • Loading branch information
mishig25 committed Oct 30, 2023
1 parent 2a26927 commit 6c8db96
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,7 @@
}
}
interface GetOutputOptions {
withModelLoading?: boolean;
isOnLoadCall?: boolean;
sampleOutput?: WidgetExampleOutputLabels;
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false, sampleOutput = undefined }: GetOutputOptions = {}) {
// don't call api-inference if sample output already exists
if(isValidOutputLabels(sampleOutput)) {
output = sampleOutput;
outputJson = "";
return;
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false } = {}) {
if (!file && !selectedSampleUrl) {
error = "You must select or record an audio file";
output = [];
Expand Down Expand Up @@ -140,7 +127,7 @@
filename = sample.example_title!;
fileUrl = sample.src;
selectedSampleUrl = sample.src;
getOutput({sampleOutput: sample.output});
getOutput();
}
function previewInputSample(sample: WidgetExampleAssetInput<WidgetExampleOutputLabels>) {
Expand All @@ -160,12 +147,12 @@
}
onMount(() => {
const [exampleTitle, src, output] = getDemoInputs(model, ["example_title", "src", "output"]);
const [exampleTitle, src] = getDemoInputs(model, ["example_title", "src"]);
if (callApiOnMount && src) {
filename = exampleTitle ?? "";
fileUrl = src;
selectedSampleUrl = src;
getOutput({ isOnLoadCall: true, sampleOutput: output });
getOutput({ isOnLoadCall: true });
}
});
</script>
Expand Down

0 comments on commit 6c8db96

Please sign in to comment.