Skip to content

Commit

Permalink
rn getResponse -> callInferenceApi
Browse files Browse the repository at this point in the history
  • Loading branch information
mishig25 committed Oct 18, 2023
1 parent ebfbb0d commit e16171c
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 47 deletions.
2 changes: 1 addition & 1 deletion js/src/lib/components/InferenceWidget/shared/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ interface CacheNotFound {

type Result<T> = Success<T> | LoadingModel | Error | CacheNotFound;

export async function getResponse<T>(
export async function callInferenceApi<T>(
url: string,
repoId: string,
requestBody: Record<string, any>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import WidgetRecorder from "../../shared/WidgetRecorder/WidgetRecorder.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isValidOutputLabels } from "../../shared/outputValidation";
import { isAssetInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -77,7 +77,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import WidgetRecorder from "../../shared/WidgetRecorder/WidgetRecorder.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isAssetInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -77,7 +77,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import WidgetRealtimeRecorder from "../../shared/WidgetRealtimeRecorder/WidgetRealtimeRecorder.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isValidOutputText } from "../../shared/outputValidation";
import { isAssetInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -79,7 +79,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isTextInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -86,7 +92,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isTextInput } from "../../shared/inputValidation";
import { DataTable } from "./DataTable";
Expand Down Expand Up @@ -63,7 +69,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import WidgetTextarea from "../../shared/WidgetTextarea/WidgetTextarea.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isValidOutputLabels } from "../../shared/outputValidation";
import { isTextInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -66,7 +72,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import WidgetDropzone from "../../shared/WidgetDropzone/WidgetDropzone.svelte";
import WidgetOutputChart from "../../shared/WidgetOutputChart/WidgetOutputChart.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isValidOutputLabels } from "../../shared/outputValidation";
import { isTextInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -52,7 +52,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { COLORS } from "../../shared/consts";
import { clamp, mod, hexToRgb } from "../../../../utils/ViewUtils";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import WidgetFileInput from "../../shared/WidgetFileInput/WidgetFileInput.svelte";
import WidgetDropzone from "../../shared/WidgetDropzone/WidgetDropzone.svelte";
import WidgetOutputChart from "../../shared/WidgetOutputChart/WidgetOutputChart.svelte";
Expand Down Expand Up @@ -66,7 +66,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import WidgetTextInput from "../../shared/WidgetTextInput/WidgetTextInput.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse } from "../../shared/helpers";
import { addInferenceParameters, getDemoInputs, callInferenceApi } from "../../shared/helpers";
import { isAssetAndPromptInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -97,7 +97,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import WidgetDropzone from "../../shared/WidgetDropzone/WidgetDropzone.svelte";
import WidgetOutputText from "../../shared/WidgetOutputText/WidgetOutputText.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isAssetInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -51,7 +51,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import WidgetDropzone from "../../shared/WidgetDropzone/WidgetDropzone.svelte";
import WidgetOutputChart from "../../shared/WidgetOutputChart/WidgetOutputChart.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { getResponse, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { callInferenceApi, getBlobFromUrl, getDemoInputs } from "../../shared/helpers";
import { isAssetInput } from "../../shared/inputValidation";
import BoundingBoxes from "./SvgBoundingBoxes.svelte";
Expand Down Expand Up @@ -56,7 +56,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
import WidgetTextarea from "../../shared/WidgetTextarea/WidgetTextarea.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isValidOutputAnswerScore } from "../../shared/outputValidation";
import { isTextAndContextInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -81,7 +87,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import WidgetAddSentenceBtn from "../../shared/WidgetAddSentenceBtn/WidgetAddSentenceBtn.svelte";
import WidgetTextInput from "../../shared/WidgetTextInput/WidgetTextInput.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse } from "../../shared/helpers";
import { addInferenceParameters, getDemoInputs, callInferenceApi } from "../../shared/helpers";
import { isSentenceSimilarityInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -74,7 +74,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetTextarea from "../../shared/WidgetTextarea/WidgetTextarea.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isTextInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -64,7 +70,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
convertDataToTable,
convertTableToData,
getDemoInputs,
getResponse,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
Expand Down Expand Up @@ -102,7 +102,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
addInferenceParameters,
convertDataToTable,
convertTableToData,
getResponse,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
Expand Down Expand Up @@ -119,7 +119,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
import WidgetTimer from "../../shared/WidgetTimer/WidgetTimer.svelte";
import WidgetOutputText from "../../shared/WidgetOutputText/WidgetOutputText.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isValidOutputText } from "../../shared/outputValidation";
import { isTextInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -104,7 +110,7 @@
isLoading = true;
inferenceTimer.start();
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isValidOutputUrl } from "../../shared/outputValidation";
import { isTextInput } from "../../shared/inputValidation";
Expand Down Expand Up @@ -61,7 +67,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import WidgetTextarea from "../../shared/WidgetTextarea/WidgetTextarea.svelte";
import WidgetSubmitBtn from "../../shared/WidgetSubmitBtn/WidgetSubmitBtn.svelte";
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
import { addInferenceParameters, getDemoInputs, getResponse, getSearchParams, updateUrl } from "../../shared/helpers";
import {
addInferenceParameters,
getDemoInputs,
callInferenceApi,
getSearchParams,
updateUrl,
} from "../../shared/helpers";
import { isTextInput } from "../../shared/inputValidation";
export let apiToken: WidgetProps["apiToken"];
Expand Down Expand Up @@ -63,7 +69,7 @@
isLoading = true;
const res = await getResponse(
const res = await callInferenceApi(
apiUrl,
model.id,
requestBody,
Expand Down
Loading

0 comments on commit e16171c

Please sign in to comment.