Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mishig25 committed Oct 16, 2023
1 parent 047ac90 commit b4f8657
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions js/src/lib/components/InferenceWidget/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export interface WidgetProps {
isLoggedIn?: boolean;
}

export interface InferenceRunOpts {
export interface InferenceRunFlags {
withModelLoading?: boolean;
isOnLoadCall?: boolean;
useCache?: boolean;
}

export interface ExampleRunOpts {
isPreview?: boolean;
inferenceOpts?: InferenceRunOpts;
inferenceOpts?: InferenceRunFlags;
}

export type LoadState = "Loadable" | "Loaded" | "TooBig" | "error";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExample, WidgetExampleAssetInput, WidgetExampleOutputLabels } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -61,7 +61,7 @@
}
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
if (!file && !selectedSampleUrl) {
error = "You must select or record an audio file";
output = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -64,7 +64,7 @@
}
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
if (!file && !selectedSampleUrl) {
error = "You must select or record an audio file";
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExample, WidgetExampleAssetInput, WidgetExampleOutputText } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -63,7 +63,7 @@
}
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
if (!file && !selectedSampleUrl) {
error = "You must select or record an audio file";
output = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -69,7 +69,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
if (!trimmedText) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -49,7 +49,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
if (!trimmedText) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput, WidgetExampleOutputLabels, WidgetExample } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -53,7 +53,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
if (!trimmedText) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, InferenceRunOpts, ExampleRunOpts } from "../../shared/types";
import type { WidgetProps, InferenceRunFlags, ExampleRunOpts } from "../../shared/types";
import type { WidgetExample, WidgetExampleAssetInput, WidgetExampleOutputLabels } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -38,7 +38,7 @@
async function getOutput(
file: File | Blob,
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}
) {
if (!file) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ImageSegment, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ImageSegment, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -52,7 +52,7 @@
async function getOutput(
file: File | Blob,
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}
) {
if (!file) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetAndPromptInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -78,7 +78,7 @@
getOutput(inferenceOpts);
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedPrompt = prompt.trim();
if (!imageBase64) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -37,7 +37,7 @@
async function getOutput(
file: File | Blob,
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}
) {
if (!file) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, DetectedObject, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, DetectedObject, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -42,7 +42,7 @@
async function getOutput(
file: File | Blob,
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}
{ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}
) {
if (!file) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type {
WidgetExample,
WidgetExampleOutputAnswerScore,
Expand Down Expand Up @@ -59,7 +59,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedQuestion = question.trim();
const trimmedContext = context.trim();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleSentenceSimilarityInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -33,7 +33,7 @@
let output: Array<{ label: string; score: number }> = [];
let outputJson: string;
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedSourceSentence = sourceSentence.trim();
if (!trimmedSourceSentence) {
error = "You need to input some text";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -50,7 +50,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedValue = text.trim();
if (!trimmedValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
TableData,
HighlightCoordinates,
ExampleRunOpts,
InferenceRunOpts,
InferenceRunFlags,
} from "../../shared/types";
import type { WidgetExampleTextAndTableInput } from "../../shared/WidgetExample";
Expand Down Expand Up @@ -79,7 +79,7 @@
table = updatedTable;
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedQuery = query.trim();
if (!trimmedQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
WidgetProps,
TableData,
HighlightCoordinates,
InferenceRunOpts,
InferenceRunFlags,
ExampleRunOpts,
} from "../../shared/types";
import type { WidgetExampleStructuredDataInput, WidgetExampleOutputLabels } from "../../shared/WidgetExample";
Expand Down Expand Up @@ -89,7 +89,7 @@
output = [];
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
for (let [i, row] of table.entries()) {
for (const [j, cell] of row.entries()) {
if (!String(cell)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { PipelineType } from "../../../../interfaces/Types";
import type { WidgetExampleTextInput, WidgetExampleOutputText, WidgetExample } from "../../shared/WidgetExample";
Expand Down Expand Up @@ -68,7 +68,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false, useCache = true }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false, useCache = true }: InferenceRunFlags = {}) {
if (isBloomLoginRequired) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -50,7 +50,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
if (!trimmedText) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -67,7 +67,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
if (!trimmedText) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetAndTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -82,7 +82,7 @@
getOutput(inferenceOpts);
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedQuestion = question.trim();
if (!trimmedQuestion) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleAssetAndZeroShotInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -83,7 +83,7 @@
getOutput(inferenceOpts);
}
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedCandidateLabels = candidateLabels.trim().split(",").join(",");
if (!trimmedCandidateLabels) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types";
import type { WidgetProps, ExampleRunOpts, InferenceRunFlags } from "../../shared/types";
import type { WidgetExampleZeroShotTextInput } from "../../shared/WidgetExample";
import { onMount } from "svelte";
Expand Down Expand Up @@ -61,7 +61,7 @@
}
});
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunFlags = {}) {
const trimmedText = text.trim();
const trimmedCandidateLabels = candidateLabels.trim().split(",").join(",");
Expand Down

0 comments on commit b4f8657

Please sign in to comment.