{#if models !== null} {#if selectedModelId === null}
{$i18n.t("Models")}
{filteredModels.length}
{#if $user?.role === "admin"}
{ if (importFiles.length > 0) { const reader = new FileReader(); reader.onload = async (event) => { modelsImportInProgress = true; try { const models = JSON.parse( String(event.target.result), ); const res = await importModels( localStorage.token, models, ); if (res) { toast.success( $i18n.t( "Models imported successfully", ), ); await init(); } else { toast.error( $i18n.t( "Failed to import models", ), ); } } catch (e) { toast.error( e?.detail ?? $i18n.t( "Invalid JSON file", ), ); console.error(e); } modelsImportInProgress = false; }; reader.readAsText(importFiles[0]); } }} />
{ modelsImportInputElement.click(); }} > {#if modelsImportInProgress}
{/if}
{$i18n.t("Import")}
{ downloadModels(models); }} >
{$i18n.t("Export")}
{/if}
{ showManageModal = true; }} >
{$i18n.t("Manage")}
{ showConfigModal = true; }} >
{$i18n.t("Settings")}
{#if searchValue}
{ searchValue = ""; }} >
{/if}
{ enableAllHandler(); }} >
{$i18n.t("Enable All")}
{ disableAllHandler(); }} >
{$i18n.t("Disable All")}
{ showAllHandler(); }} >
{$i18n.t("Show All")}
{ hideAllHandler(); }} >
{$i18n.t("Hide All")}
{#if filteredModels.length > 0} {#each filteredModels.slice((currentPage - 1) * perPage, currentPage * perPage) as model, modelIdx (`${model.id}-${modelIdx}`)}
{ selectedModelId = model.id; }} >
{ e.target.src = "/favicon.png"; }} />
{model.name}
g.principal_type === "user" && g.principal_id === "*" && g.permission === "read", ) ? "success" : "muted"} content={( model?.access_grants ?? [] ).some( (g) => g.principal_type === "user" && g.principal_id === "*" && g.permission === "read", ) ? $i18n.t("Public") : $i18n.t("Private")} />
{!!model?.meta?.description ? model?.meta?.description : model?.ollama?.digest ? `${model.id} (${model?.ollama?.digest})` : model.id}
{#if shiftKey}
{ hideModelHandler(model); }} > {#if model?.meta?.hidden}
{:else}
{/if}
{:else}
{ selectedModelId = model.id; }} >
{ exportModelHandler(model); }} hideHandler={() => { hideModelHandler(model); }} pinModelHandler={() => { pinModelHandler(model.id); }} copyLinkHandler={() => { copyLinkHandler(model); }} cloneHandler={() => { cloneHandler(model); }} onClose={() => {}} >
{ toggleModelHandler(model); }} />
{/if}
{/each} {:else}
{$i18n.t("No models found")}
{$i18n.t( "Try adjusting your search or filter to find what you are looking for.", )}
{/if}
{#if filteredModels.length > perPage}
{/if}
{:else}
m.id === selectedModelId)} preset={false} onSubmit={(model) => { console.log(model); upsertModelHandler(model); selectedModelId = null; }} onBack={async () => { selectedModelId = null; await init(); }} /> {/if} {:else}
{/if}