|
73 | 73 |
|
74 | 74 | onMount(() => {
|
75 | 75 | (async () => {
|
76 |
| - modelLoadInfo = await getModelLoadInfo(apiUrl, model.id, includeCredentials); |
77 |
| - $modelLoadStates[model.id] = modelLoadInfo; |
78 |
| - modelTooBig = modelLoadInfo?.state === "TooBig"; |
| 76 | + if (model.inference === InferenceDisplayability.Yes) { |
| 77 | + modelLoadInfo = await getModelLoadInfo(apiUrl, model.id, includeCredentials); |
| 78 | + $modelLoadStates[model.id] = modelLoadInfo; |
| 79 | + modelTooBig = modelLoadInfo?.state === "TooBig"; |
79 | 80 |
|
80 |
| - if (modelTooBig) { |
81 |
| - // disable the widget |
82 |
| - isDisabled = true; |
83 |
| - inputSamples = allInputSamples.filter((sample) => sample.output !== undefined); |
84 |
| - inputGroups = getExamplesGroups(); |
| 81 | + if (modelTooBig) { |
| 82 | + // disable the widget |
| 83 | + isDisabled = true; |
| 84 | + inputSamples = allInputSamples.filter((sample) => sample.output !== undefined); |
| 85 | + inputGroups = getExamplesGroups(); |
| 86 | + } |
85 | 87 | }
|
86 | 88 |
|
87 | 89 | const exampleFromQueryParams = {} as TWidgetExample;
|
|
110 | 112 | <WidgetHeader pipeline={model.pipeline_tag} noTitle={true} />
|
111 | 113 | <WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} />
|
112 | 114 | {:else}
|
113 |
| - <div |
114 |
| - class="flex w-full max-w-full flex-col |
115 |
| - {isMaximized ? 'fixed inset-0 z-20 bg-white p-12' : ''} |
116 |
| - {!modelLoadInfo ? 'hidden' : ''}" |
117 |
| - > |
118 |
| - {#if isMaximized} |
119 |
| - <button class="absolute right-12 top-6" on:click={() => (isMaximized = !isMaximized)}> |
120 |
| - <IconCross classNames="text-xl text-gray-500 hover:text-black" /> |
121 |
| - </button> |
122 |
| - {/if} |
123 |
| - <WidgetHeader {noTitle} pipeline={model.pipeline_tag} {isDisabled}> |
124 |
| - {#if !!inputGroups.length} |
125 |
| - <div class="ml-auto flex gap-x-1"> |
126 |
| - <!-- Show samples selector when there are more than one sample --> |
127 |
| - {#if inputGroups.length > 1} |
128 |
| - <WidgetInputSamplesGroup |
129 |
| - bind:selectedInputGroup |
| 115 | + <!-- require that we have `modelLoadInfo` for InferenceDisplayability.Yes models --> |
| 116 | + {#if modelLoadInfo || model.inference !== InferenceDisplayability.Yes} |
| 117 | + <div |
| 118 | + class="flex w-full max-w-full flex-col |
| 119 | + {isMaximized ? 'fixed inset-0 z-20 bg-white p-12' : ''}" |
| 120 | + > |
| 121 | + {#if isMaximized} |
| 122 | + <button class="absolute right-12 top-6" on:click={() => (isMaximized = !isMaximized)}> |
| 123 | + <IconCross classNames="text-xl text-gray-500 hover:text-black" /> |
| 124 | + </button> |
| 125 | + {/if} |
| 126 | + <WidgetHeader {noTitle} pipeline={model.pipeline_tag} {isDisabled}> |
| 127 | + {#if !!inputGroups.length} |
| 128 | + <div class="ml-auto flex gap-x-1"> |
| 129 | + <!-- Show samples selector when there are more than one sample --> |
| 130 | + {#if inputGroups.length > 1} |
| 131 | + <WidgetInputSamplesGroup |
| 132 | + bind:selectedInputGroup |
| 133 | + {isLoading} |
| 134 | + inputGroups={inputGroups.map(({ group }) => group)} |
| 135 | + /> |
| 136 | + {/if} |
| 137 | + <WidgetInputSamples |
| 138 | + classNames={!selectedInputSamples ? "opacity-50 pointer-events-none" : ""} |
130 | 139 | {isLoading}
|
131 |
| - inputGroups={inputGroups.map(({ group }) => group)} |
| 140 | + inputSamples={selectedInputSamples?.inputSamples ?? []} |
| 141 | + {applyInputSample} |
132 | 142 | />
|
133 |
| - {/if} |
134 |
| - <WidgetInputSamples |
135 |
| - classNames={!selectedInputSamples ? "opacity-50 pointer-events-none" : ""} |
136 |
| - {isLoading} |
137 |
| - inputSamples={selectedInputSamples?.inputSamples ?? []} |
138 |
| - {applyInputSample} |
139 |
| - /> |
140 |
| - </div> |
| 143 | + </div> |
| 144 | + {/if} |
| 145 | + </WidgetHeader> |
| 146 | + <slot name="top" {isDisabled} /> |
| 147 | + <WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} /> |
| 148 | + {#if modelLoading.isLoading} |
| 149 | + <WidgetModelLoading estimatedTime={modelLoading.estimatedTime} /> |
141 | 150 | {/if}
|
142 |
| - </WidgetHeader> |
143 |
| - <slot name="top" {isDisabled} /> |
144 |
| - <WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} /> |
145 |
| - {#if modelLoading.isLoading} |
146 |
| - <WidgetModelLoading estimatedTime={modelLoading.estimatedTime} /> |
147 |
| - {/if} |
148 |
| - <slot name="bottom" /> |
149 |
| - <WidgetFooter bind:isMaximized {outputJson} {isDisabled} /> |
150 |
| - </div> |
| 151 | + <slot name="bottom" /> |
| 152 | + <WidgetFooter bind:isMaximized {outputJson} {isDisabled} /> |
| 153 | + </div> |
| 154 | + {/if} |
151 | 155 | {/if}
|
0 commit comments